1 /* event.c- event loop and handling
3 * Window Maker window manager
5 * Copyright (c) 1997-2003 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,
23 #include <sys/inotify.h>
35 #include <X11/Xutil.h>
37 # include <X11/extensions/shape.h>
43 #ifdef KEEP_XKB_LOCK_STATUS
44 #include <X11/XKBlib.h>
45 #endif /* KEEP_XKB_LOCK_STATUS */
47 #include "WindowMaker.h"
53 #include "application.h"
56 #include "workspace.h"
59 #include "properties.h"
67 /******** Global Variables **********/
68 extern XContext wWinContext
;
69 extern XContext wVEdgeContext
;
71 extern Cursor wCursor
[WCUR_LAST
];
73 extern WShortKey wKeyBindings
[WKBD_LAST
];
74 extern int wScreenCount
;
75 extern Time LastTimestamp
;
76 extern Time LastFocusChange
;
78 extern WPreferences wPreferences
;
80 #define MOD_MASK wPreferences.modifier_mask
82 extern Atom _XA_WM_COLORMAP_NOTIFY
;
84 extern Atom _XA_WM_CHANGE_STATE
;
85 extern Atom _XA_WM_DELETE_WINDOW
;
86 extern Atom _XA_GNUSTEP_WM_ATTR
;
87 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
88 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
89 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
90 extern Atom _XA_WINDOWMAKER_COMMAND
;
94 extern Bool wShapeSupported
;
95 extern int wShapeEventBase
;
98 #ifdef KEEP_XKB_LOCK_STATUS
99 extern int wXkbEventBase
;
103 /*extern char WDelayedActionSet;*/
106 /************ Local stuff ***********/
108 static void saveTimestamp(XEvent
*event
);
109 static void handleColormapNotify();
110 static void handleMapNotify();
111 static void handleUnmapNotify();
112 static void handleButtonPress();
113 static void handleExpose();
114 static void handleDestroyNotify();
115 static void handleConfigureRequest();
116 static void handleMapRequest();
117 static void handlePropertyNotify();
118 static void handleEnterNotify();
119 static void handleLeaveNotify();
120 static void handleExtensions();
121 static void handleClientMessage();
122 static void handleKeyPress();
123 static void handleFocusIn();
124 static void handleMotionNotify();
125 static void handleVisibilityNotify();
129 static void handleShapeNotify();
132 /* called from the signal handler */
133 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
135 /* real dead process handler */
136 static void handleDeadProcess(void *foo
);
139 typedef struct DeadProcesses
{
141 unsigned char exit_status
;
144 /* stack of dead processes */
145 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
146 static int deadProcessPtr
=0;
149 typedef struct DeathHandler
{
150 WDeathHandler
*callback
;
155 static WMArray
*deathHandlers
=NULL
;
160 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
162 DeathHandler
*handler
;
164 handler
= malloc(sizeof(DeathHandler
));
169 handler
->callback
= callback
;
170 handler
->client_data
= cdata
;
173 deathHandlers
= WMCreateArrayWithDestructor(8, wfree
);
175 WMAddToArray(deathHandlers
, handler
);
183 wDeleteDeathHandler(WMagicNumber id
)
185 DeathHandler
*handler
=(DeathHandler
*)id
;
187 if (!handler
|| !deathHandlers
)
190 /* array destructor will call wfree(handler) */
191 WMRemoveFromArray(deathHandlers
, handler
);
196 DispatchEvent(XEvent
*event
)
199 handleDeadProcess(NULL
);
201 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
202 WCHANGE_STATE(WSTATE_EXITING
);
203 /* received SIGTERM */
205 * WMHandleEvent() can't be called from anything
206 * executed inside here, or we can get in a infinite
209 Shutdown(WSExitMode
);
211 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
212 WCHANGE_STATE(WSTATE_RESTARTING
);
214 Shutdown(WSRestartPreparationMode
);
215 /* received SIGHUP */
217 } else if (WCHECK_STATE(WSTATE_NEED_REREAD
)) {
218 WCHANGE_STATE(WSTATE_NORMAL
);
219 wDefaultsCheckDomains();
222 /* for the case that all that is wanted to be dispatched is
227 saveTimestamp(event
);
228 switch (event
->type
) {
230 handleMapRequest(event
);
234 handleKeyPress(event
);
238 handleMotionNotify(event
);
241 case ConfigureRequest
:
242 handleConfigureRequest(event
);
246 handleDestroyNotify(event
);
250 handleMapNotify(event
);
254 handleUnmapNotify(event
);
258 handleButtonPress(event
);
266 handlePropertyNotify(event
);
270 handleEnterNotify(event
);
274 handleLeaveNotify(event
);
278 handleClientMessage(event
);
282 handleColormapNotify(event
);
286 if (event
->xmapping
.request
== MappingKeyboard
287 || event
->xmapping
.request
== MappingModifier
)
288 XRefreshKeyboardMapping(&event
->xmapping
);
292 handleFocusIn(event
);
295 case VisibilityNotify
:
296 handleVisibilityNotify(event
);
299 handleExtensions(event
);
305 *----------------------------------------------------------------------
306 * inotifyHandleEvents-
307 * Check for inotify events
310 * After reading events for the given file descriptor (fd) and
311 * watch descriptor (wd)
314 * Calls wDefaultsCheckDomains if config database is updated
315 *----------------------------------------------------------------------
318 #define BUFF_SIZE ((sizeof(struct inotify_event) + 16)*512)
319 void inotifyHandleEvents (int fd
, int wd
)
321 extern void wDefaultsCheckDomains();
322 ssize_t eventQLength
, i
= 0;
323 char buff
[BUFF_SIZE
] = {0};
324 /* Check config only once per read of the event queue */
328 * Read off the queued events
329 * queue overflow is not checked (IN_Q_OVERFLOW). In practise this should
330 * not occur; the block is on Xevents, but a config file change will normally
331 * occur as a result of an Xevent - so the event queue should never have more than
332 * a few entries before a read().
334 eventQLength
= read(fd
, buff
, BUFF_SIZE
);
336 /* check what events occured */
337 /* Should really check wd here too, but for now we only have one watch! */
338 while (i
< eventQLength
) {
339 struct inotify_event
*pevent
= (struct inotify_event
*)&buff
[i
];
342 * see inotify.h for event types.
344 if (pevent
->mask
& IN_DELETE_SELF
) {
345 wwarning(_("the defaults database has been deleted!"
346 " Restart Window Maker to create the database"
347 " with the default settings"));
350 if (pevent
->mask
& IN_UNMOUNT
) {
351 wwarning(_("the unit containing the defaults database has"
352 " been unmounted. Setting --static mode."
353 " Any changes will not be saved."));
355 wPreferences
.flags
.noupdates
=1;
357 if ((pevent
->mask
& IN_MODIFY
) && oneShotFlag
== 0) {
358 fprintf(stdout
,"wmaker: reading config files in defaults database.\n");
359 wDefaultsCheckDomains();
362 /* move to next event in the buffer */
363 i
+= sizeof(struct inotify_event
) + pevent
->len
;
368 *----------------------------------------------------------------------
370 * Processes X and internal events indefinitely.
376 * The LastTimestamp global variable is updated.
377 * Calls inotifyGetEvents if defaults database changes.
378 *----------------------------------------------------------------------
384 extern int inotifyFD
;
385 extern int inotifyWD
;
390 if (inotifyFD
< 0 || inotifyWD
< 0)
395 WMNextEvent(dpy
, &event
); /* Blocks here */
396 WMHandleEvent(&event
);
402 FD_SET (inotifyFD
, &rfds
);
404 /* check for available read data from inotify - don't block! */
405 retVal
= select (inotifyFD
+ 1, &rfds
, NULL
, NULL
, &time
);
407 if (retVal
< 0) { /* an error has occured */
408 wwarning(_("select failed. The inotify instance will be closed."
409 " Changes to the defaults database will require"
410 " a restart to take effect."));
414 if (FD_ISSET (inotifyFD
, &rfds
))
415 inotifyHandleEvents(inotifyFD
,inotifyWD
);
421 *----------------------------------------------------------------------
422 * ProcessPendingEvents --
423 * Processes the events that are currently pending (at the time
424 * this function is called) in the display's queue.
427 * After the pending events that were present at the function call
431 * Many -- whatever handling events may involve.
433 *----------------------------------------------------------------------
436 ProcessPendingEvents()
443 /* Take a snapshot of the event count in the queue */
444 count
= XPending(dpy
);
446 while (count
>0 && XPending(dpy
)) {
447 WMNextEvent(dpy
, &event
);
448 WMHandleEvent(&event
);
455 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
457 if ((scr
->last_click_time
>0) &&
458 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
459 && (event
->xbutton
.button
== scr
->last_click_button
)
460 && (event
->xbutton
.window
== scr
->last_click_window
)) {
462 scr
->flags
.next_click_is_not_double
= 1;
463 scr
->last_click_time
= 0;
464 scr
->last_click_window
= event
->xbutton
.window
;
473 NotifyDeadProcess(pid_t pid
, unsigned char status
)
475 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
476 wwarning("stack overflow: too many dead processes");
479 /* stack the process to be handled later,
480 * as this is called from the signal handler */
481 deadProcesses
[deadProcessPtr
].pid
= pid
;
482 deadProcesses
[deadProcessPtr
].exit_status
= status
;
488 handleDeadProcess(void *foo
)
493 for (i
=0; i
<deadProcessPtr
; i
++) {
494 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
497 if (!deathHandlers
) {
502 /* get the pids on the queue and call handlers */
503 while (deadProcessPtr
>0) {
506 for (i
= WMGetArrayItemCount(deathHandlers
)-1; i
>= 0; i
--) {
507 tmp
= WMGetFromArray(deathHandlers
, i
);
511 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
512 (*tmp
->callback
)(tmp
->pid
,
513 deadProcesses
[deadProcessPtr
].exit_status
,
515 wDeleteDeathHandler(tmp
);
523 saveTimestamp(XEvent
*event
)
526 * Never save CurrentTime as LastTimestamp because CurrentTime
527 * it's not a real timestamp (it's the 0L constant)
530 switch (event
->type
) {
533 LastTimestamp
= event
->xbutton
.time
;
537 LastTimestamp
= event
->xkey
.time
;
540 LastTimestamp
= event
->xmotion
.time
;
543 LastTimestamp
= event
->xproperty
.time
;
547 LastTimestamp
= event
->xcrossing
.time
;
550 LastTimestamp
= event
->xselectionclear
.time
;
552 case SelectionRequest
:
553 LastTimestamp
= event
->xselectionrequest
.time
;
555 case SelectionNotify
:
556 LastTimestamp
= event
->xselection
.time
;
558 wXDNDProcessSelection(event
);
566 matchWindow(void *item
, void *cdata
)
568 return (((WFakeGroupLeader
*)item
)->origLeader
== (Window
)cdata
);
573 handleExtensions(XEvent
*event
)
575 #ifdef KEEP_XKB_LOCK_STATUS
577 xkbevent
= (XkbEvent
*)event
;
578 #endif /*KEEP_XKB_LOCK_STATUS*/
580 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
581 handleShapeNotify(event
);
584 #ifdef KEEP_XKB_LOCK_STATUS
585 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
586 handleXkbIndicatorStateNotify(event
);
588 #endif /*KEEP_XKB_LOCK_STATUS*/
593 handleMapRequest(XEvent
*ev
)
597 Window window
= ev
->xmaprequest
.window
;
600 printf("got map request for %x\n", (unsigned)window
);
602 if ((wwin
= wWindowFor(window
))) {
603 if (wwin
->flags
.shaded
) {
604 wUnshadeWindow(wwin
);
606 /* deiconify window */
607 if (wwin
->flags
.miniaturized
) {
608 wDeiconifyWindow(wwin
);
609 } else if (wwin
->flags
.hidden
) {
610 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
611 /* go to the last workspace that the user worked on the app */
613 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
615 wUnhideApplication(wapp
, False
, False
);
620 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
622 wwin
= wManageWindow(scr
, window
);
625 * This is to let the Dock know that the application it launched
626 * has already been mapped (eg: it has finished launching).
627 * It is not necessary for normally docked apps, but is needed for
628 * apps that were forcedly docked (like with dockit).
630 if (scr
->last_dock
) {
631 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
632 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
634 wDockTrackWindowLaunch(scr
->last_dock
, window
);
638 wClientSetState(wwin
, NormalState
, None
);
639 if (wwin
->flags
.maximized
) {
640 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
642 if (wwin
->flags
.shaded
) {
643 wwin
->flags
.shaded
= 0;
644 wwin
->flags
.skip_next_animation
= 1;
647 if (wwin
->flags
.miniaturized
) {
648 wwin
->flags
.miniaturized
= 0;
649 wwin
->flags
.skip_next_animation
= 1;
650 wIconifyWindow(wwin
);
652 if (wwin
->flags
.fullscreen
) {
653 wwin
->flags
.fullscreen
= 0;
654 wFullscreenWindow(wwin
);
656 if (wwin
->flags
.hidden
) {
657 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
659 wwin
->flags
.hidden
= 0;
660 wwin
->flags
.skip_next_animation
= 1;
662 wHideApplication(wapp
);
670 handleDestroyNotify(XEvent
*event
)
674 Window window
= event
->xdestroywindow
.window
;
675 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
679 printf("got destroy notify\n");
681 wwin
= wWindowFor(window
);
683 wUnmanageWindow(wwin
, False
, True
);
687 while ((widx
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
,
688 (void*)window
)) != WANotFound
) {
689 WFakeGroupLeader
*fPtr
;
691 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, widx
);
692 if (fPtr
->retainCount
> 0) {
694 if (fPtr
->retainCount
==0 && fPtr
->leader
!=None
) {
695 XDestroyWindow(dpy
, fPtr
->leader
);
700 fPtr
->origLeader
= None
;
704 app
= wApplicationOf(window
);
706 if (window
== app
->main_window
) {
708 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
710 if (wwin
->main_window
== window
) {
711 wwin
->main_window
= None
;
716 wApplicationDestroy(app
);
723 handleExpose(XEvent
*event
)
725 WObjDescriptor
*desc
;
729 printf("got expose\n");
731 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
733 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
734 (XPointer
*)&desc
)==XCNOENT
) {
738 if (desc
->handle_expose
) {
739 (*desc
->handle_expose
)(desc
, event
);
744 executeButtonAction(WScreen
*scr
, XEvent
*event
, int action
)
747 case WA_SELECT_WINDOWS
:
748 wUnselectWindows(scr
);
749 wSelectWindows(scr
, event
);
751 case WA_OPEN_APPMENU
:
752 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
754 if (scr
->root_menu
) {
755 if (scr
->root_menu
->brother
->flags
.mapped
)
756 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
758 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
761 case WA_OPEN_WINLISTMENU
:
762 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
763 if (scr
->switch_menu
) {
764 if (scr
->switch_menu
->brother
->flags
.mapped
)
765 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
767 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
778 handleButtonPress(XEvent
*event
)
780 WObjDescriptor
*desc
;
784 printf("got button press\n");
786 scr
= wScreenForRootWindow(event
->xbutton
.root
);
794 if (event
->xbutton
.window
==scr
->root_win
) {
795 if (event
->xbutton
.button
==Button1
&&
796 wPreferences
.mouse_button1
!=WA_NONE
) {
797 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
798 } else if (event
->xbutton
.button
==Button2
&&
799 wPreferences
.mouse_button2
!=WA_NONE
) {
800 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
801 } else if (event
->xbutton
.button
==Button3
&&
802 wPreferences
.mouse_button3
!=WA_NONE
) {
803 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
804 } else if (event
->xbutton
.button
==Button4
&&
805 wPreferences
.mouse_wheel
!=WA_NONE
) {
806 wWorkspaceRelativeChange(scr
, 1);
807 } else if (event
->xbutton
.button
==Button5
&&
808 wPreferences
.mouse_wheel
!=WA_NONE
) {
809 wWorkspaceRelativeChange(scr
, -1);
815 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
816 (XPointer
*)&desc
)==XCNOENT
) {
817 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
818 (XPointer
*)&desc
)==XCNOENT
) {
823 if (desc
->parent_type
== WCLASS_WINDOW
) {
826 if (event
->xbutton
.state
& MOD_MASK
) {
827 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
830 /* if (wPreferences.focus_mode == WKF_CLICK) {*/
831 if (wPreferences
.ignore_focus_click
) {
832 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
834 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
837 } else if (desc
->parent_type
== WCLASS_APPICON
838 || desc
->parent_type
== WCLASS_MINIWINDOW
839 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
840 if (event
->xbutton
.state
& MOD_MASK
) {
842 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
847 if (desc
->handle_mousedown
!=NULL
) {
848 (*desc
->handle_mousedown
)(desc
, event
);
851 /* save double-click information */
852 if (scr
->flags
.next_click_is_not_double
) {
853 scr
->flags
.next_click_is_not_double
= 0;
855 scr
->last_click_time
= event
->xbutton
.time
;
856 scr
->last_click_button
= event
->xbutton
.button
;
857 scr
->last_click_window
= event
->xbutton
.window
;
863 handleMapNotify(XEvent
*event
)
869 wwin
= wWindowFor(event
->xmap
.event
);
870 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
871 if (wwin
->flags
.miniaturized
) {
872 wDeiconifyWindow(wwin
);
876 wClientSetState(wwin
, NormalState
, None
);
884 handleUnmapNotify(XEvent
*event
)
888 Bool withdraw
= False
;
890 printf("got unmap\n");
892 /* only process windows with StructureNotify selected
893 * (ignore SubstructureNotify) */
894 wwin
= wWindowFor(event
->xunmap
.window
);
898 /* whether the event is a Withdrawal request */
899 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
900 && event
->xunmap
.send_event
)
903 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
906 if (!wwin
->flags
.mapped
&& !withdraw
907 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
908 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
912 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
913 wwin
->flags
.mapped
= 0;
915 /* check if the window was destroyed */
916 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
919 Bool reparented
= False
;
921 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
924 /* withdraw window */
925 wwin
->flags
.mapped
= 0;
927 wClientSetState(wwin
, WithdrawnState
, None
);
929 /* if the window was reparented, do not reparent it back to the
931 wUnmanageWindow(wwin
, !reparented
, False
);
938 handleConfigureRequest(XEvent
*event
)
942 printf("got configure request\n");
944 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
946 * Configure request for unmapped window
948 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
950 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
956 handlePropertyNotify(XEvent
*event
)
965 printf("got property notify\n");
968 wwin
= wWindowFor(event
->xproperty
.window
);
970 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
971 &ju
, &ju
, &ju
, &ju
)) {
974 wClientCheckProperty(wwin
, &event
->xproperty
);
976 wapp
= wApplicationOf(event
->xproperty
.window
);
978 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
981 scr
= wScreenForWindow(event
->xproperty
.window
);
986 handleClientMessage(XEvent
*event
)
989 WObjDescriptor
*desc
;
991 printf("got client message\n");
993 /* handle transition from Normal to Iconic state */
994 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
995 && event
->xclient
.format
== 32
996 && event
->xclient
.data
.l
[0] == IconicState
) {
998 wwin
= wWindowFor(event
->xclient
.window
);
1000 if (!wwin
->flags
.miniaturized
)
1001 wIconifyWindow(wwin
);
1002 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
1003 && event
->xclient
.format
== 32) {
1004 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
1009 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
1010 wColormapAllowClientInstallation(scr
, True
);
1011 } else { /* stopping */
1012 wColormapAllowClientInstallation(scr
, False
);
1014 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
1016 wDefaultsCheckDomains();
1018 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
1021 wapp
= wApplicationOf(event
->xclient
.window
);
1023 switch (event
->xclient
.data
.l
[0]) {
1024 case WMFHideOtherApplications
:
1025 wHideOtherApplications(wapp
->main_window_desc
);
1029 case WMFHideApplication
:
1030 wHideApplication(wapp
);
1036 wwin
= wWindowFor(event
->xclient
.window
);
1038 switch (event
->xclient
.data
.l
[0]) {
1039 case WMFHideOtherApplications
:
1040 wHideOtherApplications(wwin
);
1043 case WMFHideApplication
:
1044 wHideApplication(wApplicationOf(wwin
->main_window
));
1049 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
1050 wwin
= wWindowFor(event
->xclient
.window
);
1052 switch (event
->xclient
.data
.l
[0]) {
1053 case GSWindowLevelAttr
:
1055 int level
= (int)event
->xclient
.data
.l
[1];
1057 if (WINDOW_LEVEL(wwin
) != level
) {
1058 ChangeStackingLevel(wwin
->frame
->core
, level
);
1063 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
1064 wwin
= wWindowFor(event
->xclient
.window
);
1066 switch (event
->xclient
.data
.l
[0]) {
1067 case WMTitleBarNormal
:
1068 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1070 case WMTitleBarMain
:
1071 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
1074 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1078 } else if (wNETWMProcessClientMessage(&event
->xclient
)) {
1082 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
1087 * Non-standard thing, but needed by OffiX DND.
1088 * For when the icon frame gets a ClientMessage
1089 * that should have gone to the icon_window.
1091 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
1092 (XPointer
*)&desc
)!=XCNOENT
) {
1093 struct WIcon
*icon
=NULL
;
1095 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
1096 icon
= (WIcon
*)desc
->parent
;
1097 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
1098 || desc
->parent_type
== WCLASS_APPICON
) {
1099 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
1101 if (icon
&& (wwin
=icon
->owner
)) {
1102 if (wwin
->client_win
!=event
->xclient
.window
) {
1103 event
->xclient
.window
= wwin
->client_win
;
1104 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
1114 raiseWindow(WScreen
*scr
)
1118 scr
->autoRaiseTimer
= NULL
;
1120 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1124 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1125 wRaiseFrame(wwin
->frame
->core
);
1126 /* this is needed or a race condition will occur */
1133 handleEnterNotify(XEvent
*event
)
1136 WObjDescriptor
*desc
= NULL
;
1137 #ifdef VIRTUAL_DESKTOP
1138 void (*vdHandler
)(XEvent
* event
);
1141 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1143 printf("got enter notify\n");
1146 #ifdef VIRTUAL_DESKTOP
1147 if (XFindContext(dpy
, event
->xcrossing
.window
, wVEdgeContext
,
1148 (XPointer
*)&vdHandler
)!=XCNOENT
) {
1149 (*vdHandler
)(event
);
1153 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1155 /* already left the window... */
1157 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1158 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1163 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1164 (XPointer
*)&desc
)!=XCNOENT
) {
1165 if(desc
->handle_enternotify
)
1166 (*desc
->handle_enternotify
)(desc
, event
);
1169 /* enter to window */
1170 wwin
= wWindowFor(event
->xcrossing
.window
);
1172 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1173 wColormapInstallForWindow(scr
, NULL
);
1175 if (scr
->autoRaiseTimer
1176 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1177 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1178 scr
->autoRaiseTimer
= NULL
;
1181 /* set auto raise timer even if in focus-follows-mouse mode
1182 * and the event is for the frame window, even if the window
1183 * has focus already. useful if you move the pointer from a focused
1184 * window to the root window and back pretty fast
1186 * set focus if in focus-follows-mouse mode and the event
1187 * is for the frame window and window doesn't have focus yet */
1188 if (wPreferences
.focus_mode
==WKF_SLOPPY
1189 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1190 && !scr
->flags
.doing_alt_tab
) {
1192 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1193 wSetFocusTo(scr
, wwin
);
1195 if (scr
->autoRaiseTimer
)
1196 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1197 scr
->autoRaiseTimer
= NULL
;
1199 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1200 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1202 = WMAddTimerHandler(wPreferences
.raise_delay
,
1203 (WMCallback
*)raiseWindow
, scr
);
1206 /* Install colormap for window, if the colormap installation mode
1207 * is colormap_follows_mouse */
1208 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1209 if (wwin
->client_win
==event
->xcrossing
.window
)
1210 wColormapInstallForWindow(scr
, wwin
);
1212 wColormapInstallForWindow(scr
, NULL
);
1216 /* a little kluge to hide the clip balloon */
1217 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1219 XUnmapWindow(dpy
, scr
->clip_balloon
);
1220 scr
->flags
.clip_balloon_mapped
= 0;
1222 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1223 || scr
->clip_icon
!= desc
->parent
) {
1224 XUnmapWindow(dpy
, scr
->clip_balloon
);
1225 scr
->flags
.clip_balloon_mapped
= 0;
1230 if (event
->xcrossing
.window
== event
->xcrossing
.root
1231 && event
->xcrossing
.detail
== NotifyNormal
1232 && event
->xcrossing
.detail
!= NotifyInferior
1233 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1235 wSetFocusTo(scr
, scr
->focused_window
);
1239 wBalloonEnteredObject(scr
, desc
);
1245 handleLeaveNotify(XEvent
*event
)
1247 WObjDescriptor
*desc
= NULL
;
1249 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1250 (XPointer
*)&desc
)!=XCNOENT
) {
1251 if(desc
->handle_leavenotify
)
1252 (*desc
->handle_leavenotify
)(desc
, event
);
1259 handleShapeNotify(XEvent
*event
)
1261 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1265 printf("got shape notify\n");
1267 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1268 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1270 if (sev
->kind
== ShapeBounding
) {
1271 if (sev
->shaped
== shev
->shaped
) {
1274 XPutBackEvent(dpy
, &ev
);
1280 wwin
= wWindowFor(shev
->window
);
1281 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1284 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1286 wwin
->flags
.shaped
= 0;
1287 wWindowClearShape(wwin
);
1289 } else if (shev
->shaped
) {
1291 wwin
->flags
.shaped
= 1;
1292 wWindowSetShape(wwin
);
1297 #ifdef KEEP_XKB_LOCK_STATUS
1298 /* please help ]d if you know what to do */
1299 handleXkbIndicatorStateNotify(XEvent
*event
)
1303 XkbStateRec staterec
;
1306 for (i
=0; i
<wScreenCount
; i
++) {
1307 scr
= wScreenWithNumber(i
);
1308 wwin
= scr
->focused_window
;
1309 if (wwin
&& wwin
->flags
.focused
) {
1310 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1311 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1312 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1313 wwin
->frame
->languagemode
= staterec
.group
;
1315 #ifdef XKB_BUTTON_HINT
1316 if (wwin
->frame
->titlebar
) {
1317 wFrameWindowPaint(wwin
->frame
);
1323 #endif /*KEEP_XKB_LOCK_STATUS*/
1326 handleColormapNotify(XEvent
*event
)
1330 Bool reinstall
= False
;
1332 wwin
= wWindowFor(event
->xcolormap
.window
);
1336 scr
= wwin
->screen_ptr
;
1340 if (event
->xcolormap
.new) {
1341 XWindowAttributes attr
;
1343 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1345 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1346 scr
->current_colormap
= attr
.colormap
;
1349 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1350 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1352 /* some bastard app (like XV) removed our colormap */
1354 * can't enforce or things like xscreensaver wont work
1357 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1358 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1360 /* someone has put our colormap back */
1364 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1365 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1367 if (reinstall
&& scr
->current_colormap
!=None
) {
1368 if (!scr
->flags
.colormap_stuff_blocked
)
1369 XInstallColormap(dpy
, scr
->current_colormap
);
1376 handleFocusIn(XEvent
*event
)
1381 * For applications that like stealing the focus.
1383 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1384 saveTimestamp(event
);
1385 if (event
->xfocus
.mode
== NotifyUngrab
1386 || event
->xfocus
.mode
== NotifyGrab
1387 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1391 wwin
= wWindowFor(event
->xfocus
.window
);
1392 if (wwin
&& !wwin
->flags
.focused
) {
1393 if (wwin
->flags
.mapped
)
1394 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1396 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1398 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1400 wSetFocusTo(scr
, NULL
);
1406 windowUnderPointer(WScreen
*scr
)
1412 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1414 return wWindowFor(win
);
1419 static int CheckFullScreenWindowFocused(WScreen
*scr
)
1421 if (scr
->focused_window
&& scr
->focused_window
->flags
.fullscreen
)
1429 handleKeyPress(XEvent
*event
)
1431 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1432 WWindow
*wwin
= scr
->focused_window
;
1436 #ifdef KEEP_XKB_LOCK_STATUS
1437 XkbStateRec staterec
;
1438 #endif /*KEEP_XKB_LOCK_STATUS*/
1440 /* ignore CapsLock */
1441 modifiers
= event
->xkey
.state
& ValidModMask
;
1443 for (i
=0; i
<WKBD_LAST
; i
++) {
1444 if (wKeyBindings
[i
].keycode
==0)
1447 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1448 && (/*wKeyBindings[i].modifier==0
1449 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1463 if (!wRootMenuPerformShortcut(event
)) {
1465 static int dontLoop
= 0;
1467 if (dontLoop
> 10) {
1468 wwarning("problem with key event processing code");
1472 /* if the focused window is an internal window, try redispatching
1473 * the event to the managed window, as it can be a WINGs window */
1474 if (wwin
&& wwin
->flags
.internal_window
1475 && wwin
->client_leader
!=None
) {
1476 /* client_leader contains the WINGs toplevel */
1477 event
->xany
.window
= wwin
->client_leader
;
1478 WMHandleEvent(event
);
1485 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1486 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1491 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/
1492 if (!CheckFullScreenWindowFocused(scr
)) {
1493 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1494 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1497 case WKBD_WINDOWLIST
:
1498 if (!CheckFullScreenWindowFocused(scr
)) {
1499 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1500 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1504 case WKBD_WINDOWMENU
:
1505 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1506 OpenWindowMenu(wwin
, wwin
->frame_x
,
1507 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1509 case WKBD_MINIATURIZE
:
1510 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1511 && !WFLAGP(wwin
, no_miniaturizable
)) {
1512 CloseWindowMenu(scr
);
1514 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1515 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1516 event
->xbutton
.time
);
1518 wIconifyWindow(wwin
);
1523 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1524 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1525 CloseWindowMenu(scr
);
1527 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1528 wHideApplication(wapp
);
1532 case WKBD_HIDE_OTHERS
:
1533 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1534 CloseWindowMenu(scr
);
1536 wHideOtherApplications(wwin
);
1540 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1541 int newdir
= (MAX_VERTICAL
|MAX_HORIZONTAL
);
1543 CloseWindowMenu(scr
);
1545 if (wwin
->flags
.maximized
== newdir
) {
1546 wUnmaximizeWindow(wwin
);
1548 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1552 case WKBD_VMAXIMIZE
:
1553 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1554 int newdir
= (MAX_VERTICAL
^ wwin
->flags
.maximized
);
1556 CloseWindowMenu(scr
);
1559 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1561 wUnmaximizeWindow(wwin
);
1565 case WKBD_HMAXIMIZE
:
1566 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1567 int newdir
= (MAX_HORIZONTAL
^ wwin
->flags
.maximized
);
1569 CloseWindowMenu(scr
);
1572 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1574 wUnmaximizeWindow(wwin
);
1579 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1580 CloseWindowMenu(scr
);
1582 wRaiseFrame(wwin
->frame
->core
);
1586 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1587 CloseWindowMenu(scr
);
1589 wLowerFrame(wwin
->frame
->core
);
1592 case WKBD_RAISELOWER
:
1593 /* raise or lower the window under the pointer, not the
1596 wwin
= windowUnderPointer(scr
);
1598 wRaiseLowerFrame(wwin
->frame
->core
);
1601 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1602 if (wwin
->flags
.shaded
)
1603 wUnshadeWindow(wwin
);
1608 case WKBD_MOVERESIZE
:
1609 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) &&
1610 (IS_RESIZABLE(wwin
) || IS_MOVABLE(wwin
))) {
1611 CloseWindowMenu(scr
);
1613 wKeyboardMoveResizeWindow(wwin
);
1617 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1618 CloseWindowMenu(scr
);
1619 if (wwin
->protocols
.DELETE_WINDOW
)
1620 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1625 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1626 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1629 case WKBD_FOCUSNEXT
:
1630 StartWindozeCycle(wwin
, event
, True
);
1633 case WKBD_FOCUSPREV
:
1634 StartWindozeCycle(wwin
, event
, False
);
1637 case WKBD_WORKSPACE1
... WKBD_WORKSPACE10
:
1638 widx
= command
- WKBD_WORKSPACE1
;
1639 i
= (scr
->current_workspace
/ 10) * 10 + widx
;
1640 if (wPreferences
.ws_advance
|| i
< scr
->workspace_count
)
1641 wWorkspaceChange(scr
, i
);
1644 case WKBD_NEXTWORKSPACE
:
1645 wWorkspaceRelativeChange(scr
, 1);
1647 case WKBD_PREVWORKSPACE
:
1648 wWorkspaceRelativeChange(scr
, -1);
1661 widx
= command
-WKBD_WINDOW1
;
1663 if (scr
->shortcutWindows
[widx
]) {
1664 WMArray
*list
= scr
->shortcutWindows
[widx
];
1666 int count
= WMGetArrayItemCount(list
);
1668 WMArrayIterator iter
;
1671 wUnselectWindows(scr
);
1672 cw
= scr
->current_workspace
;
1674 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1676 wWindowChangeWorkspace(wwin
, cw
);
1678 wMakeWindowVisible(wwin
);
1681 wSelectWindow(wwin
, True
);
1684 /* rotate the order of windows, to create a cycling effect */
1685 twin
= WMGetFromArray(list
, 0);
1686 WMDeleteFromArray(list
, 0);
1687 WMAddToArray(list
, twin
);
1689 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1690 if (scr
->shortcutWindows
[widx
]) {
1691 WMFreeArray(scr
->shortcutWindows
[widx
]);
1692 scr
->shortcutWindows
[widx
] = NULL
;
1695 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1696 scr
->shortcutWindows
[widx
] =
1697 WMDuplicateArray(scr
->selected_windows
);
1698 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1699 WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
1701 scr
->shortcutWindows
[widx
] = WMCreateArray(4);
1702 WMAddToArray(scr
->shortcutWindows
[widx
], wwin
);
1705 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1708 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1711 } else if (scr
->selected_windows
1712 && WMGetArrayItemCount(scr
->selected_windows
)) {
1714 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1715 if (scr
->shortcutWindows
[widx
]) {
1716 WMFreeArray(scr
->shortcutWindows
[widx
]);
1718 scr
->shortcutWindows
[widx
] =
1719 WMDuplicateArray(scr
->selected_windows
);
1725 case WKBD_SWITCH_SCREEN
:
1726 if (wScreenCount
> 1) {
1730 /* find index of this screen */
1731 for (i
= 0; i
< wScreenCount
; i
++) {
1732 if (wScreenWithNumber(i
) == scr
)
1736 if (i
>= wScreenCount
) {
1739 scr2
= wScreenWithNumber(i
);
1742 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1743 scr2
->scr_width
/2, scr2
->scr_height
/2);
1748 case WKBD_NEXTWSLAYER
:
1749 case WKBD_PREVWSLAYER
:
1753 row
= scr
->current_workspace
/10;
1754 column
= scr
->current_workspace
%10;
1756 if (command
==WKBD_NEXTWSLAYER
) {
1757 if ((row
+1)*10 < scr
->workspace_count
)
1758 wWorkspaceChange(scr
, column
+(row
+1)*10);
1761 wWorkspaceChange(scr
, column
+(row
-1)*10);
1765 case WKBD_CLIPLOWER
:
1766 if (!wPreferences
.flags
.noclip
)
1767 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1769 case WKBD_CLIPRAISE
:
1770 if (!wPreferences
.flags
.noclip
)
1771 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1773 case WKBD_CLIPRAISELOWER
:
1774 if (!wPreferences
.flags
.noclip
)
1775 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1777 #ifdef KEEP_XKB_LOCK_STATUS
1779 if(wPreferences
.modelock
) {
1781 wwin
= scr
->focused_window
;
1783 if (wwin
&& wwin
->flags
.mapped
1784 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1785 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1786 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1788 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1789 wwin
->frame
->last_languagemode
= staterec
.group
;
1790 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1795 #endif /* KEEP_XKB_LOCK_STATUS */
1796 #ifdef VIRTUAL_DESKTOP
1797 case WKBD_VDESK_LEFT
:
1798 wWorkspaceKeyboardMoveDesktop(scr
, VEC_LEFT
);
1801 case WKBD_VDESK_RIGHT
:
1802 wWorkspaceKeyboardMoveDesktop(scr
, VEC_RIGHT
);
1806 wWorkspaceKeyboardMoveDesktop(scr
, VEC_UP
);
1809 case WKBD_VDESK_DOWN
:
1810 wWorkspaceKeyboardMoveDesktop(scr
, VEC_DOWN
);
1819 handleMotionNotify(XEvent
*event
)
1821 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1823 if (wPreferences
.scrollable_menus
) {
1824 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1825 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1827 if (scr
->flags
.jump_back_pending
||
1828 p
.x
<= (rect
.pos
.x
+ 1) ||
1829 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1830 p
.y
<= (rect
.pos
.y
+ 1) ||
1831 p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1834 printf("pointer at screen edge\n");
1836 menu
= wMenuUnderPointer(scr
);
1838 wMenuScroll(menu
, event
);
1845 handleVisibilityNotify(XEvent
*event
)
1849 wwin
= wWindowFor(event
->xvisibility
.window
);
1852 wwin
->flags
.obscured
=
1853 (event
->xvisibility
.state
== VisibilityFullyObscured
);