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"
72 /******** Global Variables **********/
73 extern XContext wWinContext
;
74 extern XContext wVEdgeContext
;
76 extern Cursor wCursor
[WCUR_LAST
];
78 extern WShortKey wKeyBindings
[WKBD_LAST
];
79 extern int wScreenCount
;
80 extern Time LastTimestamp
;
81 extern Time LastFocusChange
;
83 extern WPreferences wPreferences
;
85 #define MOD_MASK wPreferences.modifier_mask
87 extern Atom _XA_WM_COLORMAP_NOTIFY
;
89 extern Atom _XA_WM_CHANGE_STATE
;
90 extern Atom _XA_WM_DELETE_WINDOW
;
91 extern Atom _XA_GNUSTEP_WM_ATTR
;
92 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
93 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
94 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
95 extern Atom _XA_WINDOWMAKER_COMMAND
;
96 extern Atom _XA_WM_IGNORE_FOCUS_EVENTS
;
99 extern Bool wShapeSupported
;
100 extern int wShapeEventBase
;
103 #ifdef KEEP_XKB_LOCK_STATUS
104 extern int wXkbEventBase
;
108 extern Bool has_randr
;
109 extern int randr_event_base
;
113 /*extern char WDelayedActionSet;*/
115 /************ Local stuff ***********/
117 static void saveTimestamp(XEvent
*event
);
118 static void handleColormapNotify(XEvent
*event
);
119 static void handleMapNotify(XEvent
*event
);
120 static void handleUnmapNotify(XEvent
*event
);
121 static void handleButtonPress(XEvent
*event
);
122 static void handleExpose(XEvent
*event
);
123 static void handleDestroyNotify(XEvent
*event
);
124 static void handleConfigureRequest(XEvent
*event
);
125 static void handleMapRequest(XEvent
*event
);
126 static void handlePropertyNotify(XEvent
*event
);
127 static void handleEnterNotify(XEvent
*event
);
128 static void handleLeaveNotify(XEvent
*event
);
129 static void handleExtensions(XEvent
*event
);
130 static void handleClientMessage(XEvent
*event
);
131 static void handleKeyPress(XEvent
*event
);
132 static void handleFocusIn(XEvent
*event
);
133 static void handleMotionNotify(XEvent
*event
);
134 static void handleVisibilityNotify(XEvent
*event
);
135 static void handle_inotify_events(int fd
, int wd
);
136 static void wdelete_death_handler(WMagicNumber id
);
140 static void handleShapeNotify(XEvent
*event
);
143 #ifdef KEEP_XKB_LOCK_STATUS
144 static void handleXkbIndicatorStateNotify(XEvent
*event
);
147 /* called from the signal handler */
148 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
150 /* real dead process handler */
151 static void handleDeadProcess(void *foo
);
153 typedef struct DeadProcesses
{
155 unsigned char exit_status
;
158 /* stack of dead processes */
159 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
160 static int deadProcessPtr
= 0;
162 typedef struct DeathHandler
{
163 WDeathHandler
*callback
;
168 static WMArray
*deathHandlers
= NULL
;
170 WMagicNumber
wAddDeathHandler(pid_t pid
, WDeathHandler
* callback
, void *cdata
)
172 DeathHandler
*handler
;
174 handler
= malloc(sizeof(DeathHandler
));
179 handler
->callback
= callback
;
180 handler
->client_data
= cdata
;
183 deathHandlers
= WMCreateArrayWithDestructor(8, free
);
185 WMAddToArray(deathHandlers
, handler
);
190 static void wdelete_death_handler(WMagicNumber id
)
192 DeathHandler
*handler
= (DeathHandler
*) id
;
194 if (!handler
|| !deathHandlers
)
197 /* array destructor will call free(handler) */
198 WMRemoveFromArray(deathHandlers
, handler
);
201 void DispatchEvent(XEvent
* event
)
204 handleDeadProcess(NULL
);
206 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
207 WCHANGE_STATE(WSTATE_EXITING
);
208 /* received SIGTERM */
210 * WMHandleEvent() can't be called from anything
211 * executed inside here, or we can get in a infinite
214 Shutdown(WSExitMode
);
216 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
217 WCHANGE_STATE(WSTATE_RESTARTING
);
219 Shutdown(WSRestartPreparationMode
);
220 /* received SIGHUP */
222 } else if (WCHECK_STATE(WSTATE_NEED_REREAD
)) {
223 WCHANGE_STATE(WSTATE_NORMAL
);
224 wDefaultsCheckDomains(NULL
);
227 /* for the case that all that is wanted to be dispatched is
232 saveTimestamp(event
);
233 switch (event
->type
) {
235 handleMapRequest(event
);
239 handleKeyPress(event
);
243 handleMotionNotify(event
);
246 case ConfigureRequest
:
247 handleConfigureRequest(event
);
251 handleDestroyNotify(event
);
255 handleMapNotify(event
);
259 handleUnmapNotify(event
);
263 handleButtonPress(event
);
271 handlePropertyNotify(event
);
275 handleEnterNotify(event
);
279 handleLeaveNotify(event
);
283 handleClientMessage(event
);
287 handleColormapNotify(event
);
291 if (event
->xmapping
.request
== MappingKeyboard
|| event
->xmapping
.request
== MappingModifier
)
292 XRefreshKeyboardMapping(&event
->xmapping
);
296 handleFocusIn(event
);
299 case VisibilityNotify
:
300 handleVisibilityNotify(event
);
303 case ConfigureNotify
:
304 if (event
->xconfigure
.window
== DefaultRootWindow(dpy
)) {
306 XRRUpdateConfiguration(event
);
312 handleExtensions(event
);
319 *----------------------------------------------------------------------
320 * handle_inotify_events-
321 * Check for inotify events
324 * After reading events for the given file descriptor (fd) and
325 * watch descriptor (wd)
328 * Calls wDefaultsCheckDomains if config database is updated
329 *----------------------------------------------------------------------
331 /* allow 5 simultaneous events, with path + filenames up to 64 chars */
332 #define BUFF_SIZE ((sizeof(struct inotify_event) + 64)*5)
333 static void handle_inotify_events(int fd
, int wd
)
335 extern void wDefaultsCheckDomains(void *);
336 ssize_t eventQLength
, i
= 0;
337 char buff
[BUFF_SIZE
] = { 0 };
338 /* Check config only once per read of the event queue */
342 * Read off the queued events
343 * queue overflow is not checked (IN_Q_OVERFLOW). In practise this should
344 * not occur; the block is on Xevents, but a config file change will normally
345 * occur as a result of an Xevent - so the event queue should never have more than
346 * a few entries before a read().
348 eventQLength
= read(fd
, buff
, BUFF_SIZE
);
350 /* check what events occured */
351 /* Should really check wd here too, but for now we only have one watch! */
352 while (i
< eventQLength
) {
353 struct inotify_event
*pevent
= (struct inotify_event
*)&buff
[i
];
356 * see inotify.h for event types.
358 if (pevent
->mask
& IN_DELETE_SELF
) {
359 wwarning(_("the defaults database has been deleted!"
360 " Restart Window Maker to create the database" " with the default settings"));
363 if (pevent
->mask
& IN_UNMOUNT
) {
364 wwarning(_("the unit containing the defaults database has"
365 " been unmounted. Setting --static mode." " Any changes will not be saved."));
367 wPreferences
.flags
.noupdates
= 1;
369 if ((pevent
->mask
& IN_MODIFY
) && oneShotFlag
== 0) {
370 wwarning(_("Inotify: Reading config files in defaults database."));
371 wDefaultsCheckDomains(NULL
);
374 /* move to next event in the buffer */
375 i
+= sizeof(struct inotify_event
) + pevent
->len
;
378 #endif /* HAVE_INOTIFY */
381 *----------------------------------------------------------------------
383 * Processes X and internal events indefinitely.
389 * The LastTimestamp global variable is updated.
390 * Calls inotifyGetEvents if defaults database changes.
391 *----------------------------------------------------------------------
397 extern int inotifyFD
;
398 extern int inotifyWD
;
403 if (inotifyFD
< 0 || inotifyWD
< 0)
409 WMNextEvent(dpy
, &event
); /* Blocks here */
410 WMHandleEvent(&event
);
416 FD_SET(inotifyFD
, &rfds
);
418 /* check for available read data from inotify - don't block! */
419 retVal
= select(inotifyFD
+ 1, &rfds
, NULL
, NULL
, &time
);
421 if (retVal
< 0) { /* an error has occured */
422 wwarning(_("select failed. The inotify instance will be closed."
423 " Changes to the defaults database will require"
424 " a restart to take effect."));
428 if (FD_ISSET(inotifyFD
, &rfds
))
429 handle_inotify_events(inotifyFD
, inotifyWD
);
436 *----------------------------------------------------------------------
437 * ProcessPendingEvents --
438 * Processes the events that are currently pending (at the time
439 * this function is called) in the display's queue.
442 * After the pending events that were present at the function call
446 * Many -- whatever handling events may involve.
448 *----------------------------------------------------------------------
450 void ProcessPendingEvents(void)
457 /* Take a snapshot of the event count in the queue */
458 count
= XPending(dpy
);
460 while (count
> 0 && XPending(dpy
)) {
461 WMNextEvent(dpy
, &event
);
462 WMHandleEvent(&event
);
467 Bool
IsDoubleClick(WScreen
* scr
, XEvent
* event
)
469 if ((scr
->last_click_time
> 0) &&
470 (event
->xbutton
.time
- scr
->last_click_time
<= wPreferences
.dblclick_time
)
471 && (event
->xbutton
.button
== scr
->last_click_button
)
472 && (event
->xbutton
.window
== scr
->last_click_window
)) {
474 scr
->flags
.next_click_is_not_double
= 1;
475 scr
->last_click_time
= 0;
476 scr
->last_click_window
= event
->xbutton
.window
;
483 void NotifyDeadProcess(pid_t pid
, unsigned char status
)
485 if (deadProcessPtr
>= MAX_DEAD_PROCESSES
- 1) {
486 wwarning("stack overflow: too many dead processes");
489 /* stack the process to be handled later,
490 * as this is called from the signal handler */
491 deadProcesses
[deadProcessPtr
].pid
= pid
;
492 deadProcesses
[deadProcessPtr
].exit_status
= status
;
496 static void handleDeadProcess(void *foo
)
501 for (i
= 0; i
< deadProcessPtr
; i
++) {
502 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
505 if (!deathHandlers
) {
510 /* get the pids on the queue and call handlers */
511 while (deadProcessPtr
> 0) {
514 for (i
= WMGetArrayItemCount(deathHandlers
) - 1; i
>= 0; i
--) {
515 tmp
= WMGetFromArray(deathHandlers
, i
);
519 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
520 (*tmp
->callback
) (tmp
->pid
,
521 deadProcesses
[deadProcessPtr
].exit_status
, tmp
->client_data
);
522 wdelete_death_handler(tmp
);
528 static void saveTimestamp(XEvent
* event
)
531 * Never save CurrentTime as LastTimestamp because CurrentTime
532 * it's not a real timestamp (it's the 0L constant)
535 switch (event
->type
) {
538 LastTimestamp
= event
->xbutton
.time
;
542 LastTimestamp
= event
->xkey
.time
;
545 LastTimestamp
= event
->xmotion
.time
;
548 LastTimestamp
= event
->xproperty
.time
;
552 LastTimestamp
= event
->xcrossing
.time
;
555 LastTimestamp
= event
->xselectionclear
.time
;
557 case SelectionRequest
:
558 LastTimestamp
= event
->xselectionrequest
.time
;
560 case SelectionNotify
:
561 LastTimestamp
= event
->xselection
.time
;
563 wXDNDProcessSelection(event
);
569 static int matchWindow(const void *item
, const void *cdata
)
571 return (((WFakeGroupLeader
*) item
)->origLeader
== (Window
) cdata
);
574 static void handleExtensions(XEvent
* event
)
576 #ifdef KEEP_XKB_LOCK_STATUS
578 xkbevent
= (XkbEvent
*) event
;
579 #endif /*KEEP_XKB_LOCK_STATUS */
581 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ ShapeNotify
)) {
582 handleShapeNotify(event
);
585 #ifdef KEEP_XKB_LOCK_STATUS
586 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)) {
587 handleXkbIndicatorStateNotify(event
);
589 #endif /*KEEP_XKB_LOCK_STATUS */
591 if (has_randr
&& event
->type
== (randr_event_base
+ RRScreenChangeNotify
)) {
592 /* From xrandr man page: "Clients must call back into Xlib using
593 * XRRUpdateConfiguration when screen configuration change notify
594 * events are generated */
595 XRRUpdateConfiguration(event
);
596 WCHANGE_STATE(WSTATE_RESTARTING
);
597 Shutdown(WSRestartPreparationMode
);
603 static void handleMapRequest(XEvent
* ev
)
607 Window window
= ev
->xmaprequest
.window
;
609 if ((wwin
= wWindowFor(window
))) {
610 if (wwin
->flags
.shaded
) {
611 wUnshadeWindow(wwin
);
613 /* deiconify window */
614 if (wwin
->flags
.miniaturized
) {
615 wDeiconifyWindow(wwin
);
616 } else if (wwin
->flags
.hidden
) {
617 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
618 /* go to the last workspace that the user worked on the app */
620 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
622 wUnhideApplication(wapp
, False
, False
);
627 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
629 wwin
= wManageWindow(scr
, window
);
632 * This is to let the Dock know that the application it launched
633 * has already been mapped (eg: it has finished launching).
634 * It is not necessary for normally docked apps, but is needed for
635 * apps that were forcedly docked (like with dockit).
637 if (scr
->last_dock
) {
638 if (wwin
&& wwin
->main_window
!= None
&& wwin
->main_window
!= window
)
639 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
641 wDockTrackWindowLaunch(scr
->last_dock
, window
);
645 wClientSetState(wwin
, NormalState
, None
);
646 if (wwin
->flags
.maximized
) {
647 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
649 if (wwin
->flags
.shaded
) {
650 wwin
->flags
.shaded
= 0;
651 wwin
->flags
.skip_next_animation
= 1;
654 if (wwin
->flags
.miniaturized
) {
655 wwin
->flags
.miniaturized
= 0;
656 wwin
->flags
.skip_next_animation
= 1;
657 wIconifyWindow(wwin
);
659 if (wwin
->flags
.fullscreen
) {
660 wwin
->flags
.fullscreen
= 0;
661 wFullscreenWindow(wwin
);
663 if (wwin
->flags
.hidden
) {
664 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
666 wwin
->flags
.hidden
= 0;
667 wwin
->flags
.skip_next_animation
= 1;
669 wHideApplication(wapp
);
675 static void handleDestroyNotify(XEvent
* event
)
679 Window window
= event
->xdestroywindow
.window
;
680 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
683 wwin
= wWindowFor(window
);
685 wUnmanageWindow(wwin
, False
, True
);
689 while ((widx
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
, (void *)window
)) != WANotFound
) {
690 WFakeGroupLeader
*fPtr
;
692 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, widx
);
693 if (fPtr
->retainCount
> 0) {
695 if (fPtr
->retainCount
== 0 && fPtr
->leader
!= None
) {
696 XDestroyWindow(dpy
, fPtr
->leader
);
701 fPtr
->origLeader
= None
;
705 app
= wApplicationOf(window
);
707 if (window
== app
->main_window
) {
709 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
711 if (wwin
->main_window
== window
) {
712 wwin
->main_window
= None
;
717 wApplicationDestroy(app
);
721 static void handleExpose(XEvent
* event
)
723 WObjDescriptor
*desc
;
726 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
)) ;
728 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
732 if (desc
->handle_expose
) {
733 (*desc
->handle_expose
) (desc
, event
);
737 static void executeButtonAction(WScreen
* scr
, XEvent
* event
, int action
)
740 case WA_SELECT_WINDOWS
:
741 wUnselectWindows(scr
);
742 wSelectWindows(scr
, event
);
744 case WA_OPEN_APPMENU
:
745 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
747 if (scr
->root_menu
) {
748 if (scr
->root_menu
->brother
->flags
.mapped
)
749 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
751 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
754 case WA_OPEN_WINLISTMENU
:
755 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
756 if (scr
->switch_menu
) {
757 if (scr
->switch_menu
->brother
->flags
.mapped
)
758 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
760 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
769 static void handleButtonPress(XEvent
* event
)
771 WObjDescriptor
*desc
;
774 scr
= wScreenForRootWindow(event
->xbutton
.root
);
780 if (event
->xbutton
.window
== scr
->root_win
) {
781 if (event
->xbutton
.button
== Button1
&& wPreferences
.mouse_button1
!= WA_NONE
) {
782 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
783 } else if (event
->xbutton
.button
== Button2
&& wPreferences
.mouse_button2
!= WA_NONE
) {
784 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
785 } else if (event
->xbutton
.button
== Button3
&& wPreferences
.mouse_button3
!= WA_NONE
) {
786 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
787 } else if (event
->xbutton
.button
== Button4
&& wPreferences
.mouse_wheel
!= WA_NONE
) {
788 wWorkspaceRelativeChange(scr
, 1);
789 } else if (event
->xbutton
.button
== Button5
&& wPreferences
.mouse_wheel
!= WA_NONE
) {
790 wWorkspaceRelativeChange(scr
, -1);
795 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
796 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
, (XPointer
*) & desc
) == XCNOENT
) {
801 if (desc
->parent_type
== WCLASS_WINDOW
) {
804 if (event
->xbutton
.state
& ( MOD_MASK
| ControlMask
)) {
805 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
807 /* if (wPreferences.focus_mode == WKF_CLICK) { */
808 if (wPreferences
.ignore_focus_click
) {
809 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
811 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
815 } else if (desc
->parent_type
== WCLASS_APPICON
816 || desc
->parent_type
== WCLASS_MINIWINDOW
|| desc
->parent_type
== WCLASS_DOCK_ICON
) {
817 if (event
->xbutton
.state
& MOD_MASK
) {
819 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
824 if (desc
->handle_mousedown
!= NULL
) {
825 (*desc
->handle_mousedown
) (desc
, event
);
828 /* save double-click information */
829 if (scr
->flags
.next_click_is_not_double
) {
830 scr
->flags
.next_click_is_not_double
= 0;
832 scr
->last_click_time
= event
->xbutton
.time
;
833 scr
->last_click_button
= event
->xbutton
.button
;
834 scr
->last_click_window
= event
->xbutton
.window
;
838 static void handleMapNotify(XEvent
* event
)
842 wwin
= wWindowFor(event
->xmap
.event
);
843 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
844 if (wwin
->flags
.miniaturized
) {
845 wDeiconifyWindow(wwin
);
849 wClientSetState(wwin
, NormalState
, None
);
855 static void handleUnmapNotify(XEvent
* event
)
859 Bool withdraw
= False
;
861 /* only process windows with StructureNotify selected
862 * (ignore SubstructureNotify) */
863 wwin
= wWindowFor(event
->xunmap
.window
);
867 /* whether the event is a Withdrawal request */
868 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
&& event
->xunmap
.send_event
)
871 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
874 if (!wwin
->flags
.mapped
&& !withdraw
875 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
876 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
880 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
881 wwin
->flags
.mapped
= 0;
883 /* check if the window was destroyed */
884 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
, &ev
)) {
887 Bool reparented
= False
;
889 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
892 /* withdraw window */
893 wwin
->flags
.mapped
= 0;
895 wClientSetState(wwin
, WithdrawnState
, None
);
897 /* if the window was reparented, do not reparent it back to the
899 wUnmanageWindow(wwin
, !reparented
, False
);
904 static void handleConfigureRequest(XEvent
* event
)
908 if (!(wwin
= wWindowFor(event
->xconfigurerequest
.window
))) {
910 * Configure request for unmapped window
912 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
914 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
918 static void handlePropertyNotify(XEvent
* event
)
926 wwin
= wWindowFor(event
->xproperty
.window
);
928 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
, &ju
, &ju
, &ju
, &ju
)) {
931 wClientCheckProperty(wwin
, &event
->xproperty
);
933 wapp
= wApplicationOf(event
->xproperty
.window
);
935 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
939 static void handleClientMessage(XEvent
* event
)
942 WObjDescriptor
*desc
;
944 /* handle transition from Normal to Iconic state */
945 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
946 && event
->xclient
.format
== 32 && event
->xclient
.data
.l
[0] == IconicState
) {
948 wwin
= wWindowFor(event
->xclient
.window
);
951 if (!wwin
->flags
.miniaturized
)
952 wIconifyWindow(wwin
);
953 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
&& event
->xclient
.format
== 32) {
954 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
959 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
960 wColormapAllowClientInstallation(scr
, True
);
961 } else { /* stopping */
962 wColormapAllowClientInstallation(scr
, False
);
964 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
969 len
= sizeof(event
->xclient
.data
.b
) + 1;
970 command
= wmalloc(len
);
971 strncpy(command
, event
->xclient
.data
.b
, sizeof(event
->xclient
.data
.b
));
973 if (strncmp(command
, "Reconfigure", sizeof("Reconfigure")) == 0) {
974 wwarning(_("Got Reconfigure command"));
975 wDefaultsCheckDomains(NULL
);
977 wwarning(_("Got unknown command %s"), command
);
982 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
985 wapp
= wApplicationOf(event
->xclient
.window
);
987 switch (event
->xclient
.data
.l
[0]) {
988 case WMFHideOtherApplications
:
989 wHideOtherApplications(wapp
->main_window_desc
);
993 case WMFHideApplication
:
994 wHideApplication(wapp
);
1000 wwin
= wWindowFor(event
->xclient
.window
);
1002 switch (event
->xclient
.data
.l
[0]) {
1003 case WMFHideOtherApplications
:
1004 wHideOtherApplications(wwin
);
1007 case WMFHideApplication
:
1008 wHideApplication(wApplicationOf(wwin
->main_window
));
1013 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
1014 wwin
= wWindowFor(event
->xclient
.window
);
1017 switch (event
->xclient
.data
.l
[0]) {
1018 case GSWindowLevelAttr
:
1020 int level
= (int)event
->xclient
.data
.l
[1];
1022 if (WINDOW_LEVEL(wwin
) != level
) {
1023 ChangeStackingLevel(wwin
->frame
->core
, level
);
1028 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
1029 wwin
= wWindowFor(event
->xclient
.window
);
1032 switch (event
->xclient
.data
.l
[0]) {
1033 case WMTitleBarNormal
:
1034 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1036 case WMTitleBarMain
:
1037 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
1040 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1043 } else if (event
->xclient
.message_type
== _XA_WM_IGNORE_FOCUS_EVENTS
) {
1044 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
1047 scr
->flags
.ignore_focus_events
= event
->xclient
.data
.l
[0] ? 1 : 0;
1048 } else if (wNETWMProcessClientMessage(&event
->xclient
)) {
1051 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
1056 * Non-standard thing, but needed by OffiX DND.
1057 * For when the icon frame gets a ClientMessage
1058 * that should have gone to the icon_window.
1060 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1061 struct WIcon
*icon
= NULL
;
1063 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
1064 icon
= (WIcon
*) desc
->parent
;
1065 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
|| desc
->parent_type
== WCLASS_APPICON
) {
1066 icon
= ((WAppIcon
*) desc
->parent
)->icon
;
1068 if (icon
&& (wwin
= icon
->owner
)) {
1069 if (wwin
->client_win
!= event
->xclient
.window
) {
1070 event
->xclient
.window
= wwin
->client_win
;
1071 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
, event
);
1078 static void raiseWindow(WScreen
* scr
)
1082 scr
->autoRaiseTimer
= NULL
;
1084 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1088 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1089 wRaiseFrame(wwin
->frame
->core
);
1090 /* this is needed or a race condition will occur */
1095 static void handleEnterNotify(XEvent
* event
)
1098 WObjDescriptor
*desc
= NULL
;
1100 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1102 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
, &ev
)) {
1103 /* already left the window... */
1105 if (ev
.xcrossing
.mode
== event
->xcrossing
.mode
&& ev
.xcrossing
.detail
== event
->xcrossing
.detail
) {
1110 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1111 if (desc
->handle_enternotify
)
1112 (*desc
->handle_enternotify
) (desc
, event
);
1115 /* enter to window */
1116 wwin
= wWindowFor(event
->xcrossing
.window
);
1118 if (wPreferences
.colormap_mode
== WCM_POINTER
) {
1119 wColormapInstallForWindow(scr
, NULL
);
1121 if (scr
->autoRaiseTimer
&& event
->xcrossing
.root
== event
->xcrossing
.window
) {
1122 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1123 scr
->autoRaiseTimer
= NULL
;
1126 /* set auto raise timer even if in focus-follows-mouse mode
1127 * and the event is for the frame window, even if the window
1128 * has focus already. useful if you move the pointer from a focused
1129 * window to the root window and back pretty fast
1131 * set focus if in focus-follows-mouse mode and the event
1132 * is for the frame window and window doesn't have focus yet */
1133 if (wPreferences
.focus_mode
== WKF_SLOPPY
1134 && wwin
->frame
->core
->window
== event
->xcrossing
.window
&& !scr
->flags
.doing_alt_tab
) {
1136 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1137 wSetFocusTo(scr
, wwin
);
1139 if (scr
->autoRaiseTimer
)
1140 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1141 scr
->autoRaiseTimer
= NULL
;
1143 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1144 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1146 = WMAddTimerHandler(wPreferences
.raise_delay
, (WMCallback
*) raiseWindow
, scr
);
1149 /* Install colormap for window, if the colormap installation mode
1150 * is colormap_follows_mouse */
1151 if (wPreferences
.colormap_mode
== WCM_POINTER
) {
1152 if (wwin
->client_win
== event
->xcrossing
.window
)
1153 wColormapInstallForWindow(scr
, wwin
);
1155 wColormapInstallForWindow(scr
, NULL
);
1159 if (event
->xcrossing
.window
== event
->xcrossing
.root
1160 && event
->xcrossing
.detail
== NotifyNormal
1161 && event
->xcrossing
.detail
!= NotifyInferior
&& wPreferences
.focus_mode
!= WKF_CLICK
) {
1163 wSetFocusTo(scr
, scr
->focused_window
);
1166 wBalloonEnteredObject(scr
, desc
);
1170 static void handleLeaveNotify(XEvent
* event
)
1172 WObjDescriptor
*desc
= NULL
;
1174 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
, (XPointer
*) & desc
) != XCNOENT
) {
1175 if (desc
->handle_leavenotify
)
1176 (*desc
->handle_leavenotify
) (desc
, event
);
1181 static void handleShapeNotify(XEvent
* event
)
1183 XShapeEvent
*shev
= (XShapeEvent
*) event
;
1190 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
.xevent
)) {
1191 if (ev
.xshape
.kind
== ShapeBounding
) {
1192 if (ev
.xshape
.shaped
== shev
->shaped
) {
1195 XPutBackEvent(dpy
, &ev
.xevent
);
1201 wwin
= wWindowFor(shev
->window
);
1202 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1205 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1207 wwin
->flags
.shaped
= 0;
1208 wWindowClearShape(wwin
);
1210 } else if (shev
->shaped
) {
1212 wwin
->flags
.shaped
= 1;
1213 wWindowSetShape(wwin
);
1218 #ifdef KEEP_XKB_LOCK_STATUS
1219 /* please help ]d if you know what to do */
1220 static void handleXkbIndicatorStateNotify(XEvent
*event
)
1224 XkbStateRec staterec
;
1227 for (i
= 0; i
< wScreenCount
; i
++) {
1228 scr
= wScreenWithNumber(i
);
1229 wwin
= scr
->focused_window
;
1230 if (wwin
&& wwin
->flags
.focused
) {
1231 XkbGetState(dpy
, XkbUseCoreKbd
, &staterec
);
1232 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1233 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1234 wwin
->frame
->languagemode
= staterec
.group
;
1236 #ifdef XKB_BUTTON_HINT
1237 if (wwin
->frame
->titlebar
) {
1238 wFrameWindowPaint(wwin
->frame
);
1244 #endif /*KEEP_XKB_LOCK_STATUS */
1246 static void handleColormapNotify(XEvent
* event
)
1250 Bool reinstall
= False
;
1252 wwin
= wWindowFor(event
->xcolormap
.window
);
1256 scr
= wwin
->screen_ptr
;
1260 if (event
->xcolormap
.new) {
1261 XWindowAttributes attr
;
1263 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1265 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1266 scr
->current_colormap
= attr
.colormap
;
1269 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1270 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1272 /* some bastard app (like XV) removed our colormap */
1274 * can't enforce or things like xscreensaver wont work
1277 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1278 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1280 /* someone has put our colormap back */
1284 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1285 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1287 if (reinstall
&& scr
->current_colormap
!= None
) {
1288 if (!scr
->flags
.colormap_stuff_blocked
)
1289 XInstallColormap(dpy
, scr
->current_colormap
);
1293 static void handleFocusIn(XEvent
* event
)
1298 * For applications that like stealing the focus.
1300 while (XCheckTypedEvent(dpy
, FocusIn
, event
)) ;
1301 saveTimestamp(event
);
1302 if (event
->xfocus
.mode
== NotifyUngrab
1303 || event
->xfocus
.mode
== NotifyGrab
|| event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1307 wwin
= wWindowFor(event
->xfocus
.window
);
1308 if (wwin
&& !wwin
->flags
.focused
) {
1309 if (wwin
->flags
.mapped
)
1310 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1312 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1314 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1316 wSetFocusTo(scr
, NULL
);
1320 static WWindow
*windowUnderPointer(WScreen
* scr
)
1326 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
, &mask
))
1327 return wWindowFor(win
);
1331 static int CheckFullScreenWindowFocused(WScreen
* scr
)
1333 if (scr
->focused_window
&& scr
->focused_window
->flags
.fullscreen
)
1339 static void handleKeyPress(XEvent
* event
)
1341 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1342 WWindow
*wwin
= scr
->focused_window
;
1346 #ifdef KEEP_XKB_LOCK_STATUS
1347 XkbStateRec staterec
;
1348 #endif /*KEEP_XKB_LOCK_STATUS */
1350 /* ignore CapsLock */
1351 modifiers
= event
->xkey
.state
& ValidModMask
;
1353 for (i
= 0; i
< WKBD_LAST
; i
++) {
1354 if (wKeyBindings
[i
].keycode
== 0)
1357 if (wKeyBindings
[i
].keycode
== event
->xkey
.keycode
&& ( /*wKeyBindings[i].modifier==0
1358 || */ wKeyBindings
[i
].modifier
==
1367 if (!wRootMenuPerformShortcut(event
)) {
1368 static int dontLoop
= 0;
1370 if (dontLoop
> 10) {
1371 wwarning("problem with key event processing code");
1375 /* if the focused window is an internal window, try redispatching
1376 * the event to the managed window, as it can be a WINGs window */
1377 if (wwin
&& wwin
->flags
.internal_window
&& wwin
->client_leader
!= None
) {
1378 /* client_leader contains the WINGs toplevel */
1379 event
->xany
.window
= wwin
->client_leader
;
1380 WMHandleEvent(event
);
1386 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1387 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1392 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True); */
1393 if (!CheckFullScreenWindowFocused(scr
)) {
1394 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1395 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2, rect
.pos
.y
+ rect
.size
.height
/ 2,
1399 case WKBD_WINDOWLIST
:
1400 if (!CheckFullScreenWindowFocused(scr
)) {
1401 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1402 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/ 2, rect
.pos
.y
+ rect
.size
.height
/ 2,
1407 case WKBD_WINDOWMENU
:
1408 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1409 OpenWindowMenu(wwin
, wwin
->frame_x
, wwin
->frame_y
+ wwin
->frame
->top_width
, True
);
1411 case WKBD_MINIMIZEALL
:
1412 CloseWindowMenu(scr
);
1415 case WKBD_MINIATURIZE
:
1416 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1417 && !WFLAGP(wwin
, no_miniaturizable
)) {
1418 CloseWindowMenu(scr
);
1420 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1421 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
, event
->xbutton
.time
);
1423 wIconifyWindow(wwin
);
1428 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1429 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1430 CloseWindowMenu(scr
);
1432 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1433 wHideApplication(wapp
);
1437 case WKBD_HIDE_OTHERS
:
1438 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1439 CloseWindowMenu(scr
);
1441 wHideOtherApplications(wwin
);
1445 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1446 CloseWindowMenu(scr
);
1448 handleMaximize(wwin
, MAX_VERTICAL
| MAX_HORIZONTAL
| MAX_KEYBOARD
);
1451 case WKBD_VMAXIMIZE
:
1452 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1453 CloseWindowMenu(scr
);
1455 handleMaximize(wwin
, MAX_VERTICAL
| MAX_KEYBOARD
);
1458 case WKBD_HMAXIMIZE
:
1459 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1460 CloseWindowMenu(scr
);
1462 handleMaximize(wwin
, MAX_HORIZONTAL
| MAX_KEYBOARD
);
1465 case WKBD_LHMAXIMIZE
:
1466 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1467 CloseWindowMenu(scr
);
1469 handleMaximize(wwin
, MAX_VERTICAL
| MAX_LEFTHALF
| MAX_KEYBOARD
);
1472 case WKBD_RHMAXIMIZE
:
1473 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1474 CloseWindowMenu(scr
);
1476 handleMaximize(wwin
, MAX_VERTICAL
| MAX_RIGHTHALF
| MAX_KEYBOARD
);
1480 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1481 CloseWindowMenu(scr
);
1483 handleMaximize(wwin
, MAX_MAXIMUS
| MAX_KEYBOARD
);
1487 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1488 CloseWindowMenu(scr
);
1490 wRaiseFrame(wwin
->frame
->core
);
1494 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1495 CloseWindowMenu(scr
);
1497 wLowerFrame(wwin
->frame
->core
);
1500 case WKBD_RAISELOWER
:
1501 /* raise or lower the window under the pointer, not the
1504 wwin
= windowUnderPointer(scr
);
1506 wRaiseLowerFrame(wwin
->frame
->core
);
1509 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1510 if (wwin
->flags
.shaded
)
1511 wUnshadeWindow(wwin
);
1516 case WKBD_MOVERESIZE
:
1517 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && (IS_RESIZABLE(wwin
) || IS_MOVABLE(wwin
))) {
1518 CloseWindowMenu(scr
);
1520 wKeyboardMoveResizeWindow(wwin
);
1524 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1525 CloseWindowMenu(scr
);
1526 if (wwin
->protocols
.DELETE_WINDOW
)
1527 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, event
->xkey
.time
);
1531 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1532 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1535 case WKBD_FOCUSNEXT
:
1536 StartWindozeCycle(wwin
, event
, True
, False
);
1539 case WKBD_FOCUSPREV
:
1540 StartWindozeCycle(wwin
, event
, False
, False
);
1543 case WKBD_GROUPNEXT
:
1544 StartWindozeCycle(wwin
, event
, True
, True
);
1547 case WKBD_GROUPPREV
:
1548 StartWindozeCycle(wwin
, event
, False
, True
);
1551 case WKBD_WORKSPACE1
... WKBD_WORKSPACE10
:
1552 widx
= command
- WKBD_WORKSPACE1
;
1553 i
= (scr
->current_workspace
/ 10) * 10 + widx
;
1554 if (wPreferences
.ws_advance
|| i
< scr
->workspace_count
)
1555 wWorkspaceChange(scr
, i
);
1558 case WKBD_NEXTWORKSPACE
:
1559 wWorkspaceRelativeChange(scr
, 1);
1561 case WKBD_PREVWORKSPACE
:
1562 wWorkspaceRelativeChange(scr
, -1);
1576 widx
= command
- WKBD_WINDOW1
;
1578 if (scr
->shortcutWindows
[widx
]) {
1579 WMArray
*list
= scr
->shortcutWindows
[widx
];
1581 int count
= WMGetArrayItemCount(list
);
1583 WMArrayIterator iter
;
1586 wUnselectWindows(scr
);
1587 cw
= scr
->current_workspace
;
1589 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1591 wWindowChangeWorkspace(wwin
, cw
);
1593 wMakeWindowVisible(wwin
);
1596 wSelectWindow(wwin
, True
);
1599 /* rotate the order of windows, to create a cycling effect */
1600 twin
= WMGetFromArray(list
, 0);
1601 WMDeleteFromArray(list
, 0);
1602 WMAddToArray(list
, twin
);
1604 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1605 if (scr
->shortcutWindows
[widx
]) {
1606 WMFreeArray(scr
->shortcutWindows
[widx
]);
1607 scr
->shortcutWindows
[widx
] = NULL
;
1610 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1611 scr
->shortcutWindows
[widx
] = WMDuplicateArray(scr
->selected_windows
);
1612 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1613 WMInsertInArray(scr->shortcutWindows[index], 0, wwin); */
1615 scr
->shortcutWindows
[widx
] = WMCreateArray(4);
1616 WMAddToArray(scr
->shortcutWindows
[widx
], wwin
);
1619 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1622 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1625 } else if (scr
->selected_windows
&& WMGetArrayItemCount(scr
->selected_windows
)) {
1627 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1628 if (scr
->shortcutWindows
[widx
]) {
1629 WMFreeArray(scr
->shortcutWindows
[widx
]);
1631 scr
->shortcutWindows
[widx
] = WMDuplicateArray(scr
->selected_windows
);
1638 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1639 (void) RelaunchWindow(wwin
);
1643 case WKBD_SWITCH_SCREEN
:
1644 if (wScreenCount
> 1) {
1648 /* find index of this screen */
1649 for (i
= 0; i
< wScreenCount
; i
++) {
1650 if (wScreenWithNumber(i
) == scr
)
1654 if (i
>= wScreenCount
) {
1657 scr2
= wScreenWithNumber(i
);
1660 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1661 scr2
->scr_width
/ 2, scr2
->scr_height
/ 2);
1666 case WKBD_NEXTWSLAYER
:
1667 case WKBD_PREVWSLAYER
:
1671 row
= scr
->current_workspace
/ 10;
1672 column
= scr
->current_workspace
% 10;
1674 if (command
== WKBD_NEXTWSLAYER
) {
1675 if ((row
+ 1) * 10 < scr
->workspace_count
)
1676 wWorkspaceChange(scr
, column
+ (row
+ 1) * 10);
1679 wWorkspaceChange(scr
, column
+ (row
- 1) * 10);
1683 case WKBD_CLIPRAISELOWER
:
1684 if (!wPreferences
.flags
.noclip
)
1685 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1687 case WKBD_DOCKRAISELOWER
:
1688 if (!wPreferences
.flags
.nodock
)
1689 wDockRaiseLower(scr
->dock
);
1691 #ifdef KEEP_XKB_LOCK_STATUS
1693 if (wPreferences
.modelock
) {
1695 wwin
= scr
->focused_window
;
1697 if (wwin
&& wwin
->flags
.mapped
1698 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1699 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1700 XkbGetState(dpy
, XkbUseCoreKbd
, &staterec
);
1702 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1703 wwin
->frame
->last_languagemode
= staterec
.group
;
1704 XkbLockGroup(dpy
, XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1709 #endif /* KEEP_XKB_LOCK_STATUS */
1713 static void handleMotionNotify(XEvent
* event
)
1715 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1717 if (wPreferences
.scrollable_menus
) {
1718 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1719 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1721 if (scr
->flags
.jump_back_pending
||
1722 p
.x
<= (rect
.pos
.x
+ 1) ||
1723 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1724 p
.y
<= (rect
.pos
.y
+ 1) || p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1727 menu
= wMenuUnderPointer(scr
);
1729 wMenuScroll(menu
, event
);
1734 static void handleVisibilityNotify(XEvent
* event
)
1738 wwin
= wWindowFor(event
->xvisibility
.window
);
1741 wwin
->flags
.obscured
= (event
->xvisibility
.state
== VisibilityFullyObscured
);