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,
36 #include <X11/Xutil.h>
38 # include <X11/extensions/shape.h>
44 #ifdef KEEP_XKB_LOCK_STATUS
45 #include <X11/XKBlib.h>
46 #endif /* KEEP_XKB_LOCK_STATUS */
48 #include "WindowMaker.h"
54 #include "application.h"
57 #include "workspace.h"
60 #include "properties.h"
70 /******** Global Variables **********/
71 extern XContext wWinContext
;
73 extern Cursor wCursor
[WCUR_LAST
];
75 extern WShortKey wKeyBindings
[WKBD_LAST
];
76 extern int wScreenCount
;
77 extern Time LastTimestamp
;
78 extern Time LastFocusChange
;
80 extern WPreferences wPreferences
;
82 #define MOD_MASK wPreferences.modifier_mask
84 extern Atom _XA_WM_COLORMAP_NOTIFY
;
86 extern Atom _XA_WM_CHANGE_STATE
;
87 extern Atom _XA_WM_DELETE_WINDOW
;
88 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
89 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
90 extern Atom _XA_WINDOWMAKER_COMMAND
;
93 extern Atom _XA_DND_PROTOCOL
;
98 extern Bool wShapeSupported
;
99 extern int wShapeEventBase
;
102 #ifdef KEEP_XKB_LOCK_STATUS
103 extern int wXkbEventBase
;
107 extern char WDelayedActionSet
;
110 /************ Local stuff ***********/
113 static void saveTimestamp(XEvent
*event
);
114 static void handleColormapNotify();
115 static void handleMapNotify(), handleUnmapNotify();
116 static void handleButtonPress(), handleExpose();
117 static void handleDestroyNotify();
118 static void handleConfigureRequest();
119 static void handleMapRequest();
120 static void handlePropertyNotify();
121 static void handleEnterNotify();
122 static void handleLeaveNotify();
123 static void handleExtensions();
124 static void handleClientMessage();
125 static void handleKeyPress();
126 static void handleFocusIn();
127 static void handleMotionNotify();
128 static void handleVisibilityNotify();
132 static void handleShapeNotify();
135 /* called from the signal handler */
136 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
138 /* real dead process handler */
139 static void handleDeadProcess(void *foo
);
142 typedef struct DeadProcesses
{
144 unsigned char exit_status
;
147 /* stack of dead processes */
148 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
149 static int deadProcessPtr
=0;
152 typedef struct DeathHandler
{
153 WDeathHandler
*callback
;
158 static WMBag
*deathHandlers
=NULL
;
163 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
165 DeathHandler
*handler
;
167 handler
= malloc(sizeof(DeathHandler
));
172 handler
->callback
= callback
;
173 handler
->client_data
= cdata
;
176 deathHandlers
= WMCreateBag(8);
178 WMPutInBag(deathHandlers
, handler
);
186 wDeleteDeathHandler(WMagicNumber id
)
188 DeathHandler
*handler
=(DeathHandler
*)id
;
190 if (!handler
|| !deathHandlers
)
193 WMRemoveFromBag(deathHandlers
, handler
);
200 DispatchEvent(XEvent
*event
)
203 handleDeadProcess(NULL
);
205 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
206 WCHANGE_STATE(WSTATE_EXITING
);
207 /* received SIGTERM */
209 * WMHandleEvent() can't be called from anything
210 * executed inside here, or we can get in a infinite
213 Shutdown(WSExitMode
);
215 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
216 WCHANGE_STATE(WSTATE_RESTARTING
);
218 Shutdown(WSRestartPreparationMode
);
219 /* received SIGHUP */
223 /* for the case that all that is wanted to be dispatched is
228 saveTimestamp(event
);
229 switch (event
->type
) {
231 handleMapRequest(event
);
235 handleKeyPress(event
);
239 handleMotionNotify(event
);
242 case ConfigureRequest
:
243 handleConfigureRequest(event
);
247 handleDestroyNotify(event
);
251 handleMapNotify(event
);
255 handleUnmapNotify(event
);
259 handleButtonPress(event
);
267 handlePropertyNotify(event
);
271 handleEnterNotify(event
);
275 handleLeaveNotify(event
);
279 handleClientMessage(event
);
283 handleColormapNotify(event
);
287 if (event
->xmapping
.request
== MappingKeyboard
288 || event
->xmapping
.request
== MappingModifier
)
289 XRefreshKeyboardMapping(&event
->xmapping
);
293 handleFocusIn(event
);
296 case VisibilityNotify
:
297 handleVisibilityNotify(event
);
300 handleExtensions(event
);
307 *----------------------------------------------------------------------
309 * Processes X and internal events indefinitely.
315 * The LastTimestamp global variable is updated.
316 *----------------------------------------------------------------------
324 WMNextEvent(dpy
, &event
);
325 WMHandleEvent(&event
);
332 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
334 if ((scr
->last_click_time
>0) &&
335 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
336 && (event
->xbutton
.button
== scr
->last_click_button
)
337 && (event
->xbutton
.window
== scr
->last_click_window
)) {
339 scr
->flags
.next_click_is_not_double
= 1;
340 scr
->last_click_time
= 0;
341 scr
->last_click_window
= event
->xbutton
.window
;
350 NotifyDeadProcess(pid_t pid
, unsigned char status
)
352 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
353 wwarning("stack overflow: too many dead processes");
356 /* stack the process to be handled later,
357 * as this is called from the signal handler */
358 deadProcesses
[deadProcessPtr
].pid
= pid
;
359 deadProcesses
[deadProcessPtr
].exit_status
= status
;
365 handleDeadProcess(void *foo
)
370 for (i
=0; i
<deadProcessPtr
; i
++) {
371 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
374 if (!deathHandlers
) {
379 /* get the pids on the queue and call handlers */
380 while (deadProcessPtr
>0) {
383 for (i
= WMGetBagItemCount(deathHandlers
)-1; i
>= 0; i
--) {
384 tmp
= WMGetFromBag(deathHandlers
, i
);
388 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
389 (*tmp
->callback
)(tmp
->pid
,
390 deadProcesses
[deadProcessPtr
].exit_status
,
392 wDeleteDeathHandler(tmp
);
400 saveTimestamp(XEvent
*event
)
402 LastTimestamp
= CurrentTime
;
404 switch (event
->type
) {
407 LastTimestamp
= event
->xbutton
.time
;
411 LastTimestamp
= event
->xkey
.time
;
414 LastTimestamp
= event
->xmotion
.time
;
417 LastTimestamp
= event
->xproperty
.time
;
421 LastTimestamp
= event
->xcrossing
.time
;
424 LastTimestamp
= event
->xselectionclear
.time
;
426 case SelectionRequest
:
427 LastTimestamp
= event
->xselectionrequest
.time
;
429 case SelectionNotify
:
430 LastTimestamp
= event
->xselection
.time
;
432 wXDNDProcessSelection(event
);
440 handleExtensions(XEvent
*event
)
442 #ifdef KEEP_XKB_LOCK_STATUS
444 xkbevent
= (XkbEvent
*)event
;
445 #endif /*KEEP_XKB_LOCK_STATUS*/
447 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
448 handleShapeNotify(event
);
451 #ifdef KEEP_XKB_LOCK_STATUS
452 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
453 handleXkbIndicatorStateNotify(event
);
455 #endif /*KEEP_XKB_LOCK_STATUS*/
460 handleMapRequest(XEvent
*ev
)
464 Window window
= ev
->xmaprequest
.window
;
467 L("got map request for %x\n", (unsigned)window
);
469 if ((wwin
= wWindowFor(window
))) {
470 if (wwin
->flags
.shaded
) {
471 wUnshadeWindow(wwin
);
473 /* deiconify window */
474 if (wwin
->flags
.miniaturized
) {
475 wDeiconifyWindow(wwin
);
476 } else if (wwin
->flags
.hidden
) {
477 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
478 /* go to the last workspace that the user worked on the app */
479 #ifndef REDUCE_APPICONS
480 /* This severely breaks REDUCE_APPICONS. last_workspace is a neat
481 * concept but it needs to be reworked to handle REDUCE_APPICONS -cls
484 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
487 wUnhideApplication(wapp
, False
, False
);
492 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
494 wwin
= wManageWindow(scr
, window
);
497 * This is to let the Dock know that the application it launched
498 * has already been mapped (eg: it has finished launching).
499 * It is not necessary for normally docked apps, but is needed for
500 * apps that were forcedly docked (like with dockit).
502 if (scr
->last_dock
) {
503 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
504 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
506 wDockTrackWindowLaunch(scr
->last_dock
, window
);
510 wClientSetState(wwin
, NormalState
, None
);
511 if (wwin
->flags
.maximized
) {
512 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
514 if (wwin
->flags
.shaded
) {
515 wwin
->flags
.shaded
= 0;
516 wwin
->flags
.skip_next_animation
= 1;
519 if (wwin
->flags
.miniaturized
) {
520 wwin
->flags
.miniaturized
= 0;
521 wwin
->flags
.skip_next_animation
= 1;
522 wIconifyWindow(wwin
);
524 if (wwin
->flags
.hidden
) {
525 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
527 wwin
->flags
.hidden
= 0;
528 wwin
->flags
.skip_next_animation
= 1;
530 wHideApplication(wapp
);
538 handleDestroyNotify(XEvent
*event
)
542 Window window
= event
->xdestroywindow
.window
;
545 L("got destroy notify");
547 wwin
= wWindowFor(window
);
549 wUnmanageWindow(wwin
, False
, True
);
552 app
= wApplicationOf(window
);
554 if (window
== app
->main_window
) {
556 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
558 if (wwin
->main_window
== window
) {
559 wwin
->main_window
= None
;
564 wApplicationDestroy(app
);
568 wKWMCheckDestroy(&event
->xdestroywindow
);
575 handleExpose(XEvent
*event
)
577 WObjDescriptor
*desc
;
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
;
603 L("got button press");
605 scr
= wScreenForRootWindow(event
->xbutton
.root
);
613 if (event
->xbutton
.window
==scr
->root_win
) {
615 if (event
->xbutton
.button
==wPreferences
.menu_button
) {
616 OpenRootMenu(scr
, event
->xbutton
.x_root
,
617 event
->xbutton
.y_root
, False
);
619 if (scr
->root_menu
) {
620 if (scr
->root_menu
->brother
->flags
.mapped
)
621 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
623 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
625 } else if (event
->xbutton
.button
==wPreferences
.windowl_button
) {
626 OpenSwitchMenu(scr
, event
->xbutton
.x_root
,
627 event
->xbutton
.y_root
, False
);
628 if (scr
->switch_menu
) {
629 if (scr
->switch_menu
->brother
->flags
.mapped
)
630 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
632 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
634 } else if (event
->xbutton
.button
==wPreferences
.select_button
) {
635 wUnselectWindows(scr
);
636 wSelectWindows(scr
, event
);
638 #ifdef MOUSE_WS_SWITCH
639 else if (event
->xbutton
.button
==Button5
) {
641 wWorkspaceRelativeChange(scr
, -1);
643 } else if (event
->xbutton
.button
==Button4
) {
645 wWorkspaceRelativeChange(scr
, 1);
648 #endif /* MOUSE_WS_SWITCH */
650 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
656 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
657 (XPointer
*)&desc
)==XCNOENT
) {
658 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
659 (XPointer
*)&desc
)==XCNOENT
) {
664 if (desc
->handle_mousedown
!=NULL
) {
665 (*desc
->handle_mousedown
)(desc
, event
);
668 if (desc
->parent_type
== WCLASS_WINDOW
) {
671 if (event
->xbutton
.state
& MOD_MASK
) {
672 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
675 if (wPreferences
.focus_mode
== WKF_CLICK
) {
676 if (wPreferences
.ignore_focus_click
) {
677 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
679 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
682 } else if (desc
->parent_type
== WCLASS_APPICON
683 || desc
->parent_type
== WCLASS_MINIWINDOW
684 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
685 if (event
->xbutton
.state
& MOD_MASK
) {
687 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
692 /* save double-click information */
693 if (scr
->flags
.next_click_is_not_double
) {
694 scr
->flags
.next_click_is_not_double
= 0;
696 scr
->last_click_time
= event
->xbutton
.time
;
697 scr
->last_click_button
= event
->xbutton
.button
;
698 scr
->last_click_window
= event
->xbutton
.window
;
704 handleMapNotify(XEvent
*event
)
710 wwin
= wWindowFor(event
->xmap
.event
);
711 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
712 if (wwin
->flags
.miniaturized
) {
713 wDeiconifyWindow(wwin
);
717 wClientSetState(wwin
, NormalState
, None
);
725 handleUnmapNotify(XEvent
*event
)
729 Bool withdraw
= False
;
733 /* only process windows with StructureNotify selected
734 * (ignore SubstructureNotify) */
735 wwin
= wWindowFor(event
->xunmap
.window
);
739 /* whether the event is a Withdrawal request */
740 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
741 && event
->xunmap
.send_event
)
744 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
747 if (!wwin
->flags
.mapped
&& !withdraw
748 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
749 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
753 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
754 wwin
->flags
.mapped
= 0;
756 /* check if the window was destroyed */
757 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
760 Bool reparented
= False
;
762 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
765 /* withdraw window */
766 wwin
->flags
.mapped
= 0;
768 wClientSetState(wwin
, WithdrawnState
, None
);
770 /* if the window was reparented, do not reparent it back to the
772 wUnmanageWindow(wwin
, !reparented
, False
);
779 handleConfigureRequest(XEvent
*event
)
783 L("got configure request");
785 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
787 * Configure request for unmapped window
789 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
791 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
797 handlePropertyNotify(XEvent
*event
)
806 L("got property notify");
808 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
809 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
810 &ju
, &ju
, &ju
, &ju
)) {
813 wClientCheckProperty(wwin
, &event
->xproperty
);
815 wapp
= wApplicationOf(event
->xproperty
.window
);
817 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
820 scr
= wScreenForWindow(event
->xproperty
.window
);
821 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
823 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
830 handleClientMessage(XEvent
*event
)
833 WObjDescriptor
*desc
;
835 L("got client message");
837 /* handle transition from Normal to Iconic state */
838 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
839 && event
->xclient
.format
== 32
840 && event
->xclient
.data
.l
[0] == IconicState
) {
842 wwin
= wWindowFor(event
->xclient
.window
);
844 if (!wwin
->flags
.miniaturized
)
845 wIconifyWindow(wwin
);
846 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
847 && event
->xclient
.format
== 32) {
848 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
853 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
854 wColormapAllowClientInstallation(scr
, True
);
855 } else { /* stopping */
856 wColormapAllowClientInstallation(scr
, False
);
858 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
860 wDefaultsCheckDomains("bla");
862 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
865 wapp
= wApplicationOf(event
->xclient
.window
);
867 switch (event
->xclient
.data
.l
[0]) {
868 case WMFHideOtherApplications
:
869 wHideOtherApplications(wapp
->main_window_desc
);
873 case WMFHideApplication
:
874 wHideApplication(wapp
);
880 wwin
= wWindowFor(event
->xclient
.window
);
882 switch (event
->xclient
.data
.l
[0]) {
883 case WMFHideOtherApplications
:
884 wHideOtherApplications(wwin
);
887 case WMFHideApplication
:
888 wHideApplication(wApplicationOf(wwin
->main_window
));
894 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
896 #endif /* GNOME_STUFF */
898 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
900 #endif /* KWM_HINTS */
902 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
906 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
907 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
908 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
909 goto redirect_message
;
910 #endif /* OFFIX_DND */
916 * Non-standard thing, but needed by OffiX DND.
917 * For when the icon frame gets a ClientMessage
918 * that should have gone to the icon_window.
920 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
921 (XPointer
*)&desc
)!=XCNOENT
) {
922 struct WIcon
*icon
=NULL
;
924 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
925 icon
= (WIcon
*)desc
->parent
;
926 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
927 || desc
->parent_type
== WCLASS_APPICON
) {
928 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
930 if (icon
&& (wwin
=icon
->owner
)) {
931 if (wwin
->client_win
!=event
->xclient
.window
) {
932 event
->xclient
.window
= wwin
->client_win
;
933 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
943 raiseWindow(WScreen
*scr
)
947 scr
->autoRaiseTimer
= NULL
;
949 wwin
= wWindowFor(scr
->autoRaiseWindow
);
953 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
954 wRaiseFrame(wwin
->frame
->core
);
955 /* this is needed or a race condition will occur */
962 handleEnterNotify(XEvent
*event
)
966 WObjDescriptor
*desc
= NULL
;
968 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
970 L("got enter notify");
972 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
974 /* already left the window... */
976 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
977 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
982 /* start my fix scrolled menus */
983 if (wPreferences
.scrollable_menus
) {
984 if (scr
->flags
.jump_back_pending
||
985 event
->xcrossing
.x_root
<= 1 ||
986 event
->xcrossing
.x_root
>= (scr
->scr_width
- 2) ||
987 event
->xcrossing
.y_root
<= 1 ||
988 event
->xcrossing
.y_root
>= (scr
->scr_height
- 2)) {
990 L("pointer at screen edge in EnterNotify event, fear");
992 menu
= wMenuUnderPointer(scr
);
994 wMenuScroll(menu
, event
);
999 /* end fix scrolled menus */
1002 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1003 (XPointer
*)&desc
)!=XCNOENT
) {
1004 if(desc
->handle_enternotify
)
1005 (*desc
->handle_enternotify
)(desc
, event
);
1008 /* enter to window */
1009 wwin
= wWindowFor(event
->xcrossing
.window
);
1011 if (wPreferences
.focus_mode
==WKF_POINTER
1012 && event
->xcrossing
.window
==event
->xcrossing
.root
) {
1013 wSetFocusTo(scr
, NULL
);
1015 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1016 wColormapInstallForWindow(scr
, NULL
);
1018 if (scr
->autoRaiseTimer
1019 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1020 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1021 scr
->autoRaiseTimer
= NULL
;
1024 /* set auto raise timer even if in focus-follows-mouse mode
1025 * and the event is for the frame window, even if the window
1026 * has focus already. useful if you move the pointer from a focused
1027 * window to the root window and back pretty fast
1029 * set focus if in focus-follows-mouse mode and the event
1030 * is for the frame window and window doesn't have focus yet */
1031 if ((wPreferences
.focus_mode
==WKF_POINTER
1032 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1033 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1034 && !scr
->flags
.doing_alt_tab
) {
1036 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1037 wSetFocusTo(scr
, wwin
);
1039 if (scr
->autoRaiseTimer
)
1040 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1041 scr
->autoRaiseTimer
= NULL
;
1043 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1044 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1046 = WMAddTimerHandler(wPreferences
.raise_delay
,
1047 (WMCallback
*)raiseWindow
, scr
);
1050 /* Install colormap for window, if the colormap installation mode
1051 * is colormap_follows_mouse */
1052 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1053 if (wwin
->client_win
==event
->xcrossing
.window
)
1054 wColormapInstallForWindow(scr
, wwin
);
1056 wColormapInstallForWindow(scr
, NULL
);
1060 /* a little kluge to hide the clip balloon */
1061 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1063 XUnmapWindow(dpy
, scr
->clip_balloon
);
1064 scr
->flags
.clip_balloon_mapped
= 0;
1066 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1067 || scr
->clip_icon
!= desc
->parent
) {
1068 XUnmapWindow(dpy
, scr
->clip_balloon
);
1069 scr
->flags
.clip_balloon_mapped
= 0;
1074 if (event
->xcrossing
.window
== event
->xcrossing
.root
1075 && event
->xcrossing
.detail
== NotifyNormal
1076 && event
->xcrossing
.detail
!= NotifyInferior
1077 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1079 wSetFocusTo(scr
, scr
->focused_window
);
1083 wBalloonEnteredObject(scr
, desc
);
1089 handleLeaveNotify(XEvent
*event
)
1091 WObjDescriptor
*desc
= NULL
;
1093 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1094 (XPointer
*)&desc
)!=XCNOENT
) {
1095 if(desc
->handle_leavenotify
)
1096 (*desc
->handle_leavenotify
)(desc
, event
);
1098 if (event
->xcrossing
.window
== event
->xcrossing
.root
1099 && event
->xcrossing
.mode
== NotifyNormal
1100 && event
->xcrossing
.detail
!= NotifyInferior
1101 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1103 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1105 wSetFocusTo(scr
, NULL
);
1112 handleShapeNotify(XEvent
*event
)
1114 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1118 L("got shape notify");
1120 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1121 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1123 if (sev
->kind
== ShapeBounding
) {
1124 if (sev
->shaped
== shev
->shaped
) {
1127 XPutBackEvent(dpy
, &ev
);
1133 wwin
= wWindowFor(shev
->window
);
1134 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1137 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1139 wwin
->flags
.shaped
= 0;
1140 wWindowClearShape(wwin
);
1142 } else if (shev
->shaped
) {
1144 wwin
->flags
.shaped
= 1;
1145 wWindowSetShape(wwin
);
1150 #ifdef KEEP_XKB_LOCK_STATUS
1151 /* please help ]d if you know what to do */
1152 handleXkbIndicatorStateNotify(XEvent
*event
)
1156 XkbStateRec staterec
;
1159 for (i
=0; i
<wScreenCount
; i
++) {
1160 scr
= wScreenWithNumber(i
);
1161 wwin
= scr
->focused_window
;
1162 if (wwin
&& wwin
->flags
.focused
) {
1163 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1164 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1165 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1166 wwin
->frame
->languagemode
= staterec
.group
;
1168 #ifdef XKB_BUTTON_HINT
1169 if (wwin
->frame
->titlebar
) {
1170 wFrameWindowPaint(wwin
->frame
);
1176 #endif /*KEEP_XKB_LOCK_STATUS*/
1179 handleColormapNotify(XEvent
*event
)
1183 Bool reinstall
= False
;
1185 wwin
= wWindowFor(event
->xcolormap
.window
);
1189 scr
= wwin
->screen_ptr
;
1193 if (event
->xcolormap
.new) {
1194 XWindowAttributes attr
;
1196 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1198 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1199 scr
->current_colormap
= attr
.colormap
;
1202 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1203 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1205 /* some bastard app (like XV) removed our colormap */
1207 * can't enforce or things like xscreensaver wont work
1210 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1211 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1213 /* someone has put our colormap back */
1217 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1218 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1220 if (reinstall
&& scr
->current_colormap
!=None
) {
1221 if (!scr
->flags
.colormap_stuff_blocked
)
1222 XInstallColormap(dpy
, scr
->current_colormap
);
1229 handleFocusIn(XEvent
*event
)
1234 * For applications that like stealing the focus.
1236 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1237 saveTimestamp(event
);
1238 if (event
->xfocus
.mode
== NotifyUngrab
1239 || event
->xfocus
.mode
== NotifyGrab
1240 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1244 wwin
= wWindowFor(event
->xfocus
.window
);
1245 if (wwin
&& !wwin
->flags
.focused
) {
1246 if (wwin
->flags
.mapped
)
1247 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1249 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1251 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1253 wSetFocusTo(scr
, NULL
);
1259 windowUnderPointer(WScreen
*scr
)
1265 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1267 return wWindowFor(win
);
1272 #ifdef WEENDOZE_CYCLE
1275 nextToFocusAfter(WWindow
*wwin
)
1277 WWindow
*tmp
= wwin
->prev
;
1280 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1288 /* start over from the beginning of the list */
1292 while (tmp
&& tmp
!= wwin
) {
1293 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1305 nextToFocusBefore(WWindow
*wwin
)
1307 WWindow
*tmp
= wwin
->next
;
1310 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1317 /* start over from the beginning of the list */
1322 while (tmp
&& tmp
!= wwin
) {
1323 if (wWindowCanReceiveFocus(tmp
) && !WFLAGP(tmp
, skip_window_list
)) {
1336 doWindozeCycle(WWindow
*wwin
, XEvent
*event
, Bool next
)
1338 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1340 Bool openedSwitchMenu
= False
;
1341 WWindow
*newFocused
;
1342 WWindow
*oldFocused
;
1344 XModifierKeymap
*keymap
;
1349 keymap
= XGetModifierMapping(dpy
);
1352 XGrabKeyboard(dpy
, scr
->root_win
, False
, GrabModeAsync
, GrabModeAsync
,
1356 newFocused
= nextToFocusAfter(wwin
);
1358 newFocused
= nextToFocusBefore(wwin
);
1361 scr
->flags
.doing_alt_tab
= 1;
1363 wWindowFocus(newFocused
, scr
->focused_window
);
1364 oldFocused
= newFocused
;
1365 if (wPreferences
.circ_raise
)
1366 wRaiseFrame(newFocused
->frame
->core
);
1368 if (wPreferences
.popup_switchmenu
&&
1369 (!scr
->switch_menu
|| !scr
->switch_menu
->flags
.mapped
)) {
1371 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1372 openedSwitchMenu
= True
;
1378 WMMaskEvent(dpy
,KeyPressMask
|KeyReleaseMask
|ExposureMask
, &ev
);
1379 /* WMNextEvent(dpy, &ev);*/
1380 if (ev
.type
!= KeyRelease
&& ev
.type
!= KeyPress
) {
1384 /* ignore CapsLock */
1385 modifiers
= ev
.xkey
.state
& ValidModMask
;
1387 if (ev
.type
== KeyPress
1388 && wKeyBindings
[WKBD_FOCUSNEXT
].keycode
== ev
.xkey
.keycode
1389 && wKeyBindings
[WKBD_FOCUSNEXT
].modifier
== modifiers
) {
1391 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1392 newFocused
= nextToFocusAfter(newFocused
);
1393 wWindowFocus(newFocused
, oldFocused
);
1394 oldFocused
= newFocused
;
1395 if (wPreferences
.circ_raise
)
1396 wRaiseFrame(newFocused
->frame
->core
);
1397 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1399 } else if (ev
.type
== KeyPress
1400 && wKeyBindings
[WKBD_FOCUSPREV
].keycode
== ev
.xkey
.keycode
1401 && wKeyBindings
[WKBD_FOCUSPREV
].modifier
== modifiers
) {
1403 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1404 newFocused
= nextToFocusBefore(newFocused
);
1405 wWindowFocus(newFocused
, oldFocused
);
1406 oldFocused
= newFocused
;
1407 if (wPreferences
.circ_raise
)
1408 wRaiseFrame(newFocused
->frame
->core
);
1409 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1411 if (ev
.type
== KeyRelease
) {
1414 for (i
= 0; i
<= 8 * keymap
->max_keypermod
; i
++) {
1415 if (keymap
->modifiermap
[i
] == ev
.xkey
.keycode
&&
1416 wKeyBindings
[WKBD_FOCUSNEXT
].modifier
1417 & 1<<(i
/keymap
->max_keypermod
)) {
1426 XUngrabKeyboard(dpy
, CurrentTime
);
1427 wSetFocusTo(scr
, newFocused
);
1428 scr
->flags
.doing_alt_tab
= 0;
1429 if (openedSwitchMenu
)
1430 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1434 #endif /* WEENDOZE_CYCLE */
1440 handleKeyPress(XEvent
*event
)
1442 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1443 WWindow
*wwin
= scr
->focused_window
;
1446 int command
=-1, index
;
1447 #ifdef KEEP_XKB_LOCK_STATUS
1448 XkbStateRec staterec
;
1449 #endif /*KEEP_XKB_LOCK_STATUS*/
1451 /* ignore CapsLock */
1452 modifiers
= event
->xkey
.state
& ValidModMask
;
1454 for (i
=0; i
<WKBD_LAST
; i
++) {
1455 if (wKeyBindings
[i
].keycode
==0)
1458 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1459 && (/*wKeyBindings[i].modifier==0
1460 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1473 if (!wRootMenuPerformShortcut(event
)) {
1475 static int dontLoop
= 0;
1477 if (dontLoop
> 10) {
1478 wwarning("problem with key event processing code");
1482 /* if the focused window is an internal window, try redispatching
1483 * the event to the managed window, as it can be a WINGs window */
1484 if (wwin
&& wwin
->flags
.internal_window
1485 && wwin
->client_leader
!=None
) {
1486 /* client_leader contains the WINGs toplevel */
1487 event
->xany
.window
= wwin
->client_leader
;
1488 WMHandleEvent(event
);
1495 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1496 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1501 OpenRootMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1503 case WKBD_WINDOWLIST
:
1504 OpenSwitchMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1507 case WKBD_WINDOWMENU
:
1508 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1509 OpenWindowMenu(wwin
, wwin
->frame_x
,
1510 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1512 case WKBD_MINIATURIZE
:
1513 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1514 && !WFLAGP(wwin
, no_miniaturizable
)) {
1515 CloseWindowMenu(scr
);
1517 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1518 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1519 event
->xbutton
.time
);
1521 wIconifyWindow(wwin
);
1526 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1527 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1528 CloseWindowMenu(scr
);
1530 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1531 wHideApplication(wapp
);
1536 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1537 CloseWindowMenu(scr
);
1539 if (wwin
->flags
.maximized
) {
1540 wUnmaximizeWindow(wwin
);
1542 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1546 case WKBD_VMAXIMIZE
:
1547 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1548 CloseWindowMenu(scr
);
1550 if (wwin
->flags
.maximized
) {
1551 wUnmaximizeWindow(wwin
);
1553 wMaximizeWindow(wwin
, MAX_VERTICAL
);
1558 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1559 CloseWindowMenu(scr
);
1561 wRaiseFrame(wwin
->frame
->core
);
1565 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1566 CloseWindowMenu(scr
);
1568 wLowerFrame(wwin
->frame
->core
);
1571 case WKBD_RAISELOWER
:
1572 /* raise or lower the window under the pointer, not the
1575 wwin
= windowUnderPointer(scr
);
1577 wRaiseLowerFrame(wwin
->frame
->core
);
1580 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1581 if (wwin
->flags
.shaded
)
1582 wUnshadeWindow(wwin
);
1587 case WKBD_MOVERESIZE
:
1588 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1589 CloseWindowMenu(scr
);
1591 wKeyboardMoveResizeWindow(wwin
);
1595 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1596 CloseWindowMenu(scr
);
1597 if (wwin
->protocols
.DELETE_WINDOW
)
1598 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1603 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1604 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1607 case WKBD_FOCUSNEXT
:
1608 #ifdef WEENDOZE_CYCLE
1609 if (wPreferences
.windoze_cycling
) {
1610 doWindozeCycle(wwin
, event
, True
);
1612 #endif /* WEENDOZE_CYCLE */
1614 wwin
= NextFocusWindow(scr
);
1616 wSetFocusTo(scr
, wwin
);
1617 if (wPreferences
.circ_raise
)
1618 wRaiseFrame(wwin
->frame
->core
);
1623 case WKBD_FOCUSPREV
:
1624 #ifdef WEENDOZE_CYCLE
1625 if (wPreferences
.windoze_cycling
) {
1626 doWindozeCycle(wwin
, event
, False
);
1628 #endif /* WEENDOZE_CYCLE */
1630 wwin
= PrevFocusWindow(scr
);
1632 wSetFocusTo(scr
, wwin
);
1633 if (wPreferences
.circ_raise
)
1634 wRaiseFrame(wwin
->frame
->core
);
1639 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1640 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1641 i = (scr->current_workspace/10)*10 + wk - 1;\
1642 if (wPreferences.ws_advance || i<scr->workspace_count)\
1643 wWorkspaceChange(scr, i);\
1646 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1647 i = (scr->current_workspace/10)*10 + wk - 1;\
1648 if (wPreferences.ws_advance || i<scr->workspace_count)\
1649 wWorkspaceChange(scr, i);\
1663 case WKBD_NEXTWORKSPACE
:
1664 wWorkspaceRelativeChange(scr
, 1);
1666 case WKBD_PREVWORKSPACE
:
1667 wWorkspaceRelativeChange(scr
, -1);
1673 #ifdef EXTEND_WINDOWSHORTCUT
1682 #define INITBAG(bag) if (bag) WMEmptyBag(bag); else bag = WMCreateBag(4)
1684 index
= command
-WKBD_WINDOW1
;
1686 if (scr
->shortcutWindows
[index
]) {
1687 WMBag
*list
= scr
->shortcutWindows
[index
];
1690 int count
= WMGetBagItemCount(list
);
1693 wUnselectWindows(scr
);
1694 cw
= scr
->current_workspace
;
1696 for (i
= count
-1; i
>= 0; i
--) {
1697 WWindow
*wwin
= WMGetFromBag(list
, i
);
1700 wWindowChangeWorkspace(wwin
, cw
);
1702 wMakeWindowVisible(wwin
);
1705 wSelectWindow(wwin
, True
);
1708 /* rotate the order of windows, to create a cycling effect */
1709 twin
= WMGetFromBag(list
, 0);
1710 WMDeleteFromBag(list
, 0);
1711 WMPutInBag(list
, twin
);
1713 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1715 INITBAG(scr
->shortcutWindows
[index
]);
1716 WMPutInBag(scr
->shortcutWindows
[index
], wwin
);
1718 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1719 WMBag
*selwins
= scr
->selected_windows
;
1722 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1723 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1726 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1729 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1732 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1735 } else if (WMGetBagItemCount(scr
->selected_windows
)) {
1737 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1738 WMBag
*selwins
= scr
->selected_windows
;
1741 INITBAG(scr
->shortcutWindows
[index
]);
1743 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1744 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1746 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1753 case WKBD_NEXTWSLAYER
:
1754 case WKBD_PREVWSLAYER
:
1758 row
= scr
->current_workspace
/10;
1759 column
= scr
->current_workspace
%10;
1761 if (command
==WKBD_NEXTWSLAYER
) {
1762 if ((row
+1)*10 < scr
->workspace_count
)
1763 wWorkspaceChange(scr
, column
+(row
+1)*10);
1766 wWorkspaceChange(scr
, column
+(row
-1)*10);
1770 case WKBD_CLIPLOWER
:
1771 if (!wPreferences
.flags
.noclip
)
1772 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1774 case WKBD_CLIPRAISE
:
1775 if (!wPreferences
.flags
.noclip
)
1776 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1778 case WKBD_CLIPRAISELOWER
:
1779 if (!wPreferences
.flags
.noclip
)
1780 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1782 #ifdef KEEP_XKB_LOCK_STATUS
1784 if(wPreferences
.modelock
) {
1786 wwin
= scr
->focused_window
;
1788 if (wwin
&& wwin
->flags
.mapped
1789 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1790 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1791 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1793 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1794 wwin
->frame
->last_languagemode
= staterec
.group
;
1795 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1800 #endif /* KEEP_XKB_LOCK_STATUS */
1807 handleMotionNotify(XEvent
*event
)
1810 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1812 if (wPreferences
.scrollable_menus
) {
1813 if (scr
->flags
.jump_back_pending
||
1814 event
->xmotion
.x_root
<= 1 ||
1815 event
->xmotion
.x_root
>= (scr
->scr_width
- 2) ||
1816 event
->xmotion
.y_root
<= 1 ||
1817 event
->xmotion
.y_root
>= (scr
->scr_height
- 2)) {
1819 L("pointer at screen edge");
1821 menu
= wMenuUnderPointer(scr
);
1823 wMenuScroll(menu
, event
);
1827 if (event
->xmotion
.subwindow
== None
)
1830 if (scr
->scrolledFMaximize
!= None
) {
1833 twin
= wWindowFor(scr
->scrolledFMaximize
);
1834 if (twin
&& twin
->frame_y
==) {
1838 scr
->scrolledFMaximize
= NULL
;
1842 /* scroll full maximized window */
1843 if (event
->xmotion
.y_root
< 1
1844 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1846 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1848 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1849 && WFLAGP(wwin
, full_maximize
)
1850 && event
->xmotion
.x_root
>= wwin
->frame_x
1851 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1853 if (!WFLAGP(wwin
, no_titlebar
)
1854 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1856 wWindowMove(wwin
, wwin
->frame_x
, 0);
1857 wwin
->flags
.dragged_while_fmaximized
= 0;
1859 } else if (!WFLAGP(wwin
, no_resizebar
)
1860 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1861 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1863 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1865 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1867 wWindowMove(wwin
, wwin
->frame_x
, y
);
1868 wwin
->flags
.dragged_while_fmaximized
= 0;
1877 handleVisibilityNotify(XEvent
*event
)
1881 wwin
= wWindowFor(event
->xvisibility
.window
);
1884 wwin
->flags
.obscured
=
1885 (event
->xvisibility
.state
== VisibilityFullyObscured
);