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_ATTR
;
89 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
90 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
91 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
92 extern Atom _XA_WINDOWMAKER_COMMAND
;
95 extern Atom _XA_DND_PROTOCOL
;
100 extern Bool wShapeSupported
;
101 extern int wShapeEventBase
;
104 #ifdef KEEP_XKB_LOCK_STATUS
105 extern int wXkbEventBase
;
109 extern char WDelayedActionSet
;
112 /************ Local stuff ***********/
115 static void saveTimestamp(XEvent
*event
);
116 static void handleColormapNotify();
117 static void handleMapNotify(), handleUnmapNotify();
118 static void handleButtonPress(), handleExpose();
119 static void handleDestroyNotify();
120 static void handleConfigureRequest();
121 static void handleMapRequest();
122 static void handlePropertyNotify();
123 static void handleEnterNotify();
124 static void handleLeaveNotify();
125 static void handleExtensions();
126 static void handleClientMessage();
127 static void handleKeyPress();
128 static void handleFocusIn();
129 static void handleMotionNotify();
130 static void handleVisibilityNotify();
134 static void handleShapeNotify();
137 /* called from the signal handler */
138 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
140 /* real dead process handler */
141 static void handleDeadProcess(void *foo
);
144 typedef struct DeadProcesses
{
146 unsigned char exit_status
;
149 /* stack of dead processes */
150 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
151 static int deadProcessPtr
=0;
154 typedef struct DeathHandler
{
155 WDeathHandler
*callback
;
160 static WMBag
*deathHandlers
=NULL
;
165 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
167 DeathHandler
*handler
;
169 handler
= malloc(sizeof(DeathHandler
));
174 handler
->callback
= callback
;
175 handler
->client_data
= cdata
;
178 deathHandlers
= WMCreateBag(8);
180 WMPutInBag(deathHandlers
, handler
);
188 wDeleteDeathHandler(WMagicNumber id
)
190 DeathHandler
*handler
=(DeathHandler
*)id
;
192 if (!handler
|| !deathHandlers
)
195 WMRemoveFromBag(deathHandlers
, handler
);
202 DispatchEvent(XEvent
*event
)
205 handleDeadProcess(NULL
);
207 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
208 WCHANGE_STATE(WSTATE_EXITING
);
209 /* received SIGTERM */
211 * WMHandleEvent() can't be called from anything
212 * executed inside here, or we can get in a infinite
215 Shutdown(WSExitMode
);
217 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
218 WCHANGE_STATE(WSTATE_RESTARTING
);
220 Shutdown(WSRestartPreparationMode
);
221 /* received SIGHUP */
225 /* for the case that all that is wanted to be dispatched is
230 saveTimestamp(event
);
231 switch (event
->type
) {
233 handleMapRequest(event
);
237 handleKeyPress(event
);
241 handleMotionNotify(event
);
244 case ConfigureRequest
:
245 handleConfigureRequest(event
);
249 handleDestroyNotify(event
);
253 handleMapNotify(event
);
257 handleUnmapNotify(event
);
261 handleButtonPress(event
);
269 handlePropertyNotify(event
);
273 handleEnterNotify(event
);
277 handleLeaveNotify(event
);
281 handleClientMessage(event
);
285 handleColormapNotify(event
);
289 if (event
->xmapping
.request
== MappingKeyboard
290 || event
->xmapping
.request
== MappingModifier
)
291 XRefreshKeyboardMapping(&event
->xmapping
);
295 handleFocusIn(event
);
298 case VisibilityNotify
:
299 handleVisibilityNotify(event
);
302 handleExtensions(event
);
309 *----------------------------------------------------------------------
311 * Processes X and internal events indefinitely.
317 * The LastTimestamp global variable is updated.
318 *----------------------------------------------------------------------
326 WMNextEvent(dpy
, &event
);
327 WMHandleEvent(&event
);
334 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
336 if ((scr
->last_click_time
>0) &&
337 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
338 && (event
->xbutton
.button
== scr
->last_click_button
)
339 && (event
->xbutton
.window
== scr
->last_click_window
)) {
341 scr
->flags
.next_click_is_not_double
= 1;
342 scr
->last_click_time
= 0;
343 scr
->last_click_window
= event
->xbutton
.window
;
352 NotifyDeadProcess(pid_t pid
, unsigned char status
)
354 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
355 wwarning("stack overflow: too many dead processes");
358 /* stack the process to be handled later,
359 * as this is called from the signal handler */
360 deadProcesses
[deadProcessPtr
].pid
= pid
;
361 deadProcesses
[deadProcessPtr
].exit_status
= status
;
367 handleDeadProcess(void *foo
)
372 for (i
=0; i
<deadProcessPtr
; i
++) {
373 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
376 if (!deathHandlers
) {
381 /* get the pids on the queue and call handlers */
382 while (deadProcessPtr
>0) {
385 for (i
= WMGetBagItemCount(deathHandlers
)-1; i
>= 0; i
--) {
386 tmp
= WMGetFromBag(deathHandlers
, i
);
390 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
391 (*tmp
->callback
)(tmp
->pid
,
392 deadProcesses
[deadProcessPtr
].exit_status
,
394 wDeleteDeathHandler(tmp
);
402 saveTimestamp(XEvent
*event
)
404 LastTimestamp
= CurrentTime
;
406 switch (event
->type
) {
409 LastTimestamp
= event
->xbutton
.time
;
413 LastTimestamp
= event
->xkey
.time
;
416 LastTimestamp
= event
->xmotion
.time
;
419 LastTimestamp
= event
->xproperty
.time
;
423 LastTimestamp
= event
->xcrossing
.time
;
426 LastTimestamp
= event
->xselectionclear
.time
;
428 case SelectionRequest
:
429 LastTimestamp
= event
->xselectionrequest
.time
;
431 case SelectionNotify
:
432 LastTimestamp
= event
->xselection
.time
;
434 wXDNDProcessSelection(event
);
442 handleExtensions(XEvent
*event
)
444 #ifdef KEEP_XKB_LOCK_STATUS
446 xkbevent
= (XkbEvent
*)event
;
447 #endif /*KEEP_XKB_LOCK_STATUS*/
449 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
450 handleShapeNotify(event
);
453 #ifdef KEEP_XKB_LOCK_STATUS
454 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
455 handleXkbIndicatorStateNotify(event
);
457 #endif /*KEEP_XKB_LOCK_STATUS*/
462 handleMapRequest(XEvent
*ev
)
466 Window window
= ev
->xmaprequest
.window
;
469 L("got map request for %x\n", (unsigned)window
);
471 if ((wwin
= wWindowFor(window
))) {
472 if (wwin
->flags
.shaded
) {
473 wUnshadeWindow(wwin
);
475 /* deiconify window */
476 if (wwin
->flags
.miniaturized
) {
477 wDeiconifyWindow(wwin
);
478 } else if (wwin
->flags
.hidden
) {
479 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
480 /* go to the last workspace that the user worked on the app */
481 #ifndef REDUCE_APPICONS
482 /* This severely breaks REDUCE_APPICONS. last_workspace is a neat
483 * concept but it needs to be reworked to handle REDUCE_APPICONS -cls
486 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
489 wUnhideApplication(wapp
, False
, False
);
494 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
496 wwin
= wManageWindow(scr
, window
);
499 * This is to let the Dock know that the application it launched
500 * has already been mapped (eg: it has finished launching).
501 * It is not necessary for normally docked apps, but is needed for
502 * apps that were forcedly docked (like with dockit).
504 if (scr
->last_dock
) {
505 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
506 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
508 wDockTrackWindowLaunch(scr
->last_dock
, window
);
512 wClientSetState(wwin
, NormalState
, None
);
513 if (wwin
->flags
.maximized
) {
514 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
516 if (wwin
->flags
.shaded
) {
517 wwin
->flags
.shaded
= 0;
518 wwin
->flags
.skip_next_animation
= 1;
521 if (wwin
->flags
.miniaturized
) {
522 wwin
->flags
.miniaturized
= 0;
523 wwin
->flags
.skip_next_animation
= 1;
524 wIconifyWindow(wwin
);
526 if (wwin
->flags
.hidden
) {
527 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
529 wwin
->flags
.hidden
= 0;
530 wwin
->flags
.skip_next_animation
= 1;
532 wHideApplication(wapp
);
540 handleDestroyNotify(XEvent
*event
)
544 Window window
= event
->xdestroywindow
.window
;
547 L("got destroy notify");
549 wwin
= wWindowFor(window
);
551 wUnmanageWindow(wwin
, False
, True
);
554 app
= wApplicationOf(window
);
556 if (window
== app
->main_window
) {
558 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
560 if (wwin
->main_window
== window
) {
561 wwin
->main_window
= None
;
566 wApplicationDestroy(app
);
570 wKWMCheckDestroy(&event
->xdestroywindow
);
577 handleExpose(XEvent
*event
)
579 WObjDescriptor
*desc
;
585 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
587 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
588 (XPointer
*)&desc
)==XCNOENT
) {
592 if (desc
->handle_expose
) {
593 (*desc
->handle_expose
)(desc
, event
);
599 handleButtonPress(XEvent
*event
)
601 WObjDescriptor
*desc
;
604 L("got button press");
606 scr
= wScreenForRootWindow(event
->xbutton
.root
);
614 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
));
893 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
894 wwin
= wWindowFor(event
->xclient
.window
);
896 switch (event
->xclient
.data
.l
[0]) {
897 case GSWindowLevelAttr
:
899 int level
= (int)event
->xclient
.data
.l
[0];
900 if (WINDOW_LEVEL(wwin
) != level
) {
901 ChangeStackingLevel(wwin
->frame
->core
, level
);
906 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
907 wwin
= wWindowFor(event
->xclient
.window
);
909 switch (event
->xclient
.data
.l
[0]) {
910 case WMTitleBarNormal
:
911 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
914 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
917 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
921 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
923 #endif /* GNOME_STUFF */
925 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
927 #endif /* KWM_HINTS */
929 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
933 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
934 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
935 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
936 goto redirect_message
;
937 #endif /* OFFIX_DND */
943 * Non-standard thing, but needed by OffiX DND.
944 * For when the icon frame gets a ClientMessage
945 * that should have gone to the icon_window.
947 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
948 (XPointer
*)&desc
)!=XCNOENT
) {
949 struct WIcon
*icon
=NULL
;
951 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
952 icon
= (WIcon
*)desc
->parent
;
953 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
954 || desc
->parent_type
== WCLASS_APPICON
) {
955 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
957 if (icon
&& (wwin
=icon
->owner
)) {
958 if (wwin
->client_win
!=event
->xclient
.window
) {
959 event
->xclient
.window
= wwin
->client_win
;
960 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
970 raiseWindow(WScreen
*scr
)
974 scr
->autoRaiseTimer
= NULL
;
976 wwin
= wWindowFor(scr
->autoRaiseWindow
);
980 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
981 wRaiseFrame(wwin
->frame
->core
);
982 /* this is needed or a race condition will occur */
989 handleEnterNotify(XEvent
*event
)
992 WObjDescriptor
*desc
= NULL
;
994 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
996 L("got enter notify");
999 #ifdef VIRTUAL_DESKTOP
1000 if (wPreferences
.vedge_thickness
) {
1002 if (event
->xcrossing
.window
== scr
->virtual_edge_r
) {
1003 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, scr
->scr_width
- wPreferences
.vedge_thickness
- 1, event
->xcrossing
.y_root
);
1004 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1005 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
+30, y
);
1006 } else if (event
->xcrossing
.window
== scr
->virtual_edge_l
) {
1007 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, wPreferences
.vedge_thickness
+ 1, event
->xcrossing
.y_root
);
1008 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1009 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
-30, y
);
1010 } else if (event
->xcrossing
.window
== scr
->virtual_edge_u
) {
1011 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, wPreferences
.vedge_thickness
+ 1);
1012 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1013 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
-30);
1014 } else if (event
->xcrossing
.window
== scr
->virtual_edge_d
) {
1015 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, scr
->scr_height
- wPreferences
.vedge_thickness
- 1);
1016 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1017 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
+30);
1022 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1024 /* already left the window... */
1026 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1027 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1032 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1033 (XPointer
*)&desc
)!=XCNOENT
) {
1034 if(desc
->handle_enternotify
)
1035 (*desc
->handle_enternotify
)(desc
, event
);
1038 /* enter to window */
1039 wwin
= wWindowFor(event
->xcrossing
.window
);
1041 if (wPreferences
.focus_mode
==WKF_POINTER
1042 && event
->xcrossing
.window
==event
->xcrossing
.root
) {
1043 wSetFocusTo(scr
, NULL
);
1045 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1046 wColormapInstallForWindow(scr
, NULL
);
1048 if (scr
->autoRaiseTimer
1049 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1050 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1051 scr
->autoRaiseTimer
= NULL
;
1054 /* set auto raise timer even if in focus-follows-mouse mode
1055 * and the event is for the frame window, even if the window
1056 * has focus already. useful if you move the pointer from a focused
1057 * window to the root window and back pretty fast
1059 * set focus if in focus-follows-mouse mode and the event
1060 * is for the frame window and window doesn't have focus yet */
1061 if ((wPreferences
.focus_mode
==WKF_POINTER
1062 || wPreferences
.focus_mode
==WKF_SLOPPY
)
1063 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1064 && !scr
->flags
.doing_alt_tab
) {
1066 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1067 wSetFocusTo(scr
, wwin
);
1069 if (scr
->autoRaiseTimer
)
1070 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1071 scr
->autoRaiseTimer
= NULL
;
1073 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1074 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1076 = WMAddTimerHandler(wPreferences
.raise_delay
,
1077 (WMCallback
*)raiseWindow
, scr
);
1080 /* Install colormap for window, if the colormap installation mode
1081 * is colormap_follows_mouse */
1082 if (wPreferences
.colormap_mode
==WKF_POINTER
) {
1083 if (wwin
->client_win
==event
->xcrossing
.window
)
1084 wColormapInstallForWindow(scr
, wwin
);
1086 wColormapInstallForWindow(scr
, NULL
);
1090 /* a little kluge to hide the clip balloon */
1091 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1093 XUnmapWindow(dpy
, scr
->clip_balloon
);
1094 scr
->flags
.clip_balloon_mapped
= 0;
1096 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1097 || scr
->clip_icon
!= desc
->parent
) {
1098 XUnmapWindow(dpy
, scr
->clip_balloon
);
1099 scr
->flags
.clip_balloon_mapped
= 0;
1104 if (event
->xcrossing
.window
== event
->xcrossing
.root
1105 && event
->xcrossing
.detail
== NotifyNormal
1106 && event
->xcrossing
.detail
!= NotifyInferior
1107 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1109 wSetFocusTo(scr
, scr
->focused_window
);
1113 wBalloonEnteredObject(scr
, desc
);
1119 handleLeaveNotify(XEvent
*event
)
1121 WObjDescriptor
*desc
= NULL
;
1123 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1124 (XPointer
*)&desc
)!=XCNOENT
) {
1125 if(desc
->handle_leavenotify
)
1126 (*desc
->handle_leavenotify
)(desc
, event
);
1128 if (event
->xcrossing
.window
== event
->xcrossing
.root
1129 && event
->xcrossing
.mode
== NotifyNormal
1130 && event
->xcrossing
.detail
!= NotifyInferior
1131 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1133 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1135 wSetFocusTo(scr
, NULL
);
1142 handleShapeNotify(XEvent
*event
)
1144 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1148 L("got shape notify");
1150 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1151 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1153 if (sev
->kind
== ShapeBounding
) {
1154 if (sev
->shaped
== shev
->shaped
) {
1157 XPutBackEvent(dpy
, &ev
);
1163 wwin
= wWindowFor(shev
->window
);
1164 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1167 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1169 wwin
->flags
.shaped
= 0;
1170 wWindowClearShape(wwin
);
1172 } else if (shev
->shaped
) {
1174 wwin
->flags
.shaped
= 1;
1175 wWindowSetShape(wwin
);
1180 #ifdef KEEP_XKB_LOCK_STATUS
1181 /* please help ]d if you know what to do */
1182 handleXkbIndicatorStateNotify(XEvent
*event
)
1186 XkbStateRec staterec
;
1189 for (i
=0; i
<wScreenCount
; i
++) {
1190 scr
= wScreenWithNumber(i
);
1191 wwin
= scr
->focused_window
;
1192 if (wwin
&& wwin
->flags
.focused
) {
1193 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1194 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1195 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1196 wwin
->frame
->languagemode
= staterec
.group
;
1198 #ifdef XKB_BUTTON_HINT
1199 if (wwin
->frame
->titlebar
) {
1200 wFrameWindowPaint(wwin
->frame
);
1206 #endif /*KEEP_XKB_LOCK_STATUS*/
1209 handleColormapNotify(XEvent
*event
)
1213 Bool reinstall
= False
;
1215 wwin
= wWindowFor(event
->xcolormap
.window
);
1219 scr
= wwin
->screen_ptr
;
1223 if (event
->xcolormap
.new) {
1224 XWindowAttributes attr
;
1226 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1228 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1229 scr
->current_colormap
= attr
.colormap
;
1232 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1233 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1235 /* some bastard app (like XV) removed our colormap */
1237 * can't enforce or things like xscreensaver wont work
1240 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1241 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1243 /* someone has put our colormap back */
1247 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1248 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1250 if (reinstall
&& scr
->current_colormap
!=None
) {
1251 if (!scr
->flags
.colormap_stuff_blocked
)
1252 XInstallColormap(dpy
, scr
->current_colormap
);
1259 handleFocusIn(XEvent
*event
)
1264 * For applications that like stealing the focus.
1266 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1267 saveTimestamp(event
);
1268 if (event
->xfocus
.mode
== NotifyUngrab
1269 || event
->xfocus
.mode
== NotifyGrab
1270 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1274 wwin
= wWindowFor(event
->xfocus
.window
);
1275 if (wwin
&& !wwin
->flags
.focused
) {
1276 if (wwin
->flags
.mapped
)
1277 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1279 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1281 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1283 wSetFocusTo(scr
, NULL
);
1289 windowUnderPointer(WScreen
*scr
)
1295 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1297 return wWindowFor(win
);
1305 doWindozeCycle(WWindow
*wwin
, XEvent
*event
, Bool next
)
1307 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1309 Bool openedSwitchMenu
= False
;
1310 WWindow
*newFocused
;
1311 WWindow
*oldFocused
;
1313 XModifierKeymap
*keymap
;
1318 keymap
= XGetModifierMapping(dpy
);
1321 XGrabKeyboard(dpy
, scr
->root_win
, False
, GrabModeAsync
, GrabModeAsync
,
1325 newFocused
= NextToFocusAfter(wwin
);
1327 newFocused
= NextToFocusBefore(wwin
);
1330 scr
->flags
.doing_alt_tab
= 1;
1333 if (wPreferences
.circ_raise
)
1334 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1335 wWindowFocus(newFocused
, scr
->focused_window
);
1336 oldFocused
= newFocused
;
1339 if (wPreferences
.popup_switchmenu
&&
1340 (!scr
->switch_menu
|| !scr
->switch_menu
->flags
.mapped
)) {
1342 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1343 openedSwitchMenu
= True
;
1349 WMMaskEvent(dpy
,KeyPressMask
|KeyReleaseMask
|ExposureMask
, &ev
);
1351 if (ev
.type
!= KeyRelease
&& ev
.type
!= KeyPress
) {
1355 /* ignore CapsLock */
1356 modifiers
= ev
.xkey
.state
& ValidModMask
;
1358 if (ev
.type
== KeyPress
) {
1359 if (wKeyBindings
[WKBD_FOCUSNEXT
].keycode
== ev
.xkey
.keycode
1360 && wKeyBindings
[WKBD_FOCUSNEXT
].modifier
== modifiers
) {
1362 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1363 newFocused
= NextToFocusAfter(newFocused
);
1364 wWindowFocus(newFocused
, oldFocused
);
1365 oldFocused
= newFocused
;
1367 if (wPreferences
.circ_raise
) {
1369 CommitStacking(scr
);
1370 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1373 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1375 } else if (wKeyBindings
[WKBD_FOCUSPREV
].keycode
== ev
.xkey
.keycode
1376 && wKeyBindings
[WKBD_FOCUSPREV
].modifier
== modifiers
) {
1378 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1379 newFocused
= NextToFocusBefore(newFocused
);
1380 wWindowFocus(newFocused
, oldFocused
);
1381 oldFocused
= newFocused
;
1383 if (wPreferences
.circ_raise
) {
1385 CommitStacking(scr
);
1386 XRaiseWindow(dpy
, newFocused
->frame
->core
->window
);
1388 UpdateSwitchMenu(scr
, newFocused
, ACTION_CHANGE_STATE
);
1390 } else if (wKeyBindings
[WKBD_LOWER
].keycode
== ev
.xkey
.keycode
1391 && wKeyBindings
[WKBD_LOWER
].modifier
== modifiers
) {
1393 wLowerFrame(newFocused
->frame
->core
);
1395 } else if (wKeyBindings
[WKBD_RAISE
].keycode
== ev
.xkey
.keycode
1396 && wKeyBindings
[WKBD_RAISE
].modifier
== modifiers
) {
1398 wRaiseFrame(newFocused
->frame
->core
);
1400 } else if (ev
.type
== KeyRelease
) {
1403 for (i
= 0; i
<= 8 * keymap
->max_keypermod
; i
++) {
1404 if (keymap
->modifiermap
[i
] == ev
.xkey
.keycode
&&
1405 wKeyBindings
[WKBD_FOCUSNEXT
].modifier
1406 & 1<<(i
/keymap
->max_keypermod
)) {
1415 XUngrabKeyboard(dpy
, CurrentTime
);
1416 wSetFocusTo(scr
, newFocused
);
1418 if (wPreferences
.circ_raise
) {
1419 wRaiseFrame(newFocused
->frame
->core
);
1420 CommitStacking(scr
);
1423 scr
->flags
.doing_alt_tab
= 0;
1424 if (openedSwitchMenu
)
1425 OpenSwitchMenu(scr
, scr
->scr_width
/2, scr
->scr_height
/2, False
);
1432 handleKeyPress(XEvent
*event
)
1434 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1435 WWindow
*wwin
= scr
->focused_window
;
1438 int command
=-1, index
;
1439 #ifdef KEEP_XKB_LOCK_STATUS
1440 XkbStateRec staterec
;
1441 #endif /*KEEP_XKB_LOCK_STATUS*/
1443 /* ignore CapsLock */
1444 modifiers
= event
->xkey
.state
& ValidModMask
;
1446 for (i
=0; i
<WKBD_LAST
; i
++) {
1447 if (wKeyBindings
[i
].keycode
==0)
1450 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1451 && (/*wKeyBindings[i].modifier==0
1452 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1466 if (!wRootMenuPerformShortcut(event
)) {
1468 static int dontLoop
= 0;
1470 if (dontLoop
> 10) {
1471 wwarning("problem with key event processing code");
1475 /* if the focused window is an internal window, try redispatching
1476 * the event to the managed window, as it can be a WINGs window */
1477 if (wwin
&& wwin
->flags
.internal_window
1478 && wwin
->client_leader
!=None
) {
1479 /* client_leader contains the WINGs toplevel */
1480 event
->xany
.window
= wwin
->client_leader
;
1481 WMHandleEvent(event
);
1488 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1489 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1494 OpenRootMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1496 case WKBD_WINDOWLIST
:
1497 OpenSwitchMenu(scr
, event
->xkey
.x_root
, event
->xkey
.y_root
, True
);
1500 case WKBD_WINDOWMENU
:
1501 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1502 OpenWindowMenu(wwin
, wwin
->frame_x
,
1503 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1505 case WKBD_MINIATURIZE
:
1506 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1507 && !WFLAGP(wwin
, no_miniaturizable
)) {
1508 CloseWindowMenu(scr
);
1510 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1511 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1512 event
->xbutton
.time
);
1514 wIconifyWindow(wwin
);
1519 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1520 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1521 CloseWindowMenu(scr
);
1523 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1524 wHideApplication(wapp
);
1529 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1530 CloseWindowMenu(scr
);
1532 if (wwin
->flags
.maximized
) {
1533 wUnmaximizeWindow(wwin
);
1535 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1539 case WKBD_VMAXIMIZE
:
1540 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1541 CloseWindowMenu(scr
);
1543 if (wwin
->flags
.maximized
) {
1544 wUnmaximizeWindow(wwin
);
1546 wMaximizeWindow(wwin
, MAX_VERTICAL
);
1551 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1552 CloseWindowMenu(scr
);
1554 wRaiseFrame(wwin
->frame
->core
);
1558 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1559 CloseWindowMenu(scr
);
1561 wLowerFrame(wwin
->frame
->core
);
1564 case WKBD_RAISELOWER
:
1565 /* raise or lower the window under the pointer, not the
1568 wwin
= windowUnderPointer(scr
);
1570 wRaiseLowerFrame(wwin
->frame
->core
);
1573 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1574 if (wwin
->flags
.shaded
)
1575 wUnshadeWindow(wwin
);
1580 case WKBD_MOVERESIZE
:
1581 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1582 CloseWindowMenu(scr
);
1584 wKeyboardMoveResizeWindow(wwin
);
1588 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1589 CloseWindowMenu(scr
);
1590 if (wwin
->protocols
.DELETE_WINDOW
)
1591 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1596 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1597 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1600 case WKBD_FOCUSNEXT
:
1601 doWindozeCycle(wwin
, event
, True
);
1604 case WKBD_FOCUSPREV
:
1605 doWindozeCycle(wwin
, event
, False
);
1608 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1609 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1610 i = (scr->current_workspace/10)*10 + wk - 1;\
1611 if (wPreferences.ws_advance || i<scr->workspace_count)\
1612 wWorkspaceChange(scr, i);\
1615 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1616 i = (scr->current_workspace/10)*10 + wk - 1;\
1617 if (wPreferences.ws_advance || i<scr->workspace_count)\
1618 wWorkspaceChange(scr, i);\
1632 case WKBD_NEXTWORKSPACE
:
1633 wWorkspaceRelativeChange(scr
, 1);
1635 case WKBD_PREVWORKSPACE
:
1636 wWorkspaceRelativeChange(scr
, -1);
1642 #ifdef EXTEND_WINDOWSHORTCUT
1651 #define INITBAG(bag) if (bag) WMEmptyBag(bag); else bag = WMCreateBag(4)
1653 index
= command
-WKBD_WINDOW1
;
1655 if (scr
->shortcutWindows
[index
]) {
1656 WMBag
*list
= scr
->shortcutWindows
[index
];
1659 int count
= WMGetBagItemCount(list
);
1662 wUnselectWindows(scr
);
1663 cw
= scr
->current_workspace
;
1665 for (i
= count
-1; i
>= 0; i
--) {
1666 WWindow
*wwin
= WMGetFromBag(list
, i
);
1669 wWindowChangeWorkspace(wwin
, cw
);
1671 wMakeWindowVisible(wwin
);
1674 wSelectWindow(wwin
, True
);
1677 /* rotate the order of windows, to create a cycling effect */
1678 twin
= WMGetFromBag(list
, 0);
1679 WMDeleteFromBag(list
, 0);
1680 WMPutInBag(list
, twin
);
1682 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1684 INITBAG(scr
->shortcutWindows
[index
]);
1685 WMPutInBag(scr
->shortcutWindows
[index
], wwin
);
1687 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1688 WMBag
*selwins
= scr
->selected_windows
;
1691 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1692 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1695 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1698 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1701 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1704 } else if (scr
->selected_windows
1705 && WMGetBagItemCount(scr
->selected_windows
)) {
1707 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1708 WMBag
*selwins
= scr
->selected_windows
;
1711 INITBAG(scr
->shortcutWindows
[index
]);
1713 for (i
= 0; i
< WMGetBagItemCount(selwins
); i
++) {
1714 WWindow
*tmp
= WMGetFromBag(selwins
, i
);
1716 WMPutInBag(scr
->shortcutWindows
[index
], tmp
);
1723 case WKBD_NEXTWSLAYER
:
1724 case WKBD_PREVWSLAYER
:
1728 row
= scr
->current_workspace
/10;
1729 column
= scr
->current_workspace
%10;
1731 if (command
==WKBD_NEXTWSLAYER
) {
1732 if ((row
+1)*10 < scr
->workspace_count
)
1733 wWorkspaceChange(scr
, column
+(row
+1)*10);
1736 wWorkspaceChange(scr
, column
+(row
-1)*10);
1740 case WKBD_CLIPLOWER
:
1741 if (!wPreferences
.flags
.noclip
)
1742 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1744 case WKBD_CLIPRAISE
:
1745 if (!wPreferences
.flags
.noclip
)
1746 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1748 case WKBD_CLIPRAISELOWER
:
1749 if (!wPreferences
.flags
.noclip
)
1750 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1752 #ifdef KEEP_XKB_LOCK_STATUS
1754 if(wPreferences
.modelock
) {
1756 wwin
= scr
->focused_window
;
1758 if (wwin
&& wwin
->flags
.mapped
1759 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1760 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1761 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1763 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1764 wwin
->frame
->last_languagemode
= staterec
.group
;
1765 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1770 #endif /* KEEP_XKB_LOCK_STATUS */
1777 handleMotionNotify(XEvent
*event
)
1780 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1782 if (wPreferences
.scrollable_menus
) {
1783 if (scr
->flags
.jump_back_pending
||
1784 event
->xmotion
.x_root
<= 1 ||
1785 event
->xmotion
.x_root
>= (scr
->scr_width
- 2) ||
1786 event
->xmotion
.y_root
<= 1 ||
1787 event
->xmotion
.y_root
>= (scr
->scr_height
- 2)) {
1789 L("pointer at screen edge");
1791 menu
= wMenuUnderPointer(scr
);
1793 wMenuScroll(menu
, event
);
1797 if (event
->xmotion
.subwindow
== None
)
1800 if (scr
->scrolledFMaximize
!= None
) {
1803 twin
= wWindowFor(scr
->scrolledFMaximize
);
1804 if (twin
&& twin
->frame_y
==) {
1808 scr
->scrolledFMaximize
= NULL
;
1812 /* scroll full maximized window */
1813 if (event
->xmotion
.y_root
< 1
1814 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1816 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1818 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1819 && WFLAGP(wwin
, full_maximize
)
1820 && event
->xmotion
.x_root
>= wwin
->frame_x
1821 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1823 if (!WFLAGP(wwin
, no_titlebar
)
1824 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1826 wWindowMove(wwin
, wwin
->frame_x
, 0);
1827 wwin
->flags
.dragged_while_fmaximized
= 0;
1829 } else if (!WFLAGP(wwin
, no_resizebar
)
1830 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1831 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1833 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1835 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1837 wWindowMove(wwin
, wwin
->frame_x
, y
);
1838 wwin
->flags
.dragged_while_fmaximized
= 0;
1847 handleVisibilityNotify(XEvent
*event
)
1851 wwin
= wWindowFor(event
->xvisibility
.window
);
1854 wwin
->flags
.obscured
=
1855 (event
->xvisibility
.state
== VisibilityFullyObscured
);