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"
73 /******** Global Variables **********/
74 extern XContext wWinContext
;
75 extern XContext wVEdgeContext
;
77 extern Cursor wCursor
[WCUR_LAST
];
79 extern WShortKey wKeyBindings
[WKBD_LAST
];
80 extern int wScreenCount
;
81 extern Time LastTimestamp
;
82 extern Time LastFocusChange
;
84 extern WPreferences wPreferences
;
86 #define MOD_MASK wPreferences.modifier_mask
88 extern Atom _XA_WM_COLORMAP_NOTIFY
;
90 extern Atom _XA_WM_CHANGE_STATE
;
91 extern Atom _XA_WM_DELETE_WINDOW
;
92 extern Atom _XA_GNUSTEP_WM_ATTR
;
93 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
94 extern Atom _XA_GNUSTEP_TITLEBAR_STATE
;
95 extern Atom _XA_WINDOWMAKER_WM_FUNCTION
;
96 extern Atom _XA_WINDOWMAKER_COMMAND
;
99 extern Atom _XA_DND_PROTOCOL
;
104 extern Bool wShapeSupported
;
105 extern int wShapeEventBase
;
108 #ifdef KEEP_XKB_LOCK_STATUS
109 extern int wXkbEventBase
;
113 extern char WDelayedActionSet
;
116 /************ Local stuff ***********/
119 static void saveTimestamp(XEvent
*event
);
120 static void handleColormapNotify();
121 static void handleMapNotify(), handleUnmapNotify();
122 static void handleButtonPress(), handleExpose();
123 static void handleDestroyNotify();
124 static void handleConfigureRequest();
125 static void handleMapRequest();
126 static void handlePropertyNotify();
127 static void handleEnterNotify();
128 static void handleLeaveNotify();
129 static void handleExtensions();
130 static void handleClientMessage();
131 static void handleKeyPress();
132 static void handleFocusIn();
133 static void handleMotionNotify();
134 static void handleVisibilityNotify();
138 static void handleShapeNotify();
141 /* called from the signal handler */
142 void NotifyDeadProcess(pid_t pid
, unsigned char status
);
144 /* real dead process handler */
145 static void handleDeadProcess(void *foo
);
148 typedef struct DeadProcesses
{
150 unsigned char exit_status
;
153 /* stack of dead processes */
154 static DeadProcesses deadProcesses
[MAX_DEAD_PROCESSES
];
155 static int deadProcessPtr
=0;
158 typedef struct DeathHandler
{
159 WDeathHandler
*callback
;
164 static WMArray
*deathHandlers
=NULL
;
169 wAddDeathHandler(pid_t pid
, WDeathHandler
*callback
, void *cdata
)
171 DeathHandler
*handler
;
173 handler
= malloc(sizeof(DeathHandler
));
178 handler
->callback
= callback
;
179 handler
->client_data
= cdata
;
182 deathHandlers
= WMCreateArrayWithDestructor(8, wfree
);
184 WMAddToArray(deathHandlers
, handler
);
192 wDeleteDeathHandler(WMagicNumber id
)
194 DeathHandler
*handler
=(DeathHandler
*)id
;
196 if (!handler
|| !deathHandlers
)
199 /* array destructor will call wfree(handler) */
200 WMRemoveFromArray(deathHandlers
, handler
);
205 DispatchEvent(XEvent
*event
)
208 handleDeadProcess(NULL
);
210 if (WCHECK_STATE(WSTATE_NEED_EXIT
)) {
211 WCHANGE_STATE(WSTATE_EXITING
);
212 /* received SIGTERM */
214 * WMHandleEvent() can't be called from anything
215 * executed inside here, or we can get in a infinite
218 Shutdown(WSExitMode
);
220 } else if (WCHECK_STATE(WSTATE_NEED_RESTART
)) {
221 WCHANGE_STATE(WSTATE_RESTARTING
);
223 Shutdown(WSRestartPreparationMode
);
224 /* received SIGHUP */
226 } else if (WCHECK_STATE(WSTATE_NEED_REREAD
)) {
227 WCHANGE_STATE(WSTATE_NORMAL
);
228 wDefaultsCheckDomains("bla");
231 /* for the case that all that is wanted to be dispatched is
236 saveTimestamp(event
);
237 switch (event
->type
) {
239 handleMapRequest(event
);
243 handleKeyPress(event
);
247 handleMotionNotify(event
);
250 case ConfigureRequest
:
251 handleConfigureRequest(event
);
255 handleDestroyNotify(event
);
259 handleMapNotify(event
);
263 handleUnmapNotify(event
);
267 handleButtonPress(event
);
275 handlePropertyNotify(event
);
279 handleEnterNotify(event
);
283 handleLeaveNotify(event
);
287 handleClientMessage(event
);
291 handleColormapNotify(event
);
295 if (event
->xmapping
.request
== MappingKeyboard
296 || event
->xmapping
.request
== MappingModifier
)
297 XRefreshKeyboardMapping(&event
->xmapping
);
301 handleFocusIn(event
);
304 case VisibilityNotify
:
305 handleVisibilityNotify(event
);
308 handleExtensions(event
);
315 *----------------------------------------------------------------------
317 * Processes X and internal events indefinitely.
323 * The LastTimestamp global variable is updated.
324 *----------------------------------------------------------------------
332 WMNextEvent(dpy
, &event
);
333 WMHandleEvent(&event
);
339 *----------------------------------------------------------------------
340 * ProcessPendingEvents --
341 * Processes the events that are currently pending (at the time
342 * this function is called) in the display's queue.
345 * After the pending events that were present at the function call
349 * Many -- whatever handling events may involve.
351 *----------------------------------------------------------------------
354 ProcessPendingEvents()
361 /* Take a snapshot of the event count in the queue */
362 count
= XPending(dpy
);
364 while (count
>0 && XPending(dpy
)) {
365 WMNextEvent(dpy
, &event
);
366 WMHandleEvent(&event
);
373 IsDoubleClick(WScreen
*scr
, XEvent
*event
)
375 if ((scr
->last_click_time
>0) &&
376 (event
->xbutton
.time
-scr
->last_click_time
<=wPreferences
.dblclick_time
)
377 && (event
->xbutton
.button
== scr
->last_click_button
)
378 && (event
->xbutton
.window
== scr
->last_click_window
)) {
380 scr
->flags
.next_click_is_not_double
= 1;
381 scr
->last_click_time
= 0;
382 scr
->last_click_window
= event
->xbutton
.window
;
391 NotifyDeadProcess(pid_t pid
, unsigned char status
)
393 if (deadProcessPtr
>=MAX_DEAD_PROCESSES
-1) {
394 wwarning("stack overflow: too many dead processes");
397 /* stack the process to be handled later,
398 * as this is called from the signal handler */
399 deadProcesses
[deadProcessPtr
].pid
= pid
;
400 deadProcesses
[deadProcessPtr
].exit_status
= status
;
406 handleDeadProcess(void *foo
)
411 for (i
=0; i
<deadProcessPtr
; i
++) {
412 wWindowDeleteSavedStatesForPID(deadProcesses
[i
].pid
);
415 if (!deathHandlers
) {
420 /* get the pids on the queue and call handlers */
421 while (deadProcessPtr
>0) {
424 for (i
= WMGetArrayItemCount(deathHandlers
)-1; i
>= 0; i
--) {
425 tmp
= WMGetFromArray(deathHandlers
, i
);
429 if (tmp
->pid
== deadProcesses
[deadProcessPtr
].pid
) {
430 (*tmp
->callback
)(tmp
->pid
,
431 deadProcesses
[deadProcessPtr
].exit_status
,
433 wDeleteDeathHandler(tmp
);
441 saveTimestamp(XEvent
*event
)
444 * Never save CurrentTime as LastTimestamp because CurrentTime
445 * it's not a real timestamp (it's the 0L constant)
448 switch (event
->type
) {
451 LastTimestamp
= event
->xbutton
.time
;
455 LastTimestamp
= event
->xkey
.time
;
458 LastTimestamp
= event
->xmotion
.time
;
461 LastTimestamp
= event
->xproperty
.time
;
465 LastTimestamp
= event
->xcrossing
.time
;
468 LastTimestamp
= event
->xselectionclear
.time
;
470 case SelectionRequest
:
471 LastTimestamp
= event
->xselectionrequest
.time
;
473 case SelectionNotify
:
474 LastTimestamp
= event
->xselection
.time
;
476 wXDNDProcessSelection(event
);
484 matchWindow(void *item
, void *cdata
)
486 return (((WFakeGroupLeader
*)item
)->origLeader
== (Window
)cdata
);
491 handleExtensions(XEvent
*event
)
493 #ifdef KEEP_XKB_LOCK_STATUS
495 xkbevent
= (XkbEvent
*)event
;
496 #endif /*KEEP_XKB_LOCK_STATUS*/
498 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
499 handleShapeNotify(event
);
502 #ifdef KEEP_XKB_LOCK_STATUS
503 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
504 handleXkbIndicatorStateNotify(event
);
506 #endif /*KEEP_XKB_LOCK_STATUS*/
511 handleMapRequest(XEvent
*ev
)
515 Window window
= ev
->xmaprequest
.window
;
518 printf("got map request for %x\n", (unsigned)window
);
520 if ((wwin
= wWindowFor(window
))) {
521 if (wwin
->flags
.shaded
) {
522 wUnshadeWindow(wwin
);
524 /* deiconify window */
525 if (wwin
->flags
.miniaturized
) {
526 wDeiconifyWindow(wwin
);
527 } else if (wwin
->flags
.hidden
) {
528 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
529 /* go to the last workspace that the user worked on the app */
531 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
533 wUnhideApplication(wapp
, False
, False
);
538 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
540 wwin
= wManageWindow(scr
, window
);
543 * This is to let the Dock know that the application it launched
544 * has already been mapped (eg: it has finished launching).
545 * It is not necessary for normally docked apps, but is needed for
546 * apps that were forcedly docked (like with dockit).
548 if (scr
->last_dock
) {
549 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
550 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
552 wDockTrackWindowLaunch(scr
->last_dock
, window
);
556 wClientSetState(wwin
, NormalState
, None
);
557 if (wwin
->flags
.maximized
) {
558 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
560 if (wwin
->flags
.shaded
) {
561 wwin
->flags
.shaded
= 0;
562 wwin
->flags
.skip_next_animation
= 1;
565 if (wwin
->flags
.miniaturized
) {
566 wwin
->flags
.miniaturized
= 0;
567 wwin
->flags
.skip_next_animation
= 1;
568 wIconifyWindow(wwin
);
570 if (wwin
->flags
.hidden
) {
571 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
573 wwin
->flags
.hidden
= 0;
574 wwin
->flags
.skip_next_animation
= 1;
576 wHideApplication(wapp
);
584 handleDestroyNotify(XEvent
*event
)
588 Window window
= event
->xdestroywindow
.window
;
589 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
593 printf("got destroy notify\n");
595 wwin
= wWindowFor(window
);
597 wUnmanageWindow(wwin
, False
, True
);
601 while ((index
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
,
602 (void*)window
)) != WANotFound
) {
603 WFakeGroupLeader
*fPtr
;
605 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
606 if (fPtr
->retainCount
> 0) {
608 if (fPtr
->retainCount
==0 && fPtr
->leader
!=None
) {
609 XDestroyWindow(dpy
, fPtr
->leader
);
614 fPtr
->origLeader
= None
;
618 app
= wApplicationOf(window
);
620 if (window
== app
->main_window
) {
622 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
624 if (wwin
->main_window
== window
) {
625 wwin
->main_window
= None
;
630 wApplicationDestroy(app
);
634 wKWMCheckDestroy(&event
->xdestroywindow
);
641 handleExpose(XEvent
*event
)
643 WObjDescriptor
*desc
;
647 printf("got expose\n");
649 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
651 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
652 (XPointer
*)&desc
)==XCNOENT
) {
656 if (desc
->handle_expose
) {
657 (*desc
->handle_expose
)(desc
, event
);
662 executeButtonAction(WScreen
*scr
, XEvent
*event
, int action
)
665 case WA_SELECT_WINDOWS
:
666 wUnselectWindows(scr
);
667 wSelectWindows(scr
, event
);
669 case WA_OPEN_APPMENU
:
670 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
672 if (scr
->root_menu
) {
673 if (scr
->root_menu
->brother
->flags
.mapped
)
674 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
676 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
679 case WA_OPEN_WINLISTMENU
:
680 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
681 if (scr
->switch_menu
) {
682 if (scr
->switch_menu
->brother
->flags
.mapped
)
683 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
685 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
696 handleButtonPress(XEvent
*event
)
698 WObjDescriptor
*desc
;
702 printf("got button press\n");
704 scr
= wScreenForRootWindow(event
->xbutton
.root
);
712 if (event
->xbutton
.window
==scr
->root_win
) {
713 if (event
->xbutton
.button
==Button1
&&
714 wPreferences
.mouse_button1
!=WA_NONE
) {
715 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
716 } else if (event
->xbutton
.button
==Button2
&&
717 wPreferences
.mouse_button2
!=WA_NONE
) {
718 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
719 } else if (event
->xbutton
.button
==Button3
&&
720 wPreferences
.mouse_button3
!=WA_NONE
) {
721 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
722 } else if (event
->xbutton
.button
==Button4
&&
723 wPreferences
.mouse_wheel
!=WA_NONE
) {
724 wWorkspaceRelativeChange(scr
, 1);
725 } else if (event
->xbutton
.button
==Button5
&&
726 wPreferences
.mouse_wheel
!=WA_NONE
) {
727 wWorkspaceRelativeChange(scr
, -1);
730 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
737 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
738 (XPointer
*)&desc
)==XCNOENT
) {
739 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
740 (XPointer
*)&desc
)==XCNOENT
) {
745 if (desc
->parent_type
== WCLASS_WINDOW
) {
748 if (event
->xbutton
.state
& MOD_MASK
) {
749 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
752 /* if (wPreferences.focus_mode == WKF_CLICK) {*/
753 if (wPreferences
.ignore_focus_click
) {
754 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
756 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
759 } else if (desc
->parent_type
== WCLASS_APPICON
760 || desc
->parent_type
== WCLASS_MINIWINDOW
761 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
762 if (event
->xbutton
.state
& MOD_MASK
) {
764 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
769 if (desc
->handle_mousedown
!=NULL
) {
770 (*desc
->handle_mousedown
)(desc
, event
);
773 /* save double-click information */
774 if (scr
->flags
.next_click_is_not_double
) {
775 scr
->flags
.next_click_is_not_double
= 0;
777 scr
->last_click_time
= event
->xbutton
.time
;
778 scr
->last_click_button
= event
->xbutton
.button
;
779 scr
->last_click_window
= event
->xbutton
.window
;
785 handleMapNotify(XEvent
*event
)
791 wwin
= wWindowFor(event
->xmap
.event
);
792 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
793 if (wwin
->flags
.miniaturized
) {
794 wDeiconifyWindow(wwin
);
798 wClientSetState(wwin
, NormalState
, None
);
806 handleUnmapNotify(XEvent
*event
)
810 Bool withdraw
= False
;
812 printf("got unmap\n");
814 /* only process windows with StructureNotify selected
815 * (ignore SubstructureNotify) */
816 wwin
= wWindowFor(event
->xunmap
.window
);
820 /* whether the event is a Withdrawal request */
821 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
822 && event
->xunmap
.send_event
)
825 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
828 if (!wwin
->flags
.mapped
&& !withdraw
829 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
830 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
834 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
835 wwin
->flags
.mapped
= 0;
837 /* check if the window was destroyed */
838 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
841 Bool reparented
= False
;
843 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
846 /* withdraw window */
847 wwin
->flags
.mapped
= 0;
849 wClientSetState(wwin
, WithdrawnState
, None
);
851 /* if the window was reparented, do not reparent it back to the
853 wUnmanageWindow(wwin
, !reparented
, False
);
860 handleConfigureRequest(XEvent
*event
)
864 printf("got configure request\n");
866 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
868 * Configure request for unmapped window
870 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
872 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
878 handlePropertyNotify(XEvent
*event
)
887 printf("got property notify\n");
889 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
890 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
891 &ju
, &ju
, &ju
, &ju
)) {
894 wClientCheckProperty(wwin
, &event
->xproperty
);
896 wapp
= wApplicationOf(event
->xproperty
.window
);
898 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
901 scr
= wScreenForWindow(event
->xproperty
.window
);
902 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
904 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
911 handleClientMessage(XEvent
*event
)
914 WObjDescriptor
*desc
;
916 printf("got client message\n");
918 /* handle transition from Normal to Iconic state */
919 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
920 && event
->xclient
.format
== 32
921 && event
->xclient
.data
.l
[0] == IconicState
) {
923 wwin
= wWindowFor(event
->xclient
.window
);
925 if (!wwin
->flags
.miniaturized
)
926 wIconifyWindow(wwin
);
927 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
928 && event
->xclient
.format
== 32) {
929 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
934 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
935 wColormapAllowClientInstallation(scr
, True
);
936 } else { /* stopping */
937 wColormapAllowClientInstallation(scr
, False
);
939 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
941 wDefaultsCheckDomains("bla");
943 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
946 wapp
= wApplicationOf(event
->xclient
.window
);
948 switch (event
->xclient
.data
.l
[0]) {
949 case WMFHideOtherApplications
:
950 wHideOtherApplications(wapp
->main_window_desc
);
954 case WMFHideApplication
:
955 wHideApplication(wapp
);
961 wwin
= wWindowFor(event
->xclient
.window
);
963 switch (event
->xclient
.data
.l
[0]) {
964 case WMFHideOtherApplications
:
965 wHideOtherApplications(wwin
);
968 case WMFHideApplication
:
969 wHideApplication(wApplicationOf(wwin
->main_window
));
974 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
975 wwin
= wWindowFor(event
->xclient
.window
);
977 switch (event
->xclient
.data
.l
[0]) {
978 case GSWindowLevelAttr
:
980 int level
= (int)event
->xclient
.data
.l
[1];
982 if (WINDOW_LEVEL(wwin
) != level
) {
983 ChangeStackingLevel(wwin
->frame
->core
, level
);
988 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
989 wwin
= wWindowFor(event
->xclient
.window
);
991 switch (event
->xclient
.data
.l
[0]) {
992 case WMTitleBarNormal
:
993 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
996 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
999 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1003 } else if (wNETWMProcessClientMessage(&event
->xclient
)) {
1007 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
1009 #endif /* GNOME_STUFF */
1011 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
1013 #endif /* KWM_HINTS */
1015 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
1019 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
1020 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
1021 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
1022 goto redirect_message
;
1023 #endif /* OFFIX_DND */
1029 * Non-standard thing, but needed by OffiX DND.
1030 * For when the icon frame gets a ClientMessage
1031 * that should have gone to the icon_window.
1033 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
1034 (XPointer
*)&desc
)!=XCNOENT
) {
1035 struct WIcon
*icon
=NULL
;
1037 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
1038 icon
= (WIcon
*)desc
->parent
;
1039 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
1040 || desc
->parent_type
== WCLASS_APPICON
) {
1041 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
1043 if (icon
&& (wwin
=icon
->owner
)) {
1044 if (wwin
->client_win
!=event
->xclient
.window
) {
1045 event
->xclient
.window
= wwin
->client_win
;
1046 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
1056 raiseWindow(WScreen
*scr
)
1060 scr
->autoRaiseTimer
= NULL
;
1062 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1066 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1067 wRaiseFrame(wwin
->frame
->core
);
1068 /* this is needed or a race condition will occur */
1075 handleEnterNotify(XEvent
*event
)
1078 WObjDescriptor
*desc
= NULL
;
1079 #ifdef VIRTUAL_DESKTOP
1080 void (*vdHandler
)(XEvent
* event
);
1083 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1085 printf("got enter notify\n");
1088 #ifdef VIRTUAL_DESKTOP
1089 if (XFindContext(dpy
, event
->xcrossing
.window
, wVEdgeContext
,
1090 (XPointer
*)&vdHandler
)!=XCNOENT
) {
1091 (*vdHandler
)( event
);
1095 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1097 /* already left the window... */
1099 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1100 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1105 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1106 (XPointer
*)&desc
)!=XCNOENT
) {
1107 if(desc
->handle_enternotify
)
1108 (*desc
->handle_enternotify
)(desc
, event
);
1111 /* enter to window */
1112 wwin
= wWindowFor(event
->xcrossing
.window
);
1114 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1115 wColormapInstallForWindow(scr
, NULL
);
1117 if (scr
->autoRaiseTimer
1118 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1119 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1120 scr
->autoRaiseTimer
= NULL
;
1123 /* set auto raise timer even if in focus-follows-mouse mode
1124 * and the event is for the frame window, even if the window
1125 * has focus already. useful if you move the pointer from a focused
1126 * window to the root window and back pretty fast
1128 * set focus if in focus-follows-mouse mode and the event
1129 * is for the frame window and window doesn't have focus yet */
1130 if (wPreferences
.focus_mode
==WKF_SLOPPY
1131 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1132 && !scr
->flags
.doing_alt_tab
) {
1134 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1135 wSetFocusTo(scr
, wwin
);
1137 if (scr
->autoRaiseTimer
)
1138 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1139 scr
->autoRaiseTimer
= NULL
;
1141 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1142 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1144 = WMAddTimerHandler(wPreferences
.raise_delay
,
1145 (WMCallback
*)raiseWindow
, scr
);
1148 /* Install colormap for window, if the colormap installation mode
1149 * is colormap_follows_mouse */
1150 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1151 if (wwin
->client_win
==event
->xcrossing
.window
)
1152 wColormapInstallForWindow(scr
, wwin
);
1154 wColormapInstallForWindow(scr
, NULL
);
1158 /* a little kluge to hide the clip balloon */
1159 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1161 XUnmapWindow(dpy
, scr
->clip_balloon
);
1162 scr
->flags
.clip_balloon_mapped
= 0;
1164 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1165 || scr
->clip_icon
!= desc
->parent
) {
1166 XUnmapWindow(dpy
, scr
->clip_balloon
);
1167 scr
->flags
.clip_balloon_mapped
= 0;
1172 if (event
->xcrossing
.window
== event
->xcrossing
.root
1173 && event
->xcrossing
.detail
== NotifyNormal
1174 && event
->xcrossing
.detail
!= NotifyInferior
1175 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1177 wSetFocusTo(scr
, scr
->focused_window
);
1181 wBalloonEnteredObject(scr
, desc
);
1187 handleLeaveNotify(XEvent
*event
)
1189 WObjDescriptor
*desc
= NULL
;
1191 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1192 (XPointer
*)&desc
)!=XCNOENT
) {
1193 if(desc
->handle_leavenotify
)
1194 (*desc
->handle_leavenotify
)(desc
, event
);
1201 handleShapeNotify(XEvent
*event
)
1203 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1207 printf("got shape notify\n");
1209 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1210 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1212 if (sev
->kind
== ShapeBounding
) {
1213 if (sev
->shaped
== shev
->shaped
) {
1216 XPutBackEvent(dpy
, &ev
);
1222 wwin
= wWindowFor(shev
->window
);
1223 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1226 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1228 wwin
->flags
.shaped
= 0;
1229 wWindowClearShape(wwin
);
1231 } else if (shev
->shaped
) {
1233 wwin
->flags
.shaped
= 1;
1234 wWindowSetShape(wwin
);
1239 #ifdef KEEP_XKB_LOCK_STATUS
1240 /* please help ]d if you know what to do */
1241 handleXkbIndicatorStateNotify(XEvent
*event
)
1245 XkbStateRec staterec
;
1248 for (i
=0; i
<wScreenCount
; i
++) {
1249 scr
= wScreenWithNumber(i
);
1250 wwin
= scr
->focused_window
;
1251 if (wwin
&& wwin
->flags
.focused
) {
1252 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1253 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1254 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1255 wwin
->frame
->languagemode
= staterec
.group
;
1257 #ifdef XKB_BUTTON_HINT
1258 if (wwin
->frame
->titlebar
) {
1259 wFrameWindowPaint(wwin
->frame
);
1265 #endif /*KEEP_XKB_LOCK_STATUS*/
1268 handleColormapNotify(XEvent
*event
)
1272 Bool reinstall
= False
;
1274 wwin
= wWindowFor(event
->xcolormap
.window
);
1278 scr
= wwin
->screen_ptr
;
1282 if (event
->xcolormap
.new) {
1283 XWindowAttributes attr
;
1285 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1287 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1288 scr
->current_colormap
= attr
.colormap
;
1291 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1292 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1294 /* some bastard app (like XV) removed our colormap */
1296 * can't enforce or things like xscreensaver wont work
1299 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1300 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1302 /* someone has put our colormap back */
1306 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1307 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1309 if (reinstall
&& scr
->current_colormap
!=None
) {
1310 if (!scr
->flags
.colormap_stuff_blocked
)
1311 XInstallColormap(dpy
, scr
->current_colormap
);
1318 handleFocusIn(XEvent
*event
)
1323 * For applications that like stealing the focus.
1325 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1326 saveTimestamp(event
);
1327 if (event
->xfocus
.mode
== NotifyUngrab
1328 || event
->xfocus
.mode
== NotifyGrab
1329 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1333 wwin
= wWindowFor(event
->xfocus
.window
);
1334 if (wwin
&& !wwin
->flags
.focused
) {
1335 if (wwin
->flags
.mapped
)
1336 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1338 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1340 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1342 wSetFocusTo(scr
, NULL
);
1348 windowUnderPointer(WScreen
*scr
)
1354 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1356 return wWindowFor(win
);
1364 handleKeyPress(XEvent
*event
)
1366 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1367 WWindow
*wwin
= scr
->focused_window
;
1370 int command
=-1, index
;
1371 #ifdef KEEP_XKB_LOCK_STATUS
1372 XkbStateRec staterec
;
1373 #endif /*KEEP_XKB_LOCK_STATUS*/
1375 /* ignore CapsLock */
1376 modifiers
= event
->xkey
.state
& ValidModMask
;
1378 for (i
=0; i
<WKBD_LAST
; i
++) {
1379 if (wKeyBindings
[i
].keycode
==0)
1382 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1383 && (/*wKeyBindings[i].modifier==0
1384 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1398 if (!wRootMenuPerformShortcut(event
)) {
1400 static int dontLoop
= 0;
1402 if (dontLoop
> 10) {
1403 wwarning("problem with key event processing code");
1407 /* if the focused window is an internal window, try redispatching
1408 * the event to the managed window, as it can be a WINGs window */
1409 if (wwin
&& wwin
->flags
.internal_window
1410 && wwin
->client_leader
!=None
) {
1411 /* client_leader contains the WINGs toplevel */
1412 event
->xany
.window
= wwin
->client_leader
;
1413 WMHandleEvent(event
);
1420 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1421 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1426 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/
1428 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1429 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1432 case WKBD_WINDOWLIST
:
1434 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1435 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1439 case WKBD_WINDOWMENU
:
1440 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1441 OpenWindowMenu(wwin
, wwin
->frame_x
,
1442 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1444 case WKBD_MINIATURIZE
:
1445 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1446 && !WFLAGP(wwin
, no_miniaturizable
)) {
1447 CloseWindowMenu(scr
);
1449 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1450 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1451 event
->xbutton
.time
);
1453 wIconifyWindow(wwin
);
1458 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1459 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1460 CloseWindowMenu(scr
);
1462 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1463 wHideApplication(wapp
);
1467 case WKBD_HIDE_OTHERS
:
1468 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1469 CloseWindowMenu(scr
);
1471 wHideOtherApplications(wwin
);
1475 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1476 int newdir
= (MAX_VERTICAL
|MAX_HORIZONTAL
);
1478 CloseWindowMenu(scr
);
1480 if (wwin
->flags
.maximized
== newdir
) {
1481 wUnmaximizeWindow(wwin
);
1483 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1487 case WKBD_VMAXIMIZE
:
1488 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1489 int newdir
= (MAX_VERTICAL
^ wwin
->flags
.maximized
);
1491 CloseWindowMenu(scr
);
1494 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1496 wUnmaximizeWindow(wwin
);
1500 case WKBD_HMAXIMIZE
:
1501 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && IS_RESIZABLE(wwin
)) {
1502 int newdir
= (MAX_HORIZONTAL
^ wwin
->flags
.maximized
);
1504 CloseWindowMenu(scr
);
1507 wMaximizeWindow(wwin
, newdir
|MAX_KEYBOARD
);
1509 wUnmaximizeWindow(wwin
);
1514 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1515 CloseWindowMenu(scr
);
1517 wRaiseFrame(wwin
->frame
->core
);
1521 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1522 CloseWindowMenu(scr
);
1524 wLowerFrame(wwin
->frame
->core
);
1527 case WKBD_RAISELOWER
:
1528 /* raise or lower the window under the pointer, not the
1531 wwin
= windowUnderPointer(scr
);
1533 wRaiseLowerFrame(wwin
->frame
->core
);
1536 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1537 if (wwin
->flags
.shaded
)
1538 wUnshadeWindow(wwin
);
1543 case WKBD_MOVERESIZE
:
1544 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) &&
1545 (IS_RESIZABLE(wwin
) || IS_MOVABLE(wwin
))) {
1546 CloseWindowMenu(scr
);
1548 wKeyboardMoveResizeWindow(wwin
);
1552 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1553 CloseWindowMenu(scr
);
1554 if (wwin
->protocols
.DELETE_WINDOW
)
1555 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1560 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1561 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1564 case WKBD_FOCUSNEXT
:
1565 StartWindozeCycle(wwin
, event
, True
);
1568 case WKBD_FOCUSPREV
:
1569 StartWindozeCycle(wwin
, event
, False
);
1572 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1573 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1574 i = (scr->current_workspace/10)*10 + wk - 1;\
1575 if (wPreferences.ws_advance || i<scr->workspace_count)\
1576 wWorkspaceChange(scr, i);\
1579 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1580 i = (scr->current_workspace/10)*10 + wk - 1;\
1581 if (wPreferences.ws_advance || i<scr->workspace_count)\
1582 wWorkspaceChange(scr, i);\
1596 case WKBD_NEXTWORKSPACE
:
1597 wWorkspaceRelativeChange(scr
, 1);
1599 case WKBD_PREVWORKSPACE
:
1600 wWorkspaceRelativeChange(scr
, -1);
1613 index
= command
-WKBD_WINDOW1
;
1615 if (scr
->shortcutWindows
[index
]) {
1616 WMArray
*list
= scr
->shortcutWindows
[index
];
1618 int count
= WMGetArrayItemCount(list
);
1620 WMArrayIterator iter
;
1623 wUnselectWindows(scr
);
1624 cw
= scr
->current_workspace
;
1626 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1628 wWindowChangeWorkspace(wwin
, cw
);
1630 wMakeWindowVisible(wwin
);
1633 wSelectWindow(wwin
, True
);
1636 /* rotate the order of windows, to create a cycling effect */
1637 twin
= WMGetFromArray(list
, 0);
1638 WMDeleteFromArray(list
, 0);
1639 WMAddToArray(list
, twin
);
1641 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1642 if (scr
->shortcutWindows
[index
]) {
1643 WMFreeArray(scr
->shortcutWindows
[index
]);
1644 scr
->shortcutWindows
[index
] = NULL
;
1647 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1648 scr
->shortcutWindows
[index
] =
1649 WMDuplicateArray(scr
->selected_windows
);
1650 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1651 WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
1653 scr
->shortcutWindows
[index
] = WMCreateArray(4);
1654 WMAddToArray(scr
->shortcutWindows
[index
], wwin
);
1657 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1660 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1663 } else if (scr
->selected_windows
1664 && WMGetArrayItemCount(scr
->selected_windows
)) {
1666 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1667 if (scr
->shortcutWindows
[index
]) {
1668 WMFreeArray(scr
->shortcutWindows
[index
]);
1670 scr
->shortcutWindows
[index
] =
1671 WMDuplicateArray(scr
->selected_windows
);
1677 case WKBD_SWITCH_SCREEN
:
1678 if (wScreenCount
> 1) {
1682 /* find index of this screen */
1683 for (i
= 0; i
< wScreenCount
; i
++) {
1684 if (wScreenWithNumber(i
) == scr
)
1688 if (i
>= wScreenCount
) {
1691 scr2
= wScreenWithNumber(i
);
1694 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1695 scr2
->scr_width
/2, scr2
->scr_height
/2);
1700 case WKBD_NEXTWSLAYER
:
1701 case WKBD_PREVWSLAYER
:
1705 row
= scr
->current_workspace
/10;
1706 column
= scr
->current_workspace
%10;
1708 if (command
==WKBD_NEXTWSLAYER
) {
1709 if ((row
+1)*10 < scr
->workspace_count
)
1710 wWorkspaceChange(scr
, column
+(row
+1)*10);
1713 wWorkspaceChange(scr
, column
+(row
-1)*10);
1717 case WKBD_CLIPLOWER
:
1718 if (!wPreferences
.flags
.noclip
)
1719 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1721 case WKBD_CLIPRAISE
:
1722 if (!wPreferences
.flags
.noclip
)
1723 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1725 case WKBD_CLIPRAISELOWER
:
1726 if (!wPreferences
.flags
.noclip
)
1727 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1729 #ifdef KEEP_XKB_LOCK_STATUS
1731 if(wPreferences
.modelock
) {
1733 wwin
= scr
->focused_window
;
1735 if (wwin
&& wwin
->flags
.mapped
1736 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1737 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1738 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1740 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1741 wwin
->frame
->last_languagemode
= staterec
.group
;
1742 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1747 #endif /* KEEP_XKB_LOCK_STATUS */
1748 #ifdef VIRTUAL_DESKTOP
1749 case WKBD_VDESK_LEFT
:
1750 wWorkspaceKeyboardMoveDesktop(scr
, VEC_LEFT
);
1753 case WKBD_VDESK_RIGHT
:
1754 wWorkspaceKeyboardMoveDesktop(scr
, VEC_RIGHT
);
1758 wWorkspaceKeyboardMoveDesktop(scr
, VEC_UP
);
1761 case WKBD_VDESK_DOWN
:
1762 wWorkspaceKeyboardMoveDesktop(scr
, VEC_DOWN
);
1771 handleMotionNotify(XEvent
*event
)
1773 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1775 if (wPreferences
.scrollable_menus
) {
1776 WMPoint p
= wmkpoint(event
->xmotion
.x_root
, event
->xmotion
.y_root
);
1777 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1779 if (scr
->flags
.jump_back_pending
||
1780 p
.x
<= (rect
.pos
.x
+ 1) ||
1781 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1782 p
.y
<= (rect
.pos
.y
+ 1) ||
1783 p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1786 printf("pointer at screen edge\n");
1788 menu
= wMenuUnderPointer(scr
);
1790 wMenuScroll(menu
, event
);
1794 if (event
->xmotion
.subwindow
== None
)
1797 if (scr
->scrolledFMaximize
!= None
) {
1800 twin
= wWindowFor(scr
->scrolledFMaximize
);
1801 if (twin
&& twin
->frame_y
==) {
1805 scr
->scrolledFMaximize
= NULL
;
1809 /* scroll full maximized window */
1810 if (event
->xmotion
.y_root
< 1
1811 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1813 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1815 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1816 && WFLAGP(wwin
, full_maximize
)
1817 && event
->xmotion
.x_root
>= wwin
->frame_x
1818 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1820 if (HAS_BORDER(wwin
)
1821 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1823 wWindowMove(wwin
, wwin
->frame_x
, 0);
1824 wwin
->flags
.dragged_while_fmaximized
= 0;
1826 } else if (HAS_RESIZEBAR(wwin
)
1827 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1828 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1830 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1832 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1834 wWindowMove(wwin
, wwin
->frame_x
, y
);
1835 wwin
->flags
.dragged_while_fmaximized
= 0;
1844 handleVisibilityNotify(XEvent
*event
)
1848 wwin
= wWindowFor(event
->xvisibility
.window
);
1851 wwin
->flags
.obscured
=
1852 (event
->xvisibility
.state
== VisibilityFullyObscured
);