~ubuntu-branches/ubuntu/jaunty/ctwm/jaunty

« back to all changes in this revision

Viewing changes to events.c

  • Committer: Bazaar Package Importer
  • Author(s): Branden Robinson
  • Date: 2006-07-21 10:27:56 UTC
  • mfrom: (3.1.2 edgy)
  • Revision ID: james.westby@ubuntu.com-20060721102756-w0ilcq7u9101ypsi
Tags: 3.7-3
* Merge Luk Claes's NMU.  Thanks, Luk!  Luk's changes are:
  + Make ctwm pre-depend on x11-common (>= 1:7.0.0).
  + Correct comment in the menu-method file.
  + I reverted Luk's deletion of the SVN Id keyword and Vim modeline in this
    changelog.  (We finally got a comment character for control files, now
    we need one for changelogs as well.  Lesson?  Never, ever, ever, ever
    make a file format that will be machine-parsed by anything without
    supporting comments.  ALGOL 60 called and wants its innovations back.)
* I had already done the following in SVN but was too slow to release.
  Shame on me.
  + Build-depend on xutils-dev instead of xutils for the X11R7 transition.
  + Adjust debian/rules and debian/postinst to use FHS paths, moving from
    /usr/X11R6 to /usr.  Based on a patch by Steve Langasek.  Thanks, Steve!
    (Closes: #364239)
  + Point menu-method to install-menu interpreter in /usr/bin, not
    /usr/sbin, per Lintian.
  + Add empty binary-indep target in debian/rules to quiet Lintian error.
* Fix SEGV when attempting to bring up the TwmWindows menu when no workspace
  manager is active.  Thanks to Mike O'Connor for the analysis and the
  patch! (Closes: #375240)
* Bump Standards-Version from 3.6.2 to 3.7.2; required changes involving
  placement of files in X11 paths and pre-dependency on x11-common made as
  described above.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
#if defined(AIXV3) || defined(_SYSTYPE_SVR4) || defined(ibm) || defined __QNX__
76
76
#include <sys/select.h>
77
77
#endif
78
 
#if defined(__QNX__) || defined(VMS)
79
78
#include <ctype.h>
80
 
#endif
81
79
 
82
80
#include "twm.h"
83
81
#ifdef VMS
86
84
#include <X11/Xatom.h>
87
85
#endif
88
86
#include "add_window.h"
 
87
#include "clicktofocus.h"
89
88
#include "menus.h"
90
89
#include "events.h"
91
90
#include "resize.h"
127
126
extern int  AlternateKeymap;
128
127
extern Bool AlternateContext;
129
128
 
130
 
static void CtwmNextEvent ();
131
 
static void RedoIcon();
132
 
static void do_key_menu ();
133
 
int RedoIconName();
134
 
int RestoreWithdrawnLocation (); /* in ctwm.c */
 
129
static void CtwmNextEvent (Display *dpy, XEvent  *event);
 
130
static void RedoIcon(void);
 
131
static void do_key_menu (MenuRoot *menu,        /* menu to pop up */
 
132
                         Window w);             /* invoking window or None */
 
133
void RedoIconName(void);
135
134
 
136
135
#ifdef SOUNDS
137
 
extern play_sound();
 
136
extern void play_sound(int snd);
138
137
#endif
139
138
FILE *tracefile = NULL;
140
139
 
147
146
XEvent Event;                   /* the current event */
148
147
TwmWindow *Tmp_win;             /* the current twm window */
149
148
 
 
149
extern Window captiveroot;
150
150
Window DragWindow;              /* variables used in moving windows */
151
151
int origDragX;
152
152
int origDragY;
167
167
static int ColortableThrashing;
168
168
static TwmWindow *enter_win, *raise_win, *leave_win, *lower_win;
169
169
 
170
 
ScreenInfo *FindScreenInfo();
171
170
int ButtonPressed = -1;
172
171
int Cancel = FALSE;
173
172
 
174
 
void HandleCreateNotify();
175
 
 
176
 
void HandleShapeNotify ();
177
 
void HandleFocusChange ();
 
173
void HandleCreateNotify(void);
 
174
void HandleShapeNotify (void);
 
175
void HandleFocusChange (void);
178
176
extern int ShapeEventBase, ShapeErrorBase;
179
177
 
180
178
extern Window lowerontop;
181
179
 
 
180
#ifdef GNOME
 
181
#  include "gnomewindefs.h"
 
182
  extern Atom _XA_WIN_WORKSPACE;
 
183
  extern Atom _XA_WIN_STATE;
 
184
#endif /* GNOME */
 
185
 
182
186
extern Atom _XA_WM_OCCUPATION;
183
187
extern Atom _XA_WM_CURRENTWORKSPACE;
 
188
 
 
189
int GnomeProxyButtonPress = -1;
 
190
 
184
191
/*#define TRACE_FOCUS*/
185
192
/*#define TRACE*/
186
193
 
187
 
#ifdef TRACE
188
 
static void dumpevent ();
189
 
#endif
 
194
static void dumpevent (XEvent *e);
190
195
 
191
196
#if defined(__hpux) && !defined(_XPG4_EXTENDED)
192
197
#   define FDSET int*
194
199
#   define FDSET fd_set*
195
200
#endif
196
201
 
197
 
unsigned int set_mask_ignore (modifier)
198
 
unsigned int modifier;
 
202
static unsigned int set_mask_ignore (unsigned int modifier)
199
203
{
200
204
    int i;
201
205
    unsigned int ModifierMask[8] = { ShiftMask, ControlMask, LockMask,
209
213
    return modifier;
210
214
}
211
215
 
212
 
void AutoRaiseWindow (tmp)
213
 
    TwmWindow *tmp;
 
216
void AutoRaiseWindow (TwmWindow *tmp)
214
217
{
215
218
    RaiseWindow (tmp);
216
219
 
222
225
    WMapRaise (tmp);
223
226
}
224
227
 
225
 
void SetRaiseWindow (tmp)
226
 
    TwmWindow *tmp;
 
228
void SetRaiseWindow (TwmWindow *tmp)
227
229
{
228
230
    enter_flag = TRUE;
229
231
    enter_win = NULL;
234
236
    XSync (dpy, 0);
235
237
}
236
238
 
237
 
void AutoLowerWindow (tmp)
238
 
     TwmWindow *tmp;
 
239
void AutoLowerWindow (TwmWindow *tmp)
239
240
{
240
241
    LowerWindow (tmp);
241
242
 
260
261
 ***********************************************************************
261
262
 */
262
263
 
263
 
void
264
 
InitEvents()
 
264
void InitEvents(void)
265
265
{
266
266
    int i;
267
267
 
305
305
 
306
306
Time lastTimestamp = CurrentTime;       /* until Xlib does this for us */
307
307
 
308
 
Bool StashEventTime (ev)
309
 
    register XEvent *ev;
 
308
Bool StashEventTime (register XEvent *ev)
310
309
{
311
310
    switch (ev->type) {
312
311
      case KeyPress:
347
346
 * window may not be the same as XEvent.xany.window (the first window listed
348
347
 * in the structure).
349
348
 */
350
 
Window WindowOfEvent (e)
351
 
    XEvent *e;
 
349
Window WindowOfEvent (XEvent *e)
352
350
{
353
351
    /*
354
352
     * Each window subfield is marked with whether or not it is the same as
393
391
    return None;
394
392
}
395
393
 
396
 
void FixRootEvent (e)
397
 
XEvent *e;
 
394
void FixRootEvent (XEvent *e)
398
395
{
399
396
    switch (e->type) {
400
397
      case KeyPress:
401
398
      case KeyRelease:
402
 
          e->xkey.x_root -= Scr->MyDisplayX;
403
 
          e->xkey.y_root -= Scr->MyDisplayY;
 
399
          e->xkey.x_root -= Scr->rootx;
 
400
          e->xkey.y_root -= Scr->rooty;
404
401
          e->xkey.root    = Scr->Root;
405
402
          break;
406
403
      case ButtonPress:
407
404
      case ButtonRelease:
408
 
          e->xbutton.x_root -= Scr->MyDisplayX;
409
 
          e->xbutton.y_root -= Scr->MyDisplayY;
 
405
          e->xbutton.x_root -= Scr->rootx;
 
406
          e->xbutton.y_root -= Scr->rooty;
410
407
          e->xbutton.root    = Scr->Root;
411
408
          break;
412
409
      case MotionNotify:
413
 
          e->xmotion.x_root -= Scr->MyDisplayX;
414
 
          e->xmotion.y_root -= Scr->MyDisplayY;
 
410
          e->xmotion.x_root -= Scr->rootx;
 
411
          e->xmotion.y_root -= Scr->rooty;
415
412
          e->xmotion.root    = Scr->Root;
416
413
          break;
417
414
      case EnterNotify:
418
415
      case LeaveNotify:
419
 
          e->xcrossing.x_root -= Scr->MyDisplayX;
420
 
          e->xcrossing.y_root -= Scr->MyDisplayY;
 
416
          e->xcrossing.x_root -= Scr->rootx;
 
417
          e->xcrossing.y_root -= Scr->rooty;
421
418
          e->xcrossing.root    = Scr->Root;
422
419
          break;
423
420
      default:
430
427
/***********************************************************************
431
428
 *
432
429
 *  Procedure:
433
 
 *      DispatchEvent2 - 
 
430
 *      DispatchEvent2 -
434
431
 *      handle a single X event stored in global var Event
435
432
 *      this routine for is for a call during an f.move
436
433
 *
437
434
 ***********************************************************************
438
435
 */
439
 
Bool DispatchEvent2 ()
 
436
Bool DispatchEvent2 (void)
440
437
{
441
438
    Window w = Event.xany.window;
442
439
    StashEventTime (&Event);
448
445
        Scr = FindScreenInfo (WindowOfEvent (&Event));
449
446
    }
450
447
 
 
448
    dumpevent(&Event);
 
449
 
451
450
    if (!Scr) return False;
452
 
    if (captive) FixRootEvent (&Event);
 
451
    if (Scr->Root != Scr->RealRoot) FixRootEvent (&Event);
453
452
 
454
453
#ifdef SOUNDS
455
454
    play_sound(Event.type);
472
471
 *
473
472
 ***********************************************************************
474
473
 */
475
 
Bool DispatchEvent ()
 
474
Bool DispatchEvent (void)
476
475
{
477
476
    Window w = Event.xany.window;
478
477
    StashEventTime (&Event);
484
483
        Scr = FindScreenInfo (WindowOfEvent (&Event));
485
484
    }
486
485
 
 
486
    dumpevent(&Event);
 
487
 
487
488
    if (!Scr) return False;
488
489
 
489
490
    if (captive) {
490
 
        if ((Event.type == ConfigureNotify) &&
491
 
            (Event.xconfigure.window == Scr->Root)) {
492
 
            ConfigureRootWindow (&Event);
493
 
            return (True);
494
 
        }
495
 
        FixRootEvent (&Event);
 
491
      if ((Event.type == ConfigureNotify) && (Event.xconfigure.window == Scr->CaptiveRoot)) {
 
492
        ConfigureRootWindow (&Event);
 
493
        return (False);
 
494
      }
496
495
    }
 
496
    if (Scr->Root != Scr->RealRoot) FixRootEvent (&Event);
497
497
    if (Event.type>= 0 && Event.type < MAX_X_EVENT) {
498
498
#ifdef SOUNDS
499
499
        play_sound(Event.type);
500
500
#endif
501
501
        (*EventHandler[Event.type])();
502
502
    }
503
 
 
504
503
    return True;
505
504
}
506
505
 
514
513
 ***********************************************************************
515
514
 */
516
515
 
517
 
#ifdef X11R6
518
 
#  define nextEvent(event) XtAppNextEvent(appContext, event);
519
 
#else
520
 
#  define nextEvent(event) XNextEvent(dpy, event);
521
 
#endif
522
 
 
523
 
void
524
 
HandleEvents()
 
516
void HandleEvents(void)
525
517
{
526
518
    while (TRUE)
527
519
    {
544
536
        }
545
537
        WindowMoved = FALSE;
546
538
 
547
 
        if (AnimationActive && MaybeAnimate)
548
 
            CtwmNextEvent (dpy, &Event);
549
 
        else
550
 
            nextEvent (&Event);
 
539
        CtwmNextEvent (dpy, &Event);
551
540
 
552
541
#ifdef X11R6
553
542
        if (Event.type < 0 || Event.type >= MAX_X_EVENT)
558
547
    }
559
548
}
560
549
 
 
550
#ifdef X11R6
 
551
#  define nextEvent(event) XtAppNextEvent(appContext, event);
 
552
#else
 
553
#  define nextEvent(event) XNextEvent(dpy, event);
 
554
#endif
 
555
 
561
556
#ifdef VMS
562
557
extern unsigned long timefe;
563
558
#endif
564
559
 
565
 
static void CtwmNextEvent (dpy, event)
566
 
Display *dpy;
567
 
XEvent  *event;
 
560
static void CtwmNextEvent (Display *dpy, XEvent  *event)
568
561
{
 
562
    int animate = (AnimationActive && MaybeAnimate);
 
563
 
569
564
#ifdef VMS
570
565
    if (QLength (dpy) != 0) {
571
566
        nextEvent (event);
572
567
        return;
573
568
    }
574
 
    if (AnimationPending) Animate ();
 
569
    if (animate && AnimationPending) Animate ();
575
570
    while (1) {
576
571
       sys$waitfr(timefe);
577
572
       sys$clref(timefe);
578
 
       
579
 
       if (AnimationPending) Animate ();
 
573
 
 
574
       if (animate && AnimationPending) Animate ();
580
575
       if (QLength (dpy) != 0) {
581
576
          nextEvent (event);
582
577
          return;
586
581
    int         found;
587
582
    fd_set      mask;
588
583
    int         fd;
589
 
    struct timeval timeout, *tout;
 
584
    struct timeval timeout, *tout = NULL;
590
585
 
 
586
    if (RestartFlag)
 
587
        DoRestart(CurrentTime);
591
588
    if (XEventsQueued (dpy, QueuedAfterFlush) != 0) {
592
589
        nextEvent (event);
593
590
        return;
595
592
    fd = ConnectionNumber (dpy);
596
593
 
597
594
#ifdef USE_SIGNALS
598
 
    if (AnimationPending) Animate ();
 
595
    if (animate && AnimationPending) Animate ();
599
596
    while (1) {
600
597
        FD_ZERO (&mask);
601
598
        FD_SET  (fd, &mask);
602
599
        found = select (fd + 1, (FDSET)&mask, (FDSET) 0, (FDSET) 0, 0);
 
600
        if (RestartFlag)
 
601
            DoRestart(CurrentTime);
603
602
        if (found < 0) {
604
603
            if (errno == EINTR) {
605
 
                Animate ();
 
604
                if (animate)
 
605
                    Animate ();
606
606
            }
607
607
            else perror ("select");
608
608
            continue;
613
613
        }
614
614
    }
615
615
#else /* USE_SIGNALS */
616
 
    TryToAnimate ();
 
616
    if (animate) TryToAnimate ();
 
617
    if (RestartFlag)
 
618
        DoRestart(CurrentTime);
617
619
    if (! MaybeAnimate) {
618
620
        nextEvent (event);
619
621
        return;
620
622
    }
621
 
    tout = (AnimationSpeed > 0) ? &timeout : NULL;
 
623
    if (animate) tout = (AnimationSpeed > 0) ? &timeout : NULL;
622
624
    while (1) {
623
625
        FD_ZERO (&mask);
624
626
        FD_SET  (fd, &mask);
625
 
        timeout = AnimateTimeout;
 
627
        if (animate) {
 
628
            timeout = AnimateTimeout;
 
629
        }
626
630
        found = select (fd + 1, (FDSET)&mask, (FDSET) 0, (FDSET) 0, tout);
 
631
        if (RestartFlag)
 
632
            DoRestart(CurrentTime);
627
633
        if (found < 0) {
628
634
            if (errno != EINTR) perror ("select");
629
635
            continue;
633
639
            return;
634
640
        }
635
641
        if (found == 0) {
636
 
            TryToAnimate ();
 
642
            if (animate) TryToAnimate ();
 
643
            if (RestartFlag)
 
644
                DoRestart(CurrentTime);
637
645
            if (! MaybeAnimate) {
638
646
                nextEvent (event);
639
647
                return;
659
667
 ***********************************************************************
660
668
 */
661
669
 
662
 
void
663
 
HandleColormapNotify()
 
670
void HandleColormapNotify(void)
664
671
{
665
672
    XColormapEvent *cevent = (XColormapEvent *) &Event;
666
673
    ColormapWindow *cwin, **cwins;
667
674
    TwmColormap *cmap;
668
675
    int lost, won, n, number_cwins;
669
 
    extern TwmColormap *CreateTwmColormap();
670
676
 
671
677
/*    if (! Tmp_win) return; */
672
678
    if (XFindContext(dpy, cevent->window, ColormapContext, (XPointer *)&cwin) == XCNOENT)
812
818
 *              window.
813
819
 */
814
820
 
815
 
static XEvent *
816
 
LastFocusEvent(w, first)
817
 
Window w;
818
 
XEvent *first;
 
821
static XEvent *LastFocusEvent(Window w, XEvent *first)
819
822
{
820
823
        static XEvent current;
821
824
        XEvent *last, new;
856
859
 * HandleFocusIn -- deal with the focus moving under us.
857
860
 */
858
861
 
859
 
void
860
 
HandleFocusIn(event)
861
 
XFocusInEvent *event;
 
862
void HandleFocusIn(XFocusInEvent *event)
862
863
{
863
864
 
864
865
#ifdef TRACE_FOCUS
874
875
    Scr->Focus = Tmp_win;
875
876
}
876
877
 
877
 
void
878
 
HandleFocusOut(event)
879
 
XFocusOutEvent *event;
 
878
void HandleFocusOut(XFocusOutEvent *event)
880
879
{
881
880
#ifdef TRACE_FOCUS
882
881
        printf("HandleFocusOut : -0x%x (0x%x, 0x%x), mode=%d, detail=%d\n", 
885
884
 
886
885
    if (Tmp_win->iconmgr) return;
887
886
    if (Scr->Focus != Tmp_win) return;
 
887
    if (Scr->SloppyFocus) return;
888
888
    if (Tmp_win->AutoSqueeze && !Tmp_win->squeezed) AutoSqueeze (Tmp_win);
889
889
    SetFocusVisualAttributes (Tmp_win, False);
890
890
    Scr->Focus= NULL;
891
891
}
892
892
 
893
 
void
894
 
HandleFocusChange()
 
893
void HandleFocusChange(void)
895
894
{
896
895
        XEvent *event;
897
896
        
902
901
                if ( event != NULL)
903
902
                {
904
903
                        if (event->type == FocusIn)
905
 
                          HandleFocusIn(event);
 
904
                          HandleFocusIn(&event->xfocus);
906
905
                        else
907
 
                          HandleFocusOut(event);
 
906
                          HandleFocusOut(&event->xfocus);
908
907
                }
909
908
        }
910
909
}
911
910
 
912
 
void
913
 
SynthesiseFocusOut(w)
914
 
Window w;
 
911
void SynthesiseFocusOut(Window w)
915
912
{
916
913
        XEvent event;
917
914
 
928
925
}
929
926
 
930
927
 
931
 
void
932
 
SynthesiseFocusIn(w)
933
 
Window w;
 
928
void SynthesiseFocusIn(Window w)
934
929
{
935
930
        XEvent event;
936
931
 
960
955
 ***********************************************************************
961
956
 */
962
957
 
963
 
void
964
 
HandleVisibilityNotify()
 
958
void HandleVisibilityNotify(void)
965
959
{
966
960
    XVisibilityEvent *vevent = (XVisibilityEvent *) &Event;
967
961
    ColormapWindow *cwin;
996
990
 ***********************************************************************
997
991
 */
998
992
 
999
 
void
1000
 
HandleKeyRelease()
 
993
void HandleKeyRelease(void)
1001
994
{
1002
 
    if (Tmp_win == Scr->workSpaceMgr.workspaceWindow.twm_win)
1003
 
        WMgrHandleKeyReleaseEvent (&Event);
 
995
  if (Tmp_win == Scr->currentvs->wsw->twm_win)
 
996
    WMgrHandleKeyReleaseEvent (Scr->currentvs, &Event);
1004
997
}
1005
998
/***********************************************************************
1006
999
 *
1010
1003
 ***********************************************************************
1011
1004
 */
1012
1005
 
1013
 
void
1014
 
HandleKeyPress()
 
1006
void HandleKeyPress(void)
1015
1007
{
1016
1008
    FuncKey *key;
1017
1009
    int len;
1066
1058
            item = ActiveItem;
1067
1059
        }
1068
1060
        else
1069
 
        if (!strcmp (keynam, "Left")) {
 
1061
        if (!strcmp (keynam, "Left") || !strcmp(keynam, "Escape")) {
1070
1062
            MenuRoot *menu;
1071
1063
 
1072
1064
            if (ActiveMenu->pinned) return;
1152
1144
                        if (ActiveMenu == Scr->Workspaces) {
1153
1145
                            PopDownMenu();
1154
1146
                            XUngrabPointer  (dpy, CurrentTime);
1155
 
                            GotoWorkSpaceByName (item->action + 8);
 
1147
                            GotoWorkSpaceByName (Scr->currentvs, item->action + 8);
1156
1148
                        }
1157
1149
                        else {
1158
1150
                            ExecuteFunction (item->func, item->action,
1228
1220
            Context = C_ICONMGR;
1229
1221
        if (Tmp_win->list && Event.xany.window == Tmp_win->list->icon)
1230
1222
            Context = C_ICONMGR;
 
1223
        if (Tmp_win->wspmgr)
 
1224
            Context = C_WORKSPACE;
1231
1225
    }
1232
1226
 
1233
1227
    modifier = (Event.xkey.state | AlternateKeymap) & mods_used;
1323
1317
     */
1324
1318
    if (Tmp_win)
1325
1319
    {
1326
 
        if (Tmp_win == Scr->workSpaceMgr.workspaceWindow.twm_win) {
1327
 
            WMgrHandleKeyPressEvent (&Event);
1328
 
            return;
1329
 
        }
 
1320
        if (Tmp_win == Scr->currentvs->wsw->twm_win) {
 
1321
          WMgrHandleKeyPressEvent (Scr->currentvs, &Event);
 
1322
          return;
 
1323
        }
1330
1324
        if (Tmp_win->icon && ((Event.xany.window == Tmp_win->icon->w) ||
1331
1325
            (Event.xany.window == Tmp_win->frame) ||
1332
1326
            (Event.xany.window == Tmp_win->title_w) ||
1341
1335
 
1342
1336
 
1343
1337
 
1344
 
static void free_window_names (tmp, nukefull, nukename, nukeicon)
1345
 
    TwmWindow *tmp;
1346
 
    Bool nukefull, nukename, nukeicon;
 
1338
static void free_window_names (TwmWindow *tmp,
 
1339
                               Bool nukefull, Bool nukename, Bool nukeicon)
1347
1340
{
1348
1341
/*
1349
1342
 * XXX - are we sure that nobody ever sets these to another constant (check
1375
1368
 
1376
1369
 
1377
1370
 
1378
 
void free_cwins (tmp)
1379
 
    TwmWindow *tmp;
 
1371
void free_cwins (TwmWindow *tmp)
1380
1372
{
1381
1373
    int i;
1382
1374
    TwmColormap *cmap;
1412
1404
 ***********************************************************************
1413
1405
 */
1414
1406
 
1415
 
void
1416
 
HandlePropertyNotify()
 
1407
void HandlePropertyNotify(void)
1417
1408
{
1418
 
    char *prop = NULL;
 
1409
    unsigned char *prop = NULL;
1419
1410
    Atom actual = None;
1420
1411
    int actual_format;
1421
1412
    unsigned long nitems, bytesafter;
1428
1419
    XRectangle logical_rect;
1429
1420
#endif    
1430
1421
 
 
1422
    unsigned char *gwkspc;
 
1423
 
1431
1424
    /* watch for standard colormap changes */
1432
1425
    if (Event.xproperty.window == Scr->Root) {
1433
1426
        XStandardColormap *maps = NULL;
1438
1431
                case PropertyNewValue:
1439
1432
                    if (XGetWindowProperty (dpy, Scr->Root, _XA_WM_CURRENTWORKSPACE,
1440
1433
                                0L, 200L, False, XA_STRING, &actual, &actual_format,
1441
 
                                &nitems, &bytesafter, (unsigned char **) &prop) == Success) {
 
1434
                                &nitems, &bytesafter, &prop) == Success) {
1442
1435
                        if (nitems == 0) return;
1443
 
                        GotoWorkSpaceByName (prop);
 
1436
                        GotoWorkSpaceByName (Scr->vScreenList, (char*)prop);
1444
1437
                        XFree ((char*) prop);
1445
1438
                    }
1446
1439
                    return;
1478
1471
        if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, 
1479
1472
                                MAX_NAME_LEN, False, XA_STRING, &actual,
1480
1473
                                &actual_format, &nitems, &bytesafter,
1481
 
                                (unsigned char **) &prop) != Success ||
 
1474
                                &prop) != Success ||
1482
1475
            actual == None)
1483
1476
          return;
1484
1477
        if (!prop) prop = NoName;
1485
1478
#endif /* NO_LOCALE */
 
1479
#ifdef CLAUDE
 
1480
        if (strstr (prop, " - Mozilla")) {
 
1481
          char *moz = strstr (prop, " - Mozilla");
 
1482
          *moz = '\0';
 
1483
        }
 
1484
#endif
1486
1485
        free_window_names (Tmp_win, True, True, False);
1487
1486
 
1488
 
        Tmp_win->full_name = prop;
1489
 
        Tmp_win->name = prop;
 
1487
        Tmp_win->full_name = (char*) prop;
 
1488
        Tmp_win->name = (char*) prop;
1490
1489
#ifdef X11R6
1491
1490
        Tmp_win->nameChanged = 1;
1492
1491
#endif
1557
1556
        if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0, 
1558
1557
                                MAX_ICON_NAME_LEN, False, XA_STRING, &actual,
1559
1558
                                &actual_format, &nitems, &bytesafter,
1560
 
                                (unsigned char **) &prop) != Success ||
 
1559
                                &prop) != Success ||
1561
1560
            actual == None)
1562
1561
          return;
1563
1562
        if (!prop) prop = NoName;
1564
1563
#endif /* NO_LOCALE */
1565
1564
#ifdef CLAUDE
1566
 
        if ((strlen (prop) > 11) && (strncmp (prop, "Netscape: ", 10) == 0)) {
1567
 
            char *tmp;
1568
 
 
1569
 
            tmp = strdup (prop + 10);
1570
 
            XFree ((char*) prop);
1571
 
            prop = tmp;
 
1565
        if (strstr (prop, " - Mozilla")) {
 
1566
          char *moz = strstr (prop, " - Mozilla");
 
1567
          *moz = '\0';
1572
1568
        }
1573
1569
#endif
1574
 
        icon_change = strcmp (Tmp_win->icon_name, prop);
 
1570
        icon_change = strcmp (Tmp_win->icon_name, (char*) prop);
1575
1571
        free_window_names (Tmp_win, False, False, True);
1576
 
        Tmp_win->icon_name = prop;
 
1572
        Tmp_win->icon_name = (char*) prop;
1577
1573
 
1578
1574
        if (icon_change) {
1579
1575
            RedoIcon();
1749
1745
        } else if (Event.xproperty.atom == _XA_WM_OCCUPATION) {
1750
1746
          if (XGetWindowProperty (dpy, Tmp_win->w, Event.xproperty.atom, 0L, MAX_NAME_LEN, False,
1751
1747
                                  XA_STRING, &actual, &actual_format, &nitems,
1752
 
                                  &bytesafter, (unsigned char **) &prop) != Success ||
 
1748
                                  &bytesafter, &prop) != Success ||
1753
1749
              actual == None) return;
1754
1750
          ChangeOccupation (Tmp_win, GetMaskFromProperty (prop, nitems));
1755
1751
        }
 
1752
#ifdef GNOME
 
1753
        else if (Event.xproperty.atom == _XA_WIN_WORKSPACE){
 
1754
          if(XGetWindowProperty(dpy, Tmp_win->w, Event.xproperty.atom, 0L, 32, False,
 
1755
                                XA_CARDINAL, &actual, &actual_format, &nitems, &bytesafter,
 
1756
                                &gwkspc) != Success || actual == None) return;
 
1757
          ChangeOccupation (Tmp_win, 1 << (int)(*gwkspc));
 
1758
        }
 
1759
#endif /* GNOME */
1756
1760
        break;
1757
1761
    }
1758
1762
}
1759
1763
 
1760
1764
 
1761
1765
 
1762
 
static void RedoIcon()
 
1766
static void RedoIcon(void)
1763
1767
{
1764
1768
    Icon *icon;
1765
1769
    char *pattern;
1769
1773
        return;
1770
1774
    }
1771
1775
    icon = (Icon*) 0;
1772
 
    if (pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->icon_name)) {
1773
 
        icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern);
1774
 
    }
1775
 
    else
1776
 
    if (pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->full_name)) {
1777
 
        icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern);
1778
 
    }
1779
 
    else
1780
 
    if (pattern = LookPatternInList (Scr->IconNames, Tmp_win->full_name, &Tmp_win->class)) {
 
1776
    if ((pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->icon_name))) {
 
1777
        icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern);
 
1778
    }
 
1779
    else
 
1780
    if ((pattern = LookPatternInNameList (Scr->IconNames, Tmp_win->full_name))) {
 
1781
        icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern);
 
1782
    }
 
1783
    else
 
1784
    if ((pattern = LookPatternInList (Scr->IconNames, Tmp_win->full_name, &Tmp_win->class))) {
1781
1785
        icon = (Icon*) LookInNameList (Tmp_win->iconslist, pattern);
1782
1786
    }
1783
1787
    if (pattern == NULL) {
1789
1793
            RedoIconName ();
1790
1794
            return;
1791
1795
        }
1792
 
        if (Tmp_win->icon_on && (OCCUPY (Tmp_win, Scr->workSpaceMgr.activeWSPC))) {
 
1796
        if (Tmp_win->icon_on && visible (Tmp_win)) {
1793
1797
            IconDown (Tmp_win);
1794
1798
            if (Tmp_win->icon && Tmp_win->icon->w) XUnmapWindow (dpy, Tmp_win->icon->w);
1795
1799
            Tmp_win->icon = icon;
1796
1800
            IconUp (Tmp_win);
1797
1801
            XMapRaised (dpy, Tmp_win->icon->w);
1798
 
        }
 
1802
        }
1799
1803
        else {
1800
1804
            Tmp_win->icon = icon;
1801
1805
        }
1802
1806
        RedoIconName ();
1803
1807
    }
1804
1808
    else {
1805
 
        if (Tmp_win->icon_on && (OCCUPY (Tmp_win, Scr->workSpaceMgr.activeWSPC))) {
 
1809
        if (Tmp_win->icon_on && visible (Tmp_win)) {
1806
1810
            IconDown (Tmp_win);
1807
1811
            if (Tmp_win->icon && Tmp_win->icon->w) XUnmapWindow (dpy, Tmp_win->icon->w);
1808
1812
            CreateIconWindow (Tmp_win, -100, -100);
1824
1828
 ***********************************************************************
1825
1829
 */
1826
1830
 
1827
 
RedoIconName()
 
1831
void RedoIconName(void)
1828
1832
{
1829
1833
    int x;
1830
1834
#ifdef I18N
1899
1903
                        0, 0, &rect, 1, ShapeSet, 0);
1900
1904
        }
1901
1905
        if (Tmp_win->icon->has_title) {
1902
 
            if (Scr->SchrinkIconTitles && Tmp_win->icon->title_schrinked) {
 
1906
            if (Scr->ShrinkIconTitles && Tmp_win->icon->title_shrunk) {
1903
1907
                rect.x      = x;
1904
1908
                rect.y      = Tmp_win->icon->height;
1905
1909
                rect.width  = Tmp_win->icon->width;
1914
1918
                                     0, &rect, 1, ShapeUnion, 0);
1915
1919
        }
1916
1920
    }
1917
 
    if (Scr->SchrinkIconTitles &&
1918
 
        Tmp_win->icon->title_schrinked &&
1919
 
        Tmp_win->icon_on &&
1920
 
        (OCCUPY (Tmp_win, Scr->workSpaceMgr.activeWSPC))) {
 
1921
    if (Scr->ShrinkIconTitles &&
 
1922
        Tmp_win->icon->title_shrunk &&
 
1923
        Tmp_win->icon_on && (visible (Tmp_win))) {
1921
1924
        IconDown (Tmp_win);
1922
1925
        IconUp (Tmp_win);
1923
1926
    }
1939
1942
 ***********************************************************************
1940
1943
 */
1941
1944
 
1942
 
void
1943
 
HandleClientMessage()
 
1945
void HandleClientMessage(void)
1944
1946
{
1945
 
    if (Event.xclient.message_type == _XA_WM_CHANGE_STATE)
1946
 
    {
1947
 
        if (Tmp_win != NULL)
1948
 
        {
1949
 
            if (Event.xclient.data.l[0] == IconicState && !Tmp_win->isicon)
1950
 
            {
 
1947
    TwmWindow *twm_win;
 
1948
    int i;
 
1949
 
 
1950
    if (Event.xclient.message_type == _XA_WM_CHANGE_STATE) {
 
1951
        if (Tmp_win != NULL) {
 
1952
            if (Event.xclient.data.l[0] == IconicState && !Tmp_win->isicon) {
1951
1953
                XEvent button;
1952
 
 
1953
 
                XQueryPointer( dpy, Scr->Root, &JunkRoot, &JunkChild,
1954
 
                              &(button.xmotion.x_root),
1955
 
                              &(button.xmotion.y_root),
1956
 
                              &JunkX, &JunkY, &JunkMask);
1957
 
 
1958
 
                ExecuteFunction(F_ICONIFY, NULLSTR, Event.xany.window,
1959
 
                    Tmp_win, &button, FRAME, FALSE);
1960
 
                XUngrabPointer(dpy, CurrentTime);
 
1954
                XQueryPointer (dpy, Scr->Root, &JunkRoot, &JunkChild,
 
1955
                               &(button.xmotion.x_root),
 
1956
                               &(button.xmotion.y_root),
 
1957
                               &JunkX, &JunkY, &JunkMask);
 
1958
 
 
1959
                ExecuteFunction (F_ICONIFY, NULLSTR, Event.xany.window,
 
1960
                                 Tmp_win, &button, FRAME, FALSE);
 
1961
                XUngrabPointer (dpy, CurrentTime);
1961
1962
            }
1962
1963
        }
1963
 
    }
 
1964
        return;
 
1965
    }
 
1966
#ifdef GNOME
 
1967
    /* 6/19/1999 nhd for GNOME compliance */
 
1968
    if (Event.xclient.message_type == _XA_WIN_WORKSPACE) {
 
1969
      /* XXXXX
 
1970
         supposedly works with a single screen, but is less certain with
 
1971
         multiple screens */
 
1972
      GotoWorkSpaceByNumber (Scr->currentvs, Event.xclient.data.l[0]);
 
1973
      return;
 
1974
    }
 
1975
    if (Event.xclient.message_type == _XA_WIN_STATE) {
 
1976
      unsigned long new_stuff = (unsigned long) Event.xclient.data.l [1];
 
1977
      unsigned long old_stuff = (unsigned long) Event.xclient.data.l [0];
 
1978
      Window          tmp_win = Event.xclient.window;
 
1979
      for (twm_win = (Scr->TwmRoot).next; twm_win != NULL; twm_win = twm_win->next)
 
1980
        if (twm_win->w == tmp_win) break;
 
1981
      if (twm_win == NULL) return;
 
1982
      for (i = 1; i < (1 << 10); i <<= 1){
 
1983
        switch (old_stuff & i) {
 
1984
          case WIN_STATE_STICKY: /* sticky */
 
1985
            if (new_stuff & i) OccupyAll (twm_win);
 
1986
            else ChangeOccupation (twm_win, (1<<(Scr->currentvs->wsw->currentwspc->number)));
 
1987
            break;
 
1988
          case WIN_STATE_MINIMIZED: /* minimized - reserved */
 
1989
            break;
 
1990
          case WIN_STATE_MAXIMIZED_VERT: /* window in maximized V state */
 
1991
            break;
 
1992
          case WIN_STATE_MAXIMIZED_HORIZ: /* maximized horizontally */
 
1993
            break;
 
1994
          case WIN_STATE_HIDDEN: /* hidden - what does this mean?? */
 
1995
            break;
 
1996
          case WIN_STATE_SHADED: /* shaded (squeezed) */
 
1997
            Squeeze (twm_win);
 
1998
            break;
 
1999
          case WIN_STATE_HID_WORKSPACE: /* not on this workspace */
 
2000
            break;
 
2001
          case WIN_STATE_HID_TRANSIENT: /* owner of transient hidden ? */
 
2002
            break;
 
2003
          case WIN_STATE_FIXED_POSITION: /* position fixed, don't move */
 
2004
            break;
 
2005
          case WIN_STATE_ARRANGE_IGNORE: /* ignore when auto-arranging */
 
2006
            break;
 
2007
        }
 
2008
      }
 
2009
    }
 
2010
#endif /* GNOME */
1964
2011
}
1965
2012
 
1966
2013
 
1973
2020
 ***********************************************************************
1974
2021
 */
1975
2022
 
1976
 
static void flush_expose();
 
2023
static void flush_expose(Window w);
1977
2024
 
1978
 
void
1979
 
HandleExpose()
 
2025
void HandleExpose(void)
1980
2026
{
1981
2027
    MenuRoot *tmp;
 
2028
    virtualScreen *vs;
1982
2029
 
1983
2030
    if (XFindContext(dpy, Event.xany.window, MenuContext, (XPointer *)&tmp) == 0)
1984
2031
    {
2054
2101
                }
2055
2102
            }
2056
2103
        }
2057
 
        if (Tmp_win == Scr->workSpaceMgr.workspaceWindow.twm_win) {
2058
 
            WMgrHandleExposeEvent (&Event);
 
2104
        for (vs = Scr->vScreenList; vs != NULL; vs = vs->next) {
 
2105
          if (Tmp_win == vs->wsw->twm_win) {
 
2106
            WMgrHandleExposeEvent (vs, &Event);
2059
2107
            flush_expose (Event.xany.window);
2060
2108
            return;
 
2109
          }
2061
2110
        }
2062
 
        else if (Tmp_win == Scr->workSpaceMgr.occupyWindow.twm_win) {
 
2111
        if (Tmp_win == Scr->workSpaceMgr.occupyWindow->twm_win) {
2063
2112
            PaintOccupyWindow ();
2064
2113
            flush_expose (Event.xany.window);
2065
2114
            return;
2122
2171
                flush_expose (Event.xany.window);
2123
2172
                return;
2124
2173
            }
2125
 
        } 
 
2174
        }
2126
2175
    }
2127
2176
}
2128
2177
 
2129
2178
 
2130
2179
 
2131
 
static void remove_window_from_ring (tmp)
2132
 
    TwmWindow *tmp;
 
2180
static void remove_window_from_ring (TwmWindow *tmp)
2133
2181
{
2134
2182
    TwmWindow *prev = tmp->ring.prev, *next = tmp->ring.next;
2135
2183
 
2167
2215
 ***********************************************************************
2168
2216
 */
2169
2217
 
2170
 
void
2171
 
HandleDestroyNotify()
 
2218
void HandleDestroyNotify(void)
2172
2219
{
2173
2220
    int i;
2174
 
 
2175
2221
    /*
2176
2222
     * Warning, this is also called by HandleUnmapNotify; if it ever needs to
2177
2223
     * look at the event, HandleUnmapNotify will have to mash the UnmapNotify
2182
2228
        return;
2183
2229
 
2184
2230
    RemoveWindowFromRegion (Tmp_win);
 
2231
#ifdef GNOME
 
2232
    GnomeDeleteClientWindow (Tmp_win); /* Fix the gnome client list */
 
2233
#endif /* GNOME */
2185
2234
    if (Tmp_win == Scr->Focus)
2186
2235
    {
2187
2236
        Scr->Focus = (TwmWindow*) NULL;
2281
2330
    free((char *)Tmp_win);
2282
2331
 
2283
2332
    if (Scr->ClickToFocus || Scr->SloppyFocus)
2284
 
        set_last_window (Scr->workSpaceMgr.activeWSPC);
 
2333
        set_last_window (Scr->currentvs->wsw->currentwspc);
2285
2334
}
2286
2335
 
2287
2336
 
2288
2337
 
2289
 
void
2290
 
HandleCreateNotify()
 
2338
void HandleCreateNotify(void)
2291
2339
{
2292
2340
#ifdef DEBUG_EVENTS
2293
2341
    fprintf(stderr, "CreateNotify w = 0x%x\n", Event.xcreatewindow.window);
2307
2355
 ***********************************************************************
2308
2356
 */
2309
2357
 
2310
 
void
2311
 
HandleMapRequest()
 
2358
void HandleMapRequest(void)
2312
2359
{
2313
2360
    int stat;
2314
2361
    int zoom_save;
2323
2370
    {
2324
2371
        /* Add decorations. */
2325
2372
        Tmp_win = AddWindow(Event.xany.window, FALSE, (IconMgr *) NULL);
2326
 
        if (Tmp_win == NULL)
2327
 
            return;
 
2373
        if (Tmp_win == NULL) return;
 
2374
#ifdef GNOME
 
2375
        GnomeAddClientWindow (Tmp_win); /* add the new window to the gnome client list */
 
2376
#endif /* GNOME */
2328
2377
    }
2329
2378
    else
2330
2379
    {
2380
2429
            case InactiveState:
2381
2430
                Tmp_win->mapped = TRUE;
2382
2431
                if (Tmp_win->UnmapByMovingFarAway) {
2383
 
                    XMoveWindow (dpy, Tmp_win->frame, Scr->MyDisplayWidth  + 1,
2384
 
                                                      Scr->MyDisplayHeight + 1);
 
2432
                    XMoveWindow (dpy, Tmp_win->frame, Scr->rootw + 1, Scr->rooth + 1);
2385
2433
                    XMapWindow  (dpy, Tmp_win->w);
2386
2434
                    XMapWindow  (dpy, Tmp_win->frame);
2387
2435
                }
2414
2462
 
2415
2463
 
2416
2464
 
2417
 
void SimulateMapRequest (w)
2418
 
    Window w;
 
2465
void SimulateMapRequest (Window w)
2419
2466
{
2420
2467
    Event.xmaprequest.window = w;
2421
2468
    HandleMapRequest ();
2431
2478
 ***********************************************************************
2432
2479
 */
2433
2480
 
2434
 
void
2435
 
HandleMapNotify()
 
2481
void HandleMapNotify(void)
2436
2482
{
2437
2483
    if (Tmp_win == NULL)
2438
2484
        return;
2471
2517
 ***********************************************************************
2472
2518
 */
2473
2519
 
2474
 
void
2475
 
HandleUnmapNotify()
 
2520
void HandleUnmapNotify(void)
2476
2521
{
2477
2522
    int dstx, dsty;
2478
2523
    Window dumwin;
2548
2593
 ***********************************************************************
2549
2594
 */
2550
2595
 
2551
 
void
2552
 
HandleMotionNotify()
 
2596
void HandleMotionNotify(void)
2553
2597
{
2554
2598
    if (ResizeWindow != (Window) 0)
2555
2599
    {
2559
2603
            &(Event.xmotion.x), &(Event.xmotion.y),
2560
2604
            &JunkMask);
2561
2605
 
2562
 
        if (captive) FixRootEvent (&Event);
 
2606
        if (Scr->Root != Scr->RealRoot) FixRootEvent (&Event);
2563
2607
        /* Set WindowMoved appropriately so that f.deltastop will
2564
2608
           work with resize as well as move. */
2565
2609
        if (abs (Event.xmotion.x - ResizeOrigX) >= Scr->MoveDelta
2589
2633
 *
2590
2634
 ***********************************************************************
2591
2635
 */
2592
 
void
2593
 
HandleButtonRelease()
 
2636
void HandleButtonRelease(void)
2594
2637
{
2595
2638
    int xl, yt, w, h;
2596
2639
    unsigned mask;
2597
2640
 
 
2641
#ifdef GNOME
 
2642
    if (GnomeProxyButtonPress == Event.xbutton.button) {
 
2643
      GnomeProxyButtonPress = -1;
 
2644
      XSendEvent (dpy, Scr->currentvs->wsw->w, False, SubstructureNotifyMask, &Event);
 
2645
    }
 
2646
#endif /* GNOME */
2598
2647
    if (InfoLines)              /* delete info box on 2nd button release  */
2599
2648
      if (Context == C_IDENTIFY) {
2600
2649
        XUnmapWindow(dpy, Scr->InfoWindow);
2648
2697
            Scr->OpaqueMove &&
2649
2698
            DragWindow == Tmp_win->frame) TryToPush (Tmp_win,  xl,  yt, 0);
2650
2699
        if (MoveFunction == F_MOVEPACK ||
2651
 
            MoveFunction == F_MOVEPUSH &&
2652
 
            DragWindow == Tmp_win->frame) TryToPack (Tmp_win, &xl, &yt);
 
2700
            (MoveFunction == F_MOVEPUSH &&
 
2701
             DragWindow == Tmp_win->frame)) TryToPack (Tmp_win, &xl, &yt);
2653
2702
        if (Scr->DontMoveOff && MoveFunction != F_FORCEMOVE)
2654
2703
        {
2655
2704
            ConstrainByBorders (Tmp_win, &xl, w, &yt, h);
2681
2730
 
2682
2731
        /* CCC equivalent code for auto lower not needed? */
2683
2732
 
 
2733
#if 0
 
2734
        if (Scr->NumAutoLowers) {
 
2735
            leave_flag = TRUE;
 
2736
            leave_win = NULL;
 
2737
            lower_win = ((DragWindow == Tmp_win->frame)
 
2738
                         ? Tmp_win : NULL);
 
2739
        }
 
2740
#endif
 
2741
 
2684
2742
        DragWindow = (Window) 0;
2685
2743
        ConstMove = FALSE;
2686
2744
    }
2789
2847
 
2790
2848
 
2791
2849
 
2792
 
static do_menu (menu, w)
2793
 
    MenuRoot *menu;                     /* menu to pop up */
2794
 
    Window w;                           /* invoking window or None */
 
2850
static void do_menu (MenuRoot *menu,    /* menu to pop up */
 
2851
                     Window w)          /* invoking window or None */
2795
2852
{
2796
2853
    int x = Event.xbutton.x_root;
2797
2854
    int y = Event.xbutton.y_root;
2815
2872
    }
2816
2873
}
2817
2874
 
2818
 
static void do_key_menu (menu, w)
2819
 
    MenuRoot *menu;                     /* menu to pop up */
2820
 
    Window w;                           /* invoking window or None */
 
2875
static void do_key_menu (MenuRoot *menu,        /* menu to pop up */
 
2876
                         Window w)              /* invoking window or None */
2821
2877
{
2822
2878
    int x = Event.xkey.x_root;
2823
2879
    int y = Event.xkey.y_root;
2852
2908
 *
2853
2909
 ***********************************************************************
2854
2910
 */
2855
 
void
2856
 
HandleButtonPress()
 
2911
void HandleButtonPress(void)
2857
2912
{
2858
2913
    unsigned int modifier;
2859
2914
    Cursor cur;
2860
2915
    MenuRoot *mr;
2861
2916
    FuncButton *tmp;
2862
 
    int func;
 
2917
    int func = 0;
2863
2918
    Window w;
2864
2919
 
 
2920
    GnomeProxyButtonPress = -1;
 
2921
 
2865
2922
    /* pop down the menu, if any */
2866
2923
 
2867
2924
    if (XFindContext (dpy, Event.xbutton.window, MenuContext, (XPointer *) &mr) != XCSUCCESS) {
2885
2942
        Cancel = TRUE;
2886
2943
        CurrentDragX = origDragX;
2887
2944
        CurrentDragY = origDragY;
2888
 
        if (!menuFromFrameOrWindowOrTitlebar)
 
2945
        if (!menuFromFrameOrWindowOrTitlebar) {
2889
2946
          if (Scr->OpaqueMove && DragWindow != None) {
2890
2947
            XMoveWindow (dpy, DragWindow, origDragX, origDragY);
2891
2948
          } else {
2892
2949
            MoveOutline(Scr->Root, 0, 0, 0, 0, 0, 0);
2893
2950
          }
 
2951
        }
2894
2952
        XUnmapWindow(dpy, Scr->SizeWindow);
2895
2953
        if (!Scr->OpaqueMove)
2896
2954
            UninstallRootColormap();
3076
3134
                Tmp_win->wmhints &&
3077
3135
                Tmp_win->wmhints->input) SetFocus (Tmp_win, CurrentTime);
3078
3136
        }
3079
 
        else if ((Tmp_win == Scr->workSpaceMgr.workspaceWindow.twm_win) ||
3080
 
                 (Tmp_win == Scr->workSpaceMgr.occupyWindow.twm_win)) {
 
3137
        else if (Tmp_win->wspmgr ||
 
3138
                 (Tmp_win == Scr->workSpaceMgr.occupyWindow->twm_win)) {
3081
3139
            Context = C_WINDOW;
3082
3140
        }
3083
3141
        else if (Tmp_win->list) {
3192
3250
                }
3193
3251
        }
3194
3252
    }
3195
 
    else if (Tmp_win == Scr->workSpaceMgr.workspaceWindow.twm_win) /* Baaad */
3196
 
    {
3197
 
        WMgrHandleButtonEvent (&Event);
 
3253
    else {
 
3254
        if (Tmp_win == Scr->currentvs->wsw->twm_win) {
 
3255
          WMgrHandleButtonEvent (Scr->currentvs, &Event);
 
3256
          return;
 
3257
        }
3198
3258
    }
3199
 
    else if (Tmp_win == Scr->workSpaceMgr.occupyWindow.twm_win)
 
3259
    if (Tmp_win == Scr->workSpaceMgr.occupyWindow->twm_win)
3200
3260
    {
3201
3261
        OccupyHandleButtonEvent (&Event);
3202
3262
    }
3203
 
    else if (Scr->DefaultFunction.func != 0)
 
3263
    else if (func == 0 && Scr->DefaultFunction.func != 0)
3204
3264
    {
3205
3265
        if (Scr->DefaultFunction.func == F_MENU)
3206
3266
        {
3214
3274
               Event.xany.window, Tmp_win, &Event, Context, FALSE);
3215
3275
        }
3216
3276
    }
 
3277
#ifdef GNOME1 /* Makes DeferExecution (in menus.c) fail. TODO. */
 
3278
    else {
 
3279
        /* GNOME: Pass on the event to any applications listening for root window clicks */
 
3280
        GnomeProxyButtonPress = Event.xbutton.button;
 
3281
        ButtonPressed = -1;
 
3282
        XUngrabPointer (dpy, CurrentTime);
 
3283
        XSendEvent (dpy, Scr->currentvs->wsw->twm_win->w, False,
 
3284
                    SubstructureNotifyMask, &Event);
 
3285
    }
 
3286
#endif /* GNOME1 */
3217
3287
}
3218
3288
 
3219
3289
 
3239
3309
} HENScanArgs;
3240
3310
 
3241
3311
/* ARGSUSED*/
3242
 
static Bool
3243
 
HENQueueScanner(dpy, ev, args)
3244
 
    Display *dpy;
3245
 
    XEvent *ev;
3246
 
    char *args;
 
3312
static Bool HENQueueScanner(Display *dpy, XEvent *ev, char *args)
3247
3313
{
3248
3314
    if (ev->type == LeaveNotify) {
3249
3315
        if (ev->xcrossing.window == ((HENScanArgs *) args)->w &&
3273
3339
 ***********************************************************************
3274
3340
 */
3275
3341
 
3276
 
void
3277
 
HandleEnterNotify()
 
3342
void HandleEnterNotify(void)
3278
3343
{
3279
3344
    MenuRoot *mr, *tmp;
3280
3345
    XEnterWindowEvent *ewp = &Event.xcrossing;
3281
3346
    HENScanArgs scanArgs;
3282
3347
    XEvent dummy;
3283
3348
    extern int RaiseDelay;
 
3349
    virtualScreen *vs;
3284
3350
 
3285
3351
    /*
3286
3352
     * if we aren't in the middle of menu processing
3318
3384
            }
3319
3385
            return;
3320
3386
        }
 
3387
        for (vs = Scr->vScreenList; vs != NULL; vs = vs->next) {
 
3388
          if (ewp->window == vs->window) {
 
3389
            Scr->Root  = vs->window;
 
3390
            Scr->rootx = Scr->crootx + vs->x;
 
3391
            Scr->rooty = Scr->crooty + vs->y;
 
3392
            Scr->rootw = vs->w;
 
3393
            Scr->rooth = vs->h;
 
3394
            Scr->currentvs = vs;
 
3395
            /*fprintf (stderr, "entering new vs : 0x%x, 0x%x, %d, %d, %d, %d\n",
 
3396
              vs, Scr->Root, vs->x, vs->y, vs->w, vs->h);*/
 
3397
            return;
 
3398
          }
 
3399
        }
3321
3400
 
3322
3401
        /* Handle RaiseDelay, if any.....
3323
3402
         */
3409
3488
            if (Scr->FocusRoot && (!scanArgs.leaves || scanArgs.inferior)) {
3410
3489
                Bool accinput;
3411
3490
 
3412
 
                if (Scr->SchrinkIconTitles &&
 
3491
                if (Scr->ShrinkIconTitles &&
3413
3492
                    Tmp_win->icon &&
3414
3493
                    ewp->window == Tmp_win->icon->w &&
3415
3494
                    ewp->detail != NotifyInferior) {
3626
3705
} HLNScanArgs;
3627
3706
 
3628
3707
/* ARGSUSED*/
3629
 
static Bool
3630
 
HLNQueueScanner(dpy, ev, args)
3631
 
    Display *dpy;
3632
 
    XEvent *ev;
3633
 
    char *args;
 
3708
static Bool HLNQueueScanner(Display *dpy, XEvent *ev, char *args)
3634
3709
{
3635
3710
    if (ev->type == EnterNotify && ev->xcrossing.mode != NotifyGrab) {
3636
3711
        ((HLNScanArgs *) args)->enters = True;
3651
3726
 ***********************************************************************
3652
3727
 */
3653
3728
 
3654
 
void
3655
 
HandleLeaveNotify()
 
3729
void HandleLeaveNotify(void)
3656
3730
{
3657
3731
    HLNScanArgs scanArgs;
3658
3732
    XEvent dummy;
3672
3746
        if (Event.xcrossing.mode != NotifyNormal)
3673
3747
            return;
3674
3748
 
3675
 
        if (Scr->SchrinkIconTitles &&
 
3749
        if (Scr->ShrinkIconTitles &&
3676
3750
            Tmp_win->icon &&
3677
3751
            Event.xcrossing.window == Tmp_win->icon->w &&
3678
3752
            Event.xcrossing.detail != NotifyInferior) {
3679
 
            SchrinkIconTitle (Tmp_win);
 
3753
            ShrinkIconTitle (Tmp_win);
3680
3754
            return;
3681
3755
        }
3682
3756
 
3739
3813
        }
3740
3814
        /* Autolower modification. */
3741
3815
        if (Tmp_win->auto_lower) {
3742
 
             leave_win = Tmp_win;
 
3816
            leave_win = Tmp_win;
3743
3817
            if (leave_flag == FALSE) AutoLowerWindow (Tmp_win);
3744
3818
        } else if (leave_flag && lower_win == Tmp_win)
3745
 
             leave_win = Tmp_win;
 
3819
            leave_win = Tmp_win;
3746
3820
 
3747
3821
        XSync (dpy, 0);
3748
3822
        return;
3759
3833
 ***********************************************************************
3760
3834
 */
3761
3835
 
3762
 
void
3763
 
HandleConfigureRequest()
 
3836
void HandleConfigureRequest(void)
3764
3837
{
3765
3838
    XWindowChanges xwc;
3766
3839
    unsigned long xwcm;
3879
3952
    if (width != Tmp_win->frame_width || height != Tmp_win->frame_height)
3880
3953
        Tmp_win->zoomed = ZOOM_NONE;
3881
3954
 
 
3955
    /* Workaround for Java 1.4 bug that freezes the application whenever
 
3956
     * a new window is displayed. (When UsePPosition is on and either
 
3957
     * UseThreeDBorders or BorderWidth 0 is set.)
 
3958
     */
 
3959
    if (!bw)
 
3960
        sendEvent = True; 
 
3961
 
3882
3962
    /*
3883
3963
     * SetupWindow (x,y) are the location of the upper-left outer corner and
3884
3964
     * are passed directly to XMoveResizeWindow (frame).  The (width,height)
3898
3978
 *
3899
3979
 ***********************************************************************
3900
3980
 */
3901
 
void
3902
 
HandleShapeNotify ()
 
3981
void HandleShapeNotify (void)
3903
3982
{
3904
3983
    XShapeEvent     *sev = (XShapeEvent *) &Event;
3905
3984
 
3925
4004
 ***********************************************************************
3926
4005
 */
3927
4006
 
3928
 
void
3929
 
HandleUnknown()
 
4007
void HandleUnknown(void)
3930
4008
{
3931
4009
#ifdef DEBUG_EVENTS
3932
4010
    fprintf(stderr, "type = %d\n", Event.type);
3950
4028
 ***********************************************************************
3951
4029
 */
3952
4030
 
3953
 
int
3954
 
Transient(w, propw)
3955
 
    Window w, *propw;
 
4031
int Transient(Window w, Window *propw)
3956
4032
{
3957
4033
    return (XGetTransientForHint(dpy, w, propw));
3958
4034
}
3973
4049
 ***********************************************************************
3974
4050
 */
3975
4051
 
3976
 
ScreenInfo *
3977
 
FindScreenInfo(w)
3978
 
    Window w;
 
4052
ScreenInfo *FindScreenInfo(Window w)
3979
4053
{
3980
4054
    XWindowAttributes attr;
3981
4055
    int scrnum;
3995
4069
 
3996
4070
 
3997
4071
 
3998
 
static void flush_expose (w)
3999
 
    Window w;
 
4072
static void flush_expose (Window w)
4000
4073
{
4001
4074
    XEvent dummy;
4002
4075
 
4019
4092
 ***********************************************************************
4020
4093
 */
4021
4094
 
4022
 
InstallWindowColormaps (type, tmp)
4023
 
    int type;
4024
 
    TwmWindow *tmp;
 
4095
int InstallWindowColormaps (int type, TwmWindow *tmp)
4025
4096
{
4026
4097
    int i, j, n, number_cwins, state;
4027
4098
    ColormapWindow **cwins, *cwin, **maxcwin = NULL;
4103
4174
            n--;
4104
4175
        }
4105
4176
    }
 
4177
    return (1);
4106
4178
}
4107
4179
 
4108
4180
 
4126
4198
 ***********************************************************************
4127
4199
 */
4128
4200
 
4129
 
InstallRootColormap()
 
4201
void InstallRootColormap(void)
4130
4202
{
4131
4203
    TwmWindow *tmp;
4132
4204
    if (Scr->cmapInfo.root_pushes == 0) {
4145
4217
 
4146
4218
 
4147
4219
/* ARGSUSED*/
4148
 
static Bool
4149
 
UninstallRootColormapQScanner(dpy, ev, args)
4150
 
    Display *dpy;
4151
 
    XEvent *ev;
4152
 
    char *args;
 
4220
static Bool UninstallRootColormapQScanner(Display *dpy, XEvent *ev, char *args)
4153
4221
{
4154
 
    if (!*args)
 
4222
    if (!*args) {
4155
4223
        if (ev->type == EnterNotify) {
4156
4224
            if (ev->xcrossing.mode != NotifyGrab)
4157
4225
                *args = 1;
4159
4227
            if (ev->xcrossing.mode == NotifyNormal)
4160
4228
                *args = 1;
4161
4229
        }
 
4230
    }
4162
4231
 
4163
4232
    return (False);
4164
4233
}
4165
4234
 
4166
4235
 
4167
4236
 
4168
 
UninstallRootColormap()
 
4237
void UninstallRootColormap(void)
4169
4238
{
4170
4239
    char args;
4171
4240
    XEvent dummy;
4187
4256
    }
4188
4257
}
4189
4258
 
4190
 
ConfigureRootWindow (ev)
4191
 
XEvent *ev;
 
4259
void ConfigureRootWindow (XEvent *ev)
4192
4260
{
4193
 
    Window root, child;
4194
 
    int    x, y;
4195
 
    unsigned int w, h, bw, d;
4196
 
 
4197
 
    XGetGeometry (dpy, Scr->Root, &root, &x, &y, &w, &h, &bw, &d);
4198
 
    XTranslateCoordinates (dpy, Scr->Root, root, 0, 0, &Scr->MyDisplayX,
4199
 
                                &Scr->MyDisplayY, &child);
4200
 
 
4201
 
    Scr->MyDisplayWidth  = ev->xconfigure.width;
4202
 
    Scr->MyDisplayHeight = ev->xconfigure.height;
 
4261
    Window       root, child;
 
4262
    int          x, y;
 
4263
    unsigned int w, h, bw, d, oldw, oldh;
 
4264
    extern void twmrc_error_prefix(void);
 
4265
 
 
4266
    XGetGeometry (dpy, Scr->CaptiveRoot, &root, &x, &y, &w, &h, &bw, &d);
 
4267
    XTranslateCoordinates (dpy, Scr->CaptiveRoot, root, 0, 0, &Scr->crootx, &Scr->crooty, &child);
 
4268
 
 
4269
    oldw = Scr->crootw;
 
4270
    oldh = Scr->crooth;
 
4271
    Scr->crootw = ev->xconfigure.width;
 
4272
    Scr->crooth = ev->xconfigure.height;
 
4273
    /*
 
4274
    fprintf (stderr, "ConfigureRootWindow: cx = %d, cy = %d, cw = %d, ch = %d\n",
 
4275
             Scr->crootx, Scr->crooty, Scr->crootw, Scr->crooth);
 
4276
    */
 
4277
    if (Scr->currentvs) {
 
4278
      Scr->rootx = Scr->crootx + Scr->currentvs->x;
 
4279
      Scr->rooty = Scr->crooty + Scr->currentvs->y;
 
4280
    }
 
4281
    Scr->rootw = Scr->crootw;
 
4282
    Scr->rooth = Scr->crooth;
 
4283
 
 
4284
    if (captive && ((Scr->crootw != oldw) || (Scr->crooth != oldh))) {
 
4285
      twmrc_error_prefix ();
 
4286
      fprintf (stderr, "You cannot change root window geometry with virtual screens active,\n");
 
4287
      fprintf (stderr, "from now on, the ctwm behaviour is unpredictable.\n");
 
4288
    }
4203
4289
}
4204
4290
 
4205
 
#ifdef TRACE
4206
 
static void dumpevent (e)
4207
 
    XEvent *e;
 
4291
static void dumpevent (XEvent *e)
4208
4292
{
4209
 
    char *name = NULL;
 
4293
    char *name = "Unknown event";
4210
4294
 
4211
4295
    if (! tracefile) return;
4212
4296
    switch (e->type) {
4244
4328
      case ClientMessage:  name = "ClientMessage"; break;
4245
4329
      case MappingNotify:  name = "MappingNotify"; break;
4246
4330
    }
4247
 
 
4248
 
    if (name) {
4249
 
        fprintf (tracefile, "event:  %s, %d remaining\n", name, QLength(dpy));
4250
 
    } else {
4251
 
        fprintf (tracefile, "unknown event %d, %d remaining\n", e->type, QLength(dpy));
 
4331
    fprintf (tracefile, "event:  %s in window 0x%x\n", name, e->xany.window);
 
4332
    switch (e->type) {
 
4333
      case KeyPress:
 
4334
      case KeyRelease:
 
4335
          fprintf (tracefile, "     :  +%d,+%d (+%d,+%d)  state=%d, keycode=%d\n",
 
4336
                   e->xkey.x, e->xkey.y,
 
4337
                   e->xkey.x_root, e->xkey.y_root,
 
4338
                   e->xkey.state, e->xkey.keycode);
 
4339
          break;
 
4340
      case ButtonPress:
 
4341
      case ButtonRelease:
 
4342
          fprintf (tracefile, "     :  +%d,+%d (+%d,+%d)  state=%d, button=%d\n",
 
4343
                   e->xbutton.x, e->xbutton.y,
 
4344
                   e->xbutton.x_root, e->xbutton.y_root,
 
4345
                   e->xbutton.state, e->xbutton.button);
 
4346
          break;
4252
4347
    }
4253
4348
}
4254
 
#endif /* TRACE */