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 along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <sys/select.h>
26 #include <sys/inotify.h>
37 #include <X11/Xutil.h>
39 # include <X11/extensions/shape.h>
46 #include <X11/extensions/Xrandr.h>
49 #ifdef KEEP_XKB_LOCK_STATUS
50 #include <X11/XKBlib.h>
51 #endif /* KEEP_XKB_LOCK_STATUS */
53 #include "WindowMaker.h"
59 #include "application.h"
62 #include "workspace.h"
65 #include "properties.h"
74 /******** Global Variables **********/
75 extern XContext wWinContext
;
76 extern XContext wVEdgeContext
;
78 extern Cursor wCursor
[WCUR_LAST
];
80 extern WShortKey wKeyBindings
[WKBD_LAST
];
81 extern int wScreenCount
;
82 extern Time LastTimestamp
;
83 extern Time LastFocusChange
;
85 extern WPreferences wPreferences
;
87 #define MOD_MASK wPreferences.modifier_mask
89 extern Atom _XA_WM_COLORMAP_NOTIFY
;
91 extern Atom _XA_WM_CHANGE_STATE
;
92 extern Atom _XA_WM_DELETE_WINDOW
;
93 extern Atom _XA_GNUSTEP_WM_ATTR
;
94 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
95 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
96 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
97 extern Atom _XA_WINDOWMAKER_COMMAND
;
98 extern Atom _XA_WM_IGNORE_FOCUS_EVENTS
;
101 extern Bool wShapeSupported
;
102 extern int wShapeEventBase
;
105 #ifdef KEEP_XKB_LOCK_STATUS
106 extern int wXkbEventBase
;
109 /************ Local stuff ***********/
111 static void saveTimestamp(XEvent
*event
);
112 static void handleColormapNotify(XEvent
*event
);
113 static void handleMapNotify(XEvent
*event
);
114 static void handleUnmapNotify(XEvent
*event
);
115 static void handleButtonPress(XEvent
*event
);
116 static void handleExpose(XEvent
*event
);
117 static void handleDestroyNotify(XEvent
*event
);
118 static void handleConfigureRequest(XEvent
*event
);
119 static void handleMapRequest(XEvent
*event
);
120 static void handlePropertyNotify(XEvent
*event
);
121 static void handleEnterNotify(XEvent
*event
);
122 static void handleLeaveNotify(XEvent
*event
);
123 static void handleExtensions(XEvent
*event
);
124 static void handleClientMessage(XEvent
*event
);
125 static void handleKeyPress(XEvent
*event
);
126 static void handleFocusIn(XEvent
*event
);
127 static void handleMotionNotify(XEvent
*event
);
128 static void handleVisibilityNotify(XEvent
*event
);
129 static void handle_inotify_events(int fd
, int wd
);
130 static void wdelete_death_handler(WMagicNumber id
);
134 static void handleShapeNotify(XEvent
*event
);
137 #ifdef KEEP_XKB_LOCK_STATUS
138 static void handleXkbIndicatorStateNotify(XEvent
*event
);
141 /* called from the signal handler */
142 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
144 /* real dead process handler */
145 static void handleDeadProcess(void *foo
);
147 typedef struct DeadProcesses
{
149 unsigned char exit_status
;
152 /* stack of dead processes */
153 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
154 static int deadProcessPtr
= 0;
156 typedef struct DeathHandler
{
157 WDeathHandler
*callback
;
162 static WMArray
*deathHandlers
= NULL
;
164 WMagicNumber
wAddDeathHandler(pid_t pid
, WDeathHandler
* callback
, void *cdata
)
166 DeathHandler
*handler
;
168 handler
= malloc(sizeof(DeathHandler
));
173 handler
->callback
= callback
;
174 handler
->client_data
= cdata
;
177 deathHandlers
= WMCreateArrayWithDestructor(8, free
);
179 WMAddToArray(deathHandlers
, handler
);
184 static void wdelete_death_handler(WMagicNumber id
)
186 DeathHandler
*handler
= (DeathHandler
*) id
;
188 if (!handler
|| !deathHandlers
)
191 /* array destructor will call free(handler) */
192 WMRemoveFromArray(deathHandlers
, handler
);
195 void DispatchEvent(XEvent
* event
)
198 handleDeadProcess(NULL
);
200 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
201 WCHANGE_STATE(WSTATE_EXITING
);
202 /* received SIGTERM */
204 * WMHandleEvent() can't be called from anything
205 * executed inside here, or we can get in a infinite
208 Shutdown(WSExitMode
);
210 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
211 WCHANGE_STATE(WSTATE_RESTARTING
);
213 Shutdown(WSRestartPreparationMode
);
214 /* received SIGHUP */
216 } else if (WCHECK_STATE(WSTATE_NEED_REREAD
)) {
217 WCHANGE_STATE(WSTATE_NORMAL
);
218 wDefaultsCheckDomains(NULL
);
221 /* for the case that all that is wanted to be dispatched is
226 saveTimestamp(event
);
227 switch (event
->type
) {
229 handleMapRequest(event
);
233 handleKeyPress(event
);
237 handleMotionNotify(event
);
240 case ConfigureRequest
:
241 handleConfigureRequest(event
);
245 handleDestroyNotify(event
);
249 handleMapNotify(event
);
253 handleUnmapNotify(event
);
257 handleButtonPress(event
);
265 handlePropertyNotify(event
);
269 handleEnterNotify(event
);
273 handleLeaveNotify(event
);
277 handleClientMessage(event
);
281 handleColormapNotify(event
);
285 if (event
->xmapping
.request
== MappingKeyboard
|| event
->xmapping
.request
== MappingModifier
)
286 XRefreshKeyboardMapping(&event
->xmapping
);
290 handleFocusIn(event
);
293 case VisibilityNotify
:
294 handleVisibilityNotify(event
);
297 case ConfigureNotify
:
299 if (event
->xconfigure
.window
== DefaultRootWindow(dpy
))
300 XRRUpdateConfiguration(event
);
305 handleExtensions(event
);
312 *----------------------------------------------------------------------
313 * handle_inotify_events-
314 * Check for inotify events
317 * After reading events for the given file descriptor (fd) and
318 * watch descriptor (wd)
321 * Calls wDefaultsCheckDomains if config database is updated
322 *----------------------------------------------------------------------
324 /* allow 5 simultaneous events, with path + filenames up to 64 chars */
325 #define BUFF_SIZE ((sizeof(struct inotify_event) + 64)*5)
326 static void handle_inotify_events(int fd
, int wd
)
328 extern void wDefaultsCheckDomains(void *);
329 ssize_t eventQLength
, i
= 0;
330 char buff
[BUFF_SIZE
] = { 0 };
331 /* Check config only once per read of the event queue */
335 * Read off the queued events
336 * queue overflow is not checked (IN_Q_OVERFLOW). In practise this should
337 * not occur; the block is on Xevents, but a config file change will normally
338 * occur as a result of an Xevent - so the event queue should never have more than
339 * a few entries before a read().
341 eventQLength
= read(fd
, buff
, BUFF_SIZE
);
343 /* check what events occured */
344 /* Should really check wd here too, but for now we only have one watch! */
345 while (i
< eventQLength
) {
346 struct inotify_event
*pevent
= (struct inotify_event
*)&buff
[i
];
349 * see inotify.h for event types.
351 if (pevent
->mask
& IN_DELETE_SELF
) {
352 wwarning(_("the defaults database has been deleted!"
353 " Restart Window Maker to create the database" " with the default settings"));
356 if (pevent
->mask
& IN_UNMOUNT
) {
357 wwarning(_("the unit containing the defaults database has"
358 " been unmounted. Setting --static mode." " Any changes will not be saved."));
360 wPreferences
.flags
.noupdates
= 1;
362 if ((pevent
->mask
& IN_MODIFY
) && oneShotFlag
== 0) {
363 wwarning(_("Inotify: Reading config files in defaults database."));
364 wDefaultsCheckDomains(NULL
);
367 /* move to next event in the buffer */
368 i
+= sizeof(struct inotify_event
) + pevent
->len
;
371 #endif /* HAVE_INOTIFY */
374 *----------------------------------------------------------------------
376 * Processes X and internal events indefinitely.
382 * The LastTimestamp global variable is updated.
383 * Calls inotifyGetEvents if defaults database changes.
384 *----------------------------------------------------------------------
390 extern int inotifyFD
;
391 extern int inotifyWD
;
396 if (inotifyFD
< 0 || inotifyWD
< 0)
402 WMNextEvent(dpy
, &event
); /* Blocks here */
403 WMHandleEvent(&event
);
409 FD_SET(inotifyFD
, &rfds
);
411 /* check for available read data from inotify - don't block! */
412 retVal
= select(inotifyFD
+ 1, &rfds
, NULL
, NULL
, &time
);
414 if (retVal
< 0) { /* an error has occured */
415 wwarning(_("select failed. The inotify instance will be closed."
416 " Changes to the defaults database will require"
417 " a restart to take effect."));
421 if (FD_ISSET(inotifyFD
, &rfds
))
422 handle_inotify_events(inotifyFD
, inotifyWD
);
429 *----------------------------------------------------------------------
430 * ProcessPendingEvents --
431 * Processes the events that are currently pending (at the time
432 * this function is called) in the display's queue.
435 * After the pending events that were present at the function call
439 * Many -- whatever handling events may involve.
441 *----------------------------------------------------------------------
443 void ProcessPendingEvents(void)
450 /* Take a snapshot of the event count in the queue */
451 count
= XPending(dpy
);
453 while (count
> 0 && XPending(dpy
)) {
454 WMNextEvent(dpy
, &event
);
455 WMHandleEvent(&event
);
460 Bool
IsDoubleClick(WScreen
* scr
, XEvent
* event
)
462 if ((scr
->last_click_time
> 0) &&
463 (event
->xbutton
.time
- scr
->last_click_time
<= wPreferences
.dblclick_time
)
464 && (event
->xbutton
.button
== scr
->last_click_button
)
465 && (event
->xbutton
.window
== scr
->last_click_window
)) {
467 scr
->flags
.next_click_is_not_double
= 1;
468 scr
->last_click_time
= 0;
469 scr
->last_click_window
= event
->xbutton
.window
;
476 void NotifyDeadProcess(pid_t pid
, unsigned char status
)
478 if (deadProcessPtr
>= MAX_DEAD_PROCESSES
- 1) {
479 wwarning("stack overflow: too many dead processes");
482 /* stack the process to be handled later,
483 * as this is called from the signal handler */
484 deadProcesses
[deadProcessPtr
].pid
= pid
;
485 deadProcesses
[deadProcessPtr
].exit_status
= status
;
489 static void handleDeadProcess(void *foo
)
494 for (i
= 0; i
< deadProcessPtr
; i
++) {
495 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
498 if (!deathHandlers
) {
503 /* get the pids on the queue and call handlers */
504 while (deadProcessPtr
> 0) {
507 for (i
= WMGetArrayItemCount(deathHandlers
) - 1; i
>= 0; i
--) {
508 tmp
= WMGetFromArray(deathHandlers
, i
);
512 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
513 (*tmp
->callback
) (tmp
->pid
,
514 deadProcesses
[deadProcessPtr
].exit_status
, tmp
->client_data
);
515 wdelete_death_handler(tmp
);
521 static void saveTimestamp(XEvent
* event
)
524 * Never save CurrentTime as LastTimestamp because CurrentTime
525 * it's not a real timestamp (it's the 0L constant)
528 switch (event
->type
) {
531 LastTimestamp
= event
->xbutton
.time
;
535 LastTimestamp
= event
->xkey
.time
;
538 LastTimestamp
= event
->xmotion
.time
;
541 LastTimestamp
= event
->xproperty
.time
;
545 LastTimestamp
= event
->xcrossing
.time
;
548 LastTimestamp
= event
->xselectionclear
.time
;
550 case SelectionRequest
:
551 LastTimestamp
= event
->xselectionrequest
.time
;
553 case SelectionNotify
:
554 LastTimestamp
= event
->xselection
.time
;
556 wXDNDProcessSelection(event
);
562 static int matchWindow(const void *item
, const void *cdata
)
564 return (((WFakeGroupLeader
*) item
)->origLeader
== (Window
) cdata
);
567 static void handleExtensions(XEvent
* event
)
569 #ifdef KEEP_XKB_LOCK_STATUS
571 xkbevent
= (XkbEvent
*) event
;
572 #endif /*KEEP_XKB_LOCK_STATUS */
574 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ ShapeNotify
)) {
575 handleShapeNotify(event
);
578 #ifdef KEEP_XKB_LOCK_STATUS
579 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)) {
580 handleXkbIndicatorStateNotify(event
);
582 #endif /*KEEP_XKB_LOCK_STATUS */
584 if (has_randr
&& event
->type
== (randr_event_base
+ RRScreenChangeNotify
)) {
585 /* From xrandr man page: "Clients must call back into Xlib using
586 * XRRUpdateConfiguration when screen configuration change notify
587 * events are generated */
588 XRRUpdateConfiguration(event
);
589 WCHANGE_STATE(WSTATE_RESTARTING
);
590 Shutdown(WSRestartPreparationMode
);
596 static void handleMapRequest(XEvent
* ev
)
600 Window window
= ev
->xmaprequest
.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
);
668 static void handleDestroyNotify(XEvent
* event
)
672 Window window
= event
->xdestroywindow
.window
;
673 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
676 wwin
= wWindowFor(window
);
678 wUnmanageWindow(wwin
, False
, True
);
682 while ((widx
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
, (void *)window
)) != WANotFound
) {
683 WFakeGroupLeader
*fPtr
;
685 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, widx
);
686 if (fPtr
->retainCount
> 0) {
688 if (fPtr
->retainCount
== 0 && fPtr
->leader
!= None
) {
689 XDestroyWindow(dpy
, fPtr
->leader
);
694 fPtr
->origLeader
= None
;
698 app
= wApplicationOf(window
);
700 if (window
== app
->main_window
) {
702 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
704 if (wwin
->main_window
== window
) {
705 wwin
->main_window
= None
;
710 wApplicationDestroy(app
);
714 static void handleExpose(XEvent
* event
)
716 WObjDescriptor
*desc
;
719 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
)) ;
721 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
725 if (desc
->handle_expose
) {
726 (*desc
->handle_expose
) (desc
, event
);
730 static void executeButtonAction(WScreen
* scr
, XEvent
* event
, int action
)
733 case WA_SELECT_WINDOWS
:
734 wUnselectWindows(scr
);
735 wSelectWindows(scr
, event
);
737 case WA_OPEN_APPMENU
:
738 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
740 if (scr
->root_menu
) {
741 if (scr
->root_menu
->brother
->flags
.mapped
)
742 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
744 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
747 case WA_OPEN_WINLISTMENU
:
748 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
749 if (scr
->switch_menu
) {
750 if (scr
->switch_menu
->brother
->flags
.mapped
)
751 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
753 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
762 static void handleButtonPress(XEvent
* event
)
764 WObjDescriptor
*desc
;
767 scr
= wScreenForRootWindow(event
->xbutton
.root
);
773 if (event
->xbutton
.window
== scr
->root_win
) {
774 if (event
->xbutton
.button
== Button1
&& wPreferences
.mouse_button1
!= WA_NONE
) {
775 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
776 } else if (event
->xbutton
.button
== Button2
&& wPreferences
.mouse_button2
!= WA_NONE
) {
777 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
778 } else if (event
->xbutton
.button
== Button3
&& wPreferences
.mouse_button3
!= WA_NONE
) {
779 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
780 } else if (event
->xbutton
.button
== Button4
&& wPreferences
.mouse_wheel
!= WA_NONE
) {
781 wWorkspaceRelativeChange(scr
, 1);
782 } else if (event
->xbutton
.button
== Button5
&& wPreferences
.mouse_wheel
!= WA_NONE
) {
783 wWorkspaceRelativeChange(scr
, -1);
788 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
789 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
794 if (desc
->parent_type
== WCLASS_WINDOW
) {
797 if (event
->xbutton
.state
& ( MOD_MASK
| ControlMask
)) {
798 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
800 /* if (wPreferences.focus_mode == WKF_CLICK) { */
801 if (wPreferences
.ignore_focus_click
) {
802 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
804 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
808 } else if (desc
->parent_type
== WCLASS_APPICON
809 || desc
->parent_type
== WCLASS_MINIWINDOW
|| desc
->parent_type
== WCLASS_DOCK_ICON
) {
810 if (event
->xbutton
.state
& MOD_MASK
) {
812 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
817 if (desc
->handle_mousedown
!= NULL
) {
818 (*desc
->handle_mousedown
) (desc
, event
);
821 /* save double-click information */
822 if (scr
->flags
.next_click_is_not_double
) {
823 scr
->flags
.next_click_is_not_double
= 0;
825 scr
->last_click_time
= event
->xbutton
.time
;
826 scr
->last_click_button
= event
->xbutton
.button
;
827 scr
->last_click_window
= event
->xbutton
.window
;
831 static void handleMapNotify(XEvent
* event
)
835 wwin
= wWindowFor(event
->xmap
.event
);
836 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
837 if (wwin
->flags
.miniaturized
) {
838 wDeiconifyWindow(wwin
);
842 wClientSetState(wwin
, NormalState
, None
);
848 static void handleUnmapNotify(XEvent
* event
)
852 Bool withdraw
= False
;
854 /* only process windows with StructureNotify selected
855 * (ignore SubstructureNotify) */
856 wwin
= wWindowFor(event
->xunmap
.window
);
860 /* whether the event is a Withdrawal request */
861 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
&& event
->xunmap
.send_event
)
864 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
867 if (!wwin
->flags
.mapped
&& !withdraw
868 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
869 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
873 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
874 wwin
->flags
.mapped
= 0;
876 /* check if the window was destroyed */
877 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
, &ev
)) {
880 Bool reparented
= False
;
882 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
885 /* withdraw window */
886 wwin
->flags
.mapped
= 0;
888 wClientSetState(wwin
, WithdrawnState
, None
);
890 /* if the window was reparented, do not reparent it back to the
892 wUnmanageWindow(wwin
, !reparented
, False
);
897 static void handleConfigureRequest(XEvent
* event
)
901 if (!(wwin
= wWindowFor(event
->xconfigurerequest
.window
))) {
903 * Configure request for unmapped window
905 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
907 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
911 static void handlePropertyNotify(XEvent
* event
)
919 wwin
= wWindowFor(event
->xproperty
.window
);
921 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
, &ju
, &ju
, &ju
, &ju
)) {
924 wClientCheckProperty(wwin
, &event
->xproperty
);
926 wapp
= wApplicationOf(event
->xproperty
.window
);
928 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
932 static void handleClientMessage(XEvent
* event
)
935 WObjDescriptor
*desc
;
937 /* handle transition from Normal to Iconic state */
938 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
939 && event
->xclient
.format
== 32 && event
->xclient
.data
.l
[0] == IconicState
) {
941 wwin
= wWindowFor(event
->xclient
.window
);
944 if (!wwin
->flags
.miniaturized
)
945 wIconifyWindow(wwin
);
946 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
&& event
->xclient
.format
== 32) {
947 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
952 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
953 wColormapAllowClientInstallation(scr
, True
);
954 } else { /* stopping */
955 wColormapAllowClientInstallation(scr
, False
);
957 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
962 len
= sizeof(event
->xclient
.data
.b
) + 1;
963 command
= wmalloc(len
);
964 strncpy(command
, event
->xclient
.data
.b
, sizeof(event
->xclient
.data
.b
));
966 if (strncmp(command
, "Reconfigure", sizeof("Reconfigure")) == 0) {
967 wwarning(_("Got Reconfigure command"));
968 wDefaultsCheckDomains(NULL
);
970 wwarning(_("Got unknown command %s"), command
);
975 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
978 wapp
= wApplicationOf(event
->xclient
.window
);
980 switch (event
->xclient
.data
.l
[0]) {
981 case WMFHideOtherApplications
:
982 wHideOtherApplications(wapp
->main_window_desc
);
986 case WMFHideApplication
:
987 wHideApplication(wapp
);
993 wwin
= wWindowFor(event
->xclient
.window
);
995 switch (event
->xclient
.data
.l
[0]) {
996 case WMFHideOtherApplications
:
997 wHideOtherApplications(wwin
);
1000 case WMFHideApplication
:
1001 wHideApplication(wApplicationOf(wwin
->main_window
));
1006 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
1007 wwin
= wWindowFor(event
->xclient
.window
);
1010 switch (event
->xclient
.data
.l
[0]) {
1011 case GSWindowLevelAttr
:
1013 int level
= (int)event
->xclient
.data
.l
[1];
1015 if (WINDOW_LEVEL(wwin
) != level
) {
1016 ChangeStackingLevel(wwin
->frame
->core
, level
);
1021 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
1022 wwin
= wWindowFor(event
->xclient
.window
);
1025 switch (event
->xclient
.data
.l
[0]) {
1026 case WMTitleBarNormal
:
1027 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1029 case WMTitleBarMain
:
1030 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
1033 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1036 } else if (event
->xclient
.message_type
== _XA_WM_IGNORE_FOCUS_EVENTS
) {
1037 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
1040 scr
->flags
.ignore_focus_events
= event
->xclient
.data
.l
[0] ? 1 : 0;
1041 } else if (wNETWMProcessClientMessage(&event
->xclient
)) {
1044 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
1049 * Non-standard thing, but needed by OffiX DND.
1050 * For when the icon frame gets a ClientMessage
1051 * that should have gone to the icon_window.
1053 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1054 struct WIcon
*icon
= NULL
;
1056 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
1057 icon
= (WIcon
*) desc
->parent
;
1058 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
|| desc
->parent_type
== WCLASS_APPICON
) {
1059 icon
= ((WAppIcon
*) desc
->parent
)->icon
;
1061 if (icon
&& (wwin
= icon
->owner
)) {
1062 if (wwin
->client_win
!= event
->xclient
.window
) {
1063 event
->xclient
.window
= wwin
->client_win
;
1064 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
, event
);
1071 static void raiseWindow(WScreen
* scr
)
1075 scr
->autoRaiseTimer
= NULL
;
1077 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1081 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1082 wRaiseFrame(wwin
->frame
->core
);
1083 /* this is needed or a race condition will occur */
1088 static void handleEnterNotify(XEvent
* event
)
1091 WObjDescriptor
*desc
= NULL
;
1093 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1095 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
, &ev
)) {
1096 /* already left the window... */
1098 if (ev
.xcrossing
.mode
== event
->xcrossing
.mode
&& ev
.xcrossing
.detail
== event
->xcrossing
.detail
) {
1103 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1104 if (desc
->handle_enternotify
)
1105 (*desc
->handle_enternotify
) (desc
, event
);
1108 /* enter to window */
1109 wwin
= wWindowFor(event
->xcrossing
.window
);
1111 if (wPreferences
.colormap_mode
== WCM_POINTER
) {
1112 wColormapInstallForWindow(scr
, NULL
);
1114 if (scr
->autoRaiseTimer
&& event
->xcrossing
.root
== event
->xcrossing
.window
) {
1115 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1116 scr
->autoRaiseTimer
= NULL
;
1119 /* set auto raise timer even if in focus-follows-mouse mode
1120 * and the event is for the frame window, even if the window
1121 * has focus already. useful if you move the pointer from a focused
1122 * window to the root window and back pretty fast
1124 * set focus if in focus-follows-mouse mode and the event
1125 * is for the frame window and window doesn't have focus yet */
1126 if (wPreferences
.focus_mode
== WKF_SLOPPY
1127 && wwin
->frame
->core
->window
== event
->xcrossing
.window
&& !scr
->flags
.doing_alt_tab
) {
1129 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1130 wSetFocusTo(scr
, wwin
);
1132 if (scr
->autoRaiseTimer
)
1133 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1134 scr
->autoRaiseTimer
= NULL
;
1136 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1137 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1139 = WMAddTimerHandler(wPreferences
.raise_delay
, (WMCallback
*) raiseWindow
, scr
);
1142 /* Install colormap for window, if the colormap installation mode
1143 * is colormap_follows_mouse */
1144 if (wPreferences
.colormap_mode
== WCM_POINTER
) {
1145 if (wwin
->client_win
== event
->xcrossing
.window
)
1146 wColormapInstallForWindow(scr
, wwin
);
1148 wColormapInstallForWindow(scr
, NULL
);
1152 if (event
->xcrossing
.window
== event
->xcrossing
.root
1153 && event
->xcrossing
.detail
== NotifyNormal
1154 && event
->xcrossing
.detail
!= NotifyInferior
&& wPreferences
.focus_mode
!= WKF_CLICK
) {
1156 wSetFocusTo(scr
, scr
->focused_window
);
1159 wBalloonEnteredObject(scr
, desc
);
1163 static void handleLeaveNotify(XEvent
* event
)
1165 WObjDescriptor
*desc
= NULL
;
1167 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1168 if (desc
->handle_leavenotify
)
1169 (*desc
->handle_leavenotify
) (desc
, event
);
1174 static void handleShapeNotify(XEvent
* event
)
1176 XShapeEvent
*shev
= (XShapeEvent
*) event
;
1183 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
.xevent
)) {
1184 if (ev
.xshape
.kind
== ShapeBounding
) {
1185 if (ev
.xshape
.shaped
== shev
->shaped
) {
1188 XPutBackEvent(dpy
, &ev
.xevent
);
1194 wwin
= wWindowFor(shev
->window
);
1195 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1198 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1200 wwin
->flags
.shaped
= 0;
1201 wWindowClearShape(wwin
);
1203 } else if (shev
->shaped
) {
1205 wwin
->flags
.shaped
= 1;
1206 wWindowSetShape(wwin
);
1211 #ifdef KEEP_XKB_LOCK_STATUS
1212 /* please help ]d if you know what to do */
1213 static void handleXkbIndicatorStateNotify(XEvent
*event
)
1217 XkbStateRec staterec
;
1220 for (i
= 0; i
< wScreenCount
; i
++) {
1221 scr
= wScreenWithNumber(i
);
1222 wwin
= scr
->focused_window
;
1223 if (wwin
&& wwin
->flags
.focused
) {
1224 XkbGetState(dpy
, XkbUseCoreKbd
, &staterec
);
1225 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1226 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1227 wwin
->frame
->languagemode
= staterec
.group
;
1229 #ifdef XKB_BUTTON_HINT
1230 if (wwin
->frame
->titlebar
) {
1231 wFrameWindowPaint(wwin
->frame
);
1237 #endif /*KEEP_XKB_LOCK_STATUS */
1239 static void handleColormapNotify(XEvent
* event
)
1243 Bool reinstall
= False
;
1245 wwin
= wWindowFor(event
->xcolormap
.window
);
1249 scr
= wwin
->screen_ptr
;
1253 if (event
->xcolormap
.new) {
1254 XWindowAttributes attr
;
1256 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1258 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1259 scr
->current_colormap
= attr
.colormap
;
1262 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1263 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1265 /* some bastard app (like XV) removed our colormap */
1267 * can't enforce or things like xscreensaver wont work
1270 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1271 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1273 /* someone has put our colormap back */
1277 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1278 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1280 if (reinstall
&& scr
->current_colormap
!= None
) {
1281 if (!scr
->flags
.colormap_stuff_blocked
)
1282 XInstallColormap(dpy
, scr
->current_colormap
);
1286 static void handleFocusIn(XEvent
* event
)
1291 * For applications that like stealing the focus.
1293 while (XCheckTypedEvent(dpy
, FocusIn
, event
)) ;
1294 saveTimestamp(event
);
1295 if (event
->xfocus
.mode
== NotifyUngrab
1296 || event
->xfocus
.mode
== NotifyGrab
|| event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1300 wwin
= wWindowFor(event
->xfocus
.window
);
1301 if (wwin
&& !wwin
->flags
.focused
) {
1302 if (wwin
->flags
.mapped
)
1303 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1305 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1307 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1309 wSetFocusTo(scr
, NULL
);
1313 static WWindow
*windowUnderPointer(WScreen
* scr
)
1319 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
, &mask
))
1320 return wWindowFor(win
);
1324 static int CheckFullScreenWindowFocused(WScreen
* scr
)
1326 if (scr
->focused_window
&& scr
->focused_window
->flags
.fullscreen
)
1332 static void handleKeyPress(XEvent
* event
)
1334 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1335 WWindow
*wwin
= scr
->focused_window
;
1339 #ifdef KEEP_XKB_LOCK_STATUS
1340 XkbStateRec staterec
;
1341 #endif /*KEEP_XKB_LOCK_STATUS */
1343 /* ignore CapsLock */
1344 modifiers
= event
->xkey
.state
& ValidModMask
;
1346 for (i
= 0; i
< WKBD_LAST
; i
++) {
1347 if (wKeyBindings
[i
].keycode
== 0)
1350 if (wKeyBindings
[i
].keycode
== event
->xkey
.keycode
&& ( /*wKeyBindings[i].modifier==0
1351 || */ wKeyBindings
[i
].modifier
==
1360 if (!wRootMenuPerformShortcut(event
)) {
1361 static int dontLoop
= 0;
1363 if (dontLoop
> 10) {
1364 wwarning("problem with key event processing code");
1368 /* if the focused window is an internal window, try redispatching
1369 * the event to the managed window, as it can be a WINGs window */
1370 if (wwin
&& wwin
->flags
.internal_window
&& wwin
->client_leader
!= None
) {
1371 /* client_leader contains the WINGs toplevel */
1372 event
->xany
.window
= wwin
->client_leader
;
1373 WMHandleEvent(event
);
1379 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1380 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1385 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True); */
1386 if (!CheckFullScreenWindowFocused(scr
)) {
1387 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1388 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2, rect
.pos
.y
+ rect
.size
.height
/ 2,
1392 case WKBD_WINDOWLIST
:
1393 if (!CheckFullScreenWindowFocused(scr
)) {
1394 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1395 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2, rect
.pos
.y
+ rect
.size
.height
/ 2,
1400 case WKBD_WINDOWMENU
:
1401 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1402 OpenWindowMenu(wwin
, wwin
->frame_x
, wwin
->frame_y
+ wwin
->frame
->top_width
, True
);
1404 case WKBD_MINIMIZEALL
:
1405 CloseWindowMenu(scr
);
1408 case WKBD_MINIATURIZE
:
1409 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1410 && !WFLAGP(wwin
, no_miniaturizable
)) {
1411 CloseWindowMenu(scr
);
1413 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1414 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
, event
->xbutton
.time
);
1416 wIconifyWindow(wwin
);
1421 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1422 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1423 CloseWindowMenu(scr
);
1425 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1426 wHideApplication(wapp
);
1430 case WKBD_HIDE_OTHERS
:
1431 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1432 CloseWindowMenu(scr
);
1434 wHideOtherApplications(wwin
);
1438 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1439 CloseWindowMenu(scr
);
1441 handleMaximize(wwin
, MAX_VERTICAL
| MAX_HORIZONTAL
| MAX_KEYBOARD
);
1444 case WKBD_VMAXIMIZE
:
1445 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1446 CloseWindowMenu(scr
);
1448 handleMaximize(wwin
, MAX_VERTICAL
| MAX_KEYBOARD
);
1451 case WKBD_HMAXIMIZE
:
1452 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1453 CloseWindowMenu(scr
);
1455 handleMaximize(wwin
, MAX_HORIZONTAL
| MAX_KEYBOARD
);
1458 case WKBD_LHMAXIMIZE
:
1459 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1460 CloseWindowMenu(scr
);
1462 handleMaximize(wwin
, MAX_VERTICAL
| MAX_LEFTHALF
| MAX_KEYBOARD
);
1465 case WKBD_RHMAXIMIZE
:
1466 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1467 CloseWindowMenu(scr
);
1469 handleMaximize(wwin
, MAX_VERTICAL
| MAX_RIGHTHALF
| MAX_KEYBOARD
);
1473 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1474 CloseWindowMenu(scr
);
1476 handleMaximize(wwin
, MAX_MAXIMUS
| MAX_KEYBOARD
);
1480 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1481 CloseWindowMenu(scr
);
1483 wRaiseFrame(wwin
->frame
->core
);
1487 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1488 CloseWindowMenu(scr
);
1490 wLowerFrame(wwin
->frame
->core
);
1493 case WKBD_RAISELOWER
:
1494 /* raise or lower the window under the pointer, not the
1497 wwin
= windowUnderPointer(scr
);
1499 wRaiseLowerFrame(wwin
->frame
->core
);
1502 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1503 if (wwin
->flags
.shaded
)
1504 wUnshadeWindow(wwin
);
1509 case WKBD_MOVERESIZE
:
1510 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && (IS_RESIZABLE(wwin
) || IS_MOVABLE(wwin
))) {
1511 CloseWindowMenu(scr
);
1513 wKeyboardMoveResizeWindow(wwin
);
1517 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1518 CloseWindowMenu(scr
);
1519 if (wwin
->protocols
.DELETE_WINDOW
)
1520 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, event
->xkey
.time
);
1524 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1525 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1528 case WKBD_FOCUSNEXT
:
1529 StartWindozeCycle(wwin
, event
, True
, False
);
1532 case WKBD_FOCUSPREV
:
1533 StartWindozeCycle(wwin
, event
, False
, False
);
1536 case WKBD_GROUPNEXT
:
1537 StartWindozeCycle(wwin
, event
, True
, True
);
1540 case WKBD_GROUPPREV
:
1541 StartWindozeCycle(wwin
, event
, False
, True
);
1544 case WKBD_WORKSPACE1
... WKBD_WORKSPACE10
:
1545 widx
= command
- WKBD_WORKSPACE1
;
1546 i
= (scr
->current_workspace
/ 10) * 10 + widx
;
1547 if (wPreferences
.ws_advance
|| i
< scr
->workspace_count
)
1548 wWorkspaceChange(scr
, i
);
1551 case WKBD_NEXTWORKSPACE
:
1552 wWorkspaceRelativeChange(scr
, 1);
1554 case WKBD_PREVWORKSPACE
:
1555 wWorkspaceRelativeChange(scr
, -1);
1569 widx
= command
- WKBD_WINDOW1
;
1571 if (scr
->shortcutWindows
[widx
]) {
1572 WMArray
*list
= scr
->shortcutWindows
[widx
];
1574 int count
= WMGetArrayItemCount(list
);
1576 WMArrayIterator iter
;
1579 wUnselectWindows(scr
);
1580 cw
= scr
->current_workspace
;
1582 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1584 wWindowChangeWorkspace(wwin
, cw
);
1586 wMakeWindowVisible(wwin
);
1589 wSelectWindow(wwin
, True
);
1592 /* rotate the order of windows, to create a cycling effect */
1593 twin
= WMGetFromArray(list
, 0);
1594 WMDeleteFromArray(list
, 0);
1595 WMAddToArray(list
, twin
);
1597 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1598 if (scr
->shortcutWindows
[widx
]) {
1599 WMFreeArray(scr
->shortcutWindows
[widx
]);
1600 scr
->shortcutWindows
[widx
] = NULL
;
1603 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1604 scr
->shortcutWindows
[widx
] = WMDuplicateArray(scr
->selected_windows
);
1605 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1606 WMInsertInArray(scr->shortcutWindows[index], 0, wwin); */
1608 scr
->shortcutWindows
[widx
] = WMCreateArray(4);
1609 WMAddToArray(scr
->shortcutWindows
[widx
], wwin
);
1612 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1615 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1618 } else if (scr
->selected_windows
&& WMGetArrayItemCount(scr
->selected_windows
)) {
1620 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1621 if (scr
->shortcutWindows
[widx
]) {
1622 WMFreeArray(scr
->shortcutWindows
[widx
]);
1624 scr
->shortcutWindows
[widx
] = WMDuplicateArray(scr
->selected_windows
);
1631 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1632 (void) RelaunchWindow(wwin
);
1636 case WKBD_SWITCH_SCREEN
:
1637 if (wScreenCount
> 1) {
1641 /* find index of this screen */
1642 for (i
= 0; i
< wScreenCount
; i
++) {
1643 if (wScreenWithNumber(i
) == scr
)
1647 if (i
>= wScreenCount
) {
1650 scr2
= wScreenWithNumber(i
);
1653 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1654 scr2
->scr_width
/ 2, scr2
->scr_height
/ 2);
1659 case WKBD_NEXTWSLAYER
:
1660 case WKBD_PREVWSLAYER
:
1664 row
= scr
->current_workspace
/ 10;
1665 column
= scr
->current_workspace
% 10;
1667 if (command
== WKBD_NEXTWSLAYER
) {
1668 if ((row
+ 1) * 10 < scr
->workspace_count
)
1669 wWorkspaceChange(scr
, column
+ (row
+ 1) * 10);
1672 wWorkspaceChange(scr
, column
+ (row
- 1) * 10);
1676 case WKBD_CLIPRAISELOWER
:
1677 if (!wPreferences
.flags
.noclip
)
1678 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1680 case WKBD_DOCKRAISELOWER
:
1681 if (!wPreferences
.flags
.nodock
)
1682 wDockRaiseLower(scr
->dock
);
1684 #ifdef KEEP_XKB_LOCK_STATUS
1686 if (wPreferences
.modelock
) {
1688 wwin
= scr
->focused_window
;
1690 if (wwin
&& wwin
->flags
.mapped
1691 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1692 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1693 XkbGetState(dpy
, XkbUseCoreKbd
, &staterec
);
1695 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1696 wwin
->frame
->last_languagemode
= staterec
.group
;
1697 XkbLockGroup(dpy
, XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1702 #endif /* KEEP_XKB_LOCK_STATUS */
1706 static void handleMotionNotify(XEvent
* event
)
1708 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1710 if (wPreferences
.scrollable_menus
) {
1711 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1712 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1714 if (scr
->flags
.jump_back_pending
||
1715 p
.x
<= (rect
.pos
.x
+ 1) ||
1716 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1717 p
.y
<= (rect
.pos
.y
+ 1) || p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1720 menu
= wMenuUnderPointer(scr
);
1722 wMenuScroll(menu
, event
);
1727 static void handleVisibilityNotify(XEvent
* event
)
1731 wwin
= wWindowFor(event
->xvisibility
.window
);
1734 wwin
->flags
.obscured
= (event
->xvisibility
.state
== VisibilityFullyObscured
);