source: abuse/tags/pd/macabuse/imlib/port/x11/mouse.c @ 49

Last change on this file since 49 was 49, checked in by Sam Hocevar, 11 years ago
  • Imported original public domain release, for future reference.
  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1#include "video.hpp"
2#include "sprite.hpp"
3#include "image.hpp"
4#include "filter.hpp"
5#include "mdlread.hpp"
6#include "monoprnt.hpp"
7#include "mouse.hpp"
8#include "xinclude.h"
9
10extern Window root,mainwin;
11extern Display *display;
12extern int screen_num;
13extern Colormap XCMap;
14extern Screen *screen_ptr;
15extern unsigned border_width,depth;
16extern GC gc;
17extern XFontStruct *font_info;
18extern XImage *XImg;
19
20
21
22
23
24unsigned char def_mouse[]=
25    { 0,2,0,0,0,0,0,0,
26      2,1,2,0,0,0,0,0,
27      2,1,1,2,0,0,0,0,
28      2,1,1,1,2,0,0,0,
29      2,1,1,1,1,2,0,0,
30      2,1,1,1,1,1,2,0,
31      0,2,1,1,2,2,0,0,
32      0,0,2,1,1,2,0,0,
33      0,0,2,1,1,2,0,0,
34      0,0,0,2,2,0,0,0 };
35
36
37void JCMouse::set_shape(image *im, int centerx, int centery)
38{
39  sp->change_visual(im,1);
40  cx=-centerx;
41  cy=-centery;
42}
43
44JCMouse::JCMouse(image *Screen, palette *pal)
45{
46  image *im;
47  int br,dr,h;
48  filter f;
49  but=0;
50  cx=cy=0;
51  here=1;
52  sp=NULL;
53  if (here)                     // is it here?
54  {
55    screen=Screen;
56    br=pal->brightest(1);
57    dr=pal->darkest(1);
58    f.set(1,br);
59    f.set(2,dr);
60    im=new image(8,10,def_mouse);
61    f.apply(im);
62    sp=new sprite(Screen,im,100,100);
63  }
64  mx=Screen->width()/2;
65  my=Screen->height()/2;
66
67}
68
69void JCMouse::update(int newx, int newy, int new_but)
70{
71  int butn,xx,yy;
72  if (newx<0)
73  {
74    Window w1,w2;
75    int j;
76    unsigned int mask;
77    lx=mx; ly=my; lbut=but;
78    XQueryPointer(display,mainwin,&w1,&w2,&j,&j,&mx,&my,&mask);
79    but=((mask&Button1Mask)!=0)|
80         ((mask&Button2Mask)!=0)<<2|
81         ((mask&Button3Mask)!=0)<<1;
82  } else
83  { mx=newx; my=newy; but=new_but; }
84}
85
86void JCMouse::set_position(int new_mx, int new_my)
87{
88  mx=new_mx;
89  my=new_my;
90  XWarpPointer(display,mainwin,mainwin,0,0,0,0,new_mx,new_my);
91}
92
93JCMouse::~JCMouse()
94{
95  if (sp)
96  {
97    delete sp->visual;
98    delete sp;
99  }
100}
101
102
103
104
Note: See TracBrowser for help on using the repository browser.