1 /* event.c- event loop and handling
3 * Window Maker window manager
5 * Copyright (c) 1997-2002 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
)
406 LastTimestamp
= CurrentTime
;
408 switch (event
->type
) {
411 LastTimestamp
= event
->xbutton
.time
;
415 LastTimestamp
= event
->xkey
.time
;
418 LastTimestamp
= event
->xmotion
.time
;
421 LastTimestamp
= event
->xproperty
.time
;
425 LastTimestamp
= event
->xcrossing
.time
;
428 LastTimestamp
= event
->xselectionclear
.time
;
430 case SelectionRequest
:
431 LastTimestamp
= event
->xselectionrequest
.time
;
433 case SelectionNotify
:
434 LastTimestamp
= event
->xselection
.time
;
436 wXDNDProcessSelection(event
);
444 matchWindow(void *item
, void *cdata
)
446 return (((WFakeGroupLeader
*)item
)->origLeader
== (Window
)cdata
);
451 handleExtensions(XEvent
*event
)
453 #ifdef KEEP_XKB_LOCK_STATUS
455 xkbevent
= (XkbEvent
*)event
;
456 #endif /*KEEP_XKB_LOCK_STATUS*/
458 if (wShapeSupported
&& event
->type
== (wShapeEventBase
+ShapeNotify
)) {
459 handleShapeNotify(event
);
462 #ifdef KEEP_XKB_LOCK_STATUS
463 if (wPreferences
.modelock
&& (xkbevent
->type
== wXkbEventBase
)){
464 handleXkbIndicatorStateNotify(event
);
466 #endif /*KEEP_XKB_LOCK_STATUS*/
471 handleMapRequest(XEvent
*ev
)
475 Window window
= ev
->xmaprequest
.window
;
478 L("got map request for %x\n", (unsigned)window
);
480 if ((wwin
= wWindowFor(window
))) {
481 if (wwin
->flags
.shaded
) {
482 wUnshadeWindow(wwin
);
484 /* deiconify window */
485 if (wwin
->flags
.miniaturized
) {
486 wDeiconifyWindow(wwin
);
487 } else if (wwin
->flags
.hidden
) {
488 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
489 /* go to the last workspace that the user worked on the app */
491 wWorkspaceChange(wwin
->screen_ptr
, wapp
->last_workspace
);
493 wUnhideApplication(wapp
, False
, False
);
498 scr
= wScreenForRootWindow(ev
->xmaprequest
.parent
);
500 wwin
= wManageWindow(scr
, window
);
503 * This is to let the Dock know that the application it launched
504 * has already been mapped (eg: it has finished launching).
505 * It is not necessary for normally docked apps, but is needed for
506 * apps that were forcedly docked (like with dockit).
508 if (scr
->last_dock
) {
509 if (wwin
&& wwin
->main_window
!=None
&& wwin
->main_window
!=window
)
510 wDockTrackWindowLaunch(scr
->last_dock
, wwin
->main_window
);
512 wDockTrackWindowLaunch(scr
->last_dock
, window
);
516 wClientSetState(wwin
, NormalState
, None
);
517 if (wwin
->flags
.maximized
) {
518 wMaximizeWindow(wwin
, wwin
->flags
.maximized
);
520 if (wwin
->flags
.shaded
) {
521 wwin
->flags
.shaded
= 0;
522 wwin
->flags
.skip_next_animation
= 1;
525 if (wwin
->flags
.miniaturized
) {
526 wwin
->flags
.miniaturized
= 0;
527 wwin
->flags
.skip_next_animation
= 1;
528 wIconifyWindow(wwin
);
530 if (wwin
->flags
.hidden
) {
531 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
533 wwin
->flags
.hidden
= 0;
534 wwin
->flags
.skip_next_animation
= 1;
536 wHideApplication(wapp
);
544 handleDestroyNotify(XEvent
*event
)
548 Window window
= event
->xdestroywindow
.window
;
549 WScreen
*scr
= wScreenForRootWindow(event
->xdestroywindow
.event
);
553 L("got destroy notify");
555 wwin
= wWindowFor(window
);
557 wUnmanageWindow(wwin
, False
, True
);
561 while ((index
= WMFindInArray(scr
->fakeGroupLeaders
, matchWindow
,
562 (void*)window
)) != WANotFound
) {
563 WFakeGroupLeader
*fPtr
;
565 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
566 if (fPtr
->retainCount
> 0) {
568 if (fPtr
->retainCount
==0 && fPtr
->leader
!=None
) {
569 XDestroyWindow(dpy
, fPtr
->leader
);
574 fPtr
->origLeader
= None
;
578 app
= wApplicationOf(window
);
580 if (window
== app
->main_window
) {
582 wwin
= app
->main_window_desc
->screen_ptr
->focused_window
;
584 if (wwin
->main_window
== window
) {
585 wwin
->main_window
= None
;
590 wApplicationDestroy(app
);
594 wKWMCheckDestroy(&event
->xdestroywindow
);
601 handleExpose(XEvent
*event
)
603 WObjDescriptor
*desc
;
609 while (XCheckTypedWindowEvent(dpy
, event
->xexpose
.window
, Expose
, &ev
));
611 if (XFindContext(dpy
, event
->xexpose
.window
, wWinContext
,
612 (XPointer
*)&desc
)==XCNOENT
) {
616 if (desc
->handle_expose
) {
617 (*desc
->handle_expose
)(desc
, event
);
622 executeButtonAction(WScreen
*scr
, XEvent
*event
, int action
)
625 case WA_SELECT_WINDOWS
:
626 wUnselectWindows(scr
);
627 wSelectWindows(scr
, event
);
629 case WA_OPEN_APPMENU
:
630 OpenRootMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
632 if (scr
->root_menu
) {
633 if (scr
->root_menu
->brother
->flags
.mapped
)
634 event
->xbutton
.window
= scr
->root_menu
->brother
->frame
->core
->window
;
636 event
->xbutton
.window
= scr
->root_menu
->frame
->core
->window
;
639 case WA_OPEN_WINLISTMENU
:
640 OpenSwitchMenu(scr
, event
->xbutton
.x_root
, event
->xbutton
.y_root
, False
);
641 if (scr
->switch_menu
) {
642 if (scr
->switch_menu
->brother
->flags
.mapped
)
643 event
->xbutton
.window
= scr
->switch_menu
->brother
->frame
->core
->window
;
645 event
->xbutton
.window
= scr
->switch_menu
->frame
->core
->window
;
656 handleButtonPress(XEvent
*event
)
658 WObjDescriptor
*desc
;
662 L("got button press");
664 scr
= wScreenForRootWindow(event
->xbutton
.root
);
672 if (event
->xbutton
.window
==scr
->root_win
) {
673 if (event
->xbutton
.button
==Button1
&&
674 wPreferences
.mouse_button1
!=WA_NONE
) {
675 executeButtonAction(scr
, event
, wPreferences
.mouse_button1
);
676 } else if (event
->xbutton
.button
==Button2
&&
677 wPreferences
.mouse_button2
!=WA_NONE
) {
678 executeButtonAction(scr
, event
, wPreferences
.mouse_button2
);
679 } else if (event
->xbutton
.button
==Button3
&&
680 wPreferences
.mouse_button3
!=WA_NONE
) {
681 executeButtonAction(scr
, event
, wPreferences
.mouse_button3
);
682 } else if (event
->xbutton
.button
==Button4
&&
683 wPreferences
.mouse_wheel
!=WA_NONE
) {
684 wWorkspaceRelativeChange(scr
, 1);
685 } else if (event
->xbutton
.button
==Button5
&&
686 wPreferences
.mouse_wheel
!=WA_NONE
) {
687 wWorkspaceRelativeChange(scr
, -1);
690 else if (wGNOMEProxyizeButtonEvent(scr
, event
))
697 if (XFindContext(dpy
, event
->xbutton
.subwindow
, wWinContext
,
698 (XPointer
*)&desc
)==XCNOENT
) {
699 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
700 (XPointer
*)&desc
)==XCNOENT
) {
705 if (desc
->parent_type
== WCLASS_WINDOW
) {
708 if (event
->xbutton
.state
& MOD_MASK
) {
709 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
712 /* if (wPreferences.focus_mode == WKF_CLICK) {*/
713 if (wPreferences
.ignore_focus_click
) {
714 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
716 XAllowEvents(dpy
, ReplayPointer
, CurrentTime
);
719 } else if (desc
->parent_type
== WCLASS_APPICON
720 || desc
->parent_type
== WCLASS_MINIWINDOW
721 || desc
->parent_type
== WCLASS_DOCK_ICON
) {
722 if (event
->xbutton
.state
& MOD_MASK
) {
724 XAllowEvents(dpy
, AsyncPointer
, CurrentTime
);
729 if (desc
->handle_mousedown
!=NULL
) {
730 (*desc
->handle_mousedown
)(desc
, event
);
733 /* save double-click information */
734 if (scr
->flags
.next_click_is_not_double
) {
735 scr
->flags
.next_click_is_not_double
= 0;
737 scr
->last_click_time
= event
->xbutton
.time
;
738 scr
->last_click_button
= event
->xbutton
.button
;
739 scr
->last_click_window
= event
->xbutton
.window
;
745 handleMapNotify(XEvent
*event
)
751 wwin
= wWindowFor(event
->xmap
.event
);
752 if (wwin
&& wwin
->client_win
== event
->xmap
.event
) {
753 if (wwin
->flags
.miniaturized
) {
754 wDeiconifyWindow(wwin
);
758 wClientSetState(wwin
, NormalState
, None
);
766 handleUnmapNotify(XEvent
*event
)
770 Bool withdraw
= False
;
774 /* only process windows with StructureNotify selected
775 * (ignore SubstructureNotify) */
776 wwin
= wWindowFor(event
->xunmap
.window
);
780 /* whether the event is a Withdrawal request */
781 if (event
->xunmap
.event
== wwin
->screen_ptr
->root_win
782 && event
->xunmap
.send_event
)
785 if (wwin
->client_win
!= event
->xunmap
.event
&& !withdraw
)
788 if (!wwin
->flags
.mapped
&& !withdraw
789 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
790 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
)
794 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
795 wwin
->flags
.mapped
= 0;
797 /* check if the window was destroyed */
798 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, DestroyNotify
,&ev
)) {
801 Bool reparented
= False
;
803 if (XCheckTypedWindowEvent(dpy
, wwin
->client_win
, ReparentNotify
, &ev
))
806 /* withdraw window */
807 wwin
->flags
.mapped
= 0;
809 wClientSetState(wwin
, WithdrawnState
, None
);
811 /* if the window was reparented, do not reparent it back to the
813 wUnmanageWindow(wwin
, !reparented
, False
);
820 handleConfigureRequest(XEvent
*event
)
824 L("got configure request");
826 if (!(wwin
=wWindowFor(event
->xconfigurerequest
.window
))) {
828 * Configure request for unmapped window
830 wClientConfigure(NULL
, &(event
->xconfigurerequest
));
832 wClientConfigure(wwin
, &(event
->xconfigurerequest
));
838 handlePropertyNotify(XEvent
*event
)
847 L("got property notify");
849 if ((wwin
=wWindowFor(event
->xproperty
.window
))) {
850 if (!XGetGeometry(dpy
, wwin
->client_win
, &jr
, &ji
, &ji
,
851 &ju
, &ju
, &ju
, &ju
)) {
854 wClientCheckProperty(wwin
, &event
->xproperty
);
856 wapp
= wApplicationOf(event
->xproperty
.window
);
858 wClientCheckProperty(wapp
->main_window_desc
, &event
->xproperty
);
861 scr
= wScreenForWindow(event
->xproperty
.window
);
862 if (scr
&& scr
->root_win
== event
->xproperty
.window
) {
864 wKWMCheckRootHintChange(scr
, &event
->xproperty
);
871 handleClientMessage(XEvent
*event
)
874 WObjDescriptor
*desc
;
876 L("got client message");
878 /* handle transition from Normal to Iconic state */
879 if (event
->xclient
.message_type
== _XA_WM_CHANGE_STATE
880 && event
->xclient
.format
== 32
881 && event
->xclient
.data
.l
[0] == IconicState
) {
883 wwin
= wWindowFor(event
->xclient
.window
);
885 if (!wwin
->flags
.miniaturized
)
886 wIconifyWindow(wwin
);
887 } else if (event
->xclient
.message_type
== _XA_WM_COLORMAP_NOTIFY
888 && event
->xclient
.format
== 32) {
889 WScreen
*scr
= wScreenSearchForRootWindow(event
->xclient
.window
);
894 if (event
->xclient
.data
.l
[1] == 1) { /* starting */
895 wColormapAllowClientInstallation(scr
, True
);
896 } else { /* stopping */
897 wColormapAllowClientInstallation(scr
, False
);
899 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_COMMAND
) {
901 wDefaultsCheckDomains("bla");
903 } else if (event
->xclient
.message_type
== _XA_WINDOWMAKER_WM_FUNCTION
) {
906 wapp
= wApplicationOf(event
->xclient
.window
);
908 switch (event
->xclient
.data
.l
[0]) {
909 case WMFHideOtherApplications
:
910 wHideOtherApplications(wapp
->main_window_desc
);
914 case WMFHideApplication
:
915 wHideApplication(wapp
);
921 wwin
= wWindowFor(event
->xclient
.window
);
923 switch (event
->xclient
.data
.l
[0]) {
924 case WMFHideOtherApplications
:
925 wHideOtherApplications(wwin
);
928 case WMFHideApplication
:
929 wHideApplication(wApplicationOf(wwin
->main_window
));
934 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_WM_ATTR
) {
935 wwin
= wWindowFor(event
->xclient
.window
);
937 switch (event
->xclient
.data
.l
[0]) {
938 case GSWindowLevelAttr
:
940 int level
= (int)event
->xclient
.data
.l
[1];
942 if (WINDOW_LEVEL(wwin
) != level
) {
943 ChangeStackingLevel(wwin
->frame
->core
, level
);
948 } else if (event
->xclient
.message_type
== _XA_GNUSTEP_TITLEBAR_STATE
) {
949 wwin
= wWindowFor(event
->xclient
.window
);
951 switch (event
->xclient
.data
.l
[0]) {
952 case WMTitleBarNormal
:
953 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
956 wFrameWindowChangeState(wwin
->frame
, WS_PFOCUSED
);
959 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
963 } else if (wGNOMEProcessClientMessage(&event
->xclient
)) {
965 #endif /* GNOME_STUFF */
967 } else if (wKWMProcessClientMessage(&event
->xclient
)) {
969 #endif /* KWM_HINTS */
971 } else if (wXDNDProcessClientMessage(&event
->xclient
)) {
975 } else if (event
->xclient
.message_type
==_XA_DND_PROTOCOL
) {
976 WScreen
*scr
= wScreenForWindow(event
->xclient
.window
);
977 if (scr
&& wDockReceiveDNDDrop(scr
,event
))
978 goto redirect_message
;
979 #endif /* OFFIX_DND */
985 * Non-standard thing, but needed by OffiX DND.
986 * For when the icon frame gets a ClientMessage
987 * that should have gone to the icon_window.
989 if (XFindContext(dpy
, event
->xbutton
.window
, wWinContext
,
990 (XPointer
*)&desc
)!=XCNOENT
) {
991 struct WIcon
*icon
=NULL
;
993 if (desc
->parent_type
== WCLASS_MINIWINDOW
) {
994 icon
= (WIcon
*)desc
->parent
;
995 } else if (desc
->parent_type
== WCLASS_DOCK_ICON
996 || desc
->parent_type
== WCLASS_APPICON
) {
997 icon
= ((WAppIcon
*)desc
->parent
)->icon
;
999 if (icon
&& (wwin
=icon
->owner
)) {
1000 if (wwin
->client_win
!=event
->xclient
.window
) {
1001 event
->xclient
.window
= wwin
->client_win
;
1002 XSendEvent(dpy
, wwin
->client_win
, False
, NoEventMask
,
1012 raiseWindow(WScreen
*scr
)
1016 scr
->autoRaiseTimer
= NULL
;
1018 wwin
= wWindowFor(scr
->autoRaiseWindow
);
1022 if (!wwin
->flags
.destroyed
&& wwin
->flags
.focused
) {
1023 wRaiseFrame(wwin
->frame
->core
);
1024 /* this is needed or a race condition will occur */
1031 handleEnterNotify(XEvent
*event
)
1034 WObjDescriptor
*desc
= NULL
;
1036 WScreen
*scr
= wScreenForRootWindow(event
->xcrossing
.root
);
1038 L("got enter notify");
1041 #ifdef VIRTUAL_DESKTOP
1042 /* TODO: acceleration code */
1043 if (wPreferences
.vedge_thickness
) {
1045 if (event
->xcrossing
.window
== scr
->virtual_edge_r
) {
1046 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, scr
->scr_width
- wPreferences
.vedge_thickness
- 1, event
->xcrossing
.y_root
);
1047 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1048 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
+ VIRTUALEDGE_SCROLL_HSTEP
, y
);
1049 } else if (event
->xcrossing
.window
== scr
->virtual_edge_l
) {
1050 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, wPreferences
.vedge_thickness
+ 1, event
->xcrossing
.y_root
);
1051 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1052 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
- VIRTUALEDGE_SCROLL_HSTEP
, y
);
1053 } else if (event
->xcrossing
.window
== scr
->virtual_edge_u
) {
1054 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, wPreferences
.vedge_thickness
+ 1);
1055 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1056 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
- VIRTUALEDGE_SCROLL_VSTEP
);
1057 } else if (event
->xcrossing
.window
== scr
->virtual_edge_d
) {
1058 printf("enter bottom\n");
1059 XWarpPointer(dpy
, None
, scr
->root_win
, 0,0,0,0, event
->xcrossing
.x_root
, scr
->scr_height
- wPreferences
.vedge_thickness
- 1);
1060 wWorkspaceGetViewPosition(scr
, scr
->current_workspace
, &x
, &y
);
1061 wWorkspaceSetViewPort(scr
, scr
->current_workspace
, x
, y
+ VIRTUALEDGE_SCROLL_VSTEP
);
1066 if (XCheckTypedWindowEvent(dpy
, event
->xcrossing
.window
, LeaveNotify
,
1068 /* already left the window... */
1070 if (ev
.xcrossing
.mode
==event
->xcrossing
.mode
1071 && ev
.xcrossing
.detail
==event
->xcrossing
.detail
) {
1076 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1077 (XPointer
*)&desc
)!=XCNOENT
) {
1078 if(desc
->handle_enternotify
)
1079 (*desc
->handle_enternotify
)(desc
, event
);
1082 /* enter to window */
1083 wwin
= wWindowFor(event
->xcrossing
.window
);
1085 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1086 wColormapInstallForWindow(scr
, NULL
);
1088 if (scr
->autoRaiseTimer
1089 && event
->xcrossing
.root
==event
->xcrossing
.window
) {
1090 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1091 scr
->autoRaiseTimer
= NULL
;
1094 /* set auto raise timer even if in focus-follows-mouse mode
1095 * and the event is for the frame window, even if the window
1096 * has focus already. useful if you move the pointer from a focused
1097 * window to the root window and back pretty fast
1099 * set focus if in focus-follows-mouse mode and the event
1100 * is for the frame window and window doesn't have focus yet */
1101 if (wPreferences
.focus_mode
==WKF_SLOPPY
1102 && wwin
->frame
->core
->window
==event
->xcrossing
.window
1103 && !scr
->flags
.doing_alt_tab
) {
1105 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
))
1106 wSetFocusTo(scr
, wwin
);
1108 if (scr
->autoRaiseTimer
)
1109 WMDeleteTimerHandler(scr
->autoRaiseTimer
);
1110 scr
->autoRaiseTimer
= NULL
;
1112 if (wPreferences
.raise_delay
&& !WFLAGP(wwin
, no_focusable
)) {
1113 scr
->autoRaiseWindow
= wwin
->frame
->core
->window
;
1115 = WMAddTimerHandler(wPreferences
.raise_delay
,
1116 (WMCallback
*)raiseWindow
, scr
);
1119 /* Install colormap for window, if the colormap installation mode
1120 * is colormap_follows_mouse */
1121 if (wPreferences
.colormap_mode
==WCM_POINTER
) {
1122 if (wwin
->client_win
==event
->xcrossing
.window
)
1123 wColormapInstallForWindow(scr
, wwin
);
1125 wColormapInstallForWindow(scr
, NULL
);
1129 /* a little kluge to hide the clip balloon */
1130 if (!wPreferences
.flags
.noclip
&& scr
->flags
.clip_balloon_mapped
) {
1132 XUnmapWindow(dpy
, scr
->clip_balloon
);
1133 scr
->flags
.clip_balloon_mapped
= 0;
1135 if (desc
->parent_type
!=WCLASS_DOCK_ICON
1136 || scr
->clip_icon
!= desc
->parent
) {
1137 XUnmapWindow(dpy
, scr
->clip_balloon
);
1138 scr
->flags
.clip_balloon_mapped
= 0;
1143 if (event
->xcrossing
.window
== event
->xcrossing
.root
1144 && (event
->xcrossing
.mode
== NotifyNormal
||
1145 event
->xcrossing
.mode
== NotifyUngrab
)
1146 && event
->xcrossing
.detail
== NotifyInferior
1147 && wPreferences
.focus_mode
!= WKF_CLICK
) {
1148 wSetFocusTo(scr
, NULL
);
1152 wBalloonEnteredObject(scr
, desc
);
1158 handleLeaveNotify(XEvent
*event
)
1160 WObjDescriptor
*desc
= NULL
;
1162 if (XFindContext(dpy
, event
->xcrossing
.window
, wWinContext
,
1163 (XPointer
*)&desc
)!=XCNOENT
) {
1164 if(desc
->handle_leavenotify
)
1165 (*desc
->handle_leavenotify
)(desc
, event
);
1172 handleShapeNotify(XEvent
*event
)
1174 XShapeEvent
*shev
= (XShapeEvent
*)event
;
1178 L("got shape notify");
1180 while (XCheckTypedWindowEvent(dpy
, shev
->window
, event
->type
, &ev
)) {
1181 XShapeEvent
*sev
= (XShapeEvent
*)&ev
;
1183 if (sev
->kind
== ShapeBounding
) {
1184 if (sev
->shaped
== shev
->shaped
) {
1187 XPutBackEvent(dpy
, &ev
);
1193 wwin
= wWindowFor(shev
->window
);
1194 if (!wwin
|| shev
->kind
!= ShapeBounding
)
1197 if (!shev
->shaped
&& wwin
->flags
.shaped
) {
1199 wwin
->flags
.shaped
= 0;
1200 wWindowClearShape(wwin
);
1202 } else if (shev
->shaped
) {
1204 wwin
->flags
.shaped
= 1;
1205 wWindowSetShape(wwin
);
1210 #ifdef KEEP_XKB_LOCK_STATUS
1211 /* please help ]d if you know what to do */
1212 handleXkbIndicatorStateNotify(XEvent
*event
)
1216 XkbStateRec staterec
;
1219 for (i
=0; i
<wScreenCount
; i
++) {
1220 scr
= wScreenWithNumber(i
);
1221 wwin
= scr
->focused_window
;
1222 if (wwin
&& wwin
->flags
.focused
) {
1223 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1224 if (wwin
->frame
->languagemode
!= staterec
.group
) {
1225 wwin
->frame
->last_languagemode
= wwin
->frame
->languagemode
;
1226 wwin
->frame
->languagemode
= staterec
.group
;
1228 #ifdef XKB_BUTTON_HINT
1229 if (wwin
->frame
->titlebar
) {
1230 wFrameWindowPaint(wwin
->frame
);
1236 #endif /*KEEP_XKB_LOCK_STATUS*/
1239 handleColormapNotify(XEvent
*event
)
1243 Bool reinstall
= False
;
1245 wwin
= wWindowFor(event
->xcolormap
.window
);
1249 scr
= wwin
->screen_ptr
;
1253 if (event
->xcolormap
.new) {
1254 XWindowAttributes attr
;
1256 XGetWindowAttributes(dpy
, wwin
->client_win
, &attr
);
1258 if (wwin
== scr
->cmap_window
&& wwin
->cmap_window_no
== 0)
1259 scr
->current_colormap
= attr
.colormap
;
1262 } else if (event
->xcolormap
.state
== ColormapUninstalled
&&
1263 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1265 /* some bastard app (like XV) removed our colormap */
1267 * can't enforce or things like xscreensaver wont work
1270 } else if (event
->xcolormap
.state
== ColormapInstalled
&&
1271 scr
->current_colormap
== event
->xcolormap
.colormap
) {
1273 /* someone has put our colormap back */
1277 } while (XCheckTypedEvent(dpy
, ColormapNotify
, event
)
1278 && ((wwin
= wWindowFor(event
->xcolormap
.window
)) || 1));
1280 if (reinstall
&& scr
->current_colormap
!=None
) {
1281 if (!scr
->flags
.colormap_stuff_blocked
)
1282 XInstallColormap(dpy
, scr
->current_colormap
);
1289 handleFocusIn(XEvent
*event
)
1294 * For applications that like stealing the focus.
1296 while (XCheckTypedEvent(dpy
, FocusIn
, event
));
1297 saveTimestamp(event
);
1298 if (event
->xfocus
.mode
== NotifyUngrab
1299 || event
->xfocus
.mode
== NotifyGrab
1300 || event
->xfocus
.detail
> NotifyNonlinearVirtual
) {
1304 wwin
= wWindowFor(event
->xfocus
.window
);
1305 if (wwin
&& !wwin
->flags
.focused
) {
1306 if (wwin
->flags
.mapped
)
1307 wSetFocusTo(wwin
->screen_ptr
, wwin
);
1309 wSetFocusTo(wwin
->screen_ptr
, NULL
);
1311 WScreen
*scr
= wScreenForWindow(event
->xfocus
.window
);
1313 wSetFocusTo(scr
, NULL
);
1319 windowUnderPointer(WScreen
*scr
)
1325 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
, &foo
, &foo
, &foo
, &foo
,
1327 return wWindowFor(win
);
1335 handleKeyPress(XEvent
*event
)
1337 WScreen
*scr
= wScreenForRootWindow(event
->xkey
.root
);
1338 WWindow
*wwin
= scr
->focused_window
;
1341 int command
=-1, index
;
1342 #ifdef KEEP_XKB_LOCK_STATUS
1343 XkbStateRec staterec
;
1344 #endif /*KEEP_XKB_LOCK_STATUS*/
1346 /* ignore CapsLock */
1347 modifiers
= event
->xkey
.state
& ValidModMask
;
1349 for (i
=0; i
<WKBD_LAST
; i
++) {
1350 if (wKeyBindings
[i
].keycode
==0)
1353 if (wKeyBindings
[i
].keycode
==event
->xkey
.keycode
1354 && (/*wKeyBindings[i].modifier==0
1355 ||*/ wKeyBindings
[i
].modifier
==modifiers
)) {
1369 if (!wRootMenuPerformShortcut(event
)) {
1371 static int dontLoop
= 0;
1373 if (dontLoop
> 10) {
1374 wwarning("problem with key event processing code");
1378 /* if the focused window is an internal window, try redispatching
1379 * the event to the managed window, as it can be a WINGs window */
1380 if (wwin
&& wwin
->flags
.internal_window
1381 && wwin
->client_leader
!=None
) {
1382 /* client_leader contains the WINGs toplevel */
1383 event
->xany
.window
= wwin
->client_leader
;
1384 WMHandleEvent(event
);
1391 #define ISMAPPED(w) ((w) && !(w)->flags.miniaturized && ((w)->flags.mapped || (w)->flags.shaded))
1392 #define ISFOCUSED(w) ((w) && (w)->flags.focused)
1397 /*OpenRootMenu(scr, event->xkey.x_root, event->xkey.y_root, True);*/
1399 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1400 OpenRootMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1403 case WKBD_WINDOWLIST
:
1405 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPointerLocation(scr
));
1406 OpenSwitchMenu(scr
, rect
.pos
.x
+ rect
.size
.width
/2, rect
.pos
.y
+ rect
.size
.height
/2, True
);
1410 case WKBD_WINDOWMENU
:
1411 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
))
1412 OpenWindowMenu(wwin
, wwin
->frame_x
,
1413 wwin
->frame_y
+wwin
->frame
->top_width
, True
);
1415 case WKBD_MINIATURIZE
:
1416 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)
1417 && !WFLAGP(wwin
, no_miniaturizable
)) {
1418 CloseWindowMenu(scr
);
1420 if (wwin
->protocols
.MINIATURIZE_WINDOW
)
1421 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
1422 event
->xbutton
.time
);
1424 wIconifyWindow(wwin
);
1429 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1430 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
1431 CloseWindowMenu(scr
);
1433 if (wapp
&& !WFLAGP(wapp
->main_window_desc
, no_appicon
)) {
1434 wHideApplication(wapp
);
1438 case WKBD_HIDE_OTHERS
:
1439 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1440 CloseWindowMenu(scr
);
1442 wHideOtherApplications(wwin
);
1446 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1447 CloseWindowMenu(scr
);
1449 if (wwin
->flags
.maximized
) {
1450 wUnmaximizeWindow(wwin
);
1452 wMaximizeWindow(wwin
, MAX_VERTICAL
|MAX_HORIZONTAL
);
1456 case WKBD_VMAXIMIZE
:
1457 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1458 CloseWindowMenu(scr
);
1460 if (wwin
->flags
.maximized
) {
1461 wUnmaximizeWindow(wwin
);
1463 wMaximizeWindow(wwin
, MAX_VERTICAL
);
1467 case WKBD_HMAXIMIZE
:
1468 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_resizable
)) {
1469 CloseWindowMenu(scr
);
1471 if (wwin
->flags
.maximized
) {
1472 wUnmaximizeWindow(wwin
);
1474 wMaximizeWindow(wwin
, MAX_HORIZONTAL
);
1479 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1480 CloseWindowMenu(scr
);
1482 wRaiseFrame(wwin
->frame
->core
);
1486 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1487 CloseWindowMenu(scr
);
1489 wLowerFrame(wwin
->frame
->core
);
1492 case WKBD_RAISELOWER
:
1493 /* raise or lower the window under the pointer, not the
1496 wwin
= windowUnderPointer(scr
);
1498 wRaiseLowerFrame(wwin
->frame
->core
);
1501 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_shadeable
)) {
1502 if (wwin
->flags
.shaded
)
1503 wUnshadeWindow(wwin
);
1508 case WKBD_MOVERESIZE
:
1509 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1510 CloseWindowMenu(scr
);
1512 wKeyboardMoveResizeWindow(wwin
);
1516 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
) && !WFLAGP(wwin
, no_closable
)) {
1517 CloseWindowMenu(scr
);
1518 if (wwin
->protocols
.DELETE_WINDOW
)
1519 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
,
1524 if (ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1525 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1528 case WKBD_FOCUSNEXT
:
1529 StartWindozeCycle(wwin
, event
, True
);
1532 case WKBD_FOCUSPREV
:
1533 StartWindozeCycle(wwin
, event
, False
);
1536 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
1537 #define GOTOWORKS(wk) case WKBD_WORKSPACE##wk:\
1538 i = (scr->current_workspace/10)*10 + wk - 1;\
1539 if (wPreferences.ws_advance || i<scr->workspace_count)\
1540 wWorkspaceChange(scr, i);\
1543 #define GOTOWORKS(wk) case WKBD_WORKSPACE/**/wk:\
1544 i = (scr->current_workspace/10)*10 + wk - 1;\
1545 if (wPreferences.ws_advance || i<scr->workspace_count)\
1546 wWorkspaceChange(scr, i);\
1560 case WKBD_NEXTWORKSPACE
:
1561 wWorkspaceRelativeChange(scr
, 1);
1563 case WKBD_PREVWORKSPACE
:
1564 wWorkspaceRelativeChange(scr
, -1);
1577 index
= command
-WKBD_WINDOW1
;
1579 if (scr
->shortcutWindows
[index
]) {
1580 WMArray
*list
= scr
->shortcutWindows
[index
];
1582 int count
= WMGetArrayItemCount(list
);
1584 WMArrayIterator iter
;
1587 wUnselectWindows(scr
);
1588 cw
= scr
->current_workspace
;
1590 WM_ETARETI_ARRAY(list
, wwin
, iter
) {
1592 wWindowChangeWorkspace(wwin
, cw
);
1594 wMakeWindowVisible(wwin
);
1597 wSelectWindow(wwin
, True
);
1600 /* rotate the order of windows, to create a cycling effect */
1601 twin
= WMGetFromArray(list
, 0);
1602 WMDeleteFromArray(list
, 0);
1603 WMAddToArray(list
, twin
);
1605 } else if (wwin
&& ISMAPPED(wwin
) && ISFOCUSED(wwin
)) {
1606 if (scr
->shortcutWindows
[index
]) {
1607 WMFreeArray(scr
->shortcutWindows
[index
]);
1608 scr
->shortcutWindows
[index
] = NULL
;
1611 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1612 scr
->shortcutWindows
[index
] =
1613 WMDuplicateArray(scr
->selected_windows
);
1614 /*WMRemoveFromArray(scr->shortcutWindows[index], wwin);
1615 WMInsertInArray(scr->shortcutWindows[index], 0, wwin);*/
1617 scr
->shortcutWindows
[index
] = WMCreateArray(4);
1618 WMAddToArray(scr
->shortcutWindows
[index
], wwin
);
1621 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1624 wSelectWindow(wwin
, !wwin
->flags
.selected
);
1627 } else if (scr
->selected_windows
1628 && WMGetArrayItemCount(scr
->selected_windows
)) {
1630 if (wwin
->flags
.selected
&& scr
->selected_windows
) {
1631 if (scr
->shortcutWindows
[index
]) {
1632 WMFreeArray(scr
->shortcutWindows
[index
]);
1634 scr
->shortcutWindows
[index
] =
1635 WMDuplicateArray(scr
->selected_windows
);
1641 case WKBD_SWITCH_SCREEN
:
1642 if (wScreenCount
> 1) {
1646 /* find index of this screen */
1647 for (i
= 0; i
< wScreenCount
; i
++) {
1648 if (wScreenWithNumber(i
) == scr
)
1652 if (i
>= wScreenCount
) {
1655 scr2
= wScreenWithNumber(i
);
1658 XWarpPointer(dpy
, scr
->root_win
, scr2
->root_win
, 0, 0, 0, 0,
1659 scr2
->scr_width
/2, scr2
->scr_height
/2);
1664 case WKBD_NEXTWSLAYER
:
1665 case WKBD_PREVWSLAYER
:
1669 row
= scr
->current_workspace
/10;
1670 column
= scr
->current_workspace
%10;
1672 if (command
==WKBD_NEXTWSLAYER
) {
1673 if ((row
+1)*10 < scr
->workspace_count
)
1674 wWorkspaceChange(scr
, column
+(row
+1)*10);
1677 wWorkspaceChange(scr
, column
+(row
-1)*10);
1681 case WKBD_CLIPLOWER
:
1682 if (!wPreferences
.flags
.noclip
)
1683 wDockLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1685 case WKBD_CLIPRAISE
:
1686 if (!wPreferences
.flags
.noclip
)
1687 wDockRaise(scr
->workspaces
[scr
->current_workspace
]->clip
);
1689 case WKBD_CLIPRAISELOWER
:
1690 if (!wPreferences
.flags
.noclip
)
1691 wDockRaiseLower(scr
->workspaces
[scr
->current_workspace
]->clip
);
1693 #ifdef KEEP_XKB_LOCK_STATUS
1695 if(wPreferences
.modelock
) {
1697 wwin
= scr
->focused_window
;
1699 if (wwin
&& wwin
->flags
.mapped
1700 && wwin
->frame
->workspace
== wwin
->screen_ptr
->current_workspace
1701 && !wwin
->flags
.miniaturized
&& !wwin
->flags
.hidden
) {
1702 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1704 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
1705 wwin
->frame
->last_languagemode
= staterec
.group
;
1706 XkbLockGroup(dpy
,XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1711 #endif /* KEEP_XKB_LOCK_STATUS */
1718 handleMotionNotify(XEvent
*event
)
1720 WScreen
*scr
= wScreenForRootWindow(event
->xmotion
.root
);
1722 if (wPreferences
.scrollable_menus
) {
1723 WMPoint p
= { event
->xmotion
.x_root
, event
->xmotion
.y_root
};
1724 WMRect rect
= wGetRectForHead(scr
, wGetHeadForPoint(scr
, p
));
1726 if (scr
->flags
.jump_back_pending
||
1727 p
.x
<= (rect
.pos
.x
+ 1) ||
1728 p
.x
>= (rect
.pos
.x
+ rect
.size
.width
- 2) ||
1729 p
.y
<= (rect
.pos
.y
+ 1) ||
1730 p
.y
>= (rect
.pos
.y
+ rect
.size
.height
- 2)) {
1733 L("pointer at screen edge");
1735 menu
= wMenuUnderPointer(scr
);
1737 wMenuScroll(menu
, event
);
1741 if (event
->xmotion
.subwindow
== None
)
1744 if (scr
->scrolledFMaximize
!= None
) {
1747 twin
= wWindowFor(scr
->scrolledFMaximize
);
1748 if (twin
&& twin
->frame_y
==) {
1752 scr
->scrolledFMaximize
= NULL
;
1756 /* scroll full maximized window */
1757 if (event
->xmotion
.y_root
< 1
1758 || event
->xmotion
.y_root
> scr
->scr_height
- 1) {
1760 wwin
= wWindowFor(event
->xmotion
.subwindow
);
1762 if (wwin
&& (wwin
->flags
.maximized
& MAX_VERTICAL
)
1763 && WFLAGP(wwin
, full_maximize
)
1764 && event
->xmotion
.x_root
>= wwin
->frame_x
1765 && event
->xmotion
.x_root
<= wwin
->frame_x
+ wwin
->frame
->core
->width
) {
1767 if (!WFLAGP(wwin
, no_titlebar
)
1768 && wwin
->frame_y
<= - wwin
->frame
->top_width
) {
1770 wWindowMove(wwin
, wwin
->frame_x
, 0);
1771 wwin
->flags
.dragged_while_fmaximized
= 0;
1773 } else if (!WFLAGP(wwin
, no_resizebar
)
1774 && wwin
->frame_y
+ wwin
->frame
->core
->height
>=
1775 scr
->scr_height
+ wwin
->frame
->bottom_width
) {
1777 int y
= scr
->scr_height
+ wwin
->frame
->bottom_width
;
1779 y
= scr
->scr_height
- wwin
->frame_y
- wwin
->frame
->core
->height
;
1781 wWindowMove(wwin
, wwin
->frame_x
, y
);
1782 wwin
->flags
.dragged_while_fmaximized
= 0;
1791 handleVisibilityNotify(XEvent
*event
)
1795 wwin
= wWindowFor(event
->xvisibility
.window
);
1798 wwin
->flags
.obscured
=
1799 (event
->xvisibility
.state
== VisibilityFullyObscured
);