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("bla");
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 /* Allow for 1024 simultanious events */
319 #define BUFF_SIZE ((sizeof(struct inotify_event)+FILENAME_MAX)*1024)
320 void inotifyHandleEvents (int fd
, int wd
)
322 ssize_t eventQLength
, i
= 0;
323 char buff
[BUFF_SIZE
] = {0};
324 extern void wDefaultsCheckDomains();
325 int oneShotFlag
=0; /* Only check config once per read of the event queue */
327 /* Read off the queued events
328 * queue overflow is not checked (IN_Q_OVERFLOW). In practise this should
329 * not occur; the block is on Xevents, but a config file change will normally
330 * occur as a result of an Xevent - so the event queue should never have more than
331 * a few entries before a read().
333 eventQLength
= read (fd
, buff
, BUFF_SIZE
);
335 /* check what events occured */
336 /* Should really check wd here too, but for now we only have one watch! */
337 while (i
< eventQLength
) {
338 struct inotify_event
*pevent
= (struct inotify_event
*)&buff
[i
];
341 * see inotify.h for event types.
343 if (pevent
->mask
& IN_DELETE_SELF
) {
344 wwarning(_("the defaults database has been deleted!"
345 " Restart Window Maker to create the database"
346 " with the default settings"));
349 if (pevent
->mask
& IN_UNMOUNT
) {
350 wwarning(_("the unit containing the defaults database has"
351 " been unmounted. Setting --static mode."
352 " Any changes will not be saved."));
354 wPreferences
.flags
.noupdates
=1;
356 if ((pevent
->mask
& IN_MODIFY
) && oneShotFlag
== 0) {
357 fprintf(stdout
,"wmaker: reading config files in defaults database.\n");
358 wDefaultsCheckDomains(NULL
);
360 /* Check for filename (length of name (len) > 0) */
361 /* if (pevent->len) printf ("name=%s\n", pevent->name); */
363 i
+= sizeof(struct inotify_event
) + pevent
->len
; /* move to next event in the buffer */
366 } /* inotifyHandleEvents */
369 *----------------------------------------------------------------------
371 * Processes X and internal events indefinitely.
377 * The LastTimestamp global variable is updated.
378 * Calls inotifyGetEvents if defaults database changes.
379 *----------------------------------------------------------------------
385 extern int inotifyFD
;
386 extern int inotifyWD
;
391 if (inotifyFD
< 0 || inotifyWD
< 0)
396 WMNextEvent(dpy
, &event
); /* Blocks here */
397 WMHandleEvent(&event
);
403 FD_SET (inotifyFD
, &rfds
);
405 /* check for available read data from inotify - don't block! */
406 retVal
= select (inotifyFD
+ 1, &rfds
, NULL
, NULL
, &time
);
408 if (retVal
< 0) { /* an error has occured */
409 wwarning(_("select failed. The inotify instance will be closed."
410 " Changes to the defaults database will require"
411 " a restart to take effect."));
415 if (FD_ISSET (inotifyFD
, &rfds
))
416 inotifyHandleEvents(inotifyFD
,inotifyWD
);
422 *----------------------------------------------------------------------
423 * ProcessPendingEvents --
424 * Processes the events that are currently pending (at the time
425 * this function is called) in the display's queue.
428 * After the pending events that were present at the function call
432 * Many -- whatever handling events may involve.
434 *----------------------------------------------------------------------
437 ProcessPendingEvents()
444 /* Take a snapshot of the event count in the queue */
445 count
= XPending(dpy
);
447 while (count
>0 && XPending(dpy
)) {
448 WMNextEvent(dpy
, &event
);
449 WMHandleEvent(&event
);
456 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
458 if ((scr
->last_click_time
>0) &&
459 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
460 && (event
->xbutton
.button
== scr
->last_click_button
)
461 && (event
->xbutton
.window
== scr
->last_click_window
)) {
463 scr
->flags
.next_click_is_not_double
= 1;
464 scr
->last_click_time
= 0;
465 scr
->last_click_window
= event
->xbutton
.window
;
474 NotifyDeadProcess(pid_t pid
, unsigned char status
)
476 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
477 wwarning("stack overflow: too many dead processes");
480 /* stack the process to be handled later,
481 * as this is called from the signal handler */
482 deadProcesses
[deadProcessPtr
].pid
= pid
;
483 deadProcesses
[deadProcessPtr
].exit_status
= status
;
489 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
,
516 wDeleteDeathHandler(tmp
);
524 saveTimestamp(XEvent
*event
)
527 * Never save CurrentTime as LastTimestamp because CurrentTime
528 * it's not a real timestamp (it's the 0L constant)
531 switch (event
->type
) {
534 LastTimestamp
= event
->xbutton
.time
;
538 LastTimestamp
= event
->xkey
.time
;
541 LastTimestamp
= event
->xmotion
.time
;
544 LastTimestamp
= event
->xproperty
.time
;
548 LastTimestamp
= event
->xcrossing
.time
;
551 LastTimestamp
= event
->xselectionclear
.time
;
553 case SelectionRequest
:
554 LastTimestamp
= event
->xselectionrequest
.time
;
556 case SelectionNotify
:
557 LastTimestamp
= event
->xselection
.time
;
559 wXDNDProcessSelection(event
);
567 matchWindow(void *item
, void *cdata
)
569 return (((WFakeGroupLeader
*)item
)->origLeader
== (Window
)cdata
);
574 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*/
594 handleMapRequest(XEvent
*ev
)
598 Window window
= ev
->xmaprequest
.window
;
601 printf("got map request for %x\n", (unsigned)window
);
603 if ((wwin
= wWindowFor(window
))) {
604 if (wwin
->flags
.shaded
) {
605 wUnshadeWindow(wwin
);
607 /* deiconify window */
608 if (wwin
->flags
.miniaturized
) {
609 wDeiconifyWindow(wwin
);
610 } else if (wwin
->flags
.hidden
) {
611 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
612 /* go to the last workspace that the user worked on the app */
614 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
616 wUnhideApplication(wapp
, False
, False
);
621 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
623 wwin
= wManageWindow(scr
, window
);
626 * This is to let the Dock know that the application it launched
627 * has already been mapped (eg: it has finished launching).
628 * It is not necessary for normally docked apps, but is needed for
629 * apps that were forcedly docked (like with dockit).
631 if (scr
->last_dock
) {
632 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
633 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
635 wDockTrackWindowLaunch(scr
->last_dock
, window
);
639 wClientSetState(wwin
, NormalState
, None
);
640 if (wwin
->flags
.maximized
) {
641 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
643 if (wwin
->flags
.shaded
) {
644 wwin
->flags
.shaded
= 0;
645 wwin
->flags
.skip_next_animation
= 1;
648 if (wwin
->flags
.miniaturized
) {
649 wwin
->flags
.miniaturized
= 0;
650 wwin
->flags
.skip_next_animation
= 1;
651 wIconifyWindow(wwin
);
653 if (wwin
->flags
.fullscreen
) {
654 wwin
->flags
.fullscreen
= 0;
655 wFullscreenWindow(wwin
);
657 if (wwin
->flags
.hidden
) {
658 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
660 wwin
->flags
.hidden
= 0;
661 wwin
->flags
.skip_next_animation
= 1;
663 wHideApplication(wapp
);
671 handleDestroyNotify(XEvent
*event
)
675 Window window
= event
->xdestroywindow
.window
;
676 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
680 printf("got destroy notify\n");
682 wwin
= wWindowFor(window
);
684 wUnmanageWindow(wwin
, False
, True
);
688 while ((index
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
,
689 (void*)window
)) != WANotFound
) {
690 WFakeGroupLeader
*fPtr
;
692 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
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
);
724 handleExpose(XEvent
*event
)
726 WObjDescriptor
*desc
;
730 printf("got expose\n");
732 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
734 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
735 (XPointer
*)&desc
)==XCNOENT
) {
739 if (desc
->handle_expose
) {
740 (*desc
->handle_expose
)(desc
, event
);
745 executeButtonAction(WScreen
*scr
, XEvent
*event
, int action
)
748 case WA_SELECT_WINDOWS
:
749 wUnselectWindows(scr
);
750 wSelectWindows(scr
, event
);
752 case WA_OPEN_APPMENU
:
753 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
755 if (scr
->root_menu
) {
756 if (scr
->root_menu
->brother
->flags
.mapped
)
757 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
759 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
762 case WA_OPEN_WINLISTMENU
:
763 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
764 if (scr
->switch_menu
) {
765 if (scr
->switch_menu
->brother
->flags
.mapped
)
766 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
768 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
779 handleButtonPress(XEvent
*event
)
781 WObjDescriptor
*desc
;
785 printf("got button press\n");
787 scr
= wScreenForRootWindow(event
->xbutton
.root
);
795 if (event
->xbutton
.window
==scr
->root_win
) {
796 if (event
->xbutton
.button
==Button1
&&
797 wPreferences
.mouse_button1
!=WA_NONE
) {
798 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
799 } else if (event
->xbutton
.button
==Button2
&&
800 wPreferences
.mouse_button2
!=WA_NONE
) {
801 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
802 } else if (event
->xbutton
.button
==Button3
&&
803 wPreferences
.mouse_button3
!=WA_NONE
) {
804 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
805 } else if (event
->xbutton
.button
==Button4
&&
806 wPreferences
.mouse_wheel
!=WA_NONE
) {
807 wWorkspaceRelativeChange(scr
, 1);
808 } else if (event
->xbutton
.button
==Button5
&&
809 wPreferences
.mouse_wheel
!=WA_NONE
) {
810 wWorkspaceRelativeChange(scr
, -1);
816 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
817 (XPointer
*)&desc
)==XCNOENT
) {
818 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
819 (XPointer
*)&desc
)==XCNOENT
) {
824 if (desc
->parent_type
== WCLASS_WINDOW
) {
827 if (event
->xbutton
.state
& MOD_MASK
) {
828 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
831 /* if (wPreferences.focus_mode == WKF_CLICK) {*/
832 if (wPreferences
.ignore_focus_click
) {
833 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
835 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
838 } else if (desc
->parent_type
== WCLASS_APPICON
839 || desc
->parent_type
== WCLASS_MINIWINDOW
840 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
841 if (event
->xbutton
.state
& MOD_MASK
) {
843 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
848 if (desc
->handle_mousedown
!=NULL
) {
849 (*desc
->handle_mousedown
)(desc
, event
);
852 /* save double-click information */
853 if (scr
->flags
.next_click_is_not_double
) {
854 scr
->flags
.next_click_is_not_double
= 0;
856 scr
->last_click_time
= event
->xbutton
.time
;
857 scr
->last_click_button
= event
->xbutton
.button
;
858 scr
->last_click_window
= event
->xbutton
.window
;
864 handleMapNotify(XEvent
*event
)
870 wwin
= wWindowFor(event
->xmap
.event
);
871 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
872 if (wwin
->flags
.miniaturized
) {
873 wDeiconifyWindow(wwin
);
877 wClientSetState(wwin
, NormalState
, None
);
885 handleUnmapNotify(XEvent
*event
)
889 Bool withdraw
= False
;
891 printf("got unmap\n");
893 /* only process windows with StructureNotify selected
894 * (ignore SubstructureNotify) */
895 wwin
= wWindowFor(event
->xunmap
.window
);
899 /* whether the event is a Withdrawal request */
900 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
901 && event
->xunmap
.send_event
)
904 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
907 if (!wwin
->flags
.mapped
&& !withdraw
908 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
909 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
913 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
914 wwin
->flags
.mapped
= 0;
916 /* check if the window was destroyed */
917 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
920 Bool reparented
= False
;
922 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
925 /* withdraw window */
926 wwin
->flags
.mapped
= 0;
928 wClientSetState(wwin
, WithdrawnState
, None
);
930 /* if the window was reparented, do not reparent it back to the
932 wUnmanageWindow(wwin
, !reparented
, False
);
939 handleConfigureRequest(XEvent
*event
)
943 printf("got configure request\n");
945 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
947 * Configure request for unmapped window
949 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
951 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
957 handlePropertyNotify(XEvent
*event
)
966 printf("got property notify\n");
969 wwin
= wWindowFor(event
->xproperty
.window
);
971 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
972 &ju
, &ju
, &ju
, &ju
)) {
975 wClientCheckProperty(wwin
, &event
->xproperty
);
977 wapp
= wApplicationOf(event
->xproperty
.window
);
979 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
982 scr
= wScreenForWindow(event
->xproperty
.window
);
987 handleClientMessage(XEvent
*event
)
990 WObjDescriptor
*desc
;
992 printf("got client message\n");
994 /* handle transition from Normal to Iconic state */
995 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
996 && event
->xclient
.format
== 32
997 && event
->xclient
.data
.l
[0] == IconicState
) {
999 wwin
= wWindowFor(event
->xclient
.window
);
1001 if (!wwin
->flags
.miniaturized
)
1002 wIconifyWindow(wwin
);
1003 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
1004 && event
->xclient
.format
== 32) {
1005 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
1010 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
1011 wColormapAllowClientInstallation(scr
, True
);
1012 } else { /* stopping */
1013 wColormapAllowClientInstallation(scr
, False
);
1015 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
1017 wDefaultsCheckDomains("bla");
1019 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
1022 wapp
= wApplicationOf(event
->xclient
.window
);
1024 switch (event
->xclient
.data
.l
[0]) {
1025 case WMFHideOtherApplications
:
1026 wHideOtherApplications(wapp
->main_window_desc
);
1030 case WMFHideApplication
:
1031 wHideApplication(wapp
);
1037 wwin
= wWindowFor(event
->xclient
.window
);
1039 switch (event
->xclient
.data
.l
[0]) {
1040 case WMFHideOtherApplications
:
1041 wHideOtherApplications(wwin
);
1044 case WMFHideApplication
:
1045 wHideApplication(wApplicationOf(wwin
->main_window
));
1050 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
1051 wwin
= wWindowFor(event
->xclient
.window
);
1053 switch (event
->xclient
.data
.l
[0]) {
1054 case GSWindowLevelAttr
:
1056 int level
= (int)event
->xclient
.data
.l
[1];
1058 if (WINDOW_LEVEL(wwin
) != level
) {
1059 ChangeStackingLevel(wwin
->frame
->core
, level
);
1064 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
1065 wwin
= wWindowFor(event
->xclient
.window
);
1067 switch (event
->xclient
.data
.l
[0]) {
1068 case WMTitleBarNormal
:
1069 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1071 case WMTitleBarMain
:
1072 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
1075 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1079 } else if (wNETWMProcessClientMessage(&event
->xclient
)) {
1083 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
1088 * Non-standard thing, but needed by OffiX DND.
1089 * For when the icon frame gets a ClientMessage
1090 * that should have gone to the icon_window.
1092 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
1093 (XPointer
*)&desc
)!=XCNOENT
) {
1094 struct WIcon
*icon
=NULL
;
1096 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
1097 icon
= (WIcon
*)desc
->parent
;
1098 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
1099 || desc
->parent_type
== WCLASS_APPICON
) {
1100 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
1102 if (icon
&& (wwin
=icon
->owner
)) {
1103 if (wwin
->client_win
!=event
->xclient
.window
) {
1104 event
->xclient
.window
= wwin
->client_win
;
1105 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
1115 raiseWindow(WScreen
*scr
)
1119 scr
->autoRaiseTimer
= NULL
;
1121 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1125 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1126 wRaiseFrame(wwin
->frame
->core
);
1127 /* this is needed or a race condition will occur */
1134 handleEnterNotify(XEvent
*event
)
1137 WObjDescriptor
*desc
= NULL
;
1138 #ifdef VIRTUAL_DESKTOP
1139 void (*vdHandler
)(XEvent
* event
);
1142 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1144 printf("got enter notify\n");
1147 #ifdef VIRTUAL_DESKTOP
1148 if (XFindContext(dpy
, event
->xcrossing
.window
, wVEdgeContext
,
1149 (XPointer
*)&vdHandler
)!=XCNOENT
) {
1150 (*vdHandler
)(event
);
1154 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1156 /* already left the window... */
1158 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1159 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1164 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1165 (XPointer
*)&desc
)!=XCNOENT
) {
1166 if(desc
->handle_enternotify
)
1167 (*desc
->handle_enternotify
)(desc
, event
);
1170 /* enter to window */
1171 wwin
= wWindowFor(event
->xcrossing
.window
);
1173 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1174 wColormapInstallForWindow(scr
, NULL
);
1176 if (scr
->autoRaiseTimer
1177 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1178 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1179 scr
->autoRaiseTimer
= NULL
;
1182 /* set auto raise timer even if in focus-follows-mouse mode
1183 * and the event is for the frame window, even if the window
1184 * has focus already. useful if you move the pointer from a focused
1185 * window to the root window and back pretty fast
1187 * set focus if in focus-follows-mouse mode and the event
1188 * is for the frame window and window doesn't have focus yet */
1189 if (wPreferences
.focus_mode
==WKF_SLOPPY
1190 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1191 && !scr
->flags
.doing_alt_tab
) {
1193 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1194 wSetFocusTo(scr
, wwin
);
1196 if (scr
->autoRaiseTimer
)
1197 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1198 scr
->autoRaiseTimer
= NULL
;
1200 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1201 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1203 = WMAddTimerHandler(wPreferences
.raise_delay
,
1204 (WMCallback
*)raiseWindow
, scr
);
1207 /* Install colormap for window, if the colormap installation mode
1208 * is colormap_follows_mouse */
1209 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1210 if (wwin
->client_win
==event
->xcrossing
.window
)
1211 wColormapInstallForWindow(scr
, wwin
);
1213 wColormapInstallForWindow(scr
, NULL
);
1217 /* a little kluge to hide the clip balloon */
1218 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1220 XUnmapWindow(dpy
, scr
->clip_balloon
);
1221 scr
->flags
.clip_balloon_mapped
= 0;
1223 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1224 || scr
->clip_icon
!= desc
->parent
) {
1225 XUnmapWindow(dpy
, scr
->clip_balloon
);
1226 scr
->flags
.clip_balloon_mapped
= 0;
1231 if (event
->xcrossing
.window
== event
->xcrossing
.root
1232 && event
->xcrossing
.detail
== NotifyNormal
1233 && event
->xcrossing
.detail
!= NotifyInferior
1234 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1236 wSetFocusTo(scr
, scr
->focused_window
);
1240 wBalloonEnteredObject(scr
, desc
);
1246 handleLeaveNotify(XEvent
*event
)
1248 WObjDescriptor
*desc
= NULL
;
1250 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1251 (XPointer
*)&desc
)!=XCNOENT
) {
1252 if(desc
->handle_leavenotify
)
1253 (*desc
->handle_leavenotify
)(desc
, event
);
1260 handleShapeNotify(XEvent
*event
)
1262 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1266 printf("got shape notify\n");
1268 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1269 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1271 if (sev
->kind
== ShapeBounding
) {
1272 if (sev
->shaped
== shev
->shaped
) {
1275 XPutBackEvent(dpy
, &ev
);
1281 wwin
= wWindowFor(shev
->window
);
1282 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1285 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1287 wwin
->flags
.shaped
= 0;
1288 wWindowClearShape(wwin
);
1290 } else if (shev
->shaped
) {
1292 wwin
->flags
.shaped
= 1;
1293 wWindowSetShape(wwin
);
1298 #ifdef KEEP_XKB_LOCK_STATUS
1299 /* please help ]d if you know what to do */
1300 handleXkbIndicatorStateNotify(XEvent
*event
)
1304 XkbStateRec staterec
;
1307 for (i
=0; i
<wScreenCount
; i
++) {
1308 scr
= wScreenWithNumber(i
);
1309 wwin
= scr
->focused_window
;
1310 if (wwin
&& wwin
->flags
.focused
) {
1311 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1312 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1313 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1314 wwin
->frame
->languagemode
= staterec
.group
;
1316 #ifdef XKB_BUTTON_HINT
1317 if (wwin
->frame
->titlebar
) {
1318 wFrameWindowPaint(wwin
->frame
);
1324 #endif /*KEEP_XKB_LOCK_STATUS*/
1327 handleColormapNotify(XEvent
*event
)
1331 Bool reinstall
= False
;
1333 wwin
= wWindowFor(event
->xcolormap
.window
);
1337 scr
= wwin
->screen_ptr
;
1341 if (event
->xcolormap
.new) {
1342 XWindowAttributes attr
;
1344 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1346 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1347 scr
->current_colormap
= attr
.colormap
;
1350 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1351 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1353 /* some bastard app (like XV) removed our colormap */
1355 * can't enforce or things like xscreensaver wont work
1358 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1359 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1361 /* someone has put our colormap back */
1365 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1366 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1368 if (reinstall
&& scr
->current_colormap
!=None
) {
1369 if (!scr
->flags
.colormap_stuff_blocked
)
1370 XInstallColormap(dpy
, scr
->current_colormap
);
1377 handleFocusIn(XEvent
*event
)
1382 * For applications that like stealing the focus.
1384 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1385 saveTimestamp(event
);
1386 if (event
->xfocus
.mode
== NotifyUngrab
1387 || event
->xfocus
.mode
== NotifyGrab
1388 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1392 wwin
= wWindowFor(event
->xfocus
.window
);
1393 if (wwin
&& !wwin
->flags
.focused
) {
1394 if (wwin
->flags
.mapped
)
1395 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1397 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1399 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1401 wSetFocusTo(scr
, NULL
);
1407 windowUnderPointer(WScreen
*scr
)
1413 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1415 return wWindowFor(win
);
1420 static int CheckFullScreenWindowFocused(WScreen
*scr
)
1422 if (scr
->focused_window
&& scr
->focused_window
->flags
.fullscreen
)
1430 handleKeyPress(XEvent
*event
)
1432 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1433 WWindow
*wwin
= scr
->focused_window
;
1436 int command
=-1, index
;
1437 #ifdef KEEP_XKB_LOCK_STATUS
1438 XkbStateRec staterec
;
1439 #endif /*KEEP_XKB_LOCK_STATUS*/
1441 /* ignore CapsLock */
1442 modifiers
= event
->xkey
.state
& ValidModMask
;
1444 for (i
=0; i
<WKBD_LAST
; i
++) {
1445 if (wKeyBindings
[i
].keycode
==0)
1448 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1449 && (/*wKeyBindings[i].modifier==0
1450 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1464 if (!wRootMenuPerformShortcut(event
)) {
1466 static int dontLoop
= 0;
1468 if (dontLoop
> 10) {
1469 wwarning("problem with key event processing code");
1473 /* if the focused window is an internal window, try redispatching
1474 * the event to the managed window, as it can be a WINGs window */
1475 if (wwin
&& wwin
->flags
.internal_window
1476 && wwin
->client_leader
!=None
) {
1477 /* client_leader contains the WINGs toplevel */
1478 event
->xany
.window
= wwin
->client_leader
;
1479 WMHandleEvent(event
);
1486 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1487 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1492 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/
1493 if (!CheckFullScreenWindowFocused(scr
)) {
1494 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1495 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1498 case WKBD_WINDOWLIST
:
1499 if (!CheckFullScreenWindowFocused(scr
)) {
1500 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1501 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1505 case WKBD_WINDOWMENU
:
1506 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1507 OpenWindowMenu(wwin
, wwin
->frame_x
,
1508 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1510 case WKBD_MINIATURIZE
:
1511 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1512 && !WFLAGP(wwin
, no_miniaturizable
)) {
1513 CloseWindowMenu(scr
);
1515 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1516 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1517 event
->xbutton
.time
);
1519 wIconifyWindow(wwin
);
1524 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1525 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1526 CloseWindowMenu(scr
);
1528 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1529 wHideApplication(wapp
);
1533 case WKBD_HIDE_OTHERS
:
1534 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1535 CloseWindowMenu(scr
);
1537 wHideOtherApplications(wwin
);
1541 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1542 int newdir
= (MAX_VERTICAL
|MAX_HORIZONTAL
);
1544 CloseWindowMenu(scr
);
1546 if (wwin
->flags
.maximized
== newdir
) {
1547 wUnmaximizeWindow(wwin
);
1549 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1553 case WKBD_VMAXIMIZE
:
1554 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1555 int newdir
= (MAX_VERTICAL
^ wwin
->flags
.maximized
);
1557 CloseWindowMenu(scr
);
1560 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1562 wUnmaximizeWindow(wwin
);
1566 case WKBD_HMAXIMIZE
:
1567 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1568 int newdir
= (MAX_HORIZONTAL
^ wwin
->flags
.maximized
);
1570 CloseWindowMenu(scr
);
1573 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1575 wUnmaximizeWindow(wwin
);
1580 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1581 CloseWindowMenu(scr
);
1583 wRaiseFrame(wwin
->frame
->core
);
1587 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1588 CloseWindowMenu(scr
);
1590 wLowerFrame(wwin
->frame
->core
);
1593 case WKBD_RAISELOWER
:
1594 /* raise or lower the window under the pointer, not the
1597 wwin
= windowUnderPointer(scr
);
1599 wRaiseLowerFrame(wwin
->frame
->core
);
1602 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1603 if (wwin
->flags
.shaded
)
1604 wUnshadeWindow(wwin
);
1609 case WKBD_MOVERESIZE
:
1610 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) &&
1611 (IS_RESIZABLE(wwin
) || IS_MOVABLE(wwin
))) {
1612 CloseWindowMenu(scr
);
1614 wKeyboardMoveResizeWindow(wwin
);
1618 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1619 CloseWindowMenu(scr
);
1620 if (wwin
->protocols
.DELETE_WINDOW
)
1621 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1626 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1627 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1630 case WKBD_FOCUSNEXT
:
1631 StartWindozeCycle(wwin
, event
, True
);
1634 case WKBD_FOCUSPREV
:
1635 StartWindozeCycle(wwin
, event
, False
);
1638 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1639 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1640 i = (scr->current_workspace/10)*10 + wk - 1;\
1641 if (wPreferences.ws_advance || i<scr->workspace_count)\
1642 wWorkspaceChange(scr, i);\
1645 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1646 i = (scr->current_workspace/10)*10 + wk - 1;\
1647 if (wPreferences.ws_advance || i<scr->workspace_count)\
1648 wWorkspaceChange(scr, i);\
1662 case WKBD_NEXTWORKSPACE
:
1663 wWorkspaceRelativeChange(scr
, 1);
1665 case WKBD_PREVWORKSPACE
:
1666 wWorkspaceRelativeChange(scr
, -1);
1679 index
= command
-WKBD_WINDOW1
;
1681 if (scr
->shortcutWindows
[index
]) {
1682 WMArray
*list
= scr
->shortcutWindows
[index
];
1684 int count
= WMGetArrayItemCount(list
);
1686 WMArrayIterator iter
;
1689 wUnselectWindows(scr
);
1690 cw
= scr
->current_workspace
;
1692 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1694 wWindowChangeWorkspace(wwin
, cw
);
1696 wMakeWindowVisible(wwin
);
1699 wSelectWindow(wwin
, True
);
1702 /* rotate the order of windows, to create a cycling effect */
1703 twin
= WMGetFromArray(list
, 0);
1704 WMDeleteFromArray(list
, 0);
1705 WMAddToArray(list
, twin
);
1707 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1708 if (scr
->shortcutWindows
[index
]) {
1709 WMFreeArray(scr
->shortcutWindows
[index
]);
1710 scr
->shortcutWindows
[index
] = NULL
;
1713 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1714 scr
->shortcutWindows
[index
] =
1715 WMDuplicateArray(scr
->selected_windows
);
1716 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1717 WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
1719 scr
->shortcutWindows
[index
] = WMCreateArray(4);
1720 WMAddToArray(scr
->shortcutWindows
[index
], wwin
);
1723 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1726 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1729 } else if (scr
->selected_windows
1730 && WMGetArrayItemCount(scr
->selected_windows
)) {
1732 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1733 if (scr
->shortcutWindows
[index
]) {
1734 WMFreeArray(scr
->shortcutWindows
[index
]);
1736 scr
->shortcutWindows
[index
] =
1737 WMDuplicateArray(scr
->selected_windows
);
1743 case WKBD_SWITCH_SCREEN
:
1744 if (wScreenCount
> 1) {
1748 /* find index of this screen */
1749 for (i
= 0; i
< wScreenCount
; i
++) {
1750 if (wScreenWithNumber(i
) == scr
)
1754 if (i
>= wScreenCount
) {
1757 scr2
= wScreenWithNumber(i
);
1760 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1761 scr2
->scr_width
/2, scr2
->scr_height
/2);
1766 case WKBD_NEXTWSLAYER
:
1767 case WKBD_PREVWSLAYER
:
1771 row
= scr
->current_workspace
/10;
1772 column
= scr
->current_workspace
%10;
1774 if (command
==WKBD_NEXTWSLAYER
) {
1775 if ((row
+1)*10 < scr
->workspace_count
)
1776 wWorkspaceChange(scr
, column
+(row
+1)*10);
1779 wWorkspaceChange(scr
, column
+(row
-1)*10);
1783 case WKBD_CLIPLOWER
:
1784 if (!wPreferences
.flags
.noclip
)
1785 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1787 case WKBD_CLIPRAISE
:
1788 if (!wPreferences
.flags
.noclip
)
1789 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1791 case WKBD_CLIPRAISELOWER
:
1792 if (!wPreferences
.flags
.noclip
)
1793 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1795 #ifdef KEEP_XKB_LOCK_STATUS
1797 if(wPreferences
.modelock
) {
1799 wwin
= scr
->focused_window
;
1801 if (wwin
&& wwin
->flags
.mapped
1802 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1803 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1804 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1806 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1807 wwin
->frame
->last_languagemode
= staterec
.group
;
1808 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1813 #endif /* KEEP_XKB_LOCK_STATUS */
1814 #ifdef VIRTUAL_DESKTOP
1815 case WKBD_VDESK_LEFT
:
1816 wWorkspaceKeyboardMoveDesktop(scr
, VEC_LEFT
);
1819 case WKBD_VDESK_RIGHT
:
1820 wWorkspaceKeyboardMoveDesktop(scr
, VEC_RIGHT
);
1824 wWorkspaceKeyboardMoveDesktop(scr
, VEC_UP
);
1827 case WKBD_VDESK_DOWN
:
1828 wWorkspaceKeyboardMoveDesktop(scr
, VEC_DOWN
);
1837 handleMotionNotify(XEvent
*event
)
1839 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1841 if (wPreferences
.scrollable_menus
) {
1842 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1843 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1845 if (scr
->flags
.jump_back_pending
||
1846 p
.x
<= (rect
.pos
.x
+ 1) ||
1847 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1848 p
.y
<= (rect
.pos
.y
+ 1) ||
1849 p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1852 printf("pointer at screen edge\n");
1854 menu
= wMenuUnderPointer(scr
);
1856 wMenuScroll(menu
, event
);
1863 handleVisibilityNotify(XEvent
*event
)
1867 wwin
= wWindowFor(event
->xvisibility
.window
);
1870 wwin
->flags
.obscured
=
1871 (event
->xvisibility
.state
== VisibilityFullyObscured
);