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
);
597 handleButtonPress(XEvent
*event
)
599 WObjDescriptor
*desc
;
602 L("got button press");
604 scr
= wScreenForRootWindow(event
->xbutton
.root
);
612 if (event
->xbutton
.window
==scr
->root_win
) {
613 if (event
->xbutton
.button
==wPreferences
.menu_button
) {
614 OpenRootMenu(scr
, event
->xbutton
.x_root
,
615 event
->xbutton
.y_root
, False
);
617 if (scr
->root_menu
) {
618 if (scr
->root_menu
->brother
->flags
.mapped
)
619 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
621 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
623 } else if (event
->xbutton
.button
==wPreferences
.windowl_button
) {
624 OpenSwitchMenu(scr
, event
->xbutton
.x_root
,
625 event
->xbutton
.y_root
, False
);
626 if (scr
->switch_menu
) {
627 if (scr
->switch_menu
->brother
->flags
.mapped
)
628 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
630 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
632 } else if (event
->xbutton
.button
==wPreferences
.select_button
) {
633 wUnselectWindows(scr
);
634 wSelectWindows(scr
, event
);
636 #ifdef MOUSE_WS_SWITCH
637 else if (event
->xbutton
.button
==Button5
) {
639 wWorkspaceRelativeChange(scr
, -1);
641 } else if (event
->xbutton
.button
==Button4
) {
643 wWorkspaceRelativeChange(scr
, 1);
646 #endif /* MOUSE_WS_SWITCH */
648 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
654 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
655 (XPointer
*)&desc
)==XCNOENT
) {
656 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
657 (XPointer
*)&desc
)==XCNOENT
) {
662 if (desc
->handle_mousedown
!=NULL
) {
663 (*desc
->handle_mousedown
)(desc
, event
);
666 if (desc
->parent_type
== WCLASS_WINDOW
) {
669 if (event
->xbutton
.state
& MOD_MASK
) {
670 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
673 if (wPreferences
.focus_mode
== WKF_CLICK
) {
674 if (wPreferences
.ignore_focus_click
) {
675 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
677 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
680 } else if (desc
->parent_type
== WCLASS_APPICON
681 || desc
->parent_type
== WCLASS_MINIWINDOW
682 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
683 if (event
->xbutton
.state
& MOD_MASK
) {
685 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
690 /* save double-click information */
691 if (scr
->flags
.next_click_is_not_double
) {
692 scr
->flags
.next_click_is_not_double
= 0;
694 scr
->last_click_time
= event
->xbutton
.time
;
695 scr
->last_click_button
= event
->xbutton
.button
;
696 scr
->last_click_window
= event
->xbutton
.window
;
702 handleMapNotify(XEvent
*event
)
708 wwin
= wWindowFor(event
->xmap
.event
);
709 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
710 if (wwin
->flags
.miniaturized
) {
711 wDeiconifyWindow(wwin
);
715 wClientSetState(wwin
, NormalState
, None
);
723 handleUnmapNotify(XEvent
*event
)
727 Bool withdraw
= False
;
731 /* only process windows with StructureNotify selected
732 * (ignore SubstructureNotify) */
733 wwin
= wWindowFor(event
->xunmap
.window
);
737 /* whether the event is a Withdrawal request */
738 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
739 && event
->xunmap
.send_event
)
742 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
745 if (!wwin
->flags
.mapped
&& !withdraw
746 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
747 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
751 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
752 wwin
->flags
.mapped
= 0;
754 /* check if the window was destroyed */
755 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
758 Bool reparented
= False
;
760 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
763 /* withdraw window */
764 wwin
->flags
.mapped
= 0;
766 wClientSetState(wwin
, WithdrawnState
, None
);
768 /* if the window was reparented, do not reparent it back to the
770 wUnmanageWindow(wwin
, !reparented
, False
);
777 handleConfigureRequest(XEvent
*event
)
781 L("got configure request");
783 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
785 * Configure request for unmapped window
787 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
789 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
795 handlePropertyNotify(XEvent
*event
)
804 L("got property notify");
806 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
807 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
808 &ju
, &ju
, &ju
, &ju
)) {
811 wClientCheckProperty(wwin
, &event
->xproperty
);
813 wapp
= wApplicationOf(event
->xproperty
.window
);
815 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
818 scr
= wScreenForWindow(event
->xproperty
.window
);
819 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
821 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
828 handleClientMessage(XEvent
*event
)
831 WObjDescriptor
*desc
;
833 L("got client message");
835 /* handle transition from Normal to Iconic state */
836 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
837 && event
->xclient
.format
== 32
838 && event
->xclient
.data
.l
[0] == IconicState
) {
840 wwin
= wWindowFor(event
->xclient
.window
);
842 if (!wwin
->flags
.miniaturized
)
843 wIconifyWindow(wwin
);
844 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
845 && event
->xclient
.format
== 32) {
846 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
851 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
852 wColormapAllowClientInstallation(scr
, True
);
853 } else { /* stopping */
854 wColormapAllowClientInstallation(scr
, False
);
856 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
858 wDefaultsCheckDomains("bla");
860 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
863 wapp
= wApplicationOf(event
->xclient
.window
);
865 switch (event
->xclient
.data
.l
[0]) {
866 case WMFHideOtherApplications
:
867 wHideOtherApplications(wapp
->main_window_desc
);
871 case WMFHideApplication
:
872 wHideApplication(wapp
);
878 wwin
= wWindowFor(event
->xclient
.window
);
880 switch (event
->xclient
.data
.l
[0]) {
881 case WMFHideOtherApplications
:
882 wHideOtherApplications(wwin
);
885 case WMFHideApplication
:
886 wHideApplication(wApplicationOf(wwin
->main_window
));
892 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
894 #endif /* GNOME_STUFF */
896 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
898 #endif /* KWM_HINTS */
900 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
904 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
905 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
906 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
907 goto redirect_message
;
908 #endif /* OFFIX_DND */
914 * Non-standard thing, but needed by OffiX DND.
915 * For when the icon frame gets a ClientMessage
916 * that should have gone to the icon_window.
918 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
919 (XPointer
*)&desc
)!=XCNOENT
) {
920 struct WIcon
*icon
=NULL
;
922 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
923 icon
= (WIcon
*)desc
->parent
;
924 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
925 || desc
->parent_type
== WCLASS_APPICON
) {
926 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
928 if (icon
&& (wwin
=icon
->owner
)) {
929 if (wwin
->client_win
!=event
->xclient
.window
) {
930 event
->xclient
.window
= wwin
->client_win
;
931 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
941 raiseWindow(WScreen
*scr
)
945 scr
->autoRaiseTimer
= NULL
;
947 wwin
= wWindowFor(scr
->autoRaiseWindow
);
951 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
952 wRaiseFrame(wwin
->frame
->core
);
953 /* this is needed or a race condition will occur */
960 handleEnterNotify(XEvent
*event
)
963 WObjDescriptor
*desc
= NULL
;
965 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
967 L("got enter notify");
970 #ifdef VIRTUAL_DESKTOP
971 if (wPreferences
.vedge_thickness
) {
973 if (event
->xcrossing
.window
== scr
->virtual_edge_r
) {
974 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, scr
->scr_width
- wPreferences
.vedge_thickness
- 1, event
->xcrossing
.y_root
);
975 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
976 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
+30, y
);
977 } else if (event
->xcrossing
.window
== scr
->virtual_edge_l
) {
978 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, wPreferences
.vedge_thickness
+ 1, event
->xcrossing
.y_root
);
979 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
980 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
-30, y
);
981 } else if (event
->xcrossing
.window
== scr
->virtual_edge_u
) {
982 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, wPreferences
.vedge_thickness
+ 1);
983 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
984 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
-30);
985 } else if (event
->xcrossing
.window
== scr
->virtual_edge_d
) {
986 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, scr
->scr_height
- wPreferences
.vedge_thickness
- 1);
987 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
988 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
+30);
993 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
995 /* already left the window... */
997 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
998 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1003 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1004 (XPointer
*)&desc
)!=XCNOENT
) {
1005 if(desc
->handle_enternotify
)
1006 (*desc
->handle_enternotify
)(desc
, event
);
1009 /* enter to window */
1010 wwin
= wWindowFor(event
->xcrossing
.window
);
1012 if (wPreferences
.focus_mode
==WKF_POINTER
1013 && event
->xcrossing
.window
==event
->xcrossing
.root
) {
1014 wSetFocusTo(scr
, NULL
);
1016 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1017 wColormapInstallForWindow(scr
, NULL
);
1019 if (scr
->autoRaiseTimer
1020 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1021 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1022 scr
->autoRaiseTimer
= NULL
;
1025 /* set auto raise timer even if in focus-follows-mouse mode
1026 * and the event is for the frame window, even if the window
1027 * has focus already. useful if you move the pointer from a focused
1028 * window to the root window and back pretty fast
1030 * set focus if in focus-follows-mouse mode and the event
1031 * is for the frame window and window doesn't have focus yet */
1032 if ((wPreferences
.focus_mode
==WKF_POINTER
1033 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1034 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1035 && !scr
->flags
.doing_alt_tab
) {
1037 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1038 wSetFocusTo(scr
, wwin
);
1040 if (scr
->autoRaiseTimer
)
1041 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1042 scr
->autoRaiseTimer
= NULL
;
1044 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1045 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1047 = WMAddTimerHandler(wPreferences
.raise_delay
,
1048 (WMCallback
*)raiseWindow
, scr
);
1051 /* Install colormap for window, if the colormap installation mode
1052 * is colormap_follows_mouse */
1053 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1054 if (wwin
->client_win
==event
->xcrossing
.window
)
1055 wColormapInstallForWindow(scr
, wwin
);
1057 wColormapInstallForWindow(scr
, NULL
);
1061 /* a little kluge to hide the clip balloon */
1062 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1064 XUnmapWindow(dpy
, scr
->clip_balloon
);
1065 scr
->flags
.clip_balloon_mapped
= 0;
1067 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1068 || scr
->clip_icon
!= desc
->parent
) {
1069 XUnmapWindow(dpy
, scr
->clip_balloon
);
1070 scr
->flags
.clip_balloon_mapped
= 0;
1075 if (event
->xcrossing
.window
== event
->xcrossing
.root
1076 && event
->xcrossing
.detail
== NotifyNormal
1077 && event
->xcrossing
.detail
!= NotifyInferior
1078 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1080 wSetFocusTo(scr
, scr
->focused_window
);
1084 wBalloonEnteredObject(scr
, desc
);
1090 handleLeaveNotify(XEvent
*event
)
1092 WObjDescriptor
*desc
= NULL
;
1094 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1095 (XPointer
*)&desc
)!=XCNOENT
) {
1096 if(desc
->handle_leavenotify
)
1097 (*desc
->handle_leavenotify
)(desc
, event
);
1099 if (event
->xcrossing
.window
== event
->xcrossing
.root
1100 && event
->xcrossing
.mode
== NotifyNormal
1101 && event
->xcrossing
.detail
!= NotifyInferior
1102 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1104 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1106 wSetFocusTo(scr
, NULL
);
1113 handleShapeNotify(XEvent
*event
)
1115 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1119 L("got shape notify");
1121 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1122 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1124 if (sev
->kind
== ShapeBounding
) {
1125 if (sev
->shaped
== shev
->shaped
) {
1128 XPutBackEvent(dpy
, &ev
);
1134 wwin
= wWindowFor(shev
->window
);
1135 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1138 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1140 wwin
->flags
.shaped
= 0;
1141 wWindowClearShape(wwin
);
1143 } else if (shev
->shaped
) {
1145 wwin
->flags
.shaped
= 1;
1146 wWindowSetShape(wwin
);
1151 #ifdef KEEP_XKB_LOCK_STATUS
1152 /* please help ]d if you know what to do */
1153 handleXkbIndicatorStateNotify(XEvent
*event
)
1157 XkbStateRec staterec
;
1160 for (i
=0; i
<wScreenCount
; i
++) {
1161 scr
= wScreenWithNumber(i
);
1162 wwin
= scr
->focused_window
;
1163 if (wwin
&& wwin
->flags
.focused
) {
1164 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1165 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1166 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1167 wwin
->frame
->languagemode
= staterec
.group
;
1169 #ifdef XKB_BUTTON_HINT
1170 if (wwin
->frame
->titlebar
) {
1171 wFrameWindowPaint(wwin
->frame
);
1177 #endif /*KEEP_XKB_LOCK_STATUS*/
1180 handleColormapNotify(XEvent
*event
)
1184 Bool reinstall
= False
;
1186 wwin
= wWindowFor(event
->xcolormap
.window
);
1190 scr
= wwin
->screen_ptr
;
1194 if (event
->xcolormap
.new) {
1195 XWindowAttributes attr
;
1197 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1199 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1200 scr
->current_colormap
= attr
.colormap
;
1203 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1204 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1206 /* some bastard app (like XV) removed our colormap */
1208 * can't enforce or things like xscreensaver wont work
1211 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1212 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1214 /* someone has put our colormap back */
1218 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1219 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1221 if (reinstall
&& scr
->current_colormap
!=None
) {
1222 if (!scr
->flags
.colormap_stuff_blocked
)
1223 XInstallColormap(dpy
, scr
->current_colormap
);
1230 handleFocusIn(XEvent
*event
)
1235 * For applications that like stealing the focus.
1237 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1238 saveTimestamp(event
);
1239 if (event
->xfocus
.mode
== NotifyUngrab
1240 || event
->xfocus
.mode
== NotifyGrab
1241 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1245 wwin
= wWindowFor(event
->xfocus
.window
);
1246 if (wwin
&& !wwin
->flags
.focused
) {
1247 if (wwin
->flags
.mapped
)
1248 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1250 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1252 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1254 wSetFocusTo(scr
, NULL
);
1260 windowUnderPointer(WScreen
*scr
)
1266 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1268 return wWindowFor(win
);
1276 doWindozeCycle(WWindow
*wwin
, XEvent
*event
, Bool next
)
1278 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1280 Bool openedSwitchMenu
= False
;
1281 WWindow
*newFocused
;
1282 WWindow
*oldFocused
;
1284 XModifierKeymap
*keymap
;
1289 keymap
= XGetModifierMapping(dpy
);
1292 XGrabKeyboard(dpy
, scr
->root_win
, False
, GrabModeAsync
, GrabModeAsync
,
1296 newFocused
= NextToFocusAfter(wwin
);
1298 newFocused
= NextToFocusBefore(wwin
);
1301 scr
->flags
.doing_alt_tab
= 1;
1304 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1305 wWindowFocus(newFocused
, scr
->focused_window
);
1306 oldFocused
= newFocused
;
1307 if (wPreferences
.circ_raise
)
1308 wRaiseFrame(newFocused
->frame
->core
);
1310 if (wPreferences
.popup_switchmenu
&&
1311 (!scr
->switch_menu
|| !scr
->switch_menu
->flags
.mapped
)) {
1313 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1314 openedSwitchMenu
= True
;
1320 WMMaskEvent(dpy
,KeyPressMask
|KeyReleaseMask
|ExposureMask
, &ev
);
1322 if (ev
.type
!= KeyRelease
&& ev
.type
!= KeyPress
) {
1326 /* ignore CapsLock */
1327 modifiers
= ev
.xkey
.state
& ValidModMask
;
1329 if (ev
.type
== KeyPress
) {
1330 if (wKeyBindings
[WKBD_FOCUSNEXT
].keycode
== ev
.xkey
.keycode
1331 && wKeyBindings
[WKBD_FOCUSNEXT
].modifier
== modifiers
) {
1333 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1334 newFocused
= NextToFocusAfter(newFocused
);
1335 wWindowFocus(newFocused
, oldFocused
);
1336 oldFocused
= newFocused
;
1339 CommitStacking(scr
);
1340 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1342 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1344 } else if (wKeyBindings
[WKBD_FOCUSPREV
].keycode
== ev
.xkey
.keycode
1345 && wKeyBindings
[WKBD_FOCUSPREV
].modifier
== modifiers
) {
1347 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1348 newFocused
= NextToFocusBefore(newFocused
);
1349 wWindowFocus(newFocused
, oldFocused
);
1350 oldFocused
= newFocused
;
1353 CommitStacking(scr
);
1354 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1356 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1358 } else if (wKeyBindings
[WKBD_LOWER
].keycode
== ev
.xkey
.keycode
1359 && wKeyBindings
[WKBD_LOWER
].modifier
== modifiers
) {
1361 wLowerFrame(newFocused
->frame
->core
);
1363 } else if (wKeyBindings
[WKBD_RAISE
].keycode
== ev
.xkey
.keycode
1364 && wKeyBindings
[WKBD_RAISE
].modifier
== modifiers
) {
1366 wRaiseFrame(newFocused
->frame
->core
);
1368 } else if (ev
.type
== KeyRelease
) {
1371 for (i
= 0; i
<= 8 * keymap
->max_keypermod
; i
++) {
1372 if (keymap
->modifiermap
[i
] == ev
.xkey
.keycode
&&
1373 wKeyBindings
[WKBD_FOCUSNEXT
].modifier
1374 & 1<<(i
/keymap
->max_keypermod
)) {
1384 CommitStacking(scr
);
1386 XUngrabKeyboard(dpy
, CurrentTime
);
1387 wSetFocusTo(scr
, newFocused
);
1389 if (wPreferences
.circ_raise
)
1390 wRaiseFrame(newFocused
->frame
->core
);
1392 scr
->flags
.doing_alt_tab
= 0;
1393 if (openedSwitchMenu
)
1394 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1401 handleKeyPress(XEvent
*event
)
1403 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1404 WWindow
*wwin
= scr
->focused_window
;
1407 int command
=-1, index
;
1408 #ifdef KEEP_XKB_LOCK_STATUS
1409 XkbStateRec staterec
;
1410 #endif /*KEEP_XKB_LOCK_STATUS*/
1412 /* ignore CapsLock */
1413 modifiers
= event
->xkey
.state
& ValidModMask
;
1415 for (i
=0; i
<WKBD_LAST
; i
++) {
1416 if (wKeyBindings
[i
].keycode
==0)
1419 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1420 && (/*wKeyBindings[i].modifier==0
1421 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1435 if (!wRootMenuPerformShortcut(event
)) {
1437 static int dontLoop
= 0;
1439 if (dontLoop
> 10) {
1440 wwarning("problem with key event processing code");
1444 /* if the focused window is an internal window, try redispatching
1445 * the event to the managed window, as it can be a WINGs window */
1446 if (wwin
&& wwin
->flags
.internal_window
1447 && wwin
->client_leader
!=None
) {
1448 /* client_leader contains the WINGs toplevel */
1449 event
->xany
.window
= wwin
->client_leader
;
1450 WMHandleEvent(event
);
1457 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1458 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1463 OpenRootMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1465 case WKBD_WINDOWLIST
:
1466 OpenSwitchMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1469 case WKBD_WINDOWMENU
:
1470 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1471 OpenWindowMenu(wwin
, wwin
->frame_x
,
1472 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1474 case WKBD_MINIATURIZE
:
1475 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1476 && !WFLAGP(wwin
, no_miniaturizable
)) {
1477 CloseWindowMenu(scr
);
1479 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1480 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1481 event
->xbutton
.time
);
1483 wIconifyWindow(wwin
);
1488 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1489 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1490 CloseWindowMenu(scr
);
1492 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1493 wHideApplication(wapp
);
1498 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1499 CloseWindowMenu(scr
);
1501 if (wwin
->flags
.maximized
) {
1502 wUnmaximizeWindow(wwin
);
1504 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1508 case WKBD_VMAXIMIZE
:
1509 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1510 CloseWindowMenu(scr
);
1512 if (wwin
->flags
.maximized
) {
1513 wUnmaximizeWindow(wwin
);
1515 wMaximizeWindow(wwin
, MAX_VERTICAL
);
1520 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1521 CloseWindowMenu(scr
);
1523 wRaiseFrame(wwin
->frame
->core
);
1527 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1528 CloseWindowMenu(scr
);
1530 wLowerFrame(wwin
->frame
->core
);
1533 case WKBD_RAISELOWER
:
1534 /* raise or lower the window under the pointer, not the
1537 wwin
= windowUnderPointer(scr
);
1539 wRaiseLowerFrame(wwin
->frame
->core
);
1542 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1543 if (wwin
->flags
.shaded
)
1544 wUnshadeWindow(wwin
);
1549 case WKBD_MOVERESIZE
:
1550 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1551 CloseWindowMenu(scr
);
1553 wKeyboardMoveResizeWindow(wwin
);
1557 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1558 CloseWindowMenu(scr
);
1559 if (wwin
->protocols
.DELETE_WINDOW
)
1560 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1565 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1566 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1569 case WKBD_FOCUSNEXT
:
1570 doWindozeCycle(wwin
, event
, True
);
1573 case WKBD_FOCUSPREV
:
1574 doWindozeCycle(wwin
, event
, False
);
1577 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1578 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1579 i = (scr->current_workspace/10)*10 + wk - 1;\
1580 if (wPreferences.ws_advance || i<scr->workspace_count)\
1581 wWorkspaceChange(scr, i);\
1584 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1585 i = (scr->current_workspace/10)*10 + wk - 1;\
1586 if (wPreferences.ws_advance || i<scr->workspace_count)\
1587 wWorkspaceChange(scr, i);\
1601 case WKBD_NEXTWORKSPACE
:
1602 wWorkspaceRelativeChange(scr
, 1);
1604 case WKBD_PREVWORKSPACE
:
1605 wWorkspaceRelativeChange(scr
, -1);
1611 #ifdef EXTEND_WINDOWSHORTCUT
1620 #define INITBAG(bag) if (bag) WMEmptyBag(bag); else bag = WMCreateBag(4)
1622 index
= command
-WKBD_WINDOW1
;
1624 if (scr
->shortcutWindows
[index
]) {
1625 WMBag
*list
= scr
->shortcutWindows
[index
];
1628 int count
= WMGetBagItemCount(list
);
1631 wUnselectWindows(scr
);
1632 cw
= scr
->current_workspace
;
1634 for (i
= count
-1; i
>= 0; i
--) {
1635 WWindow
*wwin
= WMGetFromBag(list
, i
);
1638 wWindowChangeWorkspace(wwin
, cw
);
1640 wMakeWindowVisible(wwin
);
1643 wSelectWindow(wwin
, True
);
1646 /* rotate the order of windows, to create a cycling effect */
1647 twin
= WMGetFromBag(list
, 0);
1648 WMDeleteFromBag(list
, 0);
1649 WMPutInBag(list
, twin
);
1651 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1653 INITBAG(scr
->shortcutWindows
[index
]);
1654 WMPutInBag(scr
->shortcutWindows
[index
], wwin
);
1656 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1657 WMBag
*selwins
= scr
->selected_windows
;
1660 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1661 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1664 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1667 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1670 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1673 } else if (scr
->selected_windows
1674 && WMGetBagItemCount(scr
->selected_windows
)) {
1676 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1677 WMBag
*selwins
= scr
->selected_windows
;
1680 INITBAG(scr
->shortcutWindows
[index
]);
1682 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1683 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1685 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1692 case WKBD_NEXTWSLAYER
:
1693 case WKBD_PREVWSLAYER
:
1697 row
= scr
->current_workspace
/10;
1698 column
= scr
->current_workspace
%10;
1700 if (command
==WKBD_NEXTWSLAYER
) {
1701 if ((row
+1)*10 < scr
->workspace_count
)
1702 wWorkspaceChange(scr
, column
+(row
+1)*10);
1705 wWorkspaceChange(scr
, column
+(row
-1)*10);
1709 case WKBD_CLIPLOWER
:
1710 if (!wPreferences
.flags
.noclip
)
1711 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1713 case WKBD_CLIPRAISE
:
1714 if (!wPreferences
.flags
.noclip
)
1715 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1717 case WKBD_CLIPRAISELOWER
:
1718 if (!wPreferences
.flags
.noclip
)
1719 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1721 #ifdef KEEP_XKB_LOCK_STATUS
1723 if(wPreferences
.modelock
) {
1725 wwin
= scr
->focused_window
;
1727 if (wwin
&& wwin
->flags
.mapped
1728 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1729 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1730 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1732 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1733 wwin
->frame
->last_languagemode
= staterec
.group
;
1734 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1739 #endif /* KEEP_XKB_LOCK_STATUS */
1746 handleMotionNotify(XEvent
*event
)
1749 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1751 if (wPreferences
.scrollable_menus
) {
1752 if (scr
->flags
.jump_back_pending
||
1753 event
->xmotion
.x_root
<= 1 ||
1754 event
->xmotion
.x_root
>= (scr
->scr_width
- 2) ||
1755 event
->xmotion
.y_root
<= 1 ||
1756 event
->xmotion
.y_root
>= (scr
->scr_height
- 2)) {
1758 L("pointer at screen edge");
1760 menu
= wMenuUnderPointer(scr
);
1762 wMenuScroll(menu
, event
);
1766 if (event
->xmotion
.subwindow
== None
)
1769 if (scr
->scrolledFMaximize
!= None
) {
1772 twin
= wWindowFor(scr
->scrolledFMaximize
);
1773 if (twin
&& twin
->frame_y
==) {
1777 scr
->scrolledFMaximize
= NULL
;
1781 /* scroll full maximized window */
1782 if (event
->xmotion
.y_root
< 1
1783 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1785 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1787 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1788 && WFLAGP(wwin
, full_maximize
)
1789 && event
->xmotion
.x_root
>= wwin
->frame_x
1790 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1792 if (!WFLAGP(wwin
, no_titlebar
)
1793 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1795 wWindowMove(wwin
, wwin
->frame_x
, 0);
1796 wwin
->flags
.dragged_while_fmaximized
= 0;
1798 } else if (!WFLAGP(wwin
, no_resizebar
)
1799 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1800 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1802 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1804 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1806 wWindowMove(wwin
, wwin
->frame_x
, y
);
1807 wwin
->flags
.dragged_while_fmaximized
= 0;
1816 handleVisibilityNotify(XEvent
*event
)
1820 wwin
= wWindowFor(event
->xvisibility
.window
);
1823 wwin
->flags
.obscured
=
1824 (event
->xvisibility
.state
== VisibilityFullyObscured
);