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,
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"
70 /******** Global Variables **********/
71 extern XContext wWinContext
;
73 extern Cursor wCursor
[WCUR_LAST
];
75 extern WShortKey wKeyBindings
[WKBD_LAST
];
76 extern int wScreenCount
;
77 extern Time LastTimestamp
;
78 extern Time LastFocusChange
;
80 extern WPreferences wPreferences
;
82 #define MOD_MASK wPreferences.modifier_mask
84 extern Atom _XA_WM_COLORMAP_NOTIFY
;
86 extern Atom _XA_WM_CHANGE_STATE
;
87 extern Atom _XA_WM_DELETE_WINDOW
;
88 extern Atom _XA_GNUSTEP_WM_ATTR
;
89 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
90 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
91 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
92 extern Atom _XA_WINDOWMAKER_COMMAND
;
95 extern Atom _XA_DND_PROTOCOL
;
100 extern Bool wShapeSupported
;
101 extern int wShapeEventBase
;
104 #ifdef KEEP_XKB_LOCK_STATUS
105 extern int wXkbEventBase
;
109 extern char WDelayedActionSet
;
112 /************ Local stuff ***********/
115 static void saveTimestamp(XEvent
*event
);
116 static void handleColormapNotify();
117 static void handleMapNotify(), handleUnmapNotify();
118 static void handleButtonPress(), handleExpose();
119 static void handleDestroyNotify();
120 static void handleConfigureRequest();
121 static void handleMapRequest();
122 static void handlePropertyNotify();
123 static void handleEnterNotify();
124 static void handleLeaveNotify();
125 static void handleExtensions();
126 static void handleClientMessage();
127 static void handleKeyPress();
128 static void handleFocusIn();
129 static void handleMotionNotify();
130 static void handleVisibilityNotify();
134 static void handleShapeNotify();
137 /* called from the signal handler */
138 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
140 /* real dead process handler */
141 static void handleDeadProcess(void *foo
);
144 typedef struct DeadProcesses
{
146 unsigned char exit_status
;
149 /* stack of dead processes */
150 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
151 static int deadProcessPtr
=0;
154 typedef struct DeathHandler
{
155 WDeathHandler
*callback
;
160 static WMArray
*deathHandlers
=NULL
;
165 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
167 DeathHandler
*handler
;
169 handler
= malloc(sizeof(DeathHandler
));
174 handler
->callback
= callback
;
175 handler
->client_data
= cdata
;
178 deathHandlers
= WMCreateArrayWithDestructor(8, wfree
);
180 WMAddToArray(deathHandlers
, handler
);
188 wDeleteDeathHandler(WMagicNumber id
)
190 DeathHandler
*handler
=(DeathHandler
*)id
;
192 if (!handler
|| !deathHandlers
)
195 /* array destructor will call wfree(handler) */
196 WMRemoveFromArray(deathHandlers
, handler
);
201 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("bla");
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
292 || event
->xmapping
.request
== MappingModifier
)
293 XRefreshKeyboardMapping(&event
->xmapping
);
297 handleFocusIn(event
);
300 case VisibilityNotify
:
301 handleVisibilityNotify(event
);
304 handleExtensions(event
);
311 *----------------------------------------------------------------------
313 * Processes X and internal events indefinitely.
319 * The LastTimestamp global variable is updated.
320 *----------------------------------------------------------------------
328 WMNextEvent(dpy
, &event
);
329 WMHandleEvent(&event
);
336 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
338 if ((scr
->last_click_time
>0) &&
339 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
340 && (event
->xbutton
.button
== scr
->last_click_button
)
341 && (event
->xbutton
.window
== scr
->last_click_window
)) {
343 scr
->flags
.next_click_is_not_double
= 1;
344 scr
->last_click_time
= 0;
345 scr
->last_click_window
= event
->xbutton
.window
;
354 NotifyDeadProcess(pid_t pid
, unsigned char status
)
356 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
357 wwarning("stack overflow: too many dead processes");
360 /* stack the process to be handled later,
361 * as this is called from the signal handler */
362 deadProcesses
[deadProcessPtr
].pid
= pid
;
363 deadProcesses
[deadProcessPtr
].exit_status
= status
;
369 handleDeadProcess(void *foo
)
374 for (i
=0; i
<deadProcessPtr
; i
++) {
375 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
378 if (!deathHandlers
) {
383 /* get the pids on the queue and call handlers */
384 while (deadProcessPtr
>0) {
387 for (i
= WMGetArrayItemCount(deathHandlers
)-1; i
>= 0; i
--) {
388 tmp
= WMGetFromArray(deathHandlers
, i
);
392 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
393 (*tmp
->callback
)(tmp
->pid
,
394 deadProcesses
[deadProcessPtr
].exit_status
,
396 wDeleteDeathHandler(tmp
);
404 saveTimestamp(XEvent
*event
)
407 * Never save CurrentTime as LastTimestamp because CurrentTime
408 * it's not a real timestamp (it's the 0L constant)
411 switch (event
->type
) {
414 LastTimestamp
= event
->xbutton
.time
;
418 LastTimestamp
= event
->xkey
.time
;
421 LastTimestamp
= event
->xmotion
.time
;
424 LastTimestamp
= event
->xproperty
.time
;
428 LastTimestamp
= event
->xcrossing
.time
;
431 LastTimestamp
= event
->xselectionclear
.time
;
433 case SelectionRequest
:
434 LastTimestamp
= event
->xselectionrequest
.time
;
436 case SelectionNotify
:
437 LastTimestamp
= event
->xselection
.time
;
439 wXDNDProcessSelection(event
);
447 matchWindow(void *item
, void *cdata
)
449 return (((WFakeGroupLeader
*)item
)->origLeader
== (Window
)cdata
);
454 handleExtensions(XEvent
*event
)
456 #ifdef KEEP_XKB_LOCK_STATUS
458 xkbevent
= (XkbEvent
*)event
;
459 #endif /*KEEP_XKB_LOCK_STATUS*/
461 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
462 handleShapeNotify(event
);
465 #ifdef KEEP_XKB_LOCK_STATUS
466 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
467 handleXkbIndicatorStateNotify(event
);
469 #endif /*KEEP_XKB_LOCK_STATUS*/
474 handleMapRequest(XEvent
*ev
)
478 Window window
= ev
->xmaprequest
.window
;
481 L("got map request for %x\n", (unsigned)window
);
483 if ((wwin
= wWindowFor(window
))) {
484 if (wwin
->flags
.shaded
) {
485 wUnshadeWindow(wwin
);
487 /* deiconify window */
488 if (wwin
->flags
.miniaturized
) {
489 wDeiconifyWindow(wwin
);
490 } else if (wwin
->flags
.hidden
) {
491 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
492 /* go to the last workspace that the user worked on the app */
494 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
496 wUnhideApplication(wapp
, False
, False
);
501 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
503 wwin
= wManageWindow(scr
, window
);
506 * This is to let the Dock know that the application it launched
507 * has already been mapped (eg: it has finished launching).
508 * It is not necessary for normally docked apps, but is needed for
509 * apps that were forcedly docked (like with dockit).
511 if (scr
->last_dock
) {
512 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
513 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
515 wDockTrackWindowLaunch(scr
->last_dock
, window
);
519 wClientSetState(wwin
, NormalState
, None
);
520 if (wwin
->flags
.maximized
) {
521 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
523 if (wwin
->flags
.shaded
) {
524 wwin
->flags
.shaded
= 0;
525 wwin
->flags
.skip_next_animation
= 1;
528 if (wwin
->flags
.miniaturized
) {
529 wwin
->flags
.miniaturized
= 0;
530 wwin
->flags
.skip_next_animation
= 1;
531 wIconifyWindow(wwin
);
533 if (wwin
->flags
.hidden
) {
534 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
536 wwin
->flags
.hidden
= 0;
537 wwin
->flags
.skip_next_animation
= 1;
539 wHideApplication(wapp
);
547 handleDestroyNotify(XEvent
*event
)
551 Window window
= event
->xdestroywindow
.window
;
552 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
556 L("got destroy notify");
558 wwin
= wWindowFor(window
);
560 wUnmanageWindow(wwin
, False
, True
);
564 while ((index
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
,
565 (void*)window
)) != WANotFound
) {
566 WFakeGroupLeader
*fPtr
;
568 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
569 if (fPtr
->retainCount
> 0) {
571 if (fPtr
->retainCount
==0 && fPtr
->leader
!=None
) {
572 XDestroyWindow(dpy
, fPtr
->leader
);
577 fPtr
->origLeader
= None
;
581 app
= wApplicationOf(window
);
583 if (window
== app
->main_window
) {
585 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
587 if (wwin
->main_window
== window
) {
588 wwin
->main_window
= None
;
593 wApplicationDestroy(app
);
597 wKWMCheckDestroy(&event
->xdestroywindow
);
604 handleExpose(XEvent
*event
)
606 WObjDescriptor
*desc
;
612 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
614 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
615 (XPointer
*)&desc
)==XCNOENT
) {
619 if (desc
->handle_expose
) {
620 (*desc
->handle_expose
)(desc
, event
);
625 executeButtonAction(WScreen
*scr
, XEvent
*event
, int action
)
628 case WA_SELECT_WINDOWS
:
629 wUnselectWindows(scr
);
630 wSelectWindows(scr
, event
);
632 case WA_OPEN_APPMENU
:
633 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
635 if (scr
->root_menu
) {
636 if (scr
->root_menu
->brother
->flags
.mapped
)
637 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
639 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
642 case WA_OPEN_WINLISTMENU
:
643 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
644 if (scr
->switch_menu
) {
645 if (scr
->switch_menu
->brother
->flags
.mapped
)
646 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
648 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
659 handleButtonPress(XEvent
*event
)
661 WObjDescriptor
*desc
;
665 L("got button press");
667 scr
= wScreenForRootWindow(event
->xbutton
.root
);
675 if (event
->xbutton
.window
==scr
->root_win
) {
676 if (event
->xbutton
.button
==Button1
&&
677 wPreferences
.mouse_button1
!=WA_NONE
) {
678 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
679 } else if (event
->xbutton
.button
==Button2
&&
680 wPreferences
.mouse_button2
!=WA_NONE
) {
681 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
682 } else if (event
->xbutton
.button
==Button3
&&
683 wPreferences
.mouse_button3
!=WA_NONE
) {
684 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
685 } else if (event
->xbutton
.button
==Button4
&&
686 wPreferences
.mouse_wheel
!=WA_NONE
) {
687 wWorkspaceRelativeChange(scr
, 1);
688 } else if (event
->xbutton
.button
==Button5
&&
689 wPreferences
.mouse_wheel
!=WA_NONE
) {
690 wWorkspaceRelativeChange(scr
, -1);
693 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
700 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
701 (XPointer
*)&desc
)==XCNOENT
) {
702 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
703 (XPointer
*)&desc
)==XCNOENT
) {
708 if (desc
->parent_type
== WCLASS_WINDOW
) {
711 if (event
->xbutton
.state
& MOD_MASK
) {
712 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
715 /* if (wPreferences.focus_mode == WKF_CLICK) {*/
716 if (wPreferences
.ignore_focus_click
) {
717 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
719 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
722 } else if (desc
->parent_type
== WCLASS_APPICON
723 || desc
->parent_type
== WCLASS_MINIWINDOW
724 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
725 if (event
->xbutton
.state
& MOD_MASK
) {
727 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
732 if (desc
->handle_mousedown
!=NULL
) {
733 (*desc
->handle_mousedown
)(desc
, event
);
736 /* save double-click information */
737 if (scr
->flags
.next_click_is_not_double
) {
738 scr
->flags
.next_click_is_not_double
= 0;
740 scr
->last_click_time
= event
->xbutton
.time
;
741 scr
->last_click_button
= event
->xbutton
.button
;
742 scr
->last_click_window
= event
->xbutton
.window
;
748 handleMapNotify(XEvent
*event
)
754 wwin
= wWindowFor(event
->xmap
.event
);
755 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
756 if (wwin
->flags
.miniaturized
) {
757 wDeiconifyWindow(wwin
);
761 wClientSetState(wwin
, NormalState
, None
);
769 handleUnmapNotify(XEvent
*event
)
773 Bool withdraw
= False
;
777 /* only process windows with StructureNotify selected
778 * (ignore SubstructureNotify) */
779 wwin
= wWindowFor(event
->xunmap
.window
);
783 /* whether the event is a Withdrawal request */
784 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
785 && event
->xunmap
.send_event
)
788 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
791 if (!wwin
->flags
.mapped
&& !withdraw
792 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
793 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
797 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
798 wwin
->flags
.mapped
= 0;
800 /* check if the window was destroyed */
801 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
804 Bool reparented
= False
;
806 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
809 /* withdraw window */
810 wwin
->flags
.mapped
= 0;
812 wClientSetState(wwin
, WithdrawnState
, None
);
814 /* if the window was reparented, do not reparent it back to the
816 wUnmanageWindow(wwin
, !reparented
, False
);
823 handleConfigureRequest(XEvent
*event
)
827 L("got configure request");
829 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
831 * Configure request for unmapped window
833 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
835 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
841 handlePropertyNotify(XEvent
*event
)
850 L("got property notify");
852 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
853 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
854 &ju
, &ju
, &ju
, &ju
)) {
857 wClientCheckProperty(wwin
, &event
->xproperty
);
859 wapp
= wApplicationOf(event
->xproperty
.window
);
861 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
864 scr
= wScreenForWindow(event
->xproperty
.window
);
865 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
867 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
874 handleClientMessage(XEvent
*event
)
877 WObjDescriptor
*desc
;
879 L("got client message");
881 /* handle transition from Normal to Iconic state */
882 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
883 && event
->xclient
.format
== 32
884 && event
->xclient
.data
.l
[0] == IconicState
) {
886 wwin
= wWindowFor(event
->xclient
.window
);
888 if (!wwin
->flags
.miniaturized
)
889 wIconifyWindow(wwin
);
890 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
891 && event
->xclient
.format
== 32) {
892 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
897 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
898 wColormapAllowClientInstallation(scr
, True
);
899 } else { /* stopping */
900 wColormapAllowClientInstallation(scr
, False
);
902 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
904 wDefaultsCheckDomains("bla");
906 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
909 wapp
= wApplicationOf(event
->xclient
.window
);
911 switch (event
->xclient
.data
.l
[0]) {
912 case WMFHideOtherApplications
:
913 wHideOtherApplications(wapp
->main_window_desc
);
917 case WMFHideApplication
:
918 wHideApplication(wapp
);
924 wwin
= wWindowFor(event
->xclient
.window
);
926 switch (event
->xclient
.data
.l
[0]) {
927 case WMFHideOtherApplications
:
928 wHideOtherApplications(wwin
);
931 case WMFHideApplication
:
932 wHideApplication(wApplicationOf(wwin
->main_window
));
937 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
938 wwin
= wWindowFor(event
->xclient
.window
);
940 switch (event
->xclient
.data
.l
[0]) {
941 case GSWindowLevelAttr
:
943 int level
= (int)event
->xclient
.data
.l
[1];
945 if (WINDOW_LEVEL(wwin
) != level
) {
946 ChangeStackingLevel(wwin
->frame
->core
, level
);
951 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
952 wwin
= wWindowFor(event
->xclient
.window
);
954 switch (event
->xclient
.data
.l
[0]) {
955 case WMTitleBarNormal
:
956 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
959 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
962 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
966 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
968 #endif /* GNOME_STUFF */
970 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
972 #endif /* KWM_HINTS */
974 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
978 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
979 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
980 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
981 goto redirect_message
;
982 #endif /* OFFIX_DND */
988 * Non-standard thing, but needed by OffiX DND.
989 * For when the icon frame gets a ClientMessage
990 * that should have gone to the icon_window.
992 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
993 (XPointer
*)&desc
)!=XCNOENT
) {
994 struct WIcon
*icon
=NULL
;
996 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
997 icon
= (WIcon
*)desc
->parent
;
998 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
999 || desc
->parent_type
== WCLASS_APPICON
) {
1000 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
1002 if (icon
&& (wwin
=icon
->owner
)) {
1003 if (wwin
->client_win
!=event
->xclient
.window
) {
1004 event
->xclient
.window
= wwin
->client_win
;
1005 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
1015 raiseWindow(WScreen
*scr
)
1019 scr
->autoRaiseTimer
= NULL
;
1021 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1025 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1026 wRaiseFrame(wwin
->frame
->core
);
1027 /* this is needed or a race condition will occur */
1034 handleEnterNotify(XEvent
*event
)
1037 WObjDescriptor
*desc
= NULL
;
1039 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1041 L("got enter notify");
1044 #ifdef VIRTUAL_DESKTOP
1045 /* TODO: acceleration code */
1046 if (wPreferences
.vedge_thickness
) {
1048 if (event
->xcrossing
.window
== scr
->virtual_edge_r
) {
1049 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, scr
->scr_width
- wPreferences
.vedge_thickness
- 1, event
->xcrossing
.y_root
);
1050 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1051 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
+ VIRTUALEDGE_SCROLL_HSTEP
, y
);
1052 } else if (event
->xcrossing
.window
== scr
->virtual_edge_l
) {
1053 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, wPreferences
.vedge_thickness
+ 1, event
->xcrossing
.y_root
);
1054 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1055 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
- VIRTUALEDGE_SCROLL_HSTEP
, y
);
1056 } else if (event
->xcrossing
.window
== scr
->virtual_edge_u
) {
1057 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, wPreferences
.vedge_thickness
+ 1);
1058 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1059 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
- VIRTUALEDGE_SCROLL_VSTEP
);
1060 } else if (event
->xcrossing
.window
== scr
->virtual_edge_d
) {
1061 printf("enter bottom\n");
1062 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, scr
->scr_height
- wPreferences
.vedge_thickness
- 1);
1063 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1064 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
+ VIRTUALEDGE_SCROLL_VSTEP
);
1069 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1071 /* already left the window... */
1073 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1074 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1079 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1080 (XPointer
*)&desc
)!=XCNOENT
) {
1081 if(desc
->handle_enternotify
)
1082 (*desc
->handle_enternotify
)(desc
, event
);
1085 /* enter to window */
1086 wwin
= wWindowFor(event
->xcrossing
.window
);
1088 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1089 wColormapInstallForWindow(scr
, NULL
);
1091 if (scr
->autoRaiseTimer
1092 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1093 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1094 scr
->autoRaiseTimer
= NULL
;
1097 /* set auto raise timer even if in focus-follows-mouse mode
1098 * and the event is for the frame window, even if the window
1099 * has focus already. useful if you move the pointer from a focused
1100 * window to the root window and back pretty fast
1102 * set focus if in focus-follows-mouse mode and the event
1103 * is for the frame window and window doesn't have focus yet */
1104 if (wPreferences
.focus_mode
==WKF_SLOPPY
1105 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1106 && !scr
->flags
.doing_alt_tab
) {
1108 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1109 wSetFocusTo(scr
, wwin
);
1111 if (scr
->autoRaiseTimer
)
1112 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1113 scr
->autoRaiseTimer
= NULL
;
1115 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1116 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1118 = WMAddTimerHandler(wPreferences
.raise_delay
,
1119 (WMCallback
*)raiseWindow
, scr
);
1122 /* Install colormap for window, if the colormap installation mode
1123 * is colormap_follows_mouse */
1124 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1125 if (wwin
->client_win
==event
->xcrossing
.window
)
1126 wColormapInstallForWindow(scr
, wwin
);
1128 wColormapInstallForWindow(scr
, NULL
);
1132 /* a little kluge to hide the clip balloon */
1133 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1135 XUnmapWindow(dpy
, scr
->clip_balloon
);
1136 scr
->flags
.clip_balloon_mapped
= 0;
1138 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1139 || scr
->clip_icon
!= desc
->parent
) {
1140 XUnmapWindow(dpy
, scr
->clip_balloon
);
1141 scr
->flags
.clip_balloon_mapped
= 0;
1146 if (event
->xcrossing
.window
== event
->xcrossing
.root
1147 && event
->xcrossing
.detail
== NotifyNormal
1148 && event
->xcrossing
.detail
!= NotifyInferior
1149 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1151 wSetFocusTo(scr
, scr
->focused_window
);
1155 wBalloonEnteredObject(scr
, desc
);
1161 handleLeaveNotify(XEvent
*event
)
1163 WObjDescriptor
*desc
= NULL
;
1165 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1166 (XPointer
*)&desc
)!=XCNOENT
) {
1167 if(desc
->handle_leavenotify
)
1168 (*desc
->handle_leavenotify
)(desc
, event
);
1175 handleShapeNotify(XEvent
*event
)
1177 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1181 L("got shape notify");
1183 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1184 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1186 if (sev
->kind
== ShapeBounding
) {
1187 if (sev
->shaped
== shev
->shaped
) {
1190 XPutBackEvent(dpy
, &ev
);
1196 wwin
= wWindowFor(shev
->window
);
1197 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1200 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1202 wwin
->flags
.shaped
= 0;
1203 wWindowClearShape(wwin
);
1205 } else if (shev
->shaped
) {
1207 wwin
->flags
.shaped
= 1;
1208 wWindowSetShape(wwin
);
1213 #ifdef KEEP_XKB_LOCK_STATUS
1214 /* please help ]d if you know what to do */
1215 handleXkbIndicatorStateNotify(XEvent
*event
)
1219 XkbStateRec staterec
;
1222 for (i
=0; i
<wScreenCount
; i
++) {
1223 scr
= wScreenWithNumber(i
);
1224 wwin
= scr
->focused_window
;
1225 if (wwin
&& wwin
->flags
.focused
) {
1226 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1227 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1228 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1229 wwin
->frame
->languagemode
= staterec
.group
;
1231 #ifdef XKB_BUTTON_HINT
1232 if (wwin
->frame
->titlebar
) {
1233 wFrameWindowPaint(wwin
->frame
);
1239 #endif /*KEEP_XKB_LOCK_STATUS*/
1242 handleColormapNotify(XEvent
*event
)
1246 Bool reinstall
= False
;
1248 wwin
= wWindowFor(event
->xcolormap
.window
);
1252 scr
= wwin
->screen_ptr
;
1256 if (event
->xcolormap
.new) {
1257 XWindowAttributes attr
;
1259 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1261 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1262 scr
->current_colormap
= attr
.colormap
;
1265 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1266 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1268 /* some bastard app (like XV) removed our colormap */
1270 * can't enforce or things like xscreensaver wont work
1273 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1274 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1276 /* someone has put our colormap back */
1280 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1281 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1283 if (reinstall
&& scr
->current_colormap
!=None
) {
1284 if (!scr
->flags
.colormap_stuff_blocked
)
1285 XInstallColormap(dpy
, scr
->current_colormap
);
1292 handleFocusIn(XEvent
*event
)
1297 * For applications that like stealing the focus.
1299 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1300 saveTimestamp(event
);
1301 if (event
->xfocus
.mode
== NotifyUngrab
1302 || event
->xfocus
.mode
== NotifyGrab
1303 || 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
);
1322 windowUnderPointer(WScreen
*scr
)
1328 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1330 return wWindowFor(win
);
1338 handleKeyPress(XEvent
*event
)
1340 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1341 WWindow
*wwin
= scr
->focused_window
;
1344 int command
=-1, index
;
1345 #ifdef KEEP_XKB_LOCK_STATUS
1346 XkbStateRec staterec
;
1347 #endif /*KEEP_XKB_LOCK_STATUS*/
1349 /* ignore CapsLock */
1350 modifiers
= event
->xkey
.state
& ValidModMask
;
1352 for (i
=0; i
<WKBD_LAST
; i
++) {
1353 if (wKeyBindings
[i
].keycode
==0)
1356 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1357 && (/*wKeyBindings[i].modifier==0
1358 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1372 if (!wRootMenuPerformShortcut(event
)) {
1374 static int dontLoop
= 0;
1376 if (dontLoop
> 10) {
1377 wwarning("problem with key event processing code");
1381 /* if the focused window is an internal window, try redispatching
1382 * the event to the managed window, as it can be a WINGs window */
1383 if (wwin
&& wwin
->flags
.internal_window
1384 && wwin
->client_leader
!=None
) {
1385 /* client_leader contains the WINGs toplevel */
1386 event
->xany
.window
= wwin
->client_leader
;
1387 WMHandleEvent(event
);
1394 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1395 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1400 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/
1402 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1403 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1406 case WKBD_WINDOWLIST
:
1408 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1409 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1413 case WKBD_WINDOWMENU
:
1414 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1415 OpenWindowMenu(wwin
, wwin
->frame_x
,
1416 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1418 case WKBD_MINIATURIZE
:
1419 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1420 && !WFLAGP(wwin
, no_miniaturizable
)) {
1421 CloseWindowMenu(scr
);
1423 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1424 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1425 event
->xbutton
.time
);
1427 wIconifyWindow(wwin
);
1432 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1433 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1434 CloseWindowMenu(scr
);
1436 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1437 wHideApplication(wapp
);
1441 case WKBD_HIDE_OTHERS
:
1442 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1443 CloseWindowMenu(scr
);
1445 wHideOtherApplications(wwin
);
1449 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1450 int newdir
= (MAX_VERTICAL
|MAX_HORIZONTAL
);
1452 CloseWindowMenu(scr
);
1454 if (wwin
->flags
.maximized
== newdir
) {
1455 wUnmaximizeWindow(wwin
);
1457 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1461 case WKBD_VMAXIMIZE
:
1462 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1463 int newdir
= (MAX_VERTICAL
^ wwin
->flags
.maximized
);
1465 CloseWindowMenu(scr
);
1468 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1470 wUnmaximizeWindow(wwin
);
1474 case WKBD_HMAXIMIZE
:
1475 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1476 int newdir
= (MAX_HORIZONTAL
^ wwin
->flags
.maximized
);
1478 CloseWindowMenu(scr
);
1481 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1483 wUnmaximizeWindow(wwin
);
1488 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1489 CloseWindowMenu(scr
);
1491 wRaiseFrame(wwin
->frame
->core
);
1495 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1496 CloseWindowMenu(scr
);
1498 wLowerFrame(wwin
->frame
->core
);
1501 case WKBD_RAISELOWER
:
1502 /* raise or lower the window under the pointer, not the
1505 wwin
= windowUnderPointer(scr
);
1507 wRaiseLowerFrame(wwin
->frame
->core
);
1510 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1511 if (wwin
->flags
.shaded
)
1512 wUnshadeWindow(wwin
);
1517 case WKBD_MOVERESIZE
:
1518 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1519 CloseWindowMenu(scr
);
1521 wKeyboardMoveResizeWindow(wwin
);
1525 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1526 CloseWindowMenu(scr
);
1527 if (wwin
->protocols
.DELETE_WINDOW
)
1528 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1533 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1534 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1537 case WKBD_FOCUSNEXT
:
1538 StartWindozeCycle(wwin
, event
, True
);
1541 case WKBD_FOCUSPREV
:
1542 StartWindozeCycle(wwin
, event
, False
);
1545 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1546 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1547 i = (scr->current_workspace/10)*10 + wk - 1;\
1548 if (wPreferences.ws_advance || i<scr->workspace_count)\
1549 wWorkspaceChange(scr, i);\
1552 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1553 i = (scr->current_workspace/10)*10 + wk - 1;\
1554 if (wPreferences.ws_advance || i<scr->workspace_count)\
1555 wWorkspaceChange(scr, i);\
1569 case WKBD_NEXTWORKSPACE
:
1570 wWorkspaceRelativeChange(scr
, 1);
1572 case WKBD_PREVWORKSPACE
:
1573 wWorkspaceRelativeChange(scr
, -1);
1586 index
= command
-WKBD_WINDOW1
;
1588 if (scr
->shortcutWindows
[index
]) {
1589 WMArray
*list
= scr
->shortcutWindows
[index
];
1591 int count
= WMGetArrayItemCount(list
);
1593 WMArrayIterator iter
;
1596 wUnselectWindows(scr
);
1597 cw
= scr
->current_workspace
;
1599 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1601 wWindowChangeWorkspace(wwin
, cw
);
1603 wMakeWindowVisible(wwin
);
1606 wSelectWindow(wwin
, True
);
1609 /* rotate the order of windows, to create a cycling effect */
1610 twin
= WMGetFromArray(list
, 0);
1611 WMDeleteFromArray(list
, 0);
1612 WMAddToArray(list
, twin
);
1614 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1615 if (scr
->shortcutWindows
[index
]) {
1616 WMFreeArray(scr
->shortcutWindows
[index
]);
1617 scr
->shortcutWindows
[index
] = NULL
;
1620 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1621 scr
->shortcutWindows
[index
] =
1622 WMDuplicateArray(scr
->selected_windows
);
1623 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1624 WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
1626 scr
->shortcutWindows
[index
] = WMCreateArray(4);
1627 WMAddToArray(scr
->shortcutWindows
[index
], wwin
);
1630 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1633 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1636 } else if (scr
->selected_windows
1637 && WMGetArrayItemCount(scr
->selected_windows
)) {
1639 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1640 if (scr
->shortcutWindows
[index
]) {
1641 WMFreeArray(scr
->shortcutWindows
[index
]);
1643 scr
->shortcutWindows
[index
] =
1644 WMDuplicateArray(scr
->selected_windows
);
1650 case WKBD_SWITCH_SCREEN
:
1651 if (wScreenCount
> 1) {
1655 /* find index of this screen */
1656 for (i
= 0; i
< wScreenCount
; i
++) {
1657 if (wScreenWithNumber(i
) == scr
)
1661 if (i
>= wScreenCount
) {
1664 scr2
= wScreenWithNumber(i
);
1667 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1668 scr2
->scr_width
/2, scr2
->scr_height
/2);
1673 case WKBD_NEXTWSLAYER
:
1674 case WKBD_PREVWSLAYER
:
1678 row
= scr
->current_workspace
/10;
1679 column
= scr
->current_workspace
%10;
1681 if (command
==WKBD_NEXTWSLAYER
) {
1682 if ((row
+1)*10 < scr
->workspace_count
)
1683 wWorkspaceChange(scr
, column
+(row
+1)*10);
1686 wWorkspaceChange(scr
, column
+(row
-1)*10);
1690 case WKBD_CLIPLOWER
:
1691 if (!wPreferences
.flags
.noclip
)
1692 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1694 case WKBD_CLIPRAISE
:
1695 if (!wPreferences
.flags
.noclip
)
1696 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1698 case WKBD_CLIPRAISELOWER
:
1699 if (!wPreferences
.flags
.noclip
)
1700 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1702 #ifdef KEEP_XKB_LOCK_STATUS
1704 if(wPreferences
.modelock
) {
1706 wwin
= scr
->focused_window
;
1708 if (wwin
&& wwin
->flags
.mapped
1709 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1710 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1711 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1713 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1714 wwin
->frame
->last_languagemode
= staterec
.group
;
1715 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1720 #endif /* KEEP_XKB_LOCK_STATUS */
1727 handleMotionNotify(XEvent
*event
)
1729 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1731 if (wPreferences
.scrollable_menus
) {
1732 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1733 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1735 if (scr
->flags
.jump_back_pending
||
1736 p
.x
<= (rect
.pos
.x
+ 1) ||
1737 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1738 p
.y
<= (rect
.pos
.y
+ 1) ||
1739 p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1742 L("pointer at screen edge");
1744 menu
= wMenuUnderPointer(scr
);
1746 wMenuScroll(menu
, event
);
1750 if (event
->xmotion
.subwindow
== None
)
1753 if (scr
->scrolledFMaximize
!= None
) {
1756 twin
= wWindowFor(scr
->scrolledFMaximize
);
1757 if (twin
&& twin
->frame_y
==) {
1761 scr
->scrolledFMaximize
= NULL
;
1765 /* scroll full maximized window */
1766 if (event
->xmotion
.y_root
< 1
1767 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1769 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1771 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1772 && WFLAGP(wwin
, full_maximize
)
1773 && event
->xmotion
.x_root
>= wwin
->frame_x
1774 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1776 if (!WFLAGP(wwin
, no_titlebar
)
1777 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1779 wWindowMove(wwin
, wwin
->frame_x
, 0);
1780 wwin
->flags
.dragged_while_fmaximized
= 0;
1782 } else if (!WFLAGP(wwin
, no_resizebar
)
1783 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1784 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1786 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1788 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1790 wWindowMove(wwin
, wwin
->frame_x
, y
);
1791 wwin
->flags
.dragged_while_fmaximized
= 0;
1800 handleVisibilityNotify(XEvent
*event
)
1804 wwin
= wWindowFor(event
->xvisibility
.window
);
1807 wwin
->flags
.obscured
=
1808 (event
->xvisibility
.state
== VisibilityFullyObscured
);