1 /* window.c - client window managing class
3 * Window Maker window manager
5 * Copyright (c) 1997, 1998 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,
26 #include <X11/Xutil.h>
28 #include <X11/extensions/shape.h>
30 #ifdef KEEP_XKB_LOCK_STATUS
31 # include <X11/XKBlib.h>
32 #endif /* KEEP_XKB_LOCK_STATUS */
38 #include "WindowMaker.h"
47 #include "winspector.h"
49 #include "properties.h"
56 #include "workspace.h"
58 /****** Global Variables ******/
60 extern WShortKey wKeyBindings
[WKBD_LAST
];
63 extern Bool wShapeSupported
;
67 extern XContext wWinContext
;
70 extern Cursor wCursor
[WCUR_LAST
];
73 extern Atom _XA_WM_DELETE_WINDOW
;
74 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
76 extern Atom _XA_WINDOWMAKER_STATE
;
78 extern WPreferences wPreferences
;
80 #define MOD_MASK wPreferences.modifier_mask
82 extern Time LastTimestamp
;
85 extern void DoWindowBirth(WWindow
*);
88 /***** Local Stuff *****/
91 static WWindowState
*windowState
=NULL
;
96 static FocusMode
getFocusMode(WWindow
*wwin
);
98 static int getSavedState(Window window
, WSavedState
**state
);
100 static void setupGNUstepHints(WWindowAttributes
*attribs
,
101 GNUstepWMAttributes
*gs_hints
);
104 static void setupMWMHints(WWindowAttributes
*attribs
, MWMHints
*mwm_hints
);
110 /* frame window (during window grabs) */
111 static void frameMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
114 static void windowCloseClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
115 static void windowCloseDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
118 static void windowIconifyClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
121 static void titlebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
);
122 static void titlebarDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
124 static void resizebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
);
132 wWindowFor(Window window
)
134 WObjDescriptor
*desc
;
139 if (XFindContext(dpy
, window
, wWinContext
, (XPointer
*)&desc
)==XCNOENT
)
142 if (desc
->parent_type
==WCLASS_WINDOW
)
144 else if (desc
->parent_type
==WCLASS_FRAME
) {
145 WFrameWindow
*frame
= (WFrameWindow
*)desc
->parent
;
146 if (frame
->flags
.is_client_window_frame
)
158 wwin
= wmalloc(sizeof(WWindow
));
161 memset(wwin
, 0, sizeof(WWindow
));
163 wwin
->client_descriptor
.handle_mousedown
= frameMouseDown
;
164 wwin
->client_descriptor
.parent
= wwin
;
165 wwin
->client_descriptor
.self
= wwin
;
166 wwin
->client_descriptor
.parent_type
= WCLASS_WINDOW
;
172 wWindowDestroy(WWindow
*wwin
)
176 wwin
->flags
.destroyed
= 1;
178 for (i
= 0; i
< 4; i
++) {
179 if (wwin
->screen_ptr
->shortcutWindow
[i
] == wwin
) {
180 wwin
->screen_ptr
->shortcutWindow
[i
] = NULL
;
184 if (wwin
->normal_hints
)
185 free(wwin
->normal_hints
);
188 XFree(wwin
->wm_hints
);
190 if (wwin
->wm_instance
)
191 XFree(wwin
->wm_instance
);
194 XFree(wwin
->wm_class
);
196 if (wwin
->wm_gnustep_attr
)
197 free(wwin
->wm_gnustep_attr
);
199 if (wwin
->cmap_windows
)
200 XFree(wwin
->cmap_windows
);
202 XDeleteContext(dpy
, wwin
->client_win
, wWinContext
);
205 wFrameWindowDestroy(wwin
->frame
);
208 RemoveFromStackList(wwin
->icon
->core
);
209 wIconDestroy(wwin
->icon
);
210 if (wPreferences
.auto_arrange_icons
)
211 wArrangeIcons(wwin
->screen_ptr
, True
);
220 setupGNUstepHints(WWindowAttributes
*attribs
, GNUstepWMAttributes
*gs_hints
)
222 if (gs_hints
->flags
& GSWindowStyleAttr
) {
223 attribs
->no_titlebar
=
224 ((gs_hints
->window_style
& WMTitledWindowMask
)?0:1);
226 attribs
->no_close_button
= attribs
->no_closable
=
227 ((gs_hints
->window_style
& WMClosableWindowMask
)?0:1);
229 attribs
->no_miniaturize_button
= attribs
->no_miniaturizable
=
230 ((gs_hints
->window_style
& WMMiniaturizableWindowMask
)?0:1);
232 attribs
->no_resizebar
= attribs
->no_resizable
=
233 ((gs_hints
->window_style
& WMResizableWindowMask
)?0:1);
235 /* setup the defaults */
236 attribs
->no_titlebar
= 0;
237 attribs
->no_closable
= 0;
238 attribs
->no_miniaturizable
= 0;
239 attribs
->no_resizable
= 0;
240 attribs
->no_close_button
= 0;
241 attribs
->no_miniaturize_button
= 0;
242 attribs
->no_resizebar
= 0;
245 if (gs_hints
->extra_flags
& GSNoApplicationIconFlag
) {
246 attribs
->no_appicon
= 1;
253 setupMWMHints(WWindowAttributes
*attribs
, MWMHints
*mwm_hints
)
257 * We will ignore all decoration hints that have an equivalent as
258 * functions, because wmaker does not distinguish decoration hints
261 if (mwm_hints
->flags
& MWM_HINTS_DECORATIONS
) {
263 fprintf(stderr
,"has decor hints [ ");
265 attribs
->no_titlebar
= 1;
266 attribs
->no_close_button
= 1;
267 attribs
->no_miniaturize_button
= 1;
268 attribs
->no_resizebar
= 1;
270 if (mwm_hints
->decorations
& MWM_DECOR_ALL
) {
272 fprintf(stderr
,"ALL ");
274 attribs
->no_titlebar
= 0;
275 attribs
->no_close_button
= 0;
276 attribs
->no_closable
= 0;
277 attribs
->no_miniaturize_button
= 0;
278 attribs
->no_miniaturizable
= 0;
279 attribs
->no_resizebar
= 0;
280 attribs
->no_resizable
= 0;
283 if (mwm_hints->decorations & MWM_DECOR_BORDER) {
285 fprintf(stderr,"(BORDER) ");
290 if (mwm_hints
->decorations
& MWM_DECOR_RESIZEH
) {
292 fprintf(stderr
,"RESIZEH ");
294 attribs
->no_resizebar
= 0;
297 if (mwm_hints
->decorations
& MWM_DECOR_TITLE
) {
299 fprintf(stderr
,"TITLE+close ");
301 attribs
->no_titlebar
= 0;
302 attribs
->no_close_button
= 0;
303 attribs
->no_closable
= 0;
306 if (mwm_hints->decorations & MWM_DECOR_MENU) {
308 fprintf(stderr,"(MENU) ");
313 if (mwm_hints
->decorations
& MWM_DECOR_MINIMIZE
) {
315 fprintf(stderr
,"MINIMIZE ");
317 attribs
->no_miniaturize_button
= 0;
318 attribs
->no_miniaturizable
= 0;
321 if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) {
323 fprintf(stderr,"(MAXIMIZE) ");
328 fprintf(stderr
,"]\n");
333 if (mwm_hints
->flags
& MWM_HINTS_FUNCTIONS
) {
335 fprintf(stderr
,"has function hints [ ");
337 attribs
->no_closable
= 1;
338 attribs
->no_miniaturizable
= 1;
339 attribs
->no_resizable
= 1;
341 if (mwm_hints
->functions
& MWM_FUNC_ALL
) {
343 fprintf(stderr
,"ALL ");
345 attribs
->no_closable
= 0;
346 attribs
->no_miniaturizable
= 0;
347 attribs
->no_resizable
= 0;
349 if (mwm_hints
->functions
& MWM_FUNC_RESIZE
) {
351 fprintf(stderr
,"RESIZE ");
353 attribs
->no_resizable
= 0;
356 if (mwm_hints->functions & MWM_FUNC_MOVE) {
358 fprintf(stderr,"(MOVE) ");
362 if (mwm_hints
->functions
& MWM_FUNC_MINIMIZE
) {
364 fprintf(stderr
,"MINIMIZE ");
366 attribs
->no_miniaturizable
= 0;
368 if (mwm_hints
->functions
& MWM_FUNC_MAXIMIZE
) {
370 fprintf(stderr
,"MAXIMIZE ");
371 /* a window must be resizable to be maximizable */
372 attribs
->no_resizable
= 0;
375 if (mwm_hints
->functions
& MWM_FUNC_CLOSE
) {
377 fprintf(stderr
,"CLOSE ");
379 attribs
->no_closable
= 0;
382 fprintf(stderr
,"]\n");
386 #endif /* MWM_HINTS */
390 wWindowCheckAttributeSanity(WWindow
*wwin
, WWindowAttributes
*wflags
)
392 if (wflags
->no_appicon
)
393 wflags
->emulate_appicon
= 0;
395 if (wwin
->main_window
!=None
) {
396 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
397 if (wapp
&& !wapp
->flags
.emulated
)
398 wflags
->emulate_appicon
= 0;
401 if (wwin
->transient_for
!=None
402 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
)
403 wflags
->emulate_appicon
= 0;
409 wWindowCanReceiveFocus(WWindow
*wwin
)
411 if (!wwin
->flags
.mapped
&& !wwin
->flags
.shaded
)
413 if (wwin
->window_flags
.no_focusable
|| wwin
->flags
.miniaturized
)
415 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
423 *----------------------------------------------------------------
425 * reparents the window and allocates a descriptor for it.
426 * Window manager hints and other hints are fetched to configure
427 * the window decoration attributes and others. User preferences
428 * for the window are used if available, to configure window
429 * decorations and some behaviour.
432 * the new window descriptor
435 * The window is reparented and appropriate notification
436 * is done to the client. Input mask for the window is setup.
437 * The window descriptor is also associated with various window
438 * contexts and inserted in the head of the window list.
439 * Event handler contexts are associated for some objects
440 * (buttons, titlebar and resizebar)
443 * Check if the window_flags setting is correct.
444 *----------------------------------------------------------------
447 wManageWindow(WScreen
*scr
, Window window
)
451 unsigned width
, height
;
452 XWindowAttributes wattribs
;
453 XSetWindowAttributes attribs
;
455 WWindowState
*win_state
;
457 MWMHints
*motif_hints
= NULL
;
467 /* make sure the window is still there */
468 if (!XGetWindowAttributes(dpy
, window
, &wattribs
)) {
472 wwin
= wWindowCreate();
474 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
477 printf("managing window %x\n", (unsigned)window
);
481 if (wShapeSupported
) {
486 XShapeSelectInput(dpy
, window
, ShapeNotifyMask
);
487 XShapeQueryExtents(dpy
, window
, &b_shaped
, &junk
, &junk
, &ujunk
,
488 &ujunk
, &junk
, &junk
, &junk
, &ujunk
, &ujunk
);
489 wwin
->flags
.shaped
= b_shaped
;
494 *--------------------------------------------------
496 * Get hints and other information in properties
498 *--------------------------------------------------
500 wwin
->wm_hints
= XGetWMHints(dpy
, window
);
501 PropGetWMClass(window
, &wwin
->wm_class
, &wwin
->wm_instance
);
503 /* setup descriptor */
504 wwin
->client_win
= window
;
505 wwin
->screen_ptr
= scr
;
507 wwin
->old_border_width
= wattribs
.border_width
;
509 attribs
.event_mask
= CLIENT_EVENTS
;
510 attribs
.do_not_propagate_mask
= ButtonPressMask
| ButtonReleaseMask
;
511 attribs
.save_under
= False
;
512 XChangeWindowAttributes(dpy
, window
, CWEventMask
|CWDontPropagate
513 |CWSaveUnder
, &attribs
);
514 XSetWindowBorderWidth(dpy
, window
, 0);
516 /* fill in property/hint data */
517 if (!wFetchName(dpy
, window
, &title
)) {
520 /* get hints from GNUstep app */
521 if (!PropGetGNUstepWMAttr(window
, &wwin
->wm_gnustep_attr
)) {
522 wwin
->wm_gnustep_attr
=NULL
;
526 if (!PropGetMotifWMHints(window
, &motif_hints
))
528 #endif /* MWM_HINTS */
530 if (!PropGetClientLeader(window
, &wwin
->client_leader
)) {
531 wwin
->client_leader
= None
;
533 wwin
->main_window
= wwin
->client_leader
;
537 XFree(wwin
->wm_hints
);
539 wwin
->wm_hints
= XGetWMHints(dpy
, window
);
541 if (wwin
->wm_hints
) {
542 if ((wwin
->wm_hints
->flags
&StateHint
)
543 && (wwin
->wm_hints
->initial_state
== IconicState
)) {
545 /* don't do iconify animation */
546 wwin
->flags
.skip_next_animation
= 1;
549 if (wwin
->wm_hints
->flags
& WindowGroupHint
) {
550 wwin
->group_id
= wwin
->wm_hints
->window_group
;
551 /* window_group has priority over CLIENT_LEADER */
552 wwin
->main_window
= wwin
->group_id
;
554 wwin
->group_id
= None
;
557 if (wwin
->wm_hints
->flags
& UrgencyHint
)
558 wwin
->flags
.urgent
= 1;
560 wwin
->group_id
= None
;
563 PropGetProtocols(window
, &wwin
->protocols
);
565 if (!XGetTransientForHint(dpy
, window
, &wwin
->transient_for
)) {
566 wwin
->transient_for
= None
;
568 if (wwin
->transient_for
==None
|| wwin
->transient_for
==window
) {
569 wwin
->transient_for
= scr
->root_win
;
572 owner
= wWindowFor(wwin
->transient_for
);
573 if (owner
&& owner
->main_window
!=None
) {
574 wwin
->main_window
= owner
->main_window
;
576 wwin->main_window = None;
579 /* don't let transients start miniaturized if their owners
581 if (owner
&& !owner
->flags
.miniaturized
&& iconic
) {
584 wwin
->wm_hints
->initial_state
= NormalState
;
589 /* guess the focus mode */
590 wwin
->focus_mode
= getFocusMode(wwin
);
592 /* get geometry stuff */
593 wClientGetNormalHints(wwin
, &wattribs
, True
, &x
, &y
, &width
, &height
);
595 /* get colormap windows */
596 GetColormapWindows(wwin
);
600 *--------------------------------------------------
602 * Setup the decoration/window attributes and
605 *--------------------------------------------------
607 /* sets global default stuff */
608 wDefaultFillAttributes(scr
, wwin
->wm_instance
, wwin
->wm_class
,
609 &wwin
->window_flags
, True
);
611 * Decoration setting is done in this precedence (lower to higher)
612 * - use default in the resource database
613 * - guess some settings
614 * - use GNUstep/external window attributes
615 * - set hints specified for the app in the resource DB
617 wwin
->window_flags
.broken_close
= 0;
619 if (wwin
->protocols
.DELETE_WINDOW
)
620 wwin
->window_flags
.kill_close
= 0;
622 wwin
->window_flags
.kill_close
= 1;
624 /* transients can't be iconified or maximized */
625 if (wwin
->transient_for
) {
626 wwin
->window_flags
.no_miniaturizable
= 1;
627 wwin
->window_flags
.no_miniaturize_button
= 1;
629 printf("%x is transient for %x\n", (unsigned)window
,
630 (unsigned)wwin
->transient_for
);
634 /* if the window can't be resized, remove the resizebar */
635 if (wwin
->normal_hints
->flags
& (PMinSize
|PMaxSize
)
636 && (wwin
->normal_hints
->min_width
==wwin
->normal_hints
->max_width
)
637 && (wwin
->normal_hints
->min_height
==wwin
->normal_hints
->max_height
)) {
638 wwin
->window_flags
.no_resizable
= 1;
639 wwin
->window_flags
.no_resizebar
= 1;
642 /* set GNUstep window attributes */
643 if (wwin
->wm_gnustep_attr
) {
644 setupGNUstepHints(&wwin
->window_flags
, wwin
->wm_gnustep_attr
);
645 if (wwin
->wm_gnustep_attr
->flags
& GSWindowLevelAttr
) {
646 window_level
= wwin
->wm_gnustep_attr
->window_level
;
649 window_level
= WMNormalWindowLevel
;
654 setupMWMHints(&wwin
->window_flags
, motif_hints
);
656 #endif /* MWM_HINTS */
657 if (wwin
->window_flags
.floating
)
658 window_level
= WMFloatingWindowLevel
;
660 window_level
= WMNormalWindowLevel
;
668 * Set attributes specified only for that window/class.
669 * This might do duplicate work with the 1st wDefaultFillAttributes().
670 * TODO: Do something about that.
672 wDefaultFillAttributes(scr
, wwin
->wm_instance
, wwin
->wm_class
,
673 &wwin
->window_flags
, False
);
677 * Sanity checks for attributes that depend on other attributes
679 wWindowCheckAttributeSanity(wwin
, &wwin
->window_flags
);
681 wwin
->window_flags
.no_shadeable
= wwin
->window_flags
.no_titlebar
;
684 * Make broken apps behave as a nice app.
686 if (wwin
->window_flags
.emulate_appicon
) {
687 wwin
->main_window
= wwin
->client_win
;
691 *------------------------------------------------------------
693 * Setup the initial state of the window
695 *------------------------------------------------------------
697 if (wwin
->window_flags
.start_miniaturized
698 && !wwin
->window_flags
.no_miniaturizable
) {
699 wwin
->flags
.miniaturized
= 1;
703 /* if there is a saved state, restore it */
705 if (wwin
->main_window
!=None
/* && wwin->main_window!=window*/) {
706 win_state
= (WWindowState
*)wWindowGetSavedState(wwin
->main_window
);
708 win_state
= (WWindowState
*)wWindowGetSavedState(window
);
710 if (win_state
&& !(wwin
->wm_hints
&& wwin
->wm_hints
->flags
&StateHint
&&
711 wwin
->wm_hints
->initial_state
==WithdrawnState
)) {
712 if (win_state
->state
->hidden
>0)
713 wwin
->flags
.hidden
= win_state
->state
->hidden
;
714 if (win_state
->state
->shaded
>0 && !wwin
->window_flags
.no_shadeable
)
715 wwin
->flags
.shaded
= win_state
->state
->shaded
;
716 if (win_state
->state
->miniaturized
>0 &&
717 !wwin
->window_flags
.no_miniaturizable
) {
718 wwin
->flags
.miniaturized
= win_state
->state
->miniaturized
;
721 if (!wwin
->window_flags
.omnipresent
) {
722 int w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
,
724 if (w
< 0 || w
>= scr
->workspace_count
) {
725 workspace
= win_state
->state
->workspace
;
726 if (workspace
>=scr
->workspace_count
)
727 workspace
= scr
->current_workspace
;
732 workspace
= scr
->current_workspace
;
736 /* if we're restarting, restore saved state. This will overwrite previous */
740 if (getSavedState(window
, &wstate
)) {
741 wwin
->flags
.shaded
= wstate
->shaded
;
742 wwin
->flags
.hidden
= wstate
->hidden
;
743 wwin
->flags
.miniaturized
= 0;
744 workspace
= wstate
->workspace
;
750 /* set workspace on which the window starts */
751 if (workspace
>= 0) {
752 if (workspace
> scr
->workspace_count
-1) {
753 wWorkspaceMake(scr
, workspace
- scr
->workspace_count
+ 1);
754 workspace
= scr
->workspace_count
- 1;
759 w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
, wwin
->wm_class
);
760 if (w
>=0 && w
<scr
->workspace_count
&& !wwin
->window_flags
.omnipresent
) {
763 workspace
= scr
->current_workspace
;
767 /* setup window geometry */
768 if (win_state
&& win_state
->state
->use_geometry
) {
769 width
= win_state
->state
->w
;
770 height
= win_state
->state
->h
;
772 wWindowConstrainSize(wwin
, &width
, &height
);
774 /* do not ask for window placement if the window is
775 * transient, during startup, if the initial workspace is another one
776 * or if the window wants to
778 * If geometry was saved, restore it. */
779 if (win_state
&& win_state
->state
->use_geometry
) {
780 x
= win_state
->state
->x
;
781 y
= win_state
->state
->y
;
782 } else if (wwin
->transient_for
==None
&& !scr
->flags
.startup
&&
783 workspace
==scr
->current_workspace
&& !iconic
&&
784 !(wwin
->normal_hints
->flags
& (USPosition
|PPosition
))) {
785 PlaceWindow(wwin
, &x
, &y
, width
, height
);
788 if (wwin
->window_flags
.dont_move_off
)
789 wScreenBringInside(scr
, &x
, &y
, width
, height
);
792 *--------------------------------------------------
794 * Create frame, borders and do reparenting
796 *--------------------------------------------------
799 foo
= WFF_LEFT_BUTTON
| WFF_RIGHT_BUTTON
;
800 if (!wwin
->window_flags
.no_titlebar
)
802 if (!wwin
->window_flags
.no_resizebar
)
803 foo
|= WFF_RESIZEBAR
;
805 wwin
->frame
= wFrameWindowCreate(scr
, window_level
,
806 x
, y
, width
, height
, foo
,
807 scr
->window_title_texture
,
808 (WTexture
**)scr
->resizebar_texture
,
809 scr
->window_title_pixel
,
810 &scr
->window_title_gc
,
813 wwin
->frame
->flags
.is_client_window_frame
= 1;
814 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
816 /* setup button images */
817 wWindowUpdateButtonImages(wwin
);
819 /* hide unused buttons */
821 if (wwin
->window_flags
.no_close_button
)
822 foo
|= WFF_RIGHT_BUTTON
;
823 if (wwin
->window_flags
.no_miniaturize_button
)
824 foo
|= WFF_LEFT_BUTTON
;
826 wFrameWindowHideButton(wwin
->frame
, foo
);
829 wwin
->frame
->child
= wwin
;
831 wFrameWindowChangeTitle(wwin
->frame
, title
? title
: DEF_WINDOW_TITLE
);
835 wwin
->frame
->workspace
= workspace
;
837 wwin
->frame
->on_click_left
= windowIconifyClick
;
839 wwin
->frame
->on_click_right
= windowCloseClick
;
840 wwin
->frame
->on_dblclick_right
= windowCloseDblClick
;
842 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
843 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
845 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
847 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
848 0, wwin
->frame
->top_width
);
854 wClientGetGravityOffsets(wwin
, &gx
, &gy
);
855 /* set the position of the frame on screen */
856 x
+= gx
* FRAME_BORDER_WIDTH
;
857 y
+= gy
* FRAME_BORDER_WIDTH
;
858 /* if gravity is to the south, account for the border sizes */
860 y
-= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
864 * wWindowConfigure() will init the client window's size
865 * (wwin->client.{width,height}) and all other geometry
866 * related variables (frame_x,frame_y)
868 wWindowConfigure(wwin
, x
, y
, width
, height
);
871 *--------------------------------------------------
873 * Setup descriptors and save window to internal
876 *--------------------------------------------------
879 if (wwin
->main_window
!=None
) {
883 /* Leader windows do not necessary set themselves as leaders.
884 * If this is the case, point the leader of this window to
886 leader
= wWindowFor(wwin
->main_window
);
887 if (leader
&& leader
->main_window
==None
) {
888 leader
->main_window
= leader
->client_win
;
891 app
= wApplicationCreate(scr
, wwin
->main_window
);
893 app
->last_workspace
= workspace
;
896 * Do application specific stuff, like setting application
900 if (wwin
->flags
.hidden
) {
901 /* if the window was set to hidden because it was hidden
902 * in a previous incarnation and that state was restored */
903 app
->flags
.hidden
= 1;
906 if (app
->flags
.hidden
) {
907 wwin
->flags
.hidden
= 1;
912 /* setup the frame descriptor */
913 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
914 wwin
->frame
->core
->descriptor
.parent
= wwin
;
915 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
917 /* don't let windows go away if we die */
918 XAddToSaveSet(dpy
, window
);
920 XLowerWindow(dpy
, window
);
922 /* if window is in this workspace and should be mapped, then map it */
923 if (!iconic
&& (workspace
== scr
->current_workspace
924 || wwin
->window_flags
.omnipresent
)
925 && !wwin
->flags
.hidden
926 && !(wwin
->wm_hints
&& (wwin
->wm_hints
->flags
& StateHint
)
927 && wwin
->wm_hints
->initial_state
== WithdrawnState
)) {
928 /* The following "if" is to avoid crashing of clients that expect
929 * WM_STATE set before they get mapped. Else WM_STATE is set later,
930 * after the return from this function.
932 if (wwin
->wm_hints
&& (wwin
->wm_hints
->flags
& StateHint
)) {
933 wClientSetState(wwin
, wwin
->wm_hints
->initial_state
, None
);
935 wClientSetState(wwin
, NormalState
, None
);
937 if (wPreferences
.superfluous
&& !wPreferences
.no_animations
938 && !scr
->flags
.startup
&& wwin
->transient_for
==None
940 * The brain damaged idiotic non-click to focus modes will
941 * have trouble with this because:
943 * 1. window is created and mapped by the client
944 * 2. window is mapped by wmaker in small size
945 * 3. window is animated to grow to normal size
946 * 4. this function returns to normal event loop
947 * 5. eventually, the EnterNotify event that would trigger
948 * the window focusing (if the mouse is over that window)
949 * will be processed by wmaker.
950 * But since this event will be rather delayed
951 * (step 3 has a large delay) the time when the event ocurred
952 * and when it is processed, the client that owns that window
953 * will reject the XSetInputFocus() for it.
955 && (wPreferences
.focus_mode
==WKF_CLICK
956 || wPreferences
.auto_focus
)) {
959 XMapSubwindows(dpy
, wwin
->frame
->core
->window
);
962 XMapSubwindows(dpy
, wwin
->frame
->core
->window
);
965 /* setup stacking descriptor */
966 if (wPreferences
.on_top_transients
&& wwin
->transient_for
!=None
967 && wwin
->transient_for
!=scr
->root_win
) {
969 tmp
= wWindowFor(wwin
->transient_for
);
971 wwin
->frame
->core
->stacking
->child_of
= tmp
->frame
->core
;
973 wwin
->frame
->core
->stacking
->child_of
= NULL
;
977 if (!scr
->focused_window
) {
978 /* first window on the list */
981 scr
->focused_window
= wwin
;
985 /* add window at beginning of focus window list */
986 tmp
= scr
->focused_window
;
998 *--------------------------------------------------
1000 * Final preparations before window is ready to go
1002 *--------------------------------------------------
1005 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1008 if (!iconic
&& workspace
== scr
->current_workspace
) {
1009 WWindow
*tmp
= wWindowFor(wwin
->transient_for
);
1011 if ((tmp
&& tmp
->flags
.focused
) || wPreferences
.auto_focus
)
1012 wSetFocusTo(scr
, wwin
);
1014 wwin
->flags
.ignore_next_unmap
= 1;
1016 wWindowResetMouseGrabs(wwin
);
1018 if (!wwin
->window_flags
.no_bind_keys
) {
1019 wWindowSetKeyGrabs(wwin
);
1023 * Prevent window withdrawal when getting the
1024 * unmap notifies generated during reparenting
1026 wwin
->flags
.mapped
=0;
1030 wColormapInstallForWindow(wwin
->screen_ptr
, scr
->cmap_window
);
1032 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_ADD
);
1034 *--------------------------------------------------
1035 * Cleanup temporary stuff
1036 *--------------------------------------------------
1040 wWindowDeleteSavedState(win_state
);
1050 wManageInternalWindow(WScreen
*scr
, Window window
, Window owner
,
1051 char *title
, int x
, int y
, int width
, int height
)
1056 wwin
= wWindowCreate();
1058 wwin
->flags
.internal_window
= 1;
1059 wwin
->window_flags
.omnipresent
= 1;
1060 wwin
->window_flags
.no_shadeable
= 1;
1061 wwin
->window_flags
.no_resizable
= 1;
1062 wwin
->window_flags
.no_miniaturizable
= 1;
1064 wwin
->focus_mode
= WFM_PASSIVE
;
1066 wwin
->client_win
= window
;
1067 wwin
->screen_ptr
= scr
;
1069 wwin
->transient_for
= owner
;
1073 wwin
->client
.width
= width
;
1074 wwin
->client
.height
= height
;
1076 wwin
->frame_x
= wwin
->client
.x
;
1077 wwin
->frame_y
= wwin
->client
.y
;
1080 foo
= WFF_RIGHT_BUTTON
;
1081 foo
|= WFF_TITLEBAR
;
1083 wwin
->frame
= wFrameWindowCreate(scr
, WMFloatingWindowLevel
,
1084 wwin
->frame_x
, wwin
->frame_y
,
1086 scr
->window_title_texture
,
1087 (WTexture
**)scr
->resizebar_texture
,
1088 scr
->window_title_pixel
,
1089 &scr
->window_title_gc
,
1092 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
1094 wwin
->frame
->flags
.is_client_window_frame
= 1;
1095 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
1097 wFrameWindowChangeTitle(wwin
->frame
, title
);
1099 /* setup button images */
1100 wWindowUpdateButtonImages(wwin
);
1103 wFrameWindowHideButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1105 wwin
->frame
->child
= wwin
;
1107 wwin
->frame
->workspace
= wwin
->screen_ptr
->current_workspace
;
1109 wwin
->frame
->on_click_right
= windowCloseClick
;
1111 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
1112 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
1114 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
1116 wwin
->client
.y
+= wwin
->frame
->top_width
;
1117 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
1118 0, wwin
->frame
->top_width
);
1120 wWindowConfigure(wwin
, wwin
->frame_x
, wwin
->frame_y
,
1121 wwin
->client
.width
, wwin
->client
.height
);
1123 /* setup the frame descriptor */
1124 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
1125 wwin
->frame
->core
->descriptor
.parent
= wwin
;
1126 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
1129 XLowerWindow(dpy
, window
);
1130 XMapSubwindows(dpy
, wwin
->frame
->core
->window
);
1132 /* setup stacking descriptor */
1133 if (wPreferences
.on_top_transients
&& wwin
->transient_for
!=None
1134 && wwin
->transient_for
!=scr
->root_win
) {
1136 tmp
= wWindowFor(wwin
->transient_for
);
1138 wwin
->frame
->core
->stacking
->child_of
= tmp
->frame
->core
;
1140 wwin
->frame
->core
->stacking
->child_of
= NULL
;
1144 if (!scr
->focused_window
) {
1145 /* first window on the list */
1148 scr
->focused_window
= wwin
;
1152 /* add window at beginning of focus window list */
1153 tmp
= scr
->focused_window
;
1161 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1163 /* if (wPreferences.auto_focus)*/
1164 wSetFocusTo(scr
, wwin
);
1166 wWindowResetMouseGrabs(wwin
);
1168 wWindowSetKeyGrabs(wwin
);
1170 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_ADD
);
1177 *----------------------------------------------------------------------
1179 * Removes the frame window from a window and destroys all data
1180 * related to it. The window will be reparented back to the root window
1181 * if restore is True.
1184 * Everything related to the window is destroyed and the window
1185 * is removed from the window lists. Focus is set to the previous on the
1187 *----------------------------------------------------------------------
1190 wUnmanageWindow(WWindow
*wwin
, int restore
)
1192 WCoreWindow
*frame
= wwin
->frame
->core
;
1194 WWindow
*newFocusedWindow
;
1196 WScreen
*scr
= wwin
->screen_ptr
;
1198 /* First close attribute editor window if open */
1199 if (wwin
->flags
.inspector_open
) {
1200 WWindow
*pwin
= wwin
->inspector
->frame
; /* the inspector window */
1201 (*pwin
->frame
->on_click_right
)(NULL
, pwin
, NULL
);
1204 /* Close window menu if it's open for this window */
1205 if (wwin
->flags
.menu_open_for_me
) {
1206 CloseWindowMenu(scr
);
1208 if (!wwin
->flags
.internal_window
)
1209 XRemoveFromSaveSet(dpy
, wwin
->client_win
);
1210 XSelectInput(dpy
, wwin
->client_win
, NoEventMask
);
1212 XUnmapWindow(dpy
, frame
->window
);
1214 /* deselect window */
1215 wSelectWindow(wwin
, False
);
1217 /* remove all pending events on window */
1218 /* I think this only matters for autoraise */
1219 if (wPreferences
.raise_delay
)
1220 WMDeleteTimerWithClientData(wwin
->frame
->core
);
1224 UpdateSwitchMenu(scr
, wwin
, ACTION_REMOVE
);
1226 /* reparent the window back to the root */
1228 wClientRestore(wwin
);
1230 if (wwin
->transient_for
!=scr
->root_win
) {
1231 owner
= wWindowFor(wwin
->transient_for
);
1233 owner
->flags
.semi_focused
= 0;
1234 wFrameWindowChangeState(owner
->frame
, WS_UNFOCUSED
);
1238 wasNotFocused
= !wwin
->flags
.focused
;
1240 /* remove from window focus list */
1241 if (!wwin
->prev
&& !wwin
->next
) {
1242 /* was the only window */
1243 scr
->focused_window
= NULL
;
1244 newFocusedWindow
= NULL
;
1249 wwin
->prev
->next
= wwin
->next
;
1251 wwin
->next
->prev
= wwin
->prev
;
1253 scr
->focused_window
= wwin
->prev
;
1254 scr
->focused_window
->next
= NULL
;
1257 /* if in click to focus mode and the window
1258 * was a transient, focus the owner window
1261 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1262 tmp
= wWindowFor(wwin
->transient_for
);
1263 if (tmp
&& (!tmp
->flags
.mapped
|| tmp
->window_flags
.no_focusable
)) {
1267 /* otherwise, focus the next one in the focus list */
1269 tmp
= scr
->focused_window
;
1271 if (!tmp
->window_flags
.no_focusable
1272 && (tmp
->flags
.mapped
|| tmp
->flags
.shaded
))
1277 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1278 newFocusedWindow
= tmp
;
1279 } else if (wPreferences
.focus_mode
==WKF_SLOPPY
1280 || wPreferences
.focus_mode
==WKF_POINTER
) {
1285 /* This is to let the root window get the keyboard input
1286 * if Sloppy focus mode and no other window get focus.
1287 * This way keybindings will not freeze.
1290 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
,
1291 &foo
, &foo
, &foo
, &foo
, &mask
))
1292 tmp
= wWindowFor(win
);
1295 newFocusedWindow
= tmp
;
1297 newFocusedWindow
= NULL
;
1301 printf("destroying window %x frame %x\n", (unsigned)wwin
->client_win
,
1302 (unsigned)frame
->window
);
1305 wSetFocusTo(scr
, newFocusedWindow
);
1306 wWindowDestroy(wwin
);
1312 wWindowFocus(WWindow
*wwin
)
1314 #ifdef KEEP_XKB_LOCK_STATUS
1315 if (wPreferences
.modelock
) {
1316 if (!wwin
->flags
.focused
) {
1317 XkbLockGroup(dpy
, XkbUseCoreKbd
, wwin
->languagemode
);
1320 #endif /* KEEP_XKB_LOCK_STATUS */
1322 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1324 wwin
->flags
.focused
=1;
1326 wWindowResetMouseGrabs(wwin
);
1328 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1333 wWindowMap(WWindow
*wwin
)
1335 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1336 wwin
->flags
.mapped
= 1;
1342 wWindowUnfocus(WWindow
*wwin
)
1344 #ifdef KEEP_XKB_LOCK_STATUS
1345 static XkbStateRec staterec
;
1346 if (wPreferences
.modelock
) {
1347 if (wwin
->flags
.focused
) {
1348 XkbGetState(dpy
,XkbUseCoreKbd
,&staterec
);
1349 wwin
->languagemode
=staterec
.compat_state
&32?1:0;
1350 XkbLockGroup(dpy
,XkbUseCoreKbd
,0); /* reset to workspace */
1353 #endif /* KEEP_XKB_LOCK_STATUS */
1355 CloseWindowMenu(wwin
->screen_ptr
);
1357 wFrameWindowChangeState(wwin
->frame
, wwin
->flags
.semi_focused
1358 ? WS_PFOCUSED
: WS_UNFOCUSED
);
1360 if (wwin
->transient_for
!=None
1361 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
1363 owner
= wWindowFor(wwin
->transient_for
);
1364 if (owner
&& owner
->flags
.semi_focused
) {
1365 owner
->flags
.semi_focused
= 0;
1366 if (owner
->flags
.mapped
|| owner
->flags
.shaded
) {
1367 wWindowUnfocus(owner
);
1368 wFrameWindowPaint(owner
->frame
);
1372 wwin
->flags
.focused
=0;
1373 wWindowResetMouseGrabs(wwin
);
1375 UpdateSwitchMenu(wwin
->screen_ptr
, wwin
, ACTION_CHANGE_STATE
);
1381 *----------------------------------------------------------------------
1383 * wWindowConstrainSize--
1384 * Constrains size for the client window, taking the maximal size,
1385 * window resize increments and other size hints into account.
1388 * The closest size to what was given that the client window can
1391 *----------------------------------------------------------------------
1394 wWindowConstrainSize(WWindow
*wwin
, int *nwidth
, int *nheight
)
1396 XSizeHints
*sizeh
= wwin
->normal_hints
;
1397 int width
= *nwidth
;
1398 int height
= *nheight
;
1399 int winc
= sizeh
->width_inc
;
1400 int hinc
= sizeh
->height_inc
;
1402 if (width
< sizeh
->min_width
)
1403 width
= sizeh
->min_width
;
1404 if (height
< sizeh
->min_height
)
1405 height
= sizeh
->min_height
;
1407 if (width
> sizeh
->max_width
)
1408 width
= sizeh
->max_width
;
1409 if (height
> sizeh
->max_height
)
1410 height
= sizeh
->max_height
;
1412 /* aspect ratio code borrowed from olwm */
1413 if (sizeh
->flags
& PAspect
) {
1414 /* adjust max aspect ratio */
1415 if (!(sizeh
->max_aspect
.x
==1 && sizeh
->max_aspect
.y
==1)
1416 && width
* sizeh
->max_aspect
.y
> height
* sizeh
->max_aspect
.x
) {
1417 if (sizeh
->max_aspect
.x
> sizeh
->max_aspect
.y
) {
1418 height
= (width
* sizeh
->max_aspect
.y
) / sizeh
->max_aspect
.x
;
1419 if (height
> sizeh
->max_height
) {
1420 height
= sizeh
->max_height
;
1421 width
= (height
*sizeh
->max_aspect
.x
) / sizeh
->max_aspect
.y
;
1424 width
= (height
* sizeh
->max_aspect
.x
) / sizeh
->max_aspect
.y
;
1425 if (width
> sizeh
->max_width
) {
1426 width
= sizeh
->max_width
;
1427 height
= (width
*sizeh
->max_aspect
.y
) / sizeh
->max_aspect
.x
;
1432 /* adjust min aspect ratio */
1433 if (!(sizeh
->min_aspect
.x
==1 && sizeh
->min_aspect
.y
==1)
1434 && width
* sizeh
->min_aspect
.y
< height
* sizeh
->min_aspect
.x
) {
1435 if (sizeh
->min_aspect
.x
> sizeh
->min_aspect
.y
) {
1436 height
= (width
* sizeh
->min_aspect
.y
) / sizeh
->min_aspect
.x
;
1437 if (height
< sizeh
->min_height
) {
1438 height
= sizeh
->min_height
;
1439 width
= (height
*sizeh
->min_aspect
.x
) / sizeh
->min_aspect
.y
;
1442 width
= (height
* sizeh
->min_aspect
.x
) / sizeh
->min_aspect
.y
;
1443 if (width
> sizeh
->min_width
) {
1444 width
= sizeh
->min_width
;
1445 height
= (width
*sizeh
->min_aspect
.y
) / sizeh
->min_aspect
.x
;
1451 if (sizeh
->base_width
!= 0) {
1452 width
= (((width
- sizeh
->base_width
) / winc
) * winc
)
1453 + sizeh
->base_width
;
1455 width
= (((width
- sizeh
->min_width
) / winc
) * winc
)
1459 if (sizeh
->base_width
!= 0) {
1460 height
= (((height
- sizeh
->base_height
) / hinc
) * hinc
)
1461 + sizeh
->base_height
;
1463 height
= (((height
- sizeh
->min_height
) / hinc
) * hinc
)
1464 + sizeh
->min_height
;
1473 wWindowChangeWorkspace(WWindow
*wwin
, int workspace
)
1475 WScreen
*scr
= wwin
->screen_ptr
;
1478 if (workspace
>= scr
->workspace_count
|| workspace
< 0
1479 || workspace
== wwin
->frame
->workspace
)
1482 if (workspace
!= scr
->current_workspace
) {
1483 /* Sent to other workspace. Unmap window */
1484 if ((wwin
->flags
.mapped
||wwin
->flags
.shaded
)
1485 && !wwin
->window_flags
.omnipresent
1486 && !wwin
->flags
.changing_workspace
) {
1488 wapp
= wApplicationOf(wwin
->main_window
);
1490 wapp
->last_workspace
= workspace
;
1492 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
1493 wwin
->flags
.mapped
= 0;
1494 wSetFocusTo(scr
, NULL
);
1497 /* brought to current workspace. Map window */
1498 if (!wwin
->flags
.mapped
&&
1499 !(wwin
->flags
.miniaturized
|| wwin
->flags
.hidden
)) {
1503 if (!wwin
->window_flags
.omnipresent
) {
1504 wwin
->frame
->workspace
= workspace
;
1505 UpdateSwitchMenu(scr
, wwin
, ACTION_CHANGE_WORKSPACE
);
1511 wWindowSynthConfigureNotify(WWindow
*wwin
)
1515 sevent
.type
= ConfigureNotify
;
1516 sevent
.xconfigure
.display
= dpy
;
1517 sevent
.xconfigure
.event
= wwin
->client_win
;
1518 sevent
.xconfigure
.window
= wwin
->client_win
;
1520 sevent
.xconfigure
.x
= wwin
->client
.x
;
1521 sevent
.xconfigure
.y
= wwin
->client
.y
;
1522 sevent
.xconfigure
.width
= wwin
->client
.width
;
1523 sevent
.xconfigure
.height
= wwin
->client
.height
;
1525 sevent
.xconfigure
.border_width
= wwin
->old_border_width
;
1526 if (wwin
->window_flags
.no_titlebar
)
1527 sevent
.xconfigure
.above
= None
;
1529 sevent
.xconfigure
.above
= wwin
->frame
->titlebar
->window
;
1531 sevent
.xconfigure
.override_redirect
= False
;
1532 XSendEvent(dpy
, wwin
->client_win
, False
, StructureNotifyMask
, &sevent
);
1538 *----------------------------------------------------------------------
1539 * wWindowConfigure--
1540 * Configures the frame, decorations and client window to the
1541 * specified geometry. The geometry is not checked for validity,
1542 * wWindowConstrainSize() must be used for that.
1543 * The size parameters are for the client window, but the position is
1545 * The client window receives a ConfigureNotify event, according
1546 * to what ICCCM says.
1552 * Window size and position are changed and client window receives
1553 * a ConfigureNotify event.
1554 *----------------------------------------------------------------------
1557 wWindowConfigure(wwin
, req_x
, req_y
, req_width
, req_height
)
1559 int req_x
, req_y
; /* new position of the frame */
1560 int req_width
, req_height
; /* new size of the client */
1562 int synth_notify
= False
;
1565 resize
= (req_width
!=wwin
->client
.width
1566 || req_height
!=wwin
->client
.height
);
1568 * if the window is being moved but not resized then
1569 * send a synthetic ConfigureNotify
1571 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
) && !resize
) {
1572 synth_notify
= True
;
1575 if (wwin
->window_flags
.dont_move_off
)
1576 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
1577 req_width
, req_height
);
1579 if (req_width
< MIN_WINDOW_SIZE
)
1580 req_width
= MIN_WINDOW_SIZE
;
1581 if (req_height
< MIN_WINDOW_SIZE
)
1582 req_height
= MIN_WINDOW_SIZE
;
1584 /* If growing, resize inner part before frame,
1585 * if shrinking, resize frame before.
1586 * This will prevent the frame (that can have a different color)
1587 * to be exposed, causing flicker */
1588 if (req_height
> wwin
->frame
->core
->height
1589 || req_width
> wwin
->frame
->core
->width
)
1590 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
1592 if (wwin
->flags
.shaded
) {
1593 wFrameWindowResize(wwin
->frame
, req_width
, wwin
->frame
->core
->height
);
1594 wwin
->old_geometry
.height
= req_height
;
1596 wFrameWindowResizeInternal(wwin
->frame
, req_width
, req_height
);
1599 if (!(req_height
> wwin
->frame
->core
->height
1600 || req_width
> wwin
->frame
->core
->width
))
1601 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
1603 wwin
->client
.x
= req_x
;
1604 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
1605 wwin
->client
.width
= req_width
;
1606 wwin
->client
.height
= req_height
;
1608 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
1610 wwin
->client
.x
= req_x
;
1611 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
1613 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
1615 wwin
->frame_x
= req_x
;
1616 wwin
->frame_y
= req_y
;
1619 if (wShapeSupported
&& wwin
->flags
.shaped
&& resize
) {
1620 wWindowSetShape(wwin
);
1625 wWindowSynthConfigureNotify(wwin
);
1631 wWindowMove(wwin
, req_x
, req_y
)
1633 int req_x
, req_y
; /* new position of the frame */
1635 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
1636 int synth_notify
= False
;
1638 /* Send a synthetic ConfigureNotify event for every window movement. */
1639 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
)) {
1640 synth_notify
= True
;
1643 /* A single synthetic ConfigureNotify event is sent at the end of
1644 * a completed (opaque) movement in moveres.c */
1647 if (wwin
->window_flags
.dont_move_off
)
1648 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
1649 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
1651 wwin
->client
.x
= req_x
;
1652 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
1654 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
1656 wwin
->frame_x
= req_x
;
1657 wwin
->frame_y
= req_y
;
1659 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
1661 wWindowSynthConfigureNotify(wwin
);
1667 wWindowUpdateButtonImages(WWindow
*wwin
)
1669 WScreen
*scr
= wwin
->screen_ptr
;
1670 Pixmap pixmap
, mask
;
1671 WFrameWindow
*fwin
= wwin
->frame
;
1673 if (wwin
->window_flags
.no_titlebar
)
1676 /* miniaturize button */
1678 if (!wwin
->window_flags
.no_miniaturize_button
) {
1679 if (wwin
->wm_gnustep_attr
1680 && wwin
->wm_gnustep_attr
->flags
& GSMiniaturizePixmapAttr
) {
1681 pixmap
= wwin
->wm_gnustep_attr
->miniaturize_pixmap
;
1683 if (wwin
->wm_gnustep_attr
->flags
&GSMiniaturizeMaskAttr
) {
1684 mask
= wwin
->wm_gnustep_attr
->miniaturize_mask
;
1689 if (fwin
->lbutton_image
1690 && (fwin
->lbutton_image
->image
!= pixmap
1691 || fwin
->lbutton_image
->mask
!= mask
)) {
1692 wPixmapDestroy(fwin
->lbutton_image
);
1693 fwin
->lbutton_image
= NULL
;
1696 if (!fwin
->lbutton_image
) {
1697 fwin
->lbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
1698 fwin
->lbutton_image
->client_owned
= 1;
1699 fwin
->lbutton_image
->client_owned_mask
= 1;
1702 if (fwin
->lbutton_image
&& !fwin
->lbutton_image
->shared
) {
1703 wPixmapDestroy(fwin
->lbutton_image
);
1705 fwin
->lbutton_image
= scr
->b_pixmaps
[WBUT_ICONIFY
];
1711 if (!wwin
->window_flags
.no_close_button
) {
1712 if (wwin
->wm_gnustep_attr
1713 && wwin
->wm_gnustep_attr
->flags
&GSClosePixmapAttr
) {
1714 pixmap
= wwin
->wm_gnustep_attr
->close_pixmap
;
1716 if (wwin
->wm_gnustep_attr
->flags
&GSCloseMaskAttr
) {
1717 mask
= wwin
->wm_gnustep_attr
->close_mask
;
1722 if (fwin
->rbutton_image
1723 && (fwin
->rbutton_image
->image
!= pixmap
1724 || fwin
->rbutton_image
->mask
!= mask
)) {
1725 wPixmapDestroy(fwin
->rbutton_image
);
1726 fwin
->rbutton_image
= NULL
;
1729 if (!fwin
->rbutton_image
) {
1730 fwin
->rbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
1731 fwin
->rbutton_image
->client_owned
= 1;
1732 fwin
->rbutton_image
->client_owned_mask
= 1;
1734 } else if (wwin
->window_flags
.kill_close
) {
1735 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
) {
1736 wPixmapDestroy(fwin
->rbutton_image
);
1738 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_KILL
];
1739 } else if (wwin
->window_flags
.broken_close
) {
1740 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
) {
1741 wPixmapDestroy(fwin
->rbutton_image
);
1743 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_BROKENCLOSE
];
1745 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
) {
1746 wPixmapDestroy(fwin
->rbutton_image
);
1748 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_CLOSE
];
1752 /* force buttons to be redrawn */
1753 fwin
->flags
.need_texture_change
= 1;
1754 wFrameWindowPaint(fwin
);
1759 *---------------------------------------------------------------------------
1760 * wWindowConfigureBorders--
1761 * Update window border configuration according to window_flags
1763 *---------------------------------------------------------------------------
1766 wWindowConfigureBorders(WWindow
*wwin
)
1772 flags
= WFF_LEFT_BUTTON
|WFF_RIGHT_BUTTON
;
1773 if (!wwin
->window_flags
.no_titlebar
)
1774 flags
|= WFF_TITLEBAR
;
1775 if (!wwin
->window_flags
.no_resizebar
)
1776 flags
|= WFF_RESIZEBAR
;
1778 oldh
= wwin
->frame
->top_width
;
1779 wFrameWindowUpdateBorders(wwin
->frame
, flags
);
1780 if (oldh
!= wwin
->frame
->top_width
) {
1781 newy
= wwin
->frame_y
+ oldh
- wwin
->frame
->top_width
;
1783 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
1784 wWindowConfigure(wwin
, wwin
->frame_x
, newy
,
1785 wwin
->client
.width
, wwin
->client
.height
);
1789 if (!wwin
->window_flags
.no_miniaturize_button
1790 && wwin
->frame
->flags
.hide_left_button
)
1791 flags
|= WFF_LEFT_BUTTON
;
1793 if (!wwin
->window_flags
.no_close_button
1794 && wwin
->frame
->flags
.hide_right_button
)
1795 flags
|= WFF_RIGHT_BUTTON
;
1798 wWindowUpdateButtonImages(wwin
);
1799 wFrameWindowShowButton(wwin
->frame
, flags
);
1803 if (wwin
->window_flags
.no_miniaturize_button
1804 && !wwin
->frame
->flags
.hide_left_button
)
1805 flags
|= WFF_LEFT_BUTTON
;
1807 if (wwin
->window_flags
.no_close_button
1808 && !wwin
->frame
->flags
.hide_right_button
)
1809 flags
|= WFF_RIGHT_BUTTON
;
1812 wFrameWindowHideButton(wwin
->frame
, flags
);
1815 if (wShapeSupported
&& wwin
->flags
.shaped
) {
1816 wWindowSetShape(wwin
);
1824 wWindowSaveState(WWindow
*wwin
)
1828 memset(data
, 0, sizeof(CARD32
)*9);
1829 data
[0] = wwin
->frame
->workspace
;
1830 data
[2] = wwin
->flags
.shaded
;
1831 data
[3] = wwin
->flags
.hidden
;
1833 XChangeProperty(dpy
, wwin
->client_win
, _XA_WINDOWMAKER_STATE
,
1834 _XA_WINDOWMAKER_STATE
, 32, PropModeReplace
,
1835 (unsigned char *)data
, 9);
1840 getSavedState(Window window
, WSavedState
**state
)
1844 unsigned long nitems_ret
;
1845 unsigned long bytes_after_ret
;
1848 if (XGetWindowProperty(dpy
, window
, _XA_WINDOWMAKER_STATE
, 0, 9,
1849 True
, _XA_WINDOWMAKER_STATE
,
1850 &type_ret
, &fmt_ret
, &nitems_ret
, &bytes_after_ret
,
1851 (unsigned char **)&data
)!=Success
|| !data
)
1854 *state
= malloc(sizeof(WSavedState
));
1857 (*state
)->workspace
= data
[0];
1858 (*state
)->miniaturized
= data
[1];
1859 (*state
)->shaded
= data
[2];
1860 (*state
)->hidden
= data
[3];
1861 (*state
)->use_geometry
= data
[4];
1862 (*state
)->x
= data
[5];
1863 (*state
)->y
= data
[6];
1864 (*state
)->w
= data
[7];
1865 (*state
)->h
= data
[8];
1869 if (*state
&& type_ret
==_XA_WINDOWMAKER_STATE
)
1878 wWindowClearShape(WWindow
*wwin
)
1880 XShapeCombineMask(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
1881 0, wwin
->frame
->top_width
, None
, ShapeSet
);
1886 wWindowSetShape(WWindow
*wwin
)
1890 #ifdef OPTIMIZE_SHAPE
1895 /* only shape is the client's */
1896 if (wwin
->window_flags
.no_titlebar
&& wwin
->window_flags
.no_resizebar
) {
1900 /* Get array of rectangles describing the shape mask */
1901 rects
= XShapeGetRectangles(dpy
, wwin
->client_win
, ShapeBounding
,
1907 urec
= malloc(sizeof(XRectangle
)*(count
+2));
1913 /* insert our decoration rectangles in the rect list */
1914 memcpy(urec
, rects
, sizeof(XRectangle
)*count
);
1917 if (!wwin
->window_flags
.no_titlebar
) {
1919 urec
[count
].y
= -1 - wwin
->frame
->top_width
;
1920 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
1921 urec
[count
].height
= wwin
->frame
->top_width
+ 1;
1924 if (!wwin
->window_flags
.no_resizebar
) {
1926 urec
[count
].y
= wwin
->frame
->core
->height
1927 - wwin
->frame
->bottom_width
- wwin
->frame
->top_width
;
1928 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
1929 urec
[count
].height
= wwin
->frame
->bottom_width
+ 1;
1933 /* shape our frame window */
1934 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
1935 0, wwin
->frame
->top_width
, urec
, count
,
1936 ShapeSet
, Unsorted
);
1942 #endif /* OPTIMIZE_SHAPE */
1944 if (!wwin
->window_flags
.no_titlebar
) {
1947 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
1948 rect
[count
].height
= wwin
->frame
->top_width
+ 1;
1951 if (!wwin
->window_flags
.no_resizebar
) {
1953 rect
[count
].y
= wwin
->frame
->core
->height
- wwin
->frame
->bottom_width
;
1954 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
1955 rect
[count
].height
= wwin
->frame
->bottom_width
+ 1;
1959 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
1960 0, 0, rect
, count
, ShapeSet
, Unsorted
);
1962 XShapeCombineShape(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
1963 0, wwin
->frame
->top_width
, wwin
->client_win
,
1964 ShapeBounding
, (count
> 0 ? ShapeUnion
: ShapeSet
));
1969 /* ====================================================================== */
1972 getFocusMode(WWindow
*wwin
)
1976 if ((wwin
->wm_hints
) && (wwin
->wm_hints
->flags
& InputHint
)) {
1977 if (wwin
->wm_hints
->input
== True
) {
1978 if (wwin
->protocols
.TAKE_FOCUS
)
1979 mode
= WFM_LOCALLY_ACTIVE
;
1983 if (wwin
->protocols
.TAKE_FOCUS
)
1984 mode
= WFM_GLOBALLY_ACTIVE
;
1986 mode
= WFM_NO_INPUT
;
1996 wWindowSetKeyGrabs(WWindow
*wwin
)
2001 for (i
=0; i
<WKBD_LAST
; i
++) {
2002 key
= &wKeyBindings
[i
];
2004 if (key
->keycode
==0)
2006 if (key
->modifier
!=AnyModifier
) {
2007 XGrabKey(dpy
, key
->keycode
, key
->modifier
|LockMask
,
2008 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2010 /* Also grab all modifier combinations possible that include,
2011 * LockMask, ScrollLockMask and NumLockMask, so that keygrabs
2012 * work even if the NumLock/ScrollLock key is on.
2014 wHackedGrabKey(key
->keycode
, key
->modifier
,
2015 wwin
->frame
->core
->window
, True
, GrabModeAsync
,
2019 XGrabKey(dpy
, key
->keycode
, key
->modifier
,
2020 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2023 wRootMenuBindShortcuts(wwin
->frame
->core
->window
);
2029 wWindowResetMouseGrabs(WWindow
*wwin
)
2031 XUngrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
);
2033 if (!wwin
->window_flags
.no_bind_mouse
) {
2034 /* grabs for Meta+drag */
2035 wHackedGrabButton(AnyButton
, MOD_MASK
, wwin
->client_win
,
2036 True
, ButtonPressMask
, GrabModeSync
,
2037 GrabModeAsync
, None
, wCursor
[WCUR_ARROW
]);
2040 if (!wwin
->flags
.focused
) {
2041 /* the passive grabs to focus the window */
2042 if (wPreferences
.focus_mode
== WKF_CLICK
)
2043 XGrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
,
2044 True
, ButtonPressMask
, GrabModeSync
, GrabModeAsync
,
2052 wWindowUpdateGNUstepAttr(WWindow
*wwin
, GNUstepWMAttributes
*attr
)
2055 if (attr
->flags
& GSExtraFlagsAttr
) {
2056 if (wwin
->window_flags
.broken_close
!=
2057 (attr
->extra_flags
& GSDocumentEditedFlag
)) {
2058 wwin
->window_flags
.broken_close
= !wwin
->window_flags
.broken_close
;
2060 wWindowUpdateButtonImages(wwin
);
2068 wWindowAddSavedState(char *instance
, char *class, char *command
,
2069 pid_t pid
, WSavedState
*state
)
2071 WWindowState
*wstate
;
2073 wstate
= malloc(sizeof(WWindowState
));
2077 memset(wstate
, 0, sizeof(WWindowState
));
2080 wstate
->instance
= wstrdup(instance
);
2082 wstate
->class = wstrdup(class);
2084 wstate
->command
= wstrdup(command
);
2085 wstate
->state
= state
;
2087 wstate
->next
= windowState
;
2088 windowState
= wstate
;
2091 printf("Added WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2099 #define SAME(x, y) (((x) && (y) && !strcmp((x), (y))) || (!(x) && !(y)))
2103 wWindowGetSavedState(Window win
)
2105 char *instance
, *class, *command
=NULL
;
2106 WWindowState
*wstate
= windowState
;
2113 if (XGetCommand(dpy
, win
, &argv
, &argc
)) {
2115 command
= FlattenStringList(argv
, argc
);
2116 XFreeStringList(argv
);
2121 if (PropGetWMClass(win
, &class, &instance
)) {
2123 if (SAME(instance
, wstate
->instance
) &&
2124 SAME(class, wstate
->class) &&
2125 SAME(command
, wstate
->command
)) {
2128 wstate
= wstate
->next
;
2135 printf("Read WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2139 if (command
) free(command
);
2140 if (instance
) XFree(instance
);
2141 if (class) XFree(class);
2148 wWindowDeleteSavedState(WMagicNumber id
)
2150 WWindowState
*tmp
, *wstate
=(WWindowState
*)id
;
2152 if (!wstate
|| !windowState
)
2157 windowState
= wstate
->next
;
2159 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2160 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2162 if (wstate
->instance
) free(wstate
->instance
);
2163 if (wstate
->class) free(wstate
->class);
2164 if (wstate
->command
) free(wstate
->command
);
2165 free(wstate
->state
);
2169 if (tmp
->next
==wstate
) {
2170 tmp
->next
=wstate
->next
;
2172 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2173 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2175 if (wstate
->instance
) free(wstate
->instance
);
2176 if (wstate
->class) free(wstate
->class);
2177 if (wstate
->command
) free(wstate
->command
);
2178 free(wstate
->state
);
2189 wWindowDeleteSavedStatesForPID(pid_t pid
)
2191 WWindowState
*tmp
, *wstate
;
2197 if (tmp
->pid
== pid
) {
2198 wstate
= windowState
;
2199 windowState
= tmp
->next
;
2201 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2202 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2204 if (wstate
->instance
) free(wstate
->instance
);
2205 if (wstate
->class) free(wstate
->class);
2206 if (wstate
->command
) free(wstate
->command
);
2207 free(wstate
->state
);
2211 if (tmp
->next
->pid
==pid
) {
2213 tmp
->next
= wstate
->next
;
2215 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2216 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2218 if (wstate
->instance
) free(wstate
->instance
);
2219 if (wstate
->class) free(wstate
->class);
2220 if (wstate
->command
) free(wstate
->command
);
2221 free(wstate
->state
);
2231 /* ====================================================================== */
2234 resizebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2236 WWindow
*wwin
= data
;
2238 #ifndef NUMLOCK_HACK
2239 if ((event
->xbutton
.state
& ValidModMask
)
2240 != (event
->xbutton
.state
& ~LockMask
)) {
2241 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
2242 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
2246 event
->xbutton
.state
&= ValidModMask
;
2248 CloseWindowMenu(wwin
->screen_ptr
);
2250 if (wPreferences
.focus_mode
==WKF_CLICK
2251 && !(event
->xbutton
.state
&ControlMask
)) {
2252 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2255 if (event
->xbutton
.button
== Button1
)
2256 wRaiseFrame(wwin
->frame
->core
);
2258 if (event
->xbutton
.state
& MOD_MASK
) {
2259 /* move the window */
2261 if (XGrabPointer(dpy
, wwin
->frame
->resizebar
->window
, True
,
2262 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
2263 GrabModeAsync
, GrabModeAsync
, None
,
2264 None
, CurrentTime
)!=GrabSuccess
) {
2266 wwarning("pointer grab failed for window move");
2271 wMouseMoveWindow(wwin
, event
);
2272 XUngrabPointer(dpy
, CurrentTime
);
2275 /* resize the window */
2276 if (XGrabPointer(dpy
, wwin
->frame
->resizebar
->window
, True
,
2277 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
2278 GrabModeAsync
, GrabModeAsync
, None
,
2279 None
, CurrentTime
)!=GrabSuccess
) {
2281 wwarning("pointer grab failed for window resize");
2286 wMouseResizeWindow(wwin
, event
);
2287 XUngrabPointer(dpy
, CurrentTime
);
2294 titlebarDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2296 WWindow
*wwin
= data
;
2298 event
->xbutton
.state
&= ValidModMask
;
2300 if (event
->xbutton
.button
==Button1
) {
2301 if (event
->xbutton
.state
== 0) {
2302 if (!wwin
->window_flags
.no_shadeable
) {
2304 if (wwin
->flags
.shaded
)
2305 wUnshadeWindow(wwin
);
2312 if (event
->xbutton
.state
& ControlMask
)
2313 dir
|= MAX_VERTICAL
;
2315 if (event
->xbutton
.state
& ShiftMask
) {
2316 dir
|= MAX_HORIZONTAL
;
2317 if (!(event
->xbutton
.state
& ControlMask
))
2318 wSelectWindow(wwin
, !wwin
->flags
.selected
);
2321 /* maximize window */
2322 if (dir
!=0 && !wwin
->window_flags
.no_resizable
) {
2323 if (wwin
->flags
.maximized
)
2324 wUnmaximizeWindow(wwin
);
2326 wMaximizeWindow(wwin
, dir
);
2329 } else if (event
->xbutton
.button
==Button3
) {
2330 if (event
->xbutton
.state
& MOD_MASK
) {
2331 wHideOtherApplications(wwin
);
2333 } else if (event
->xbutton
.button
==Button2
) {
2334 wSelectWindow(wwin
, !wwin
->flags
.selected
);
2340 frameMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
2342 WWindow
*wwin
= desc
->parent
;
2344 event
->xbutton
.state
&= ValidModMask
;
2346 CloseWindowMenu(wwin
->screen_ptr
);
2348 if (wPreferences
.focus_mode
==WKF_CLICK
2349 && !(event
->xbutton
.state
&ControlMask
)) {
2350 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2352 if (event
->xbutton
.button
== Button1
) {
2353 wRaiseFrame(wwin
->frame
->core
);
2356 if (event
->xbutton
.state
& MOD_MASK
) {
2357 /* move the window */
2358 if (XGrabPointer(dpy
, wwin
->client_win
, False
,
2359 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
2360 GrabModeAsync
, GrabModeAsync
, None
,
2361 None
, CurrentTime
)!=GrabSuccess
) {
2363 wwarning("pointer grab failed for window move");
2367 if (event
->xbutton
.button
== Button3
&& !wwin
->window_flags
.no_resizable
)
2368 wMouseResizeWindow(wwin
, event
);
2370 wMouseMoveWindow(wwin
, event
);
2371 XUngrabPointer(dpy
, CurrentTime
);
2377 titlebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2379 WWindow
*wwin
= (WWindow
*)data
;
2381 #ifndef NUMLOCK_HACK
2382 if ((event
->xbutton
.state
& ValidModMask
)
2383 != (event
->xbutton
.state
& ~LockMask
)) {
2384 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
2385 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
2389 event
->xbutton
.state
&= ValidModMask
;
2392 CloseWindowMenu(wwin
->screen_ptr
);
2394 if (wPreferences
.focus_mode
==WKF_CLICK
2395 && !(event
->xbutton
.state
&ControlMask
)) {
2396 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2399 if (event
->xbutton
.button
== Button1
2400 || event
->xbutton
.button
== Button2
) {
2402 if (event
->xbutton
.button
== Button1
) {
2403 if (event
->xbutton
.state
& MOD_MASK
) {
2404 wLowerFrame(wwin
->frame
->core
);
2406 wRaiseFrame(wwin
->frame
->core
);
2409 if ((event
->xbutton
.state
& ShiftMask
)
2410 && !(event
->xbutton
.state
& ControlMask
)) {
2411 wSelectWindow(wwin
, !wwin
->flags
.selected
);
2414 /* move the window */
2415 wMouseMoveWindow(wwin
, event
);
2416 XUngrabPointer(dpy
, CurrentTime
);
2417 } else if (event
->xbutton
.button
== Button3
&& event
->xbutton
.state
==0
2418 && !wwin
->flags
.internal_window
) {
2419 WObjDescriptor
*desc
;
2421 OpenWindowMenu(wwin
, event
->xbutton
.x_root
,
2422 wwin
->frame_y
+wwin
->frame
->top_width
, False
);
2424 /* allow drag select */
2425 desc
= &wwin
->screen_ptr
->window_menu
->menu
->descriptor
;
2426 event
->xany
.send_event
= True
;
2427 (*desc
->handle_mousedown
)(desc
, event
);
2434 windowCloseClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2436 WWindow
*wwin
= data
;
2438 event
->xbutton
.state
&= ValidModMask
;
2440 CloseWindowMenu(wwin
->screen_ptr
);
2442 /* if control-click, kill the client */
2443 if (event
->xbutton
.state
& ControlMask
) {
2445 } else if (wwin
->protocols
.DELETE_WINDOW
&& event
->xbutton
.state
==0) {
2446 /* send delete message */
2447 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
2453 windowCloseDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2455 WWindow
*wwin
= data
;
2457 CloseWindowMenu(wwin
->screen_ptr
);
2459 /* send delete message */
2460 if (wwin
->protocols
.DELETE_WINDOW
) {
2461 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
2469 windowIconifyClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2471 WWindow
*wwin
= data
;
2473 event
->xbutton
.state
&= ValidModMask
;
2475 CloseWindowMenu(wwin
->screen_ptr
);
2477 if (wwin
->protocols
.MINIATURIZE_WINDOW
&& event
->xbutton
.state
==0) {
2478 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
2482 if ((event
->xbutton
.state
& ControlMask
) ||
2483 (event
->xbutton
.button
== Button3
)) {
2485 wapp
= wApplicationOf(wwin
->main_window
);
2486 if (wapp
&& !wwin
->window_flags
.no_appicon
)
2487 wHideApplication(wapp
);
2488 } else if (event
->xbutton
.state
==0) {
2489 wIconifyWindow(wwin
);