~ubuntu-branches/ubuntu/hardy/oneko/hardy

« back to all changes in this revision

Viewing changes to oneko.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Dunham
  • Date: 2002-09-22 07:13:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20020922071343-cwanbgeuq43nvy7f
Tags: 1.2.sakura.6-1
Removed BSD Daemon because of copyright issues

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
Display *theDisplay;                    /* $@%G%#%9%W%l%$9=B$BN(J */
19
19
int     theScreen;                      /* $@%9%/%j!<%sHV9f(J */
20
 
int     theDepth;                       /* $@%G%W%9(J */
 
20
unsigned int    theDepth;               /* $@%G%W%9(J */
21
21
Window  theRoot;                        /* $@%k!<%H%&%#%s%I%&$N#I#D(J */
22
22
Window  theWindow;                      /* $@G-%&%#%s%I%&$N#I#D(J */
 
23
char    *WindowName = NULL;             /* $@G-%&%#%s%I%&$NL>A0(J */
 
24
Window  theTarget = None;               /* $@L\I8%&%#%s%I%&$N#I#D(J */
 
25
char    *TargetName = NULL;             /* $@L\I8%&%#%s%I%&$NL>A0(J */
23
26
Cursor  theCursor;                      /* $@$M$:$_%+!<%=%k(J */
24
27
 
25
 
int     WindowWidth;                    /* $@%k!<%H%&%#%s%I%&$NI}(J */
26
 
int     WindowHeight;                   /* $@%k!<%H%&%#%s%I%&$N9b$5(J */
 
28
unsigned int    WindowWidth;            /* $@%k!<%H%&%#%s%I%&$NI}(J */
 
29
unsigned int    WindowHeight;           /* $@%k!<%H%&%#%s%I%&$N9b$5(J */
27
30
 
28
31
XColor  theForegroundColor;             /* $@?'(J ($@%U%)%"%0%i%&%s%I(J) */
29
32
XColor  theBackgroundColor;             /* $@?'(J ($@%P%C%/%0%i%&%s%I(J) */
30
33
 
31
34
int Synchronous = False;
32
35
/* Types of animals */
33
 
#define BITMAPTYPES 3
 
36
#define BITMAPTYPES 5
34
37
typedef struct _AnimalDefaults {
35
38
  char *name;
36
39
  int speed, idle, bitmap_width, bitmap_height;
37
40
  long time;
 
41
  int off_x, off_y;
38
42
  char *cursor,*mask;
39
43
  int cursor_width,cursor_height,cursor_x_hot,cursor_y_hot;
40
44
} AnimalDefaultsData;
41
45
 
42
46
AnimalDefaultsData AnimalDefaultsDataTable[] = 
43
47
{
44
 
  { "neko", 13, 6, 32, 32, 125000L, mouse_cursor_bits,mouse_cursor_mask_bits,
45
 
      mouse_cursor_width,mouse_cursor_height, mouse_cursor_x_hot,mouse_cursor_y_hot },
46
 
  { "tora", 16, 6, 32, 32, 125000L, mouse_cursor_bits,mouse_cursor_mask_bits,
47
 
      mouse_cursor_width,mouse_cursor_height, mouse_cursor_x_hot,mouse_cursor_y_hot },
48
 
  { "dog" , 10, 6, 32, 32, 125000L, bone_cursor_bits,bone_cursor_mask_bits,
 
48
  { "neko", 13, 6, 32, 32, 125000L, 0, 0, mouse_cursor_bits,mouse_cursor_mask_bits,
 
49
      mouse_cursor_width,mouse_cursor_height, mouse_cursor_x_hot,mouse_cursor_y_hot },
 
50
  { "tora", 16, 6, 32, 32, 125000L, 0, 0, mouse_cursor_bits,mouse_cursor_mask_bits,
 
51
      mouse_cursor_width,mouse_cursor_height, mouse_cursor_x_hot,mouse_cursor_y_hot },
 
52
  { "dog" , 10, 6, 32, 32, 125000L, 0, 0, bone_cursor_bits,bone_cursor_mask_bits,
49
53
      bone_cursor_width,bone_cursor_height, bone_cursor_x_hot,bone_cursor_y_hot },
 
54
  { "sakura" , 13, 6, 32, 32, 125000L, 0, 0, card_cursor_bits,card_cursor_mask_bits,
 
55
      card_cursor_width,card_cursor_height, card_cursor_x_hot,card_cursor_y_hot },
 
56
  { "tomoyo" , 10, 6, 32, 32, 125000L, 32, 32, petal_cursor_bits,petal_cursor_mask_bits,
 
57
      petal_cursor_width,petal_cursor_height, petal_cursor_x_hot,petal_cursor_y_hot },
50
58
};
51
59
 
52
60
/*
62
70
int     NekoMoyou = NOTDEFINED;         /*   tora       */
63
71
int     NoShape = NOTDEFINED;           /*   noshape    */
64
72
int     ReverseVideo = NOTDEFINED;      /*   reverse    */
 
73
int     ToWindow = NOTDEFINED;          /*   towindow   */
 
74
int     ToFocus = NOTDEFINED;           /*   tofocus    */
65
75
int     XOffset=0,YOffset=0;            /* X and Y offsets for cat from mouse
66
76
                                           pointer. */
67
77
/*
79
89
 
80
90
int     PrevMouseX = 0;         /* $@D>A0$N%^%&%9#X:BI8(J */
81
91
int     PrevMouseY = 0;         /* $@D>A0$N%^%&%9#Y:BI8(J */
 
92
Window  PrevTarget = None;      /* $@D>A0$NL\I8%&%#%s%I%&$N#I#D(J */
82
93
 
83
94
int     NekoX;                  /* $@G-#X:BI8(J */
84
95
int     NekoY;                  /* $@G-#Y:BI8(J */
141
152
 
142
153
BitmapGCData    BitmapGCDataTable[] =
143
154
{
144
 
    { &Mati2GC, &Mati2Xbm, mati2_bits, mati2_tora_bits, mati2_dog_bits,
145
 
      &Mati2Msk, mati2_mask_bits, mati2_mask_bits, mati2_dog_mask_bits },
146
 
    { &Jare2GC, &Jare2Xbm, jare2_bits, jare2_tora_bits, jare2_dog_bits,
147
 
      &Jare2Msk, jare2_mask_bits, jare2_mask_bits, jare2_dog_mask_bits },
148
 
    { &Kaki1GC, &Kaki1Xbm, kaki1_bits, kaki1_tora_bits, kaki1_dog_bits,
149
 
      &Kaki1Msk, kaki1_mask_bits, kaki1_mask_bits, kaki1_dog_mask_bits },
150
 
    { &Kaki2GC, &Kaki2Xbm, kaki2_bits, kaki2_tora_bits, kaki2_dog_bits,
151
 
      &Kaki2Msk, kaki2_mask_bits, kaki2_mask_bits, kaki2_dog_mask_bits },
152
 
    { &Mati3GC, &Mati3Xbm, mati3_bits, mati3_tora_bits, mati3_dog_bits,
153
 
      &Mati3Msk, mati3_mask_bits, mati3_mask_bits, mati3_dog_mask_bits},
154
 
    { &Sleep1GC, &Sleep1Xbm, sleep1_bits, sleep1_tora_bits, sleep1_dog_bits,
155
 
      &Sleep1Msk, sleep1_mask_bits, sleep1_mask_bits, sleep1_dog_mask_bits },
156
 
    { &Sleep2GC, &Sleep2Xbm, sleep2_bits, sleep2_tora_bits, sleep2_dog_bits,
157
 
      &Sleep2Msk, sleep2_mask_bits, sleep2_mask_bits, sleep2_dog_mask_bits },
158
 
    { &AwakeGC, &AwakeXbm, awake_bits, awake_tora_bits, awake_dog_bits,
159
 
      &AwakeMsk, awake_mask_bits, awake_mask_bits, awake_dog_mask_bits },
160
 
    { &Up1GC, &Up1Xbm, up1_bits, up1_tora_bits, up1_dog_bits,
161
 
      &Up1Msk, up1_mask_bits, up1_mask_bits, up1_dog_mask_bits },
162
 
    { &Up2GC, &Up2Xbm, up2_bits, up2_tora_bits, up2_dog_bits,
163
 
      &Up2Msk, up2_mask_bits, up2_mask_bits, up2_dog_mask_bits },
164
 
    { &Down1GC, &Down1Xbm, down1_bits, down1_tora_bits, down1_dog_bits,
165
 
      &Down1Msk, down1_mask_bits, down1_mask_bits, down1_dog_mask_bits },
166
 
    { &Down2GC, &Down2Xbm, down2_bits, down2_tora_bits, down2_dog_bits,
167
 
      &Down2Msk, down2_mask_bits, down2_mask_bits, down2_dog_mask_bits },
168
 
    { &Left1GC, &Left1Xbm, left1_bits, left1_tora_bits, left1_dog_bits,
169
 
      &Left1Msk, left1_mask_bits, left1_mask_bits, left1_dog_mask_bits },
170
 
    { &Left2GC, &Left2Xbm, left2_bits, left2_tora_bits, left2_dog_bits,
171
 
      &Left2Msk, left2_mask_bits, left2_mask_bits, left2_dog_mask_bits },
172
 
    { &Right1GC, &Right1Xbm, right1_bits, right1_tora_bits, right1_dog_bits,
173
 
      &Right1Msk, right1_mask_bits, right1_mask_bits,right1_dog_mask_bits },
174
 
    { &Right2GC, &Right2Xbm, right2_bits, right2_tora_bits, right2_dog_bits,
175
 
      &Right2Msk, right2_mask_bits, right2_mask_bits, right2_dog_mask_bits },
176
 
    { &UpLeft1GC, &UpLeft1Xbm, upleft1_bits, upleft1_tora_bits, upleft1_dog_bits,
177
 
      &UpLeft1Msk, upleft1_mask_bits, upleft1_mask_bits, upleft1_dog_mask_bits },
178
 
    { &UpLeft2GC, &UpLeft2Xbm, upleft2_bits, upleft2_tora_bits, upleft2_dog_bits,
179
 
      &UpLeft2Msk, upleft2_mask_bits, upleft2_mask_bits,upleft2_dog_mask_bits },
180
 
    { &UpRight1GC, &UpRight1Xbm, upright1_bits, upright1_tora_bits, upright1_dog_bits,
181
 
      &UpRight1Msk, upright1_mask_bits, upright1_mask_bits,upright1_dog_mask_bits },
182
 
    { &UpRight2GC, &UpRight2Xbm, upright2_bits, upright2_tora_bits, upright2_dog_bits,
183
 
      &UpRight2Msk, upright2_mask_bits, upright2_mask_bits,upright2_dog_mask_bits },
184
 
    { &DownLeft1GC, &DownLeft1Xbm, dwleft1_bits, dwleft1_tora_bits, dwleft1_dog_bits,
185
 
      &DownLeft1Msk, dwleft1_mask_bits, dwleft1_mask_bits, dwleft1_dog_mask_bits },
186
 
    { &DownLeft2GC, &DownLeft2Xbm, dwleft2_bits, dwleft2_tora_bits, dwleft2_dog_bits,
187
 
      &DownLeft2Msk, dwleft2_mask_bits, dwleft2_mask_bits, dwleft2_dog_mask_bits },
188
 
    { &DownRight1GC, &DownRight1Xbm, dwright1_bits, dwright1_tora_bits, dwright1_dog_bits,
189
 
      &DownRight1Msk, dwright1_mask_bits, dwright1_mask_bits, dwright1_dog_mask_bits },
190
 
    { &DownRight2GC, &DownRight2Xbm, dwright2_bits, dwright2_tora_bits, dwright2_dog_bits,
191
 
      &DownRight2Msk, dwright2_mask_bits, dwright2_mask_bits, dwright2_dog_mask_bits },
192
 
    { &UpTogi1GC, &UpTogi1Xbm, utogi1_bits, utogi1_tora_bits, utogi1_dog_bits,
193
 
      &UpTogi1Msk, utogi1_mask_bits, utogi1_mask_bits, utogi1_dog_mask_bits },
194
 
    { &UpTogi2GC, &UpTogi2Xbm, utogi2_bits, utogi2_tora_bits, utogi2_dog_bits,
195
 
      &UpTogi2Msk, utogi2_mask_bits, utogi2_mask_bits, utogi2_dog_mask_bits },
196
 
    { &DownTogi1GC, &DownTogi1Xbm, dtogi1_bits, dtogi1_tora_bits, dtogi1_dog_bits,
197
 
      &DownTogi1Msk, dtogi1_mask_bits, dtogi1_mask_bits, dtogi1_dog_mask_bits },
198
 
    { &DownTogi2GC, &DownTogi2Xbm, dtogi2_bits, dtogi2_tora_bits, dtogi2_dog_bits,
199
 
      &DownTogi2Msk, dtogi2_mask_bits, dtogi2_mask_bits, dtogi2_dog_mask_bits },
200
 
    { &LeftTogi1GC, &LeftTogi1Xbm, ltogi1_bits, ltogi1_tora_bits, ltogi1_dog_bits,
201
 
      &LeftTogi1Msk, ltogi1_mask_bits, ltogi1_mask_bits,ltogi1_dog_mask_bits },
202
 
    { &LeftTogi2GC, &LeftTogi2Xbm, ltogi2_bits, ltogi2_tora_bits, ltogi2_dog_bits,
203
 
      &LeftTogi2Msk, ltogi2_mask_bits, ltogi2_mask_bits,ltogi2_dog_mask_bits },
204
 
    { &RightTogi1GC, &RightTogi1Xbm, rtogi1_bits, rtogi1_tora_bits, rtogi1_dog_bits,
205
 
      &RightTogi1Msk, rtogi1_mask_bits, rtogi1_mask_bits,rtogi1_dog_mask_bits },
206
 
    { &RightTogi2GC, &RightTogi2Xbm, rtogi2_bits, rtogi2_tora_bits, rtogi2_dog_bits,
207
 
      &RightTogi2Msk, rtogi2_mask_bits, rtogi2_mask_bits,rtogi2_dog_mask_bits },
 
155
    { &Mati2GC, &Mati2Xbm,  mati2_bits, mati2_tora_bits, mati2_dog_bits, mati2_sakura_bits, mati2_tomoyo_bits,
 
156
      &Mati2Msk, mati2_mask_bits, mati2_mask_bits, mati2_dog_mask_bits, mati2_sakura_mask_bits, mati2_tomoyo_mask_bits },
 
157
    { &Jare2GC, &Jare2Xbm,  jare2_bits, jare2_tora_bits, jare2_dog_bits, jare2_sakura_bits, jare2_tomoyo_bits,
 
158
      &Jare2Msk, jare2_mask_bits, jare2_mask_bits, jare2_dog_mask_bits, jare2_sakura_mask_bits, jare2_tomoyo_mask_bits },
 
159
    { &Kaki1GC, &Kaki1Xbm,  kaki1_bits, kaki1_tora_bits, kaki1_dog_bits, kaki1_sakura_bits, kaki1_tomoyo_bits,
 
160
      &Kaki1Msk, kaki1_mask_bits, kaki1_mask_bits, kaki1_dog_mask_bits, kaki1_sakura_mask_bits, kaki1_tomoyo_mask_bits },
 
161
    { &Kaki2GC, &Kaki2Xbm,  kaki2_bits, kaki2_tora_bits, kaki2_dog_bits, kaki2_sakura_bits, kaki2_tomoyo_bits,
 
162
      &Kaki2Msk, kaki2_mask_bits, kaki2_mask_bits, kaki2_dog_mask_bits, kaki2_sakura_mask_bits, kaki2_tomoyo_mask_bits },
 
163
    { &Mati3GC, &Mati3Xbm,  mati3_bits, mati3_tora_bits, mati3_dog_bits, mati3_sakura_bits, mati3_tomoyo_bits,
 
164
      &Mati3Msk, mati3_mask_bits, mati3_mask_bits, mati3_dog_mask_bits, mati3_sakura_mask_bits, mati3_tomoyo_mask_bits },
 
165
    { &Sleep1GC, &Sleep1Xbm,  sleep1_bits, sleep1_tora_bits, sleep1_dog_bits, sleep1_sakura_bits, sleep1_tomoyo_bits,
 
166
      &Sleep1Msk, sleep1_mask_bits, sleep1_mask_bits, sleep1_dog_mask_bits, sleep1_sakura_mask_bits, sleep1_tomoyo_mask_bits },
 
167
    { &Sleep2GC, &Sleep2Xbm,  sleep2_bits, sleep2_tora_bits, sleep2_dog_bits, sleep2_sakura_bits, sleep2_tomoyo_bits,
 
168
      &Sleep2Msk, sleep2_mask_bits, sleep2_mask_bits, sleep2_dog_mask_bits, sleep2_sakura_mask_bits, sleep2_tomoyo_mask_bits },
 
169
    { &AwakeGC, &AwakeXbm,  awake_bits, awake_tora_bits, awake_dog_bits, awake_sakura_bits, awake_tomoyo_bits,
 
170
      &AwakeMsk, awake_mask_bits, awake_mask_bits, awake_dog_mask_bits, awake_sakura_mask_bits, awake_tomoyo_mask_bits },
 
171
    { &Up1GC, &Up1Xbm,  up1_bits, up1_tora_bits, up1_dog_bits, up1_sakura_bits, up1_tomoyo_bits,
 
172
      &Up1Msk, up1_mask_bits, up1_mask_bits, up1_dog_mask_bits, up1_sakura_mask_bits, up1_tomoyo_mask_bits },
 
173
    { &Up2GC, &Up2Xbm,  up2_bits, up2_tora_bits, up2_dog_bits, up2_sakura_bits, up2_tomoyo_bits,
 
174
      &Up2Msk, up2_mask_bits, up2_mask_bits, up2_dog_mask_bits, up2_sakura_mask_bits, up2_tomoyo_mask_bits },
 
175
    { &Down1GC, &Down1Xbm,  down1_bits, down1_tora_bits, down1_dog_bits, down1_sakura_bits, down1_tomoyo_bits,
 
176
      &Down1Msk, down1_mask_bits, down1_mask_bits, down1_dog_mask_bits, down1_sakura_mask_bits, down1_tomoyo_mask_bits },
 
177
    { &Down2GC, &Down2Xbm,  down2_bits, down2_tora_bits, down2_dog_bits, down2_sakura_bits, down2_tomoyo_bits,
 
178
      &Down2Msk, down2_mask_bits, down2_mask_bits, down2_dog_mask_bits, down2_sakura_mask_bits, down2_tomoyo_mask_bits },
 
179
    { &Left1GC, &Left1Xbm,  left1_bits, left1_tora_bits, left1_dog_bits, left1_sakura_bits, left1_tomoyo_bits,
 
180
      &Left1Msk, left1_mask_bits, left1_mask_bits, left1_dog_mask_bits, left1_sakura_mask_bits, left1_tomoyo_mask_bits },
 
181
    { &Left2GC, &Left2Xbm,  left2_bits, left2_tora_bits, left2_dog_bits, left2_sakura_bits, left2_tomoyo_bits,
 
182
      &Left2Msk, left2_mask_bits, left2_mask_bits, left2_dog_mask_bits, left2_sakura_mask_bits, left2_tomoyo_mask_bits },
 
183
    { &Right1GC, &Right1Xbm,  right1_bits, right1_tora_bits, right1_dog_bits, right1_sakura_bits, right1_tomoyo_bits,
 
184
      &Right1Msk, right1_mask_bits, right1_mask_bits,right1_dog_mask_bits, right1_sakura_mask_bits, right1_tomoyo_mask_bits },
 
185
    { &Right2GC, &Right2Xbm,  right2_bits, right2_tora_bits, right2_dog_bits, right2_sakura_bits, right2_tomoyo_bits,
 
186
      &Right2Msk, right2_mask_bits, right2_mask_bits, right2_dog_mask_bits, right2_sakura_mask_bits, right2_tomoyo_mask_bits },
 
187
    { &UpLeft1GC, &UpLeft1Xbm,  upleft1_bits, upleft1_tora_bits, upleft1_dog_bits, upleft1_sakura_bits, upleft1_tomoyo_bits,
 
188
      &UpLeft1Msk, upleft1_mask_bits, upleft1_mask_bits, upleft1_dog_mask_bits, upleft1_sakura_mask_bits, upleft1_tomoyo_mask_bits },
 
189
    { &UpLeft2GC, &UpLeft2Xbm,  upleft2_bits, upleft2_tora_bits, upleft2_dog_bits, upleft2_sakura_bits, upleft2_tomoyo_bits,
 
190
      &UpLeft2Msk, upleft2_mask_bits, upleft2_mask_bits,upleft2_dog_mask_bits, upleft2_sakura_mask_bits, upleft2_tomoyo_mask_bits },
 
191
    { &UpRight1GC, &UpRight1Xbm,  upright1_bits, upright1_tora_bits, upright1_dog_bits, upright1_sakura_bits, upright1_tomoyo_bits,
 
192
      &UpRight1Msk, upright1_mask_bits, upright1_mask_bits,upright1_dog_mask_bits, upright1_sakura_mask_bits, upright1_tomoyo_mask_bits },
 
193
    { &UpRight2GC, &UpRight2Xbm,  upright2_bits, upright2_tora_bits, upright2_dog_bits, upright2_sakura_bits, upright2_tomoyo_bits,
 
194
      &UpRight2Msk, upright2_mask_bits, upright2_mask_bits,upright2_dog_mask_bits, upright2_sakura_mask_bits, upright2_tomoyo_mask_bits },
 
195
    { &DownLeft1GC, &DownLeft1Xbm,  dwleft1_bits, dwleft1_tora_bits, dwleft1_dog_bits, dwleft1_sakura_bits, dwleft1_tomoyo_bits,
 
196
      &DownLeft1Msk, dwleft1_mask_bits, dwleft1_mask_bits, dwleft1_dog_mask_bits, dwleft1_sakura_mask_bits, dwleft1_tomoyo_mask_bits },
 
197
    { &DownLeft2GC, &DownLeft2Xbm,  dwleft2_bits, dwleft2_tora_bits, dwleft2_dog_bits, dwleft2_sakura_bits, dwleft2_tomoyo_bits,
 
198
      &DownLeft2Msk, dwleft2_mask_bits, dwleft2_mask_bits, dwleft2_dog_mask_bits, dwleft2_sakura_mask_bits, dwleft2_tomoyo_mask_bits },
 
199
    { &DownRight1GC, &DownRight1Xbm,  dwright1_bits, dwright1_tora_bits, dwright1_dog_bits, dwright1_sakura_bits, dwright1_tomoyo_bits,
 
200
      &DownRight1Msk, dwright1_mask_bits, dwright1_mask_bits, dwright1_dog_mask_bits, dwright1_sakura_mask_bits, dwright1_tomoyo_mask_bits },
 
201
    { &DownRight2GC, &DownRight2Xbm,  dwright2_bits, dwright2_tora_bits, dwright2_dog_bits, dwright2_sakura_bits, dwright2_tomoyo_bits,
 
202
      &DownRight2Msk, dwright2_mask_bits, dwright2_mask_bits, dwright2_dog_mask_bits, dwright2_sakura_mask_bits, dwright2_tomoyo_mask_bits },
 
203
    { &UpTogi1GC, &UpTogi1Xbm,  utogi1_bits, utogi1_tora_bits, utogi1_dog_bits, utogi1_sakura_bits, utogi1_tomoyo_bits,
 
204
      &UpTogi1Msk, utogi1_mask_bits, utogi1_mask_bits, utogi1_dog_mask_bits, utogi1_sakura_mask_bits, utogi1_tomoyo_mask_bits },
 
205
    { &UpTogi2GC, &UpTogi2Xbm,  utogi2_bits, utogi2_tora_bits, utogi2_dog_bits, utogi2_sakura_bits, utogi2_tomoyo_bits,
 
206
      &UpTogi2Msk, utogi2_mask_bits, utogi2_mask_bits, utogi2_dog_mask_bits, utogi2_sakura_mask_bits, utogi2_tomoyo_mask_bits },
 
207
    { &DownTogi1GC, &DownTogi1Xbm,  dtogi1_bits, dtogi1_tora_bits, dtogi1_dog_bits, dtogi1_sakura_bits, dtogi1_tomoyo_bits,
 
208
      &DownTogi1Msk, dtogi1_mask_bits, dtogi1_mask_bits, dtogi1_dog_mask_bits, dtogi1_sakura_mask_bits, dtogi1_tomoyo_mask_bits },
 
209
    { &DownTogi2GC, &DownTogi2Xbm,  dtogi2_bits, dtogi2_tora_bits, dtogi2_dog_bits, dtogi2_sakura_bits, dtogi2_tomoyo_bits,
 
210
      &DownTogi2Msk, dtogi2_mask_bits, dtogi2_mask_bits, dtogi2_dog_mask_bits, dtogi2_sakura_mask_bits, dtogi2_tomoyo_mask_bits },
 
211
    { &LeftTogi1GC, &LeftTogi1Xbm,  ltogi1_bits, ltogi1_tora_bits, ltogi1_dog_bits, ltogi1_sakura_bits, ltogi1_tomoyo_bits,
 
212
      &LeftTogi1Msk, ltogi1_mask_bits, ltogi1_mask_bits,ltogi1_dog_mask_bits, ltogi1_sakura_mask_bits, ltogi1_tomoyo_mask_bits },
 
213
    { &LeftTogi2GC, &LeftTogi2Xbm,  ltogi2_bits, ltogi2_tora_bits, ltogi2_dog_bits, ltogi2_sakura_bits, ltogi2_tomoyo_bits,
 
214
      &LeftTogi2Msk, ltogi2_mask_bits, ltogi2_mask_bits,ltogi2_dog_mask_bits, ltogi2_sakura_mask_bits, ltogi2_tomoyo_mask_bits },
 
215
    { &RightTogi1GC, &RightTogi1Xbm,  rtogi1_bits, rtogi1_tora_bits, rtogi1_dog_bits, rtogi1_sakura_bits, rtogi1_tomoyo_bits,
 
216
      &RightTogi1Msk, rtogi1_mask_bits, rtogi1_mask_bits,rtogi1_dog_mask_bits, rtogi1_sakura_mask_bits, rtogi1_tomoyo_mask_bits },
 
217
    { &RightTogi2GC, &RightTogi2Xbm,  rtogi2_bits, rtogi2_tora_bits, rtogi2_dog_bits, rtogi2_sakura_bits, rtogi2_tomoyo_bits,
 
218
      &RightTogi2Msk, rtogi2_mask_bits, rtogi2_mask_bits,rtogi2_dog_mask_bits, rtogi2_sakura_mask_bits, rtogi2_tomoyo_mask_bits },
208
219
    { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
209
220
};
210
221
 
215
226
 
216
227
Animation       AnimationPattern[][2] =
217
228
{
218
 
    {{ &Mati2GC, &Mati2Msk },
219
 
    { &Mati2GC, &Mati2Msk }},           /* NekoState == NEKO_STOP */
220
 
    {{ &Jare2GC, &Jare2Msk },
221
 
    { &Mati2GC, &Mati2Msk }},           /* NekoState == NEKO_JARE */
222
 
    {{ &Kaki1GC, &Kaki1Msk },
223
 
    { &Kaki2GC, &Kaki2Msk }},           /* NekoState == NEKO_KAKI */
224
 
    {{ &Mati3GC, &Mati3Msk },
225
 
    { &Mati3GC, &Mati3Msk }},           /* NekoState == NEKO_AKUBI */
226
 
    {{ &Sleep1GC, &Sleep1Msk },
227
 
    { &Sleep2GC, &Sleep2Msk }},         /* NekoState == NEKO_SLEEP */
228
 
    {{ &AwakeGC, &AwakeMsk },
229
 
    { &AwakeGC, &AwakeMsk }},           /* NekoState == NEKO_AWAKE */
230
 
    {{ &Up1GC, &Up1Msk },
231
 
    { &Up2GC, &Up2Msk }},               /* NekoState == NEKO_U_MOVE */
232
 
    {{ &Down1GC, &Down1Msk },
233
 
    { &Down2GC, &Down2Msk }},           /* NekoState == NEKO_D_MOVE */
234
 
    {{ &Left1GC, &Left1Msk },
235
 
    { &Left2GC, &Left2Msk }},           /* NekoState == NEKO_L_MOVE */
236
 
    {{ &Right1GC, &Right1Msk },
237
 
    { &Right2GC, &Right2Msk }},         /* NekoState == NEKO_R_MOVE */
238
 
    {{ &UpLeft1GC, &UpLeft1Msk },
239
 
    { &UpLeft2GC, &UpLeft2Msk }},       /* NekoState == NEKO_UL_MOVE */
240
 
    {{ &UpRight1GC, &UpRight1Msk },
241
 
    { &UpRight2GC, &UpRight2Msk }},     /* NekoState == NEKO_UR_MOVE */
242
 
    {{ &DownLeft1GC, &DownLeft1Msk },
243
 
    { &DownLeft2GC, &DownLeft2Msk }},   /* NekoState == NEKO_DL_MOVE */
244
 
    {{ &DownRight1GC, &DownRight1Msk },
245
 
    { &DownRight2GC, &DownRight2Msk }}, /* NekoState == NEKO_DR_MOVE */
246
 
    {{ &UpTogi1GC, &UpTogi1Msk },
247
 
    { &UpTogi2GC, &UpTogi2Msk }},       /* NekoState == NEKO_U_TOGI */
248
 
    {{ &DownTogi1GC, &DownTogi1Msk },
249
 
    { &DownTogi2GC, &DownTogi2Msk }},   /* NekoState == NEKO_D_TOGI */
250
 
    {{ &LeftTogi1GC, &LeftTogi1Msk },
251
 
    { &LeftTogi2GC, &LeftTogi2Msk }},   /* NekoState == NEKO_L_TOGI */
252
 
    {{ &RightTogi1GC, &RightTogi1Msk },
253
 
    { &RightTogi2GC, &RightTogi2Msk }}, /* NekoState == NEKO_R_TOGI */
 
229
  { { &Mati2GC, &Mati2Msk },
 
230
    { &Mati2GC, &Mati2Msk } },          /* NekoState == NEKO_STOP */
 
231
  { { &Jare2GC, &Jare2Msk },
 
232
    { &Mati2GC, &Mati2Msk } },          /* NekoState == NEKO_JARE */
 
233
  { { &Kaki1GC, &Kaki1Msk },
 
234
    { &Kaki2GC, &Kaki2Msk } },          /* NekoState == NEKO_KAKI */
 
235
  { { &Mati3GC, &Mati3Msk },
 
236
    { &Mati3GC, &Mati3Msk } },          /* NekoState == NEKO_AKUBI */
 
237
  { { &Sleep1GC, &Sleep1Msk },
 
238
    { &Sleep2GC, &Sleep2Msk } },                /* NekoState == NEKO_SLEEP */
 
239
  { { &AwakeGC, &AwakeMsk },
 
240
    { &AwakeGC, &AwakeMsk } },          /* NekoState == NEKO_AWAKE */
 
241
  { { &Up1GC, &Up1Msk },
 
242
    { &Up2GC, &Up2Msk } },              /* NekoState == NEKO_U_MOVE */
 
243
  { { &Down1GC, &Down1Msk },
 
244
    { &Down2GC, &Down2Msk } },          /* NekoState == NEKO_D_MOVE */
 
245
  { { &Left1GC, &Left1Msk },
 
246
    { &Left2GC, &Left2Msk } },          /* NekoState == NEKO_L_MOVE */
 
247
  { { &Right1GC, &Right1Msk },
 
248
    { &Right2GC, &Right2Msk } },                /* NekoState == NEKO_R_MOVE */
 
249
  { { &UpLeft1GC, &UpLeft1Msk },
 
250
    { &UpLeft2GC, &UpLeft2Msk } },      /* NekoState == NEKO_UL_MOVE */
 
251
  { { &UpRight1GC, &UpRight1Msk },
 
252
    { &UpRight2GC, &UpRight2Msk } },    /* NekoState == NEKO_UR_MOVE */
 
253
  { { &DownLeft1GC, &DownLeft1Msk },
 
254
    { &DownLeft2GC, &DownLeft2Msk } },  /* NekoState == NEKO_DL_MOVE */
 
255
  { { &DownRight1GC, &DownRight1Msk },
 
256
    { &DownRight2GC, &DownRight2Msk } },        /* NekoState == NEKO_DR_MOVE */
 
257
  { { &UpTogi1GC, &UpTogi1Msk },
 
258
    { &UpTogi2GC, &UpTogi2Msk } },      /* NekoState == NEKO_U_TOGI */
 
259
  { { &DownTogi1GC, &DownTogi1Msk },
 
260
    { &DownTogi2GC, &DownTogi2Msk } },  /* NekoState == NEKO_D_TOGI */
 
261
  { { &LeftTogi1GC, &LeftTogi1Msk },
 
262
    { &LeftTogi2GC, &LeftTogi2Msk } },  /* NekoState == NEKO_L_TOGI */
 
263
  { { &RightTogi1GC, &RightTogi1Msk },
 
264
    { &RightTogi2GC, &RightTogi2Msk } },        /* NekoState == NEKO_R_TOGI */
254
265
};
255
266
 
 
267
static void NullFunction();
256
268
 
257
269
/*
258
270
 *      $@%S%C%H%^%C%W%G!<%?!&(JGC $@=i4|2=(J
400
412
  if (IdleSpace == 0) {
401
413
    IdleSpace = AnimalDefaultsDataTable[NekoMoyou].idle;
402
414
  }
 
415
  XOffset = XOffset + AnimalDefaultsDataTable[NekoMoyou].off_x;
 
416
  YOffset = YOffset + AnimalDefaultsDataTable[NekoMoyou].off_y;
403
417
  if (NoShape == NOTDEFINED) {
404
418
    NoShape = False;
405
419
  }
406
420
  if (ReverseVideo == NOTDEFINED) {
407
421
    ReverseVideo = False;
408
422
  }
 
423
  if (ToWindow == NOTDEFINED) {
 
424
    ToWindow = False;
 
425
  }
 
426
  if (ToFocus == NOTDEFINED) {
 
427
    ToFocus = False;
 
428
  }
409
429
}
410
430
 
411
431
/*
477
497
}
478
498
 
479
499
/*
 
500
 * Routine to let user select a window using the mouse
 
501
 *
 
502
 * This routine originate in dsimple.c
 
503
 */
 
504
 
 
505
Window Select_Window(dpy)
 
506
     Display *dpy;
 
507
{
 
508
  int status;
 
509
  Cursor cursor;
 
510
  XEvent event;
 
511
  Window target_win = None, root = theRoot;
 
512
  int buttons = 0;
 
513
 
 
514
  /* Make the target cursor */
 
515
  cursor = theCursor;
 
516
 
 
517
  /* Grab the pointer using target cursor, letting it room all over */
 
518
  status = XGrabPointer(dpy, root, False,
 
519
                        ButtonPressMask|ButtonReleaseMask, GrabModeSync,
 
520
                        GrabModeAsync, root, cursor, CurrentTime);
 
521
  if (status != GrabSuccess) {
 
522
    fprintf(stderr, "%s: Can't grab the mouse.\n", ProgramName);
 
523
    exit(1);
 
524
  }
 
525
 
 
526
  /* Let the user select a window... */
 
527
  while ((target_win == None) || (buttons != 0)) {
 
528
    /* allow one more event */
 
529
    XAllowEvents(dpy, SyncPointer, CurrentTime);
 
530
    XWindowEvent(dpy, root, ButtonPressMask|ButtonReleaseMask, &event);
 
531
    switch (event.type) {
 
532
    case ButtonPress:
 
533
      if (target_win == None) {
 
534
        target_win = event.xbutton.subwindow; /* window selected */
 
535
        if (target_win == None) target_win = root;
 
536
      }
 
537
      buttons++;
 
538
      break;
 
539
    case ButtonRelease:
 
540
      if (buttons > 0) /* there may have been some down before we started */
 
541
        buttons--;
 
542
       break;
 
543
    }
 
544
  } 
 
545
 
 
546
  XUngrabPointer(dpy, CurrentTime);      /* Done with pointer */
 
547
 
 
548
  return(target_win);
 
549
}
 
550
 
 
551
/*
 
552
 * Window_With_Name: routine to locate a window with a given name on a display.
 
553
 *                   If no window with the given name is found, 0 is returned.
 
554
 *                   If more than one window has the given name, the first
 
555
 *                   one found will be returned.  Only top and its subwindows
 
556
 *                   are looked at.  Normally, top should be the RootWindow.
 
557
 *
 
558
 * This routine originate in dsimple.c
 
559
 */
 
560
Window Window_With_Name(dpy, top, name)
 
561
     Display *dpy;
 
562
     Window top;
 
563
     char *name;
 
564
{
 
565
        Window *children, dummy;
 
566
        unsigned int nchildren;
 
567
        int i;
 
568
        Window w=0;
 
569
        char *window_name;
 
570
 
 
571
        if (XFetchName(dpy, top, &window_name) && !strcmp(window_name, name))
 
572
          return(top);
 
573
 
 
574
        if (!XQueryTree(dpy, top, &dummy, &dummy, &children, &nchildren))
 
575
          return(0);
 
576
 
 
577
        for (i=0; i<nchildren; i++) {
 
578
                w = Window_With_Name(dpy, children[i], name);
 
579
                if (w)
 
580
                  break;
 
581
        }
 
582
        if (children) XFree ((char *)children);
 
583
        return(w);
 
584
}
 
585
 
 
586
/*
480
587
 *      $@%9%/%j!<%s4D6-=i4|2=(J
481
588
 */
482
589
 
489
596
  Window                        theTempRoot;
490
597
  int                           WindowPointX;
491
598
  int                           WindowPointY;
492
 
  unsigned long         BorderWidth;
 
599
  unsigned int          BorderWidth;
493
600
  int                           event_base, error_base;
494
601
 
495
602
  if ((theDisplay = XOpenDisplay(DisplayName)) == NULL) {
530
637
  SetupColors();
531
638
  MakeMouseCursor();
532
639
 
 
640
  if (ToWindow && theTarget == None) {
 
641
    if (TargetName != NULL) {
 
642
      int i;
 
643
 
 
644
      for (i=0; i<5; i++) {
 
645
        theTarget = Window_With_Name(theDisplay, theRoot, TargetName);
 
646
        if (theTarget != None) break;
 
647
      }
 
648
      if (theTarget == None) {
 
649
        fprintf(stderr, "%s: No window with name '%s' exists.\n",
 
650
                ProgramName, TargetName);
 
651
        exit(1);
 
652
      }
 
653
    } else {
 
654
      theTarget = Select_Window(theDisplay);
 
655
      if (theTarget == theRoot) {
 
656
        theTarget = None;
 
657
        ToWindow = False;
 
658
      }
 
659
    }
 
660
    if (theTarget != None) {
 
661
      Window            QueryRoot, QueryParent, *QueryChildren;
 
662
      unsigned int      nchild;
 
663
 
 
664
      for (;;) {
 
665
        if (XQueryTree(theDisplay, theTarget, &QueryRoot,
 
666
                       &QueryParent, &QueryChildren, &nchild)) {
 
667
          XFree(QueryChildren);
 
668
          if (QueryParent == QueryRoot) break;
 
669
          theTarget = QueryParent;
 
670
        }
 
671
        else {
 
672
          fprintf(stderr, "%s: Target Lost.\n",ProgramName);
 
673
          exit(1);
 
674
        }
 
675
      }
 
676
    }
 
677
  }
 
678
 
533
679
  theWindowAttributes.background_pixel = theBackgroundColor.pixel;
534
680
  theWindowAttributes.cursor = theCursor;
535
681
  theWindowAttributes.override_redirect = True;
536
682
 
537
 
  theWindowMask = CWCursor;
538
 
  XChangeWindowAttributes(theDisplay, theRoot, theWindowMask,
539
 
                          &theWindowAttributes);
 
683
  if (!ToWindow) XChangeWindowAttributes(theDisplay, theRoot, CWCursor,
 
684
                                         &theWindowAttributes);
540
685
 
541
686
  theWindowMask = CWBackPixel           |
542
687
    CWCursor            |
543
688
      CWOverrideRedirect;
544
689
 
545
690
  theWindow = XCreateWindow(theDisplay, theRoot, 0, 0,
546
 
#ifdef SHAPE
547
 
                            (NoShape == False)? WindowWidth: BITMAP_WIDTH,
548
 
                            (NoShape == False)? WindowHeight: BITMAP_HEIGHT,
549
 
#else SHAPE
550
691
                            BITMAP_WIDTH, BITMAP_HEIGHT,
551
 
#endif SHAPE
552
692
                            0, theDepth, InputOutput, CopyFromParent,
553
693
                            theWindowMask, &theWindowAttributes);
554
694
 
555
 
  XStoreName(theDisplay, theWindow, ProgramName);
 
695
  if (WindowName == NULL) WindowName = ProgramName;
 
696
  XStoreName(theDisplay, theWindow, WindowName);
556
697
 
557
698
  InitBitmapAndGCs();
558
699
 
559
 
  XSelectInput(theDisplay, theWindow, ExposureMask|VisibilityChangeMask);
 
700
  XSelectInput(theDisplay, theWindow, 
 
701
               ExposureMask|VisibilityChangeMask|KeyPressMask);
560
702
 
561
703
  XFlush(theDisplay);
562
704
}
563
705
 
564
706
 
565
707
/*
 
708
 *      SIGINT $@%7%0%J%k=hM}(J
 
709
 */
 
710
 
 
711
void
 
712
RestoreCursor()
 
713
{
 
714
  XSetWindowAttributes  theWindowAttributes;
 
715
  BitmapGCData *BitmapGCDataTablePtr;
 
716
 
 
717
  theWindowAttributes.cursor = None;
 
718
  XChangeWindowAttributes(theDisplay, theRoot, CWCursor,
 
719
                          &theWindowAttributes);
 
720
  for (BitmapGCDataTablePtr = BitmapGCDataTable;
 
721
       BitmapGCDataTablePtr->GCCreatePtr != NULL;
 
722
       BitmapGCDataTablePtr++) {
 
723
    XFreePixmap(theDisplay,*(BitmapGCDataTablePtr->BitmapCreatePtr));
 
724
    XFreePixmap(theDisplay,*(BitmapGCDataTablePtr->BitmapMasksPtr));
 
725
    XFreeGC(theDisplay,*(BitmapGCDataTablePtr->GCCreatePtr));
 
726
       }
 
727
  XFreeCursor(theDisplay,theCursor);
 
728
  XCloseDisplay(theDisplay);
 
729
  exit(0);
 
730
}
 
731
 
 
732
 
 
733
/*
566
734
 *      $@%$%s%?!<%P%k(J
567
735
 *
568
736
 *      $@!!$3$N4X?t$r8F$V$H!"$"$k0lDj$N;~4VJV$C$F$3$J$/$J$k!#G-(J
628
796
 
629
797
    if ((x != NekoLastX) || (y != NekoLastY)
630
798
                || (DrawGC != NekoLastGC)) {
 
799
      XWindowChanges    theChanges;
631
800
 
 
801
      theChanges.x = x;
 
802
      theChanges.y = y;
 
803
      XConfigureWindow(theDisplay, theWindow, CWX | CWY, &theChanges);
632
804
#ifdef SHAPE
633
 
        if (NoShape == False) {
634
 
            XShapeCombineMask(theDisplay, theWindow, ShapeBounding,
635
 
                x, y, DrawMask, ShapeSet);
636
 
 
637
 
            if (DontMapped) {
638
 
                XMapRaised(theDisplay, theWindow);
639
 
                DontMapped = 0;
640
 
            }
641
 
 
642
 
            XSetTSOrigin(theDisplay, DrawGC, x, y);
643
 
 
644
 
            XFillRectangle(theDisplay, theWindow, DrawGC,
645
 
                x, y, BITMAP_WIDTH, BITMAP_HEIGHT);
646
 
        } else
 
805
      if (NoShape == False) {
 
806
        XShapeCombineMask(theDisplay, theWindow, ShapeBounding,
 
807
                          0, 0, DrawMask, ShapeSet);
 
808
 
 
809
      }
647
810
#endif SHAPE
648
 
        {
649
 
            XWindowChanges      theChanges;
650
 
 
651
 
            theChanges.x = x;
652
 
            theChanges.y = y;
653
 
            XConfigureWindow(theDisplay, theWindow, CWX | CWY, &theChanges);
654
 
 
655
 
            if (DontMapped) {
656
 
                XMapWindow(theDisplay, theWindow);
657
 
                DontMapped = 0;
658
 
            }
659
 
 
660
 
            XFillRectangle(theDisplay, theWindow, DrawGC,
661
 
                0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
662
 
        }
 
811
      if (DontMapped) {
 
812
        XMapWindow(theDisplay, theWindow);
 
813
        DontMapped = 0;
 
814
      }
 
815
      XFillRectangle(theDisplay, theWindow, DrawGC,
 
816
                     0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
663
817
    }
664
818
 
665
819
    XFlush(theDisplay);
678
832
void
679
833
RedrawNeko()
680
834
{
681
 
#ifdef SHAPE
682
 
    if (NoShape == False) {
683
 
        XFillRectangle(theDisplay, theWindow, NekoLastGC,
684
 
                NekoLastX, NekoLastY,
685
 
                BITMAP_WIDTH, BITMAP_HEIGHT);
686
 
    } else
687
 
#endif SHAPE
688
 
    {
689
 
        XFillRectangle(theDisplay, theWindow, NekoLastGC,
690
 
                0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
691
 
    }
 
835
  XFillRectangle(theDisplay, theWindow, NekoLastGC,
 
836
                 0, 0, BITMAP_WIDTH, BITMAP_HEIGHT);
692
837
 
693
 
    XFlush(theDisplay);
 
838
  XFlush(theDisplay);
694
839
}
695
840
 
696
841
 
809
954
    if ((PrevMouseX >= MouseX - IdleSpace
810
955
         && PrevMouseX <= MouseX + IdleSpace) &&
811
956
         (PrevMouseY >= MouseY - IdleSpace 
812
 
         && PrevMouseY <= MouseY + IdleSpace)) {
 
957
         && PrevMouseY <= MouseY + IdleSpace) &&
 
958
        (PrevTarget == theTarget)) {
813
959
        return(False);
814
960
    } else {
815
961
        return(True);
839
985
 
840
986
    PrevMouseX = MouseX;
841
987
    PrevMouseY = MouseY;
 
988
    PrevTarget = theTarget;
842
989
 
843
990
    MouseX = AbsoluteX+XOffset;
844
991
    MouseY = AbsoluteY+YOffset;
845
992
 
846
 
    LargeX = (double)(MouseX - NekoX - BITMAP_WIDTH / 2);
847
 
    LargeY = (double)(MouseY - NekoY - BITMAP_HEIGHT);
 
993
    if (ToFocus) {
 
994
      int               revert;
 
995
 
 
996
      XGetInputFocus(theDisplay, &theTarget, &revert);
 
997
 
 
998
      if (theTarget != theRoot
 
999
          && theTarget != PointerRoot && theTarget != None) {
 
1000
        Window          QueryParent, *QueryChildren;
 
1001
        unsigned int    nchild;
 
1002
 
 
1003
        for (;;) {
 
1004
          if (XQueryTree(theDisplay, theTarget, &QueryRoot,
 
1005
                         &QueryParent, &QueryChildren, &nchild)) {
 
1006
            XFree(QueryChildren);
 
1007
            if (QueryParent == QueryRoot) break;
 
1008
            theTarget = QueryParent;
 
1009
          }
 
1010
          else {
 
1011
            theTarget = None;
 
1012
            break;
 
1013
          }
 
1014
        }
 
1015
      }
 
1016
      else {
 
1017
        theTarget = None;
 
1018
      }
 
1019
    }
 
1020
 
 
1021
    if ((ToWindow || ToFocus) && theTarget != None) {
 
1022
      int                       status;
 
1023
      XWindowAttributes         theTargetAttributes;
 
1024
 
 
1025
      status =
 
1026
        XGetWindowAttributes(theDisplay, theTarget, &theTargetAttributes);
 
1027
 
 
1028
      if (ToWindow && status == 0) {
 
1029
        fprintf(stderr, "%s: '%s', Target Lost.\n",ProgramName, WindowName);
 
1030
        RestoreCursor();
 
1031
      }
 
1032
 
 
1033
      if (theTargetAttributes.x+theTargetAttributes.width > 0 
 
1034
          && theTargetAttributes.x < (int)WindowWidth
 
1035
          && theTargetAttributes.y+theTargetAttributes.height > 0 
 
1036
          && theTargetAttributes.y < (int)WindowHeight
 
1037
          && theTargetAttributes.map_state == IsViewable) {
 
1038
        if (ToFocus) {
 
1039
          if (MouseX < theTargetAttributes.x+BITMAP_WIDTH/2)
 
1040
            LargeX = (double)(theTargetAttributes.x + XOffset - NekoX);
 
1041
          else if (MouseX > theTargetAttributes.x+theTargetAttributes.width
 
1042
                   -BITMAP_WIDTH/2)
 
1043
            LargeX = (double)(theTargetAttributes.x + theTargetAttributes.width
 
1044
                              + XOffset - NekoX - BITMAP_WIDTH);
 
1045
          else 
 
1046
            LargeX = (double)(MouseX - NekoX - BITMAP_WIDTH / 2);
 
1047
 
 
1048
          LargeY = (double)(theTargetAttributes.y
 
1049
                            + YOffset - NekoY - BITMAP_HEIGHT);
 
1050
        }
 
1051
        else {
 
1052
          MouseX = theTargetAttributes.x 
 
1053
            + theTargetAttributes.width / 2 + XOffset;
 
1054
          MouseY = theTargetAttributes.y + YOffset;
 
1055
          LargeX = (double)(MouseX - NekoX - BITMAP_WIDTH / 2);
 
1056
          LargeY = (double)(MouseY - NekoY - BITMAP_HEIGHT);    
 
1057
        }
 
1058
      }
 
1059
      else {
 
1060
        LargeX = (double)(MouseX - NekoX - BITMAP_WIDTH / 2);
 
1061
        LargeY = (double)(MouseY - NekoY - BITMAP_HEIGHT);
 
1062
      }
 
1063
    }
 
1064
    else {
 
1065
      LargeX = (double)(MouseX - NekoX - BITMAP_WIDTH / 2);
 
1066
      LargeY = (double)(MouseY - NekoY - BITMAP_HEIGHT);
 
1067
    }
848
1068
 
849
1069
    DoubleLength = LargeX * LargeX + LargeY * LargeY;
850
1070
 
895
1115
            SetNekoState(NEKO_L_TOGI);
896
1116
        } else if (NekoMoveDx > 0 && NekoX >= WindowWidth - BITMAP_WIDTH) {
897
1117
            SetNekoState(NEKO_R_TOGI);
898
 
        } else if (NekoMoveDy < 0 && NekoY <= 0) {
 
1118
        } else if ((NekoMoveDy < 0 && NekoY <= 0)
 
1119
                   || (ToFocus && theTarget != None && NekoY > MouseY)){
899
1120
            SetNekoState(NEKO_U_TOGI);
900
 
        } else if (NekoMoveDy > 0 && NekoY >= WindowHeight - BITMAP_HEIGHT) {
 
1121
        } else if ((NekoMoveDy > 0 && NekoY >= WindowHeight - BITMAP_HEIGHT)
 
1122
                   || (ToFocus && theTarget != None 
 
1123
                       &&  NekoY < MouseY - BITMAP_HEIGHT)){
901
1124
            SetNekoState(NEKO_D_TOGI);
902
1125
        } else {
903
1126
            SetNekoState(NEKO_JARE);
1017
1240
    default:
1018
1241
      break;
1019
1242
    }
1020
 
    puts("Key Event");
1021
1243
  }
1022
1244
 
1023
1245
  return(ReturnState);
1104
1326
 *      SIGALRM $@%7%0%J%k=hM}(J
1105
1327
 */
1106
1328
 
1107
 
void
 
1329
static void
1108
1330
NullFunction()
1109
1331
{
1110
 
#ifdef linux
1111
 
  signal(SIGALRM, NullFunction);
1112
 
#endif
1113
1332
  /* No Operation */
 
1333
#if defined(SYSV) || defined(SVR4)
 
1334
  signal(SIGALRM, NullFunction);
 
1335
#endif /* SYSV || SVR4 */
1114
1336
}
1115
1337
 
1116
1338
/*
1117
 
 *      SIGINT $@%7%0%J%k=hM}(J
 
1339
 *      $@%(%i!<=hM}(J
1118
1340
 */
1119
1341
 
1120
 
void
1121
 
RestoreCursor()
 
1342
int
 
1343
NekoErrorHandler(dpy, err)
 
1344
     Display            *dpy;
 
1345
     XErrorEvent        *err;
1122
1346
{
1123
 
  XSetWindowAttributes  theWindowAttributes;
1124
 
  BitmapGCData *BitmapGCDataTablePtr;
1125
 
 
1126
 
  theWindowAttributes.cursor = None;
1127
 
  XChangeWindowAttributes(theDisplay, theRoot, CWCursor,
1128
 
                          &theWindowAttributes);
1129
 
  for (BitmapGCDataTablePtr = BitmapGCDataTable;
1130
 
       BitmapGCDataTablePtr->GCCreatePtr != NULL;
1131
 
       BitmapGCDataTablePtr++) {
1132
 
    XFreePixmap(theDisplay,*(BitmapGCDataTablePtr->BitmapCreatePtr));
1133
 
    XFreePixmap(theDisplay,*(BitmapGCDataTablePtr->BitmapMasksPtr));
1134
 
    XFreeGC(theDisplay,*(BitmapGCDataTablePtr->GCCreatePtr));
1135
 
       }
1136
 
  XFreeCursor(theDisplay,theCursor);
1137
 
  XCloseDisplay(theDisplay);
1138
 
  exit(0);
 
1347
  if (err->error_code==BadWindow && (ToWindow || ToFocus)) {
 
1348
  }
 
1349
  else {
 
1350
    char msg[80];
 
1351
    XGetErrorText(dpy, err->error_code, msg, 80);
 
1352
    fprintf(stderr, "%s: Error and exit.\n%s\n", ProgramName, msg);
 
1353
    exit(1);
 
1354
  }
1139
1355
}
1140
1356
 
1141
1357
 
1152
1368
"-speed <dots>",
1153
1369
"-time <microseconds>",
1154
1370
"-idle <dots>",
 
1371
"-name <name>           : set window name of neko.",
 
1372
"-towindow              : Neko chases selected window.",
 
1373
"-toname <name>         : Neko chases specified window.",
 
1374
"-tofocus               : Neko runs on top of focus window",
1155
1375
"-rv                    : Reverse video. (effects monochrome display only)",
1156
 
"-position <geometry>   : as position of geometry, relative to mouse pointer.",
 
1376
"-position <geometry>   : adjust position relative to mouse pointer.",
1157
1377
"-debug                 : puts you in synchronous mode.",
1158
1378
"-patchlevel            : print out your current patchlevel.",
1159
1379
NULL };
1234
1454
        exit(1);
1235
1455
      }
1236
1456
    }
 
1457
    else if (strcmp(argv[ArgCounter], "-name") == 0) {
 
1458
      ArgCounter++;
 
1459
      if (ArgCounter < argc) {
 
1460
        WindowName = argv[ArgCounter];
 
1461
      } else {
 
1462
        fprintf(stderr, "%s: -name option error.\n", ProgramName);
 
1463
        exit(1);
 
1464
      }
 
1465
    }
 
1466
    else if (strcmp(argv[ArgCounter], "-towindow") == 0) {
 
1467
      ToWindow = True;
 
1468
      ToFocus = False;
 
1469
    }
 
1470
    else if (strcmp(argv[ArgCounter], "-toname") == 0) {
 
1471
      ArgCounter++;
 
1472
      if (ArgCounter < argc) {
 
1473
        TargetName = argv[ArgCounter];
 
1474
        ToWindow = True;
 
1475
        ToFocus = False;
 
1476
      } else {
 
1477
        fprintf(stderr, "%s: -toname option error.\n", ProgramName);
 
1478
        exit(1);
 
1479
      }
 
1480
    }
 
1481
    else if (strcmp(argv[ArgCounter], "-tofocus") == 0) {
 
1482
      ToFocus = True;
 
1483
      ToWindow = False;
 
1484
    }
1237
1485
    else if ((strcmp(argv[ArgCounter], "-fg") == 0) ||
1238
1486
             (strcmp(argv[ArgCounter], "-foreground") == 0)) {
1239
1487
      ArgCounter++;
1261
1509
      fprintf(stderr,"Patchlevel :%s\n",PATCHLEVEL);
1262
1510
    }
1263
1511
    else {
1264
 
      for (loop=0;loop<BITMAPTYPES;loop++)
1265
 
        if (strcmp(argv[ArgCounter]+1,AnimalDefaultsDataTable[loop].name)==0)
 
1512
      char *av = argv[ArgCounter] + 1;
 
1513
      for (loop=0;loop<BITMAPTYPES;loop++) {
 
1514
        if (strcmp(av,AnimalDefaultsDataTable[loop].name)==0)
1266
1515
          {NekoMoyou = loop;found=1;}
 
1516
      }
1267
1517
      if (!found) {
1268
1518
        fprintf(stderr,
1269
1519
                "%s: Unknown option \"%s\".\n", ProgramName,
1298
1548
 
1299
1549
  GetArguments(argc, argv, theDisplayName);
1300
1550
 
 
1551
  XSetErrorHandler(NekoErrorHandler);
 
1552
 
1301
1553
  InitScreen(theDisplayName);
1302
1554
 
1303
1555
  signal(SIGALRM, NullFunction);