-
Notifications
You must be signed in to change notification settings - Fork 0
/
menus.c
765 lines (676 loc) · 20.5 KB
/
menus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
/****************************************************************************
* This module is based on Twm, but has been siginificantly modified
* by Rob Nation ([email protected]
****************************************************************************/
/*****************************************************************************/
/** Copyright 1988 by Evans & Sutherland Computer Corporation, **/
/** Salt Lake City, Utah **/
/** Portions Copyright 1989 by the Massachusetts Institute of Technology **/
/** Cambridge, Massachusetts **/
/** **/
/** All Rights Reserved **/
/** **/
/** Permission to use, copy, modify, and distribute this software and **/
/** its documentation for any purpose and without fee is hereby **/
/** granted, provided that the above copyright notice appear in all **/
/** copies and that both that copyright notice and this permis- **/
/** sion notice appear in supporting documentation, and that the **/
/** names of Evans & Sutherland and M.I.T. not be used in advertising **/
/** in publicity pertaining to distribution of the software without **/
/** specific, written prior permission. **/
/** **/
/** EVANS & SUTHERLAND AND M.I.T. DISCLAIM ALL WARRANTIES WITH REGARD **/
/** TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANT- **/
/** ABILITY AND FITNESS, IN NO EVENT SHALL EVANS & SUTHERLAND OR **/
/** M.I.T. BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAM- **/
/** AGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA **/
/** OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER **/
/** TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE **/
/** OR PERFORMANCE OF THIS SOFTWARE. **/
/*****************************************************************************/
/***********************************************************************
*
* fvwm menu code
*
***********************************************************************/
#include <stdio.h>
#include <signal.h>
#include <string.h>
#include <X11/Xos.h>
#include "fvwm.h"
#include "menus.h"
#include "misc.h"
#include "parse.h"
#include "screen.h"
extern XEvent Event;
int menu_on=0, resize_on=0, move_on=0;
MenuRoot *ActiveMenu = NULL; /* the active menu */
MenuItem *ActiveItem = NULL; /* the active menu item */
int menuFromFrameOrWindowOrTitlebar = FALSE;
extern char *Action;
extern int Context;
extern FvwmWindow *ButtonWindow, *Tmp_win;
extern XEvent Event, ButtonEvent;
extern char **g_argv,**g_envp;
extern Window Pager_w;
extern Bool KeyboardGrabbed;
/****************************************************************************
*
* Initiates a menu pop-up
*
***************************************************************************/
void do_menu (MenuRoot *menu)
{
int x = Event.xbutton.x_root;
int y = Event.xbutton.y_root;
while(XGrabPointer(dpy, Scr.Root, True,
ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | PointerMotionHintMask,
GrabModeAsync, GrabModeAsync,
Scr.Root, Scr.MenuCursor, CurrentTime)!=GrabSuccess);
if(!KeyboardGrabbed)
while(XGrabKeyboard(dpy, Scr.Root, True, GrabModeAsync, GrabModeAsync,
CurrentTime)!=GrabSuccess);
XGrabServer(dpy);
if (PopUpMenu (menu, x, y))
{
UpdateMenu();
}
else
{
XBell (dpy, 0);
}
XUngrabServer(dpy);
XUngrabPointer(dpy,CurrentTime);
if(!KeyboardGrabbed)
XUngrabKeyboard(dpy,CurrentTime);
return;
}
/***********************************************************************
*
* Procedure:
* PaintEntry - draws a single entry in a poped up menu
*
***********************************************************************/
void PaintEntry(MenuRoot *mr, MenuItem *mi)
{
int y_offset,text_y,y,d;
y_offset = mi->item_num * Scr.EntryHeight;
text_y = y_offset + Scr.StdFont.y;
if ((mi->state)&&(mi->func != F_TITLE))
{
XFillRectangle(dpy, mr->w, Scr.NormalGC, 0, y_offset,
mr->width, Scr.EntryHeight);
XDrawString(dpy, mr->w, Scr.InvNormalGC, mi->x,
text_y, mi->item, mi->strlen);
if(mi->func == F_POPUP)
{
d=(Scr.EntryHeight-7)/2;
DrawPattern(mr->w, Scr.InvNormalGC, Scr.InvNormalGC,
mr->width-d-7,
(mi->item_num*Scr.EntryHeight+d),
mr->width-d,
(mi->item_num*Scr.EntryHeight+7+d));
}
}
else
{
XFillRectangle(dpy, mr->w, Scr.InvNormalGC, 0, y_offset,
mr->width, Scr.EntryHeight);
XDrawString(dpy, mr->w, Scr.NormalGC, mi->x,
text_y, mi->item, mi->strlen);
if(mi->func == F_TITLE)
{
/* now draw the dividing line(s) */
if (mi->item_num != 0)
{
y = ((mi->item_num) * Scr.EntryHeight);
XDrawLine(dpy, mr->w, Scr.NormalGC, 0, y, mr->width, y);
}
y = ((mi->item_num+1) * Scr.EntryHeight)-1;
XDrawLine(dpy, mr->w, Scr.NormalGC, 0, y, mr->width, y);
}
if(mi->func == F_POPUP)
{
d=(Scr.EntryHeight-7)/2;
if(Scr.d_depth <2)
DrawPattern(mr->w, Scr.StdShadowGC, Scr.StdShadowGC,
mr->width-d-7,
(mi->item_num*Scr.EntryHeight+d),
mr->width-d,
(mi->item_num*Scr.EntryHeight+7+d));
else
DrawPattern(mr->w, Scr.StdReliefGC, Scr.StdShadowGC,
mr->width-d-7,
(mi->item_num*Scr.EntryHeight+d),
mr->width-d,
(mi->item_num*Scr.EntryHeight+7+d));
}
}
return;
}
/***********************************************************************
*
* Procedure:
* PaintMenu - draws the entire menu
*
***********************************************************************/
void PaintMenu(MenuRoot *mr, XEvent *e)
{
MenuItem *mi;
for (mi = mr->first; mi != NULL; mi = mi->next)
{
int y_offset = mi->item_num * Scr.EntryHeight;
/* be smart about handling the expose, redraw only the entries
* that we need to
*/
if (e->xexpose.y < (y_offset + Scr.EntryHeight) &&
(e->xexpose.y + e->xexpose.height) > y_offset)
{
PaintEntry(mr, mi);
}
}
XSync(dpy, 0);
return;
}
/***********************************************************************
*
* Procedure:
* Updates menu display to reflect the highlighted item
*
***********************************************************************/
void UpdateMenu()
{
MenuItem *mi;
int i, x, y, x_root, y_root, entry;
int done,func;
while (TRUE)
{
/* block until there is an event */
XMaskEvent(dpy,
ButtonPressMask | ButtonReleaseMask |
EnterWindowMask | ExposureMask | KeyPressMask |
VisibilityChangeMask | LeaveWindowMask |
ButtonMotionMask, &Event);
done = 0;
if (Event.type == MotionNotify)
{
/* discard any extra motion events before a release */
while((XCheckMaskEvent(dpy,ButtonMotionMask|ButtonReleaseMask,
&Event))&&(Event.type != ButtonRelease));
}
/* Handle a limited number of key press events to allow mouseless
* operation */
if(Event.type == KeyPress)
Keyboard_shortcuts(&Event,ButtonRelease);
switch(Event.type)
{
case ButtonRelease:
PopDownMenu();
if(ActiveItem)
{
func = ActiveItem->func;
Action = ActiveItem->action;
done = 1;
if(ButtonWindow)
{
ExecuteFunction(func, Action,ButtonWindow->lead_w,
ButtonWindow, &Event, Context,
ActiveItem->val1,ActiveItem->val2,
ActiveItem->menu);
}
else
{
ExecuteFunction(func,Action,None,ButtonWindow, &Event,
Context,ActiveItem->val1,ActiveItem->val2,ActiveItem->menu);
}
}
ActiveItem = NULL;
ActiveMenu = NULL;
menuFromFrameOrWindowOrTitlebar = FALSE;
return;
case KeyPress:
case ButtonPress:
case EnterNotify:
done=1;
break;
case MotionNotify:
done = 1;
XQueryPointer( dpy, ActiveMenu->w, &JunkRoot, &JunkChild,
&x_root, &y_root, &x, &y, &JunkMask);
/* look for the entry that the mouse is in */
entry = y / Scr.EntryHeight;
mi = ActiveMenu->first;
i=0;
while((i!=entry)&&(mi!=NULL))
{
i++;
mi=mi->next;
}
/* if we weren't on the active entry, let's turn the old
* active one off */
if ((ActiveItem)&&(ActiveItem->func != F_TITLE)&&(mi!=ActiveItem))
{
ActiveItem->state = 0;
PaintEntry(ActiveMenu, ActiveItem);
}
/* if we weren't on the active item, change the active item
* and turn it on */
if ((mi!=ActiveItem)&&(mi != NULL))
{
if (mi->func != F_TITLE && !mi->state)
{
mi->state = 1;
PaintEntry(ActiveMenu, mi);
}
}
ActiveItem = mi;
break;
case Expose:
/* grab our expose events, let the rest go through */
if(Event.xany.window == ActiveMenu->w)
{
PaintMenu(ActiveMenu,&Event);
done = 1;
}
break;
case VisibilityNotify:
done=1;
break;
default:
break;
}
if(!done)DispatchEvent();
XFlush(dpy);
}
}
/***********************************************************************
*
* Procedure:
* PopUpMenu - pop up a pull down menu
*
* Inputs:
* menu - the root pointer of the menu to pop up
* x, y - location of upper left of menu
* center - whether or not to center horizontally over position
*
***********************************************************************/
int Stashed_X;
int Stashed_Y;
Bool PopUpMenu (MenuRoot *menu, int x, int y)
{
if ((!menu)||(menu->w == None)||(menu->items == 0))
return False;
menu_on = 1;
InstallRootColormap();
/* In case we wind up with a move from a menu which is
* from a window border, we'll return to here to start
* the move */
Stashed_X = x;
Stashed_Y = y;
/* pop up the menu */
ActiveMenu = menu;
x -= (menu->width / 2);
y -= (Scr.EntryHeight / 2);
/* clip to screen */
if (x + menu->width > Scr.MyDisplayWidth)
x = Scr.MyDisplayWidth - menu->width;
if (x < 0) x = 0;
if (y + menu->height > Scr.MyDisplayHeight)
y = Scr.MyDisplayHeight - menu->height;
if (y < 0) y = 0;
XMoveWindow(dpy, menu->w, x, y);
XMapRaised(dpy, menu->w);
XUngrabPointer(dpy,CurrentTime);
XGrabPointer(dpy, Scr.Root, True,
ButtonPressMask | ButtonReleaseMask |
ButtonMotionMask | PointerMotionHintMask,
GrabModeAsync, GrabModeAsync,
menu->w, Scr.MenuCursor, CurrentTime);
XSync(dpy, 0);
return True;
}
/***********************************************************************
*
* Procedure:
* PopDownMenu - unhighlight the current menu selection and
* take down the menus
*
***********************************************************************/
void PopDownMenu()
{
if (ActiveMenu == NULL)
return;
menu_on = 0;
if (ActiveItem)
{
ActiveItem->state = 0;
PaintEntry(ActiveMenu, ActiveItem);
}
XUngrabPointer(dpy,CurrentTime);
XUnmapWindow(dpy, ActiveMenu->w);
UninstallRootColormap();
XFlush(dpy);
if (Context & (C_WINDOW | C_FRAME | C_TITLE | C_SIDEBAR))
menuFromFrameOrWindowOrTitlebar = TRUE;
else
menuFromFrameOrWindowOrTitlebar = FALSE;
}
/***********************************************************************
*
* Procedure:
* ExecuteFunction - execute a fvwm built in function
*
* Inputs:
* func - the function to execute
* action - the menu action to execute
* w - the window to execute this function on
* tmp_win - the fvwm window structure
* event - the event that caused the function
* context - the context in which the button was pressed
* val1,val2 - the distances to move in a scroll operation
*
***********************************************************************/
void ExecuteFunction(int func,char *action, Window w, FvwmWindow *tmp_win,
XEvent *eventp, int context,int val1, int val2,MenuRoot *menu)
{
FvwmWindow *t;
Bool found;
char *junk;
switch (func)
{
case F_NOP:
case F_TITLE:
break;
case F_BEEP:
XBell(dpy, 0);
break;
case F_RESIZE:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.ResizeCursor,ButtonPress))
return;
resize_on = 1;
resize_window(eventp,w,tmp_win);
resize_on = 0;
break;
case F_MOVE:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.MoveCursor,ButtonPress))
return;
move_on = 1;
move_window(eventp,w,tmp_win,context);
move_on = 0;
break;
case F_SCROLL:
MoveViewport(Scr.Vx + val1, Scr.Vy+val2);
break;
case F_ICONIFY:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.SelectCursor,ButtonRelease))
return;
if (tmp_win->flags & ICON)
DeIconify(tmp_win);
else
Iconify(tmp_win, eventp->xbutton.x_root-5,eventp->xbutton.y_root-5);
break;
case F_RAISE:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.SelectCursor,ButtonRelease))
return;
if (w == tmp_win->icon_w )
XRaiseWindow(dpy, tmp_win->icon_w);
XRaiseWindow(dpy,tmp_win->lead_w);
if (LookInList(Scr.OnTop,tmp_win->name, &tmp_win->class, &junk))
tmp_win->flags |= ONTOP;
KeepOnTop();
Scr.LastWindowRaised = tmp_win;
break;
case F_LOWER:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.SelectCursor,ButtonRelease))
return;
if (w == tmp_win->icon_w)
XLowerWindow(dpy, tmp_win->icon_w);
else
XLowerWindow(dpy, tmp_win->lead_w);
if(Scr.LastWindowRaised == tmp_win)
Scr.LastWindowRaised = (FvwmWindow *)0;
tmp_win->flags &= ~ONTOP;
break;
case F_DESTROY:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.DestroyCursor,ButtonRelease))
return;
XKillClient(dpy, tmp_win->w);
break;
case F_DELETE:
if (DeferExecution(eventp,&w,&tmp_win,&context, Scr.DestroyCursor,ButtonRelease))
return;
if (tmp_win->protocols & DoesWmDeleteWindow)
send_clientmessage (tmp_win->w, _XA_WM_DELETE_WINDOW, CurrentTime);
else
XBell (dpy, 0);
break;
case F_RESTART:
MoveViewport(0,0);
if(Pager_w != (Window)0)
XDestroyWindow(dpy,Pager_w);
Reborder ();
XSync(dpy,0);
XCloseDisplay(dpy);
execve(g_argv[0],g_argv,g_envp);
break;
case F_EXEC:
XGrabPointer(dpy, Scr.Root, True,
ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync,
Scr.Root, Scr.WaitCursor, CurrentTime);
XSync (dpy, 0);
system(action);
XUngrabPointer(dpy,CurrentTime);
break;
case F_REFRESH:
{
XSetWindowAttributes attributes;
unsigned long valuemask;
valuemask = (CWBackPixel);
attributes.background_pixel = Scr.StdColors.fore;
attributes.backing_store = NotUseful;
w = XCreateWindow (dpy, Scr.Root, 0, 0,
(unsigned int) Scr.MyDisplayWidth,
(unsigned int) Scr.MyDisplayHeight,
(unsigned int) 0,
CopyFromParent, (unsigned int) CopyFromParent,
(Visual *) CopyFromParent, valuemask,
&attributes);
XMapWindow (dpy, w);
XDestroyWindow (dpy, w);
XFlush (dpy);
}
break;
case F_STICK:
/* stick/unstick a window */
if (DeferExecution(eventp,&w,&tmp_win,&context,
Scr.SelectCursor,ButtonRelease))
return;
if(tmp_win->flags & STICKY)
tmp_win->flags &= ~STICKY;
else
tmp_win->flags |=STICKY;
break;
case F_NEXT_PAGE:
/* Move forward 1 virtual desktop page */
NextPage();
break;
case F_PREV_PAGE:
/* back up 1 virtual desktop page */
PrevPage();
break;
case F_CIRCULATE_UP:
/* move focus to the previous window */
found = FALSE;
t = Scr.Focus;
while(!found)
{
if ((t == (FvwmWindow *)0)||(t == &Scr.FvwmRoot)||
(t->prev == &Scr.FvwmRoot)||(t->prev == (FvwmWindow *)NULL))
for(t=Scr.FvwmRoot.next;t->next != (FvwmWindow *)NULL;t=t->next);
else
t=t->prev;
found = TRUE;
if (LookInList(Scr.CirculateSkip,t->name, &t->class,&junk))
found = FALSE;
if (LookInList(Scr.CirculateSkip,t->icon_name, &t->class,&junk))
found = FALSE;
}
FocusOn(t);
break;
case F_CIRCULATE_DOWN:
/* move focus to the next window */
found = FALSE;
t = Scr.Focus;
while(!found)
{
if((t == (FvwmWindow *)0)||(t->next == NULL))
t = Scr.FvwmRoot.next;
else
t =t->next;
found = TRUE;
if (LookInList(Scr.CirculateSkip,t->name, &t->class,&junk))
found = FALSE;
if (LookInList(Scr.CirculateSkip,t->icon_name, &t->class,&junk))
found = FALSE;
}
FocusOn(t);
break;
case F_RAISELOWER:
if (DeferExecution(eventp,&w,&tmp_win,&context,
Scr.SelectCursor,ButtonRelease))
return;
if((tmp_win == Scr.LastWindowRaised)||
(tmp_win->flags & VISIBLE))
{
if (w == tmp_win->icon_w)
XLowerWindow(dpy, tmp_win->icon_w);
else
XLowerWindow(dpy, tmp_win->lead_w);
tmp_win->flags &= ~ONTOP;
if(Scr.LastWindowRaised == tmp_win)
Scr.LastWindowRaised = (FvwmWindow *)0;
}
else
{
if (w == tmp_win->icon_w)
XRaiseWindow(dpy, tmp_win->icon_w);
else
XRaiseWindow(dpy, tmp_win->lead_w);
if (LookInList(Scr.OnTop,tmp_win->name, &tmp_win->class,&junk))
tmp_win->flags |= ONTOP;
KeepOnTop();
Scr.LastWindowRaised = tmp_win;
}
break;
case F_POPUP:
ActiveItem = NULL;
ActiveMenu = NULL;
menuFromFrameOrWindowOrTitlebar = FALSE;
do_menu(menu);
break;
case F_QUIT:
Done();
break;
}
return;
}
/***********************************************************************
*
* Procedure:
* DeferExecution - defer the execution of a function to the
* next button press if the context is C_ROOT
*
* Inputs:
* eventp - pointer to XEvent to patch up
* w - pointer to Window to patch up
* tmp_win - pointer to FvwmWindow Structure to patch up
* context - the context in which the mouse button was pressed
* func - the function to defer
* cursor - the cursor to display while waiting
* finishEvent - ButtonRelease or ButtonPress; tells what kind of event to
* terminate on.
*
***********************************************************************/
int DeferExecution(XEvent *eventp, Window *w,FvwmWindow **tmp_win,
int *context, Cursor cursor, int FinishEvent)
{
int done;
int finished = 0;
if(*context != C_ROOT)
return FALSE;
XUngrabPointer(dpy,CurrentTime);
while(XGrabPointer(dpy, Scr.Root, True,
ButtonPressMask | ButtonReleaseMask,
GrabModeAsync, GrabModeAsync,
Scr.Root, cursor, CurrentTime)!=GrabSuccess);
if(!KeyboardGrabbed)
while(XGrabKeyboard(dpy, Scr.Root, True, GrabModeAsync, GrabModeAsync,
CurrentTime)!=GrabSuccess);
while (!finished)
{
done = 0;
/* block until there is an event */
XMaskEvent(dpy,
ButtonPressMask | ButtonReleaseMask |
EnterWindowMask | ExposureMask |KeyPressMask |
VisibilityChangeMask | LeaveWindowMask |
ButtonMotionMask, eventp);
if(eventp->type == KeyPress)
Keyboard_shortcuts(eventp,FinishEvent);
if(eventp->type == FinishEvent)
finished = 1;
if(eventp->type == ButtonPress)
done = 1;
if(eventp->type == ButtonRelease)
done = 1;
if(eventp->type == EnterNotify)
done = 1;
if(eventp->type == LeaveNotify)
done = 1;
if(!done)DispatchEvent();
}
*w = eventp->xany.window;
if((*w == Scr.Root) && (eventp->xbutton.subwindow != (Window)0))
*w = eventp->xbutton.subwindow;
if (*w == Scr.Root)
{
*context = C_ROOT;
XBell(dpy,0);
XUngrabPointer(dpy,CurrentTime);
if(!KeyboardGrabbed)
{
XUngrabKeyboard(dpy,CurrentTime);
}
return TRUE;
}
if (XFindContext (dpy, *w, FvwmContext, (caddr_t *)tmp_win) == XCNOENT)
{
*tmp_win = NULL;
XBell(dpy,0);
XUngrabPointer(dpy,CurrentTime);
if(!KeyboardGrabbed)
{
XUngrabKeyboard(dpy,CurrentTime);
}
return (TRUE);
}
if(*w == (*tmp_win)->title_w)
*context = C_TITLE;
else if(*w == (*tmp_win)->w)
*context = C_WINDOW;
else if(*w == (*tmp_win)->icon_w)
*context = C_ICON;
else if(*w == (*tmp_win)->frame)
*context = C_FRAME;
else if((*w == (*tmp_win)->left_side_w)||(*w == (*tmp_win)->right_side_w)
||(*w == (*tmp_win)->bottom_w)||(*w == (*tmp_win)->top_w))
*context = C_SIDEBAR;
XUngrabPointer(dpy,CurrentTime);
if(!KeyboardGrabbed)
{
XUngrabKeyboard(dpy,CurrentTime);
}
return FALSE;
}