1 /* event.c- event loop and handling
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 Alfredo K. Kojima
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
33 #include <X11/Xutil.h>
35 #include <X11/extensions/shape.h>
41 #ifdef KEEP_XKB_LOCK_STATUS
42 #include <X11/XKBlib.h>
43 #endif /* KEEP_XKB_LOCK_STATUS */
45 #include "WindowMaker.h"
51 #include "application.h"
54 #include "workspace.h"
57 #include "properties.h"
67 /******** Global Variables **********/
68 extern XContext wWinContext
;
70 extern Cursor wCursor
[WCUR_LAST
];
72 extern WShortKey wKeyBindings
[WKBD_LAST
];
73 extern int wScreenCount
;
74 extern Time LastTimestamp
;
75 extern Time LastFocusChange
;
77 extern WPreferences wPreferences
;
79 #define MOD_MASK wPreferences.modifier_mask
81 extern Atom _XA_WM_COLORMAP_NOTIFY
;
83 extern Atom _XA_WM_CHANGE_STATE
;
84 extern Atom _XA_WM_DELETE_WINDOW
;
85 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
86 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
87 extern Atom _XA_WINDOWMAKER_COMMAND
;
90 extern Atom _XA_DND_PROTOCOL
;
95 extern Bool wShapeSupported
;
96 extern int wShapeEventBase
;
99 #ifdef KEEP_XKB_LOCK_STATUS
100 extern int wXkbEventBase
;
104 extern char WDelayedActionSet
;
107 /************ Local stuff ***********/
110 static void saveTimestamp(XEvent
*event
);
111 static void handleColormapNotify();
112 static void handleMapNotify(), handleUnmapNotify();
113 static void handleButtonPress(), handleExpose();
114 static void handleDestroyNotify();
115 static void handleConfigureRequest();
116 static void handleMapRequest();
117 static void handlePropertyNotify();
118 static void handleEnterNotify();
119 static void handleLeaveNotify();
120 static void handleExtensions();
121 static void handleClientMessage();
122 static void handleKeyPress();
123 static void handleFocusIn();
124 static void handleMotionNotify();
125 static void handleVisibilityNotify();
129 static void handleShapeNotify();
132 /* called from the signal handler */
133 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
135 /* real dead process handler */
136 static void handleDeadProcess(void *foo
);
139 typedef struct DeadProcesses
{
141 unsigned char exit_status
;
144 /* stack of dead processes */
145 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
146 static int deadProcessPtr
=0;
149 typedef struct DeathHandler
{
150 WDeathHandler
*callback
;
155 static WMBag
*deathHandlers
=NULL
;
160 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
162 DeathHandler
*handler
;
164 handler
= malloc(sizeof(DeathHandler
));
169 handler
->callback
= callback
;
170 handler
->client_data
= cdata
;
173 deathHandlers
= WMCreateBag(8);
175 WMPutInBag(deathHandlers
, handler
);
183 wDeleteDeathHandler(WMagicNumber id
)
185 DeathHandler
*handler
=(DeathHandler
*)id
;
187 if (!handler
|| !deathHandlers
)
190 WMRemoveFromBag(deathHandlers
, handler
);
197 DispatchEvent(XEvent
*event
)
200 handleDeadProcess(NULL
);
202 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
203 WCHANGE_STATE(WSTATE_EXITING
);
204 /* received SIGTERM */
206 * WMHandleEvent() can't be called from anything
207 * executed inside here, or we can get in a infinite
210 Shutdown(WSExitMode
);
212 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
213 WCHANGE_STATE(WSTATE_RESTARTING
);
215 Shutdown(WSRestartPreparationMode
);
216 /* received SIGHUP */
220 /* for the case that all that is wanted to be dispatched is
225 saveTimestamp(event
);
226 switch (event
->type
) {
228 handleMapRequest(event
);
232 handleKeyPress(event
);
236 handleMotionNotify(event
);
239 case ConfigureRequest
:
240 handleConfigureRequest(event
);
244 handleDestroyNotify(event
);
248 handleMapNotify(event
);
252 handleUnmapNotify(event
);
256 handleButtonPress(event
);
264 handlePropertyNotify(event
);
268 handleEnterNotify(event
);
272 handleLeaveNotify(event
);
276 handleClientMessage(event
);
280 handleColormapNotify(event
);
284 if (event
->xmapping
.request
== MappingKeyboard
285 || event
->xmapping
.request
== MappingModifier
)
286 XRefreshKeyboardMapping(&event
->xmapping
);
290 handleFocusIn(event
);
293 case VisibilityNotify
:
294 handleVisibilityNotify(event
);
297 handleExtensions(event
);
304 *----------------------------------------------------------------------
306 * Processes X and internal events indefinitely.
312 * The LastTimestamp global variable is updated.
313 *----------------------------------------------------------------------
321 WMNextEvent(dpy
, &event
);
322 WMHandleEvent(&event
);
329 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
331 if ((scr
->last_click_time
>0) &&
332 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
333 && (event
->xbutton
.button
== scr
->last_click_button
)
334 && (event
->xbutton
.window
== scr
->last_click_window
)) {
336 scr
->flags
.next_click_is_not_double
= 1;
337 scr
->last_click_time
= 0;
338 scr
->last_click_window
= event
->xbutton
.window
;
347 NotifyDeadProcess(pid_t pid
, unsigned char status
)
349 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
350 wwarning("stack overflow: too many dead processes");
353 /* stack the process to be handled later,
354 * as this is called from the signal handler */
355 deadProcesses
[deadProcessPtr
].pid
= pid
;
356 deadProcesses
[deadProcessPtr
].exit_status
= status
;
362 handleDeadProcess(void *foo
)
367 for (i
=0; i
<deadProcessPtr
; i
++) {
368 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
371 if (!deathHandlers
) {
376 /* get the pids on the queue and call handlers */
377 while (deadProcessPtr
>0) {
380 for (i
= WMGetBagItemCount(deathHandlers
)-1; i
>= 0; i
--) {
381 tmp
= WMGetFromBag(deathHandlers
, i
);
385 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
386 (*tmp
->callback
)(tmp
->pid
,
387 deadProcesses
[deadProcessPtr
].exit_status
,
389 wDeleteDeathHandler(tmp
);
397 saveTimestamp(XEvent
*event
)
399 LastTimestamp
= CurrentTime
;
401 switch (event
->type
) {
404 LastTimestamp
= event
->xbutton
.time
;
408 LastTimestamp
= event
->xkey
.time
;
411 LastTimestamp
= event
->xmotion
.time
;
414 LastTimestamp
= event
->xproperty
.time
;
418 LastTimestamp
= event
->xcrossing
.time
;
421 LastTimestamp
= event
->xselectionclear
.time
;
423 case SelectionRequest
:
424 LastTimestamp
= event
->xselectionrequest
.time
;
426 case SelectionNotify
:
427 LastTimestamp
= event
->xselection
.time
;
429 wXDNDProcessSelection(event
);
437 handleExtensions(XEvent
*event
)
439 #ifdef KEEP_XKB_LOCK_STATUS
441 xkbevent
= (XkbEvent
*)event
;
442 #endif /*KEEP_XKB_LOCK_STATUS*/
444 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
445 handleShapeNotify(event
);
448 #ifdef KEEP_XKB_LOCK_STATUS
449 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
450 handleXkbIndicatorStateNotify(event
);
452 #endif /*KEEP_XKB_LOCK_STATUS*/
457 handleMapRequest(XEvent
*ev
)
461 Window window
= ev
->xmaprequest
.window
;
464 dbprintf("got map request for %x\n", (unsigned)window
);
467 if ((wwin
= wWindowFor(window
))) {
468 if (wwin
->flags
.shaded
) {
469 wUnshadeWindow(wwin
);
471 /* deiconify window */
472 if (wwin
->flags
.miniaturized
) {
473 wDeiconifyWindow(wwin
);
474 } else if (wwin
->flags
.hidden
) {
475 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
476 /* go to the last workspace that the user worked on the app */
477 #ifndef REDUCE_APPICONS
478 /* This severely breaks REDUCE_APPICONS. last_workspace is a neat
479 * concept but it needs to be reworked to handle REDUCE_APPICONS -cls
482 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
485 wUnhideApplication(wapp
, False
, False
);
490 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
492 wwin
= wManageWindow(scr
, window
);
495 * This is to let the Dock know that the application it launched
496 * has already been mapped (eg: it has finished launching).
497 * It is not necessary for normally docked apps, but is needed for
498 * apps that were forcedly docked (like with dockit).
500 if (scr
->last_dock
) {
501 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
502 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
504 wDockTrackWindowLaunch(scr
->last_dock
, window
);
508 wClientSetState(wwin
, NormalState
, None
);
509 if (wwin
->flags
.maximized
) {
510 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
512 if (wwin
->flags
.shaded
) {
513 wwin
->flags
.shaded
= 0;
514 wwin
->flags
.skip_next_animation
= 1;
517 if (wwin
->flags
.miniaturized
) {
518 wwin
->flags
.miniaturized
= 0;
519 wwin
->flags
.skip_next_animation
= 1;
520 wIconifyWindow(wwin
);
522 if (wwin
->flags
.hidden
) {
523 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
525 wwin
->flags
.hidden
= 0;
526 wwin
->flags
.skip_next_animation
= 1;
528 wHideApplication(wapp
);
536 handleDestroyNotify(XEvent
*event
)
540 Window window
= event
->xdestroywindow
.window
;
543 dbputs("got destroy notify");
546 wwin
= wWindowFor(window
);
548 wUnmanageWindow(wwin
, False
, True
);
551 app
= wApplicationOf(window
);
553 if (window
== app
->main_window
) {
555 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
557 if (wwin
->main_window
== window
) {
558 wwin
->main_window
= None
;
563 wApplicationDestroy(app
);
567 wKWMCheckDestroy(&event
->xdestroywindow
);
574 handleExpose(XEvent
*event
)
576 WObjDescriptor
*desc
;
580 dbputs("got expose");
583 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
585 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
586 (XPointer
*)&desc
)==XCNOENT
) {
590 if (desc
->handle_expose
) {
591 (*desc
->handle_expose
)(desc
, event
);
598 handleButtonPress(XEvent
*event
)
600 WObjDescriptor
*desc
;
604 dbputs("got button press");
607 scr
= wScreenForRootWindow(event
->xbutton
.root
);
615 if (event
->xbutton
.window
==scr
->root_win
) {
617 if (event
->xbutton
.button
==wPreferences
.menu_button
) {
618 OpenRootMenu(scr
, event
->xbutton
.x_root
,
619 event
->xbutton
.y_root
, False
);
621 if (scr
->root_menu
) {
622 if (scr
->root_menu
->brother
->flags
.mapped
)
623 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
625 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
627 } else if (event
->xbutton
.button
==wPreferences
.windowl_button
) {
628 OpenSwitchMenu(scr
, event
->xbutton
.x_root
,
629 event
->xbutton
.y_root
, False
);
630 if (scr
->switch_menu
) {
631 if (scr
->switch_menu
->brother
->flags
.mapped
)
632 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
634 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
636 } else if (event
->xbutton
.button
==wPreferences
.select_button
) {
637 wUnselectWindows(scr
);
638 wSelectWindows(scr
, event
);
640 #ifdef MOUSE_WS_SWITCH
641 else if (event
->xbutton
.button
==Button5
) {
643 wWorkspaceRelativeChange(scr
, -1);
645 } else if (event
->xbutton
.button
==Button4
) {
647 wWorkspaceRelativeChange(scr
, 1);
650 #endif /* MOUSE_WS_SWITCH */
652 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
658 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
659 (XPointer
*)&desc
)==XCNOENT
) {
660 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
661 (XPointer
*)&desc
)==XCNOENT
) {
666 if (desc
->handle_mousedown
!=NULL
) {
667 (*desc
->handle_mousedown
)(desc
, event
);
670 if (desc
->parent_type
== WCLASS_WINDOW
) {
673 if (event
->xbutton
.state
& MOD_MASK
) {
674 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
677 if (wPreferences
.focus_mode
== WKF_CLICK
) {
678 if (wPreferences
.ignore_focus_click
) {
679 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
681 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
684 } else if (desc
->parent_type
== WCLASS_APPICON
685 || desc
->parent_type
== WCLASS_MINIWINDOW
686 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
687 if (event
->xbutton
.state
& MOD_MASK
) {
689 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
694 /* save double-click information */
695 if (scr
->flags
.next_click_is_not_double
) {
696 scr
->flags
.next_click_is_not_double
= 0;
698 scr
->last_click_time
= event
->xbutton
.time
;
699 scr
->last_click_button
= event
->xbutton
.button
;
700 scr
->last_click_window
= event
->xbutton
.window
;
706 handleMapNotify(XEvent
*event
)
714 wwin
= wWindowFor(event
->xmap
.event
);
715 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
716 if (wwin
->flags
.miniaturized
) {
717 wDeiconifyWindow(wwin
);
721 wClientSetState(wwin
, NormalState
, None
);
729 handleUnmapNotify(XEvent
*event
)
733 Bool withdraw
= False
;
739 /* only process windows with StructureNotify selected
740 * (ignore SubstructureNotify) */
741 wwin
= wWindowFor(event
->xunmap
.window
);
745 /* whether the event is a Withdrawal request */
746 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
747 && event
->xunmap
.send_event
)
750 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
753 if (!wwin
->flags
.mapped
&& !withdraw
754 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
755 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
759 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
760 wwin
->flags
.mapped
= 0;
762 /* check if the window was destroyed */
763 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
766 Bool reparented
= False
;
768 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
771 /* withdraw window */
772 wwin
->flags
.mapped
= 0;
774 wClientSetState(wwin
, WithdrawnState
, None
);
776 /* if the window was reparented, do not reparent it back to the
778 wUnmanageWindow(wwin
, !reparented
, False
);
785 handleConfigureRequest(XEvent
*event
)
790 dbputs("got configure request");
792 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
794 * Configure request for unmapped window
796 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
798 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
804 handlePropertyNotify(XEvent
*event
)
814 dbputs("got property notify");
816 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
817 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
818 &ju
, &ju
, &ju
, &ju
)) {
821 wClientCheckProperty(wwin
, &event
->xproperty
);
823 wapp
= wApplicationOf(event
->xproperty
.window
);
825 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
828 scr
= wScreenForWindow(event
->xproperty
.window
);
829 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
831 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
838 handleClientMessage(XEvent
*event
)
841 WObjDescriptor
*desc
;
844 dbputs("got client message");
846 /* handle transition from Normal to Iconic state */
847 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
848 && event
->xclient
.format
== 32
849 && event
->xclient
.data
.l
[0] == IconicState
) {
851 wwin
= wWindowFor(event
->xclient
.window
);
853 if (!wwin
->flags
.miniaturized
)
854 wIconifyWindow(wwin
);
855 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
856 && event
->xclient
.format
== 32) {
857 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
862 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
863 wColormapAllowClientInstallation(scr
, True
);
864 } else { /* stopping */
865 wColormapAllowClientInstallation(scr
, False
);
867 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
869 wDefaultsCheckDomains("bla");
871 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
874 wapp
= wApplicationOf(event
->xclient
.window
);
876 switch (event
->xclient
.data
.l
[0]) {
877 case WMFHideOtherApplications
:
878 wHideOtherApplications(wapp
->main_window_desc
);
882 case WMFHideApplication
:
883 wHideApplication(wapp
);
889 wwin
= wWindowFor(event
->xclient
.window
);
891 switch (event
->xclient
.data
.l
[0]) {
892 case WMFHideOtherApplications
:
893 wHideOtherApplications(wwin
);
896 case WMFHideApplication
:
897 wHideApplication(wApplicationOf(wwin
->main_window
));
903 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
905 #endif /* GNOME_STUFF */
907 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
909 #endif /* KWM_HINTS */
911 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
915 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
916 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
917 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
918 goto redirect_message
;
919 #endif /* OFFIX_DND */
925 * Non-standard thing, but needed by OffiX DND.
926 * For when the icon frame gets a ClientMessage
927 * that should have gone to the icon_window.
929 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
930 (XPointer
*)&desc
)!=XCNOENT
) {
931 struct WIcon
*icon
=NULL
;
933 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
934 icon
= (WIcon
*)desc
->parent
;
935 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
936 || desc
->parent_type
== WCLASS_APPICON
) {
937 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
939 if (icon
&& (wwin
=icon
->owner
)) {
940 if (wwin
->client_win
!=event
->xclient
.window
) {
941 event
->xclient
.window
= wwin
->client_win
;
942 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
952 raiseWindow(WScreen
*scr
)
956 scr
->autoRaiseTimer
= NULL
;
958 wwin
= wWindowFor(scr
->autoRaiseWindow
);
962 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
963 wRaiseFrame(wwin
->frame
->core
);
964 /* this is needed or a race condition will occur */
971 handleEnterNotify(XEvent
*event
)
975 WObjDescriptor
*desc
= NULL
;
977 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
981 dbputs("got enter notify");
984 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
986 /* already left the window... */
988 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
989 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
994 /* start my fix scrolled menus */
995 if (wPreferences
.scrollable_menus
) {
996 if (scr
->flags
.jump_back_pending
||
997 event
->xcrossing
.x_root
<= 1 ||
998 event
->xcrossing
.x_root
>= (scr
->scr_width
- 2) ||
999 event
->xcrossing
.y_root
<= 1 ||
1000 event
->xcrossing
.y_root
>= (scr
->scr_height
- 2)) {
1003 dbputs("pointer at screen edge in EnterNotify event, fear");
1006 menu
= wMenuUnderPointer(scr
);
1008 wMenuScroll(menu
, event
);
1013 /* end fix scrolled menus */
1016 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1017 (XPointer
*)&desc
)!=XCNOENT
) {
1018 if(desc
->handle_enternotify
)
1019 (*desc
->handle_enternotify
)(desc
, event
);
1022 /* enter to window */
1023 wwin
= wWindowFor(event
->xcrossing
.window
);
1025 if (wPreferences
.focus_mode
==WKF_POINTER
1026 && event
->xcrossing
.window
==event
->xcrossing
.root
) {
1027 wSetFocusTo(scr
, NULL
);
1029 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1030 wColormapInstallForWindow(scr
, NULL
);
1032 if (scr
->autoRaiseTimer
1033 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1034 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1035 scr
->autoRaiseTimer
= NULL
;
1038 /* set auto raise timer even if in focus-follows-mouse mode
1039 * and the event is for the frame window, even if the window
1040 * has focus already. useful if you move the pointer from a focused
1041 * window to the root window and back pretty fast
1043 * set focus if in focus-follows-mouse mode and the event
1044 * is for the frame window and window doesn't have focus yet */
1045 if ((wPreferences
.focus_mode
==WKF_POINTER
1046 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1047 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1048 && !scr
->flags
.doing_alt_tab
) {
1050 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1051 wSetFocusTo(scr
, wwin
);
1053 if (scr
->autoRaiseTimer
)
1054 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1055 scr
->autoRaiseTimer
= NULL
;
1057 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1058 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1060 = WMAddTimerHandler(wPreferences
.raise_delay
,
1061 (WMCallback
*)raiseWindow
, scr
);
1064 /* Install colormap for window, if the colormap installation mode
1065 * is colormap_follows_mouse */
1066 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1067 if (wwin
->client_win
==event
->xcrossing
.window
)
1068 wColormapInstallForWindow(scr
, wwin
);
1070 wColormapInstallForWindow(scr
, NULL
);
1074 /* a little kluge to hide the clip balloon */
1075 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1077 XUnmapWindow(dpy
, scr
->clip_balloon
);
1078 scr
->flags
.clip_balloon_mapped
= 0;
1080 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1081 || scr
->clip_icon
!= desc
->parent
) {
1082 XUnmapWindow(dpy
, scr
->clip_balloon
);
1083 scr
->flags
.clip_balloon_mapped
= 0;
1088 if (event
->xcrossing
.window
== event
->xcrossing
.root
1089 && event
->xcrossing
.detail
== NotifyNormal
1090 && event
->xcrossing
.detail
!= NotifyInferior
1091 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1093 wSetFocusTo(scr
, scr
->focused_window
);
1097 wBalloonEnteredObject(scr
, desc
);
1103 handleLeaveNotify(XEvent
*event
)
1105 WObjDescriptor
*desc
= NULL
;
1107 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1108 (XPointer
*)&desc
)!=XCNOENT
) {
1109 if(desc
->handle_leavenotify
)
1110 (*desc
->handle_leavenotify
)(desc
, event
);
1112 if (event
->xcrossing
.window
== event
->xcrossing
.root
1113 && event
->xcrossing
.mode
== NotifyNormal
1114 && event
->xcrossing
.detail
!= NotifyInferior
1115 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1117 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1119 wSetFocusTo(scr
, NULL
);
1126 handleShapeNotify(XEvent
*event
)
1128 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1133 dbputs("got shape notify");
1136 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1137 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1139 if (sev
->kind
== ShapeBounding
) {
1140 if (sev
->shaped
== shev
->shaped
) {
1143 XPutBackEvent(dpy
, &ev
);
1149 wwin
= wWindowFor(shev
->window
);
1150 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1153 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1155 wwin
->flags
.shaped
= 0;
1156 wWindowClearShape(wwin
);
1158 } else if (shev
->shaped
) {
1160 wwin
->flags
.shaped
= 1;
1161 wWindowSetShape(wwin
);
1166 #ifdef KEEP_XKB_LOCK_STATUS
1167 /* please help ]d if you know what to do */
1168 handleXkbIndicatorStateNotify(XEvent
*event
)
1172 XkbStateRec staterec
;
1175 for (i
=0; i
<wScreenCount
; i
++) {
1176 scr
= wScreenWithNumber(i
);
1177 wwin
= scr
->focused_window
;
1178 if (wwin
&& wwin
->flags
.focused
) {
1179 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1180 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1181 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1182 wwin
->frame
->languagemode
= staterec
.group
;
1184 #ifdef XKB_BUTTON_HINT
1185 if (wwin
->frame
->titlebar
) {
1186 wFrameWindowPaint(wwin
->frame
);
1192 #endif /*KEEP_XKB_LOCK_STATUS*/
1195 handleColormapNotify(XEvent
*event
)
1199 Bool reinstall
= False
;
1201 wwin
= wWindowFor(event
->xcolormap
.window
);
1205 scr
= wwin
->screen_ptr
;
1209 if (event
->xcolormap
.new) {
1210 XWindowAttributes attr
;
1212 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1214 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1215 scr
->current_colormap
= attr
.colormap
;
1218 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1219 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1221 /* some bastard app (like XV) removed our colormap */
1223 * can't enforce or things like xscreensaver wont work
1226 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1227 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1229 /* someone has put our colormap back */
1233 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1234 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1236 if (reinstall
&& scr
->current_colormap
!=None
) {
1237 if (!scr
->flags
.colormap_stuff_blocked
)
1238 XInstallColormap(dpy
, scr
->current_colormap
);
1245 handleFocusIn(XEvent
*event
)
1250 * For applications that like stealing the focus.
1252 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1253 saveTimestamp(event
);
1254 if (event
->xfocus
.mode
== NotifyUngrab
1255 || event
->xfocus
.mode
== NotifyGrab
1256 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1260 wwin
= wWindowFor(event
->xfocus
.window
);
1261 if (wwin
&& !wwin
->flags
.focused
) {
1262 if (wwin
->flags
.mapped
)
1263 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1265 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1267 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1269 wSetFocusTo(scr
, NULL
);
1275 windowUnderPointer(WScreen
*scr
)
1281 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1283 return wWindowFor(win
);
1288 #ifdef WEENDOZE_CYCLE
1291 nextToFocusAfter(WWindow
*wwin
)
1293 WWindow
*tmp
= wwin
->prev
;
1296 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1304 /* start over from the beginning of the list */
1308 while (tmp
&& tmp
!= wwin
) {
1309 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1321 nextToFocusBefore(WWindow
*wwin
)
1323 WWindow
*tmp
= wwin
->next
;
1326 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1333 /* start over from the beginning of the list */
1338 while (tmp
&& tmp
!= wwin
) {
1339 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1352 doWindozeCycle(WWindow
*wwin
, XEvent
*event
, Bool next
)
1354 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1356 Bool openedSwitchMenu
= False
;
1357 WWindow
*newFocused
;
1358 WWindow
*oldFocused
;
1360 XModifierKeymap
*keymap
;
1366 keymap
= XGetModifierMapping(dpy
);
1369 XGrabKeyboard(dpy
, scr
->root_win
, False
, GrabModeAsync
, GrabModeAsync
,
1373 newFocused
= nextToFocusAfter(wwin
);
1375 newFocused
= nextToFocusBefore(wwin
);
1378 scr
->flags
.doing_alt_tab
= 1;
1380 wWindowFocus(newFocused
, scr
->focused_window
);
1381 oldFocused
= newFocused
;
1382 if (wPreferences
.circ_raise
)
1383 wRaiseFrame(newFocused
->frame
->core
);
1385 if (wPreferences
.popup_switchmenu
&&
1386 (!scr
->switch_menu
|| !scr
->switch_menu
->flags
.mapped
)) {
1388 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1389 openedSwitchMenu
= True
;
1395 WMMaskEvent(dpy
,KeyPressMask
|KeyReleaseMask
|ExposureMask
, &ev
);
1396 /* WMNextEvent(dpy, &ev);*/
1397 if (ev
.type
!= KeyRelease
&& ev
.type
!= KeyPress
) {
1402 /* ignore CapsLock */
1403 modifiers
= ev
.xkey
.state
& ValidModMask
;
1405 if (ev
.type
== KeyPress
1406 && wKeyBindings
[WKBD_FOCUSNEXT
].keycode
== ev
.xkey
.keycode
1407 && wKeyBindings
[WKBD_FOCUSNEXT
].modifier
== modifiers
) {
1409 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1410 newFocused
= nextToFocusAfter(newFocused
);
1411 wWindowFocus(newFocused
, oldFocused
);
1412 oldFocused
= newFocused
;
1413 if (wPreferences
.circ_raise
)
1414 wRaiseFrame(newFocused
->frame
->core
);
1415 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1417 } else if (ev
.type
== KeyPress
1418 && wKeyBindings
[WKBD_FOCUSPREV
].keycode
== ev
.xkey
.keycode
1419 && wKeyBindings
[WKBD_FOCUSPREV
].modifier
== modifiers
) {
1421 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1422 newFocused
= nextToFocusBefore(newFocused
);
1423 wWindowFocus(newFocused
, oldFocused
);
1424 oldFocused
= newFocused
;
1425 if (wPreferences
.circ_raise
)
1426 wRaiseFrame(newFocused
->frame
->core
);
1427 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1429 if (ev
.type
== KeyRelease
) {
1432 for (i
= 0; i
<= 8 * keymap
->max_keypermod
; i
++) {
1433 if (keymap
->modifiermap
[i
] == ev
.xkey
.keycode
&&
1434 wKeyBindings
[WKBD_FOCUSNEXT
].modifier
1435 & 1<<(i
/keymap
->max_keypermod
)) {
1445 XUngrabKeyboard(dpy
, CurrentTime
);
1446 wSetFocusTo(scr
, newFocused
);
1447 scr
->flags
.doing_alt_tab
= 0;
1448 if (openedSwitchMenu
)
1449 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1453 #endif /* WEENDOZE_CYCLE */
1459 handleKeyPress(XEvent
*event
)
1461 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1462 WWindow
*wwin
= scr
->focused_window
;
1465 int command
=-1, index
;
1466 #ifdef KEEP_XKB_LOCK_STATUS
1467 XkbStateRec staterec
;
1468 #endif /*KEEP_XKB_LOCK_STATUS*/
1470 /* ignore CapsLock */
1471 modifiers
= event
->xkey
.state
& ValidModMask
;
1473 for (i
=0; i
<WKBD_LAST
; i
++) {
1474 if (wKeyBindings
[i
].keycode
==0)
1477 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1478 && (/*wKeyBindings[i].modifier==0
1479 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1492 if (!wRootMenuPerformShortcut(event
)) {
1494 static int dontLoop
= 0;
1496 if (dontLoop
> 10) {
1497 wwarning("problem with key event processing code");
1501 /* if the focused window is an internal window, try redispatching
1502 * the event to the managed window, as it can be a WINGs window */
1503 if (wwin
&& wwin
->flags
.internal_window
1504 && wwin
->client_leader
!=None
) {
1505 /* client_leader contains the WINGs toplevel */
1506 event
->xany
.window
= wwin
->client_leader
;
1507 WMHandleEvent(event
);
1514 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1515 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1520 OpenRootMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1522 case WKBD_WINDOWLIST
:
1523 OpenSwitchMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1526 case WKBD_WINDOWMENU
:
1527 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1528 OpenWindowMenu(wwin
, wwin
->frame_x
,
1529 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1531 case WKBD_MINIATURIZE
:
1532 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1533 && !WFLAGP(wwin
, no_miniaturizable
)) {
1534 CloseWindowMenu(scr
);
1536 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1537 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1538 event
->xbutton
.time
);
1540 wIconifyWindow(wwin
);
1545 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1546 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1547 CloseWindowMenu(scr
);
1549 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1550 wHideApplication(wapp
);
1555 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1556 CloseWindowMenu(scr
);
1558 if (wwin
->flags
.maximized
) {
1559 wUnmaximizeWindow(wwin
);
1561 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1565 case WKBD_VMAXIMIZE
:
1566 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1567 CloseWindowMenu(scr
);
1569 if (wwin
->flags
.maximized
) {
1570 wUnmaximizeWindow(wwin
);
1572 wMaximizeWindow(wwin
, MAX_VERTICAL
);
1577 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1578 CloseWindowMenu(scr
);
1580 wRaiseFrame(wwin
->frame
->core
);
1584 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1585 CloseWindowMenu(scr
);
1587 wLowerFrame(wwin
->frame
->core
);
1590 case WKBD_RAISELOWER
:
1591 /* raise or lower the window under the pointer, not the
1594 wwin
= windowUnderPointer(scr
);
1596 wRaiseLowerFrame(wwin
->frame
->core
);
1599 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1600 if (wwin
->flags
.shaded
)
1601 wUnshadeWindow(wwin
);
1606 case WKBD_MOVERESIZE
:
1607 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1608 CloseWindowMenu(scr
);
1610 wKeyboardMoveResizeWindow(wwin
);
1614 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1615 CloseWindowMenu(scr
);
1616 if (wwin
->protocols
.DELETE_WINDOW
)
1617 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1622 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1623 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1626 case WKBD_FOCUSNEXT
:
1627 #ifdef WEENDOZE_CYCLE
1628 if (wPreferences
.windoze_cycling
) {
1629 doWindozeCycle(wwin
, event
, True
);
1631 #endif /* WEENDOZE_CYCLE */
1633 wwin
= NextFocusWindow(scr
);
1635 wSetFocusTo(scr
, wwin
);
1636 if (wPreferences
.circ_raise
)
1637 wRaiseFrame(wwin
->frame
->core
);
1642 case WKBD_FOCUSPREV
:
1643 #ifdef WEENDOZE_CYCLE
1644 if (wPreferences
.windoze_cycling
) {
1645 doWindozeCycle(wwin
, event
, False
);
1647 #endif /* WEENDOZE_CYCLE */
1649 wwin
= PrevFocusWindow(scr
);
1651 wSetFocusTo(scr
, wwin
);
1652 if (wPreferences
.circ_raise
)
1653 wRaiseFrame(wwin
->frame
->core
);
1658 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1659 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1660 i = (scr->current_workspace/10)*10 + wk - 1;\
1661 if (wPreferences.ws_advance || i<scr->workspace_count)\
1662 wWorkspaceChange(scr, i);\
1665 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1666 i = (scr->current_workspace/10)*10 + wk - 1;\
1667 if (wPreferences.ws_advance || i<scr->workspace_count)\
1668 wWorkspaceChange(scr, i);\
1682 case WKBD_NEXTWORKSPACE
:
1683 wWorkspaceRelativeChange(scr
, 1);
1685 case WKBD_PREVWORKSPACE
:
1686 wWorkspaceRelativeChange(scr
, -1);
1692 #ifdef EXTEND_WINDOWSHORTCUT
1701 #define INITBAG(bag) if (bag) WMEmptyBag(bag); else bag = WMCreateBag(4)
1703 index
= command
-WKBD_WINDOW1
;
1705 if (scr
->shortcutWindows
[index
]) {
1706 WMBag
*list
= scr
->shortcutWindows
[index
];
1709 int count
= WMGetBagItemCount(list
);
1712 wUnselectWindows(scr
);
1713 cw
= scr
->current_workspace
;
1715 for (i
= count
-1; i
>= 0; i
--) {
1716 WWindow
*wwin
= WMGetFromBag(list
, i
);
1719 wWindowChangeWorkspace(wwin
, cw
);
1721 wMakeWindowVisible(wwin
);
1724 wSelectWindow(wwin
, True
);
1727 /* rotate the order of windows, to create a cycling effect */
1728 twin
= WMGetFromBag(list
, 0);
1729 WMDeleteFromBag(list
, 0);
1730 WMPutInBag(list
, twin
);
1732 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1734 INITBAG(scr
->shortcutWindows
[index
]);
1735 WMPutInBag(scr
->shortcutWindows
[index
], wwin
);
1737 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1738 WMBag
*selwins
= scr
->selected_windows
;
1741 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1742 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1745 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1748 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1751 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1754 } else if (WMGetBagItemCount(scr
->selected_windows
)) {
1756 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1757 WMBag
*selwins
= scr
->selected_windows
;
1760 INITBAG(scr
->shortcutWindows
[index
]);
1762 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1763 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1765 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1772 case WKBD_NEXTWSLAYER
:
1773 case WKBD_PREVWSLAYER
:
1777 row
= scr
->current_workspace
/10;
1778 column
= scr
->current_workspace
%10;
1780 if (command
==WKBD_NEXTWSLAYER
) {
1781 if ((row
+1)*10 < scr
->workspace_count
)
1782 wWorkspaceChange(scr
, column
+(row
+1)*10);
1785 wWorkspaceChange(scr
, column
+(row
-1)*10);
1789 case WKBD_CLIPLOWER
:
1790 if (!wPreferences
.flags
.noclip
)
1791 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1793 case WKBD_CLIPRAISE
:
1794 if (!wPreferences
.flags
.noclip
)
1795 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1797 case WKBD_CLIPRAISELOWER
:
1798 if (!wPreferences
.flags
.noclip
)
1799 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1801 #ifdef KEEP_XKB_LOCK_STATUS
1803 if(wPreferences
.modelock
) {
1805 wwin
= scr
->focused_window
;
1807 if (wwin
&& wwin
->flags
.mapped
1808 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1809 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1810 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1812 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1813 wwin
->frame
->last_languagemode
= staterec
.group
;
1814 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1819 #endif /* KEEP_XKB_LOCK_STATUS */
1826 handleMotionNotify(XEvent
*event
)
1829 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1831 if (wPreferences
.scrollable_menus
) {
1832 if (scr
->flags
.jump_back_pending
||
1833 event
->xmotion
.x_root
<= 1 ||
1834 event
->xmotion
.x_root
>= (scr
->scr_width
- 2) ||
1835 event
->xmotion
.y_root
<= 1 ||
1836 event
->xmotion
.y_root
>= (scr
->scr_height
- 2)) {
1839 dbputs("pointer at screen edge");
1842 menu
= wMenuUnderPointer(scr
);
1844 wMenuScroll(menu
, event
);
1848 if (event
->xmotion
.subwindow
== None
)
1851 if (scr
->scrolledFMaximize
!= None
) {
1854 twin
= wWindowFor(scr
->scrolledFMaximize
);
1855 if (twin
&& twin
->frame_y
==) {
1859 scr
->scrolledFMaximize
= NULL
;
1863 /* scroll full maximized window */
1864 if (event
->xmotion
.y_root
< 1
1865 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1867 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1869 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1870 && WFLAGP(wwin
, full_maximize
)
1871 && event
->xmotion
.x_root
>= wwin
->frame_x
1872 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1874 if (!WFLAGP(wwin
, no_titlebar
)
1875 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1877 wWindowMove(wwin
, wwin
->frame_x
, 0);
1878 wwin
->flags
.dragged_while_fmaximized
= 0;
1880 } else if (!WFLAGP(wwin
, no_resizebar
)
1881 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1882 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1884 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1886 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1888 wWindowMove(wwin
, wwin
->frame_x
, y
);
1889 wwin
->flags
.dragged_while_fmaximized
= 0;
1898 handleVisibilityNotify(XEvent
*event
)
1902 wwin
= wWindowFor(event
->xvisibility
.window
);
1905 wwin
->flags
.obscured
=
1906 (event
->xvisibility
.state
== VisibilityFullyObscured
);