1 /* window.c - client window managing stuffs
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,
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 */
37 /* For getting mouse wheel mappings from WINGs */
38 #include <WINGs/WINGsP.h>
40 #include "WindowMaker.h"
46 #include "winspector.h"
48 #include "properties.h"
55 #include "workspace.h"
68 # include "openlook.h"
71 /****** Global Variables ******/
73 extern WShortKey wKeyBindings
[WKBD_LAST
];
76 extern Bool wShapeSupported
;
80 extern XContext wWinContext
;
83 extern Cursor wCursor
[WCUR_LAST
];
86 extern Atom _XA_WM_DELETE_WINDOW
;
87 extern Atom _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
;
89 extern Atom _XA_WINDOWMAKER_STATE
;
91 extern WPreferences wPreferences
;
93 #define MOD_MASK wPreferences.modifier_mask
95 extern Time LastTimestamp
;
98 extern void DoWindowBirth(WWindow
*);
102 /***** Local Stuff *****/
105 static WWindowState
*windowState
=NULL
;
109 /* local functions */
110 static FocusMode
getFocusMode(WWindow
*wwin
);
112 static int getSavedState(Window window
, WSavedState
**state
);
114 static void setupGNUstepHints(WWindow
*wwin
, GNUstepWMAttributes
*gs_hints
);
119 /* frame window (during window grabs) */
120 static void frameMouseDown(WObjDescriptor
*desc
, XEvent
*event
);
123 static void windowCloseClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
124 static void windowCloseDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
127 static void windowIconifyClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
129 #ifdef XKB_BUTTON_HINT
130 static void windowLanguageClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
133 static void titlebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
);
134 static void titlebarDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
);
136 static void resizebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
);
139 /****** Notification Observers ******/
142 appearanceObserver(void *self
, WMNotification
*notif
)
144 WWindow
*wwin
= (WWindow
*)self
;
145 int flags
= (int)WMGetNotificationClientData(notif
);
147 if (!wwin
->frame
|| (!wwin
->frame
->titlebar
&& !wwin
->frame
->resizebar
))
150 if (flags
& WFontSettings
) {
151 wWindowConfigureBorders(wwin
);
152 if(wwin
->flags
.shaded
) {
153 wFrameWindowResize(wwin
->frame
, wwin
->frame
->core
->width
,
154 wwin
->frame
->top_width
- 1);
156 wwin
->client
.y
= wwin
->frame_y
- wwin
->client
.height
157 + wwin
->frame
->top_width
;
158 wWindowSynthConfigureNotify(wwin
);
161 if (flags
& WTextureSettings
) {
162 wwin
->frame
->flags
.need_texture_remake
= 1;
164 if (flags
& (WTextureSettings
| WColorSettings
)) {
165 if (wwin
->frame
->titlebar
)
166 XClearWindow(dpy
, wwin
->frame
->titlebar
->window
);
168 wFrameWindowPaint(wwin
->frame
);
172 /************************************/
175 wWindowFor(Window window
)
177 WObjDescriptor
*desc
;
182 if (XFindContext(dpy
, window
, wWinContext
, (XPointer
*)&desc
)==XCNOENT
)
185 if (desc
->parent_type
==WCLASS_WINDOW
)
187 else if (desc
->parent_type
==WCLASS_FRAME
) {
188 WFrameWindow
*frame
= (WFrameWindow
*)desc
->parent
;
189 if (frame
->flags
.is_client_window_frame
)
202 wwin
= wmalloc(sizeof(WWindow
));
205 memset(wwin
, 0, sizeof(WWindow
));
207 wwin
->client_descriptor
.handle_mousedown
= frameMouseDown
;
208 wwin
->client_descriptor
.parent
= wwin
;
209 wwin
->client_descriptor
.self
= wwin
;
210 wwin
->client_descriptor
.parent_type
= WCLASS_WINDOW
;
217 wWindowDestroy(WWindow
*wwin
)
221 if (wwin
->screen_ptr
->cmap_window
== wwin
) {
222 wwin
->screen_ptr
->cmap_window
= NULL
;
225 WMRemoveNotificationObserver(wwin
);
227 wwin
->flags
.destroyed
= 1;
229 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
230 if (!wwin
->screen_ptr
->shortcutWindows
[i
])
233 WMRemoveFromArray(wwin
->screen_ptr
->shortcutWindows
[i
], wwin
);
235 if (!WMGetArrayItemCount(wwin
->screen_ptr
->shortcutWindows
[i
])) {
236 WMFreeArray(wwin
->screen_ptr
->shortcutWindows
[i
]);
237 wwin
->screen_ptr
->shortcutWindows
[i
] = NULL
;
241 if (wwin
->fake_group
&& wwin
->fake_group
->retainCount
>0) {
242 wwin
->fake_group
->retainCount
--;
243 if (wwin
->fake_group
->retainCount
==0 && wwin
->fake_group
->leader
!=None
) {
244 XDestroyWindow(dpy
, wwin
->fake_group
->leader
);
245 wwin
->fake_group
->leader
= None
;
246 wwin
->fake_group
->origLeader
= None
;
251 if (wwin
->normal_hints
)
252 XFree(wwin
->normal_hints
);
255 XFree(wwin
->wm_hints
);
257 if (wwin
->wm_instance
)
258 XFree(wwin
->wm_instance
);
261 XFree(wwin
->wm_class
);
263 if (wwin
->wm_gnustep_attr
)
264 wfree(wwin
->wm_gnustep_attr
);
266 if (wwin
->cmap_windows
)
267 XFree(wwin
->cmap_windows
);
269 XDeleteContext(dpy
, wwin
->client_win
, wWinContext
);
272 wFrameWindowDestroy(wwin
->frame
);
275 RemoveFromStackList(wwin
->icon
->core
);
276 wIconDestroy(wwin
->icon
);
277 if (wPreferences
.auto_arrange_icons
)
278 wArrangeIcons(wwin
->screen_ptr
, True
);
287 setupGNUstepHints(WWindow
*wwin
, GNUstepWMAttributes
*gs_hints
)
289 if (gs_hints
->flags
& GSWindowStyleAttr
) {
290 if (gs_hints
->window_style
== WMBorderlessWindowMask
) {
291 wwin
->client_flags
.no_border
= 1;
292 wwin
->client_flags
.no_titlebar
= 1;
293 wwin
->client_flags
.no_closable
= 1;
294 wwin
->client_flags
.no_miniaturizable
= 1;
295 wwin
->client_flags
.no_resizable
= 1;
296 wwin
->client_flags
.no_close_button
= 1;
297 wwin
->client_flags
.no_miniaturize_button
= 1;
298 wwin
->client_flags
.no_resizebar
= 1;
300 wwin
->client_flags
.no_close_button
=
301 ((gs_hints
->window_style
& WMClosableWindowMask
)?0:1);
303 wwin
->client_flags
.no_closable
=
304 ((gs_hints
->window_style
& WMClosableWindowMask
)?0:1);
306 wwin
->client_flags
.no_miniaturize_button
=
307 ((gs_hints
->window_style
& WMMiniaturizableWindowMask
)?0:1);
309 wwin
->client_flags
.no_miniaturizable
=
310 wwin
->client_flags
.no_miniaturize_button
;
312 wwin
->client_flags
.no_resizebar
=
313 ((gs_hints
->window_style
& WMResizableWindowMask
)?0:1);
315 wwin
->client_flags
.no_resizable
= wwin
->client_flags
.no_resizebar
;
317 /* these attributes supposedly imply in the existence
319 if (gs_hints
->window_style
& (WMResizableWindowMask
|
320 WMClosableWindowMask
|
321 WMMiniaturizableWindowMask
)) {
322 wwin
->client_flags
.no_titlebar
= 0;
324 wwin
->client_flags
.no_titlebar
=
325 ((gs_hints
->window_style
& WMTitledWindowMask
)?0:1);
330 /* setup the defaults */
331 wwin
->client_flags
.no_border
= 0;
332 wwin
->client_flags
.no_titlebar
= 0;
333 wwin
->client_flags
.no_closable
= 0;
334 wwin
->client_flags
.no_miniaturizable
= 0;
335 wwin
->client_flags
.no_resizable
= 0;
336 wwin
->client_flags
.no_close_button
= 0;
337 wwin
->client_flags
.no_miniaturize_button
= 0;
338 wwin
->client_flags
.no_resizebar
= 0;
340 if (gs_hints
->extra_flags
& GSNoApplicationIconFlag
) {
341 wwin
->client_flags
.no_appicon
= 1;
347 wWindowCheckAttributeSanity(WWindow
*wwin
, WWindowAttributes
*wflags
,
348 WWindowAttributes
*mask
)
350 if (wflags
->no_appicon
&& mask
->no_appicon
)
351 wflags
->emulate_appicon
= 0;
353 if (wwin
->main_window
!=None
) {
354 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
355 if (wapp
&& !wapp
->flags
.emulated
)
356 wflags
->emulate_appicon
= 0;
359 if (wwin
->transient_for
!=None
360 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
)
361 wflags
->emulate_appicon
= 0;
363 if (wflags
->sunken
&& mask
->sunken
&& wflags
->floating
&& mask
->floating
)
370 wWindowSetupInitialAttributes(WWindow
*wwin
, int *level
, int *workspace
)
372 WScreen
*scr
= wwin
->screen_ptr
;
374 /* sets global default stuff */
375 wDefaultFillAttributes(scr
, wwin
->wm_instance
, wwin
->wm_class
,
376 &wwin
->client_flags
, NULL
, True
);
378 * Decoration setting is done in this precedence (lower to higher)
379 * - use global default in the resource database
380 * - guess some settings
381 * - use GNUstep/external window attributes
382 * - set hints specified for the app in the resource DB
385 WSETUFLAG(wwin
, broken_close
, 0);
387 if (wwin
->protocols
.DELETE_WINDOW
)
388 WSETUFLAG(wwin
, kill_close
, 0);
390 WSETUFLAG(wwin
, kill_close
, 1);
392 /* transients can't be iconified or maximized */
393 if (wwin
->transient_for
!=None
&& wwin
->transient_for
!=scr
->root_win
) {
394 WSETUFLAG(wwin
, no_miniaturizable
, 1);
395 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
398 /* if the window can't be resized, remove the resizebar */
399 if (wwin
->normal_hints
->flags
& (PMinSize
|PMaxSize
)
400 && (wwin
->normal_hints
->min_width
==wwin
->normal_hints
->max_width
)
401 && (wwin
->normal_hints
->min_height
==wwin
->normal_hints
->max_height
)) {
402 WSETUFLAG(wwin
, no_resizable
, 1);
403 WSETUFLAG(wwin
, no_resizebar
, 1);
406 /* set GNUstep window attributes */
407 if (wwin
->wm_gnustep_attr
) {
408 setupGNUstepHints(wwin
, wwin
->wm_gnustep_attr
);
410 if (wwin
->wm_gnustep_attr
->flags
& GSWindowLevelAttr
) {
412 *level
= wwin
->wm_gnustep_attr
->window_level
;
414 * INT_MIN is the only illegal window level.
416 if (*level
== INT_MIN
)
417 *level
= INT_MIN
+ 1;
420 *level
= WMNormalLevel
;
423 int tmp_workspace
= -1;
424 int tmp_level
= INT_MIN
; /* INT_MIN is never used by the window levels */
430 wMWMCheckClientHints(wwin
);
431 #endif /* MWM_HINTS */
434 check
= wGNOMECheckClientHints(wwin
, &tmp_level
, &tmp_workspace
);
435 #endif /* GNOME_STUFF */
439 wKWMCheckClientHints(wwin
, &tmp_level
, &tmp_workspace
);
440 #endif /* KWM_HINTS */
443 wOLWMCheckClientHints(wwin
);
444 #endif /* OLWM_HINTS */
446 /* window levels are between INT_MIN+1 and INT_MAX, so if we still
447 * have INT_MIN that means that no window level was requested. -Dan
449 if (tmp_level
== INT_MIN
) {
450 if (WFLAGP(wwin
, floating
))
451 *level
= WMFloatingLevel
;
452 else if (WFLAGP(wwin
, sunken
))
453 *level
= WMSunkenLevel
;
455 *level
= WMNormalLevel
;
460 if (tmp_workspace
>= 0) {
461 *workspace
= tmp_workspace
% scr
->workspace_count
;
466 * Set attributes specified only for that window/class.
467 * This might do duplicate work with the 1st wDefaultFillAttributes().
469 wDefaultFillAttributes(scr
, wwin
->wm_instance
, wwin
->wm_class
,
470 &wwin
->user_flags
, &wwin
->defined_user_flags
,
473 * Sanity checks for attributes that depend on other attributes
475 if (wwin
->user_flags
.no_appicon
&& wwin
->defined_user_flags
.no_appicon
)
476 wwin
->user_flags
.emulate_appicon
= 0;
477 //WSETUFLAG(wwin, emulate_appicon, 0);
479 if (wwin
->main_window
!=None
) {
480 WApplication
*wapp
= wApplicationOf(wwin
->main_window
);
481 if (wapp
&& !wapp
->flags
.emulated
)
482 wwin
->user_flags
.emulate_appicon
= 0;
483 //WSETUFLAG(wwin, emulate_appicon, 0);
486 if (wwin
->transient_for
!=None
487 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
)
488 wwin
->user_flags
.emulate_appicon
= 0;
489 //WSETUFLAG(wwin, emulate_appicon, 0);
491 if (wwin
->user_flags
.sunken
&& wwin
->defined_user_flags
.sunken
492 && wwin
->user_flags
.floating
&& wwin
->defined_user_flags
.floating
)
493 wwin
->user_flags
.sunken
= 0;
494 //WSETUFLAG(wwin, sunken, 0);
496 WSETUFLAG(wwin
, no_shadeable
, WFLAGP(wwin
, no_titlebar
));
499 /* windows that have takefocus=False shouldn't take focus at all */
500 if (wwin
->focus_mode
== WFM_NO_INPUT
) {
501 /* dont use WSETUFLAG, since this was not an attribute change
502 * made by the user */
503 wwin
->user_flags
.no_focusable
= 1;
511 wWindowCanReceiveFocus(WWindow
*wwin
)
513 if (!wwin
->flags
.mapped
&& (!wwin
->flags
.shaded
|| wwin
->flags
.hidden
))
515 if (WFLAGP(wwin
, no_focusable
) || wwin
->flags
.miniaturized
)
517 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
525 wWindowObscuresWindow(WWindow
*wwin
, WWindow
*obscured
)
529 w1
= wwin
->frame
->core
->width
;
530 h1
= wwin
->frame
->core
->height
;
531 w2
= obscured
->frame
->core
->width
;
532 h2
= obscured
->frame
->core
->height
;
534 if (!IS_OMNIPRESENT(wwin
) && !IS_OMNIPRESENT(obscured
)
535 && wwin
->frame
->workspace
!= obscured
->frame
->workspace
)
538 if (wwin
->frame_x
+ w1
< obscured
->frame_x
539 || wwin
->frame_y
+ h1
< obscured
->frame_y
540 || wwin
->frame_x
> obscured
->frame_x
+ w2
541 || wwin
->frame_y
> obscured
->frame_y
+ h2
) {
550 createFakeWindowGroupLeader(WScreen
*scr
, Window win
, char *instance
, char *class)
552 XClassHint
*classHint
;
558 leader
= XCreateSimpleWindow(dpy
, scr
->root_win
, 10, 10, 10, 10, 0, 0, 0);
560 classHint
= XAllocClassHint();
561 classHint
->res_name
= instance
;
562 classHint
->res_class
= class;
563 XSetClassHint(dpy
, leader
, classHint
);
566 /* inherit these from the original leader if available */
567 hints
= XGetWMHints(dpy
, win
);
569 hints
= XAllocWMHints();
572 /* set window group leader to self */
573 hints
->window_group
= leader
;
574 hints
->flags
|= WindowGroupHint
;
575 XSetWMHints(dpy
, leader
, hints
);
578 if (XGetCommand(dpy
, win
, &argv
, &argc
)!=0 && argc
> 0) {
579 XSetCommand(dpy
, leader
, argv
, argc
);
580 XFreeStringList(argv
);
588 matchIdentifier(void *item
, void *cdata
)
590 return (strcmp(((WFakeGroupLeader
*)item
)->identifier
, (char*)cdata
)==0);
595 *----------------------------------------------------------------
597 * reparents the window and allocates a descriptor for it.
598 * Window manager hints and other hints are fetched to configure
599 * the window decoration attributes and others. User preferences
600 * for the window are used if available, to configure window
601 * decorations and some behaviour.
602 * If in startup, windows that are override redirect,
603 * unmapped and never were managed and are Withdrawn are not
607 * the new window descriptor
610 * The window is reparented and appropriate notification
611 * is done to the client. Input mask for the window is setup.
612 * The window descriptor is also associated with various window
613 * contexts and inserted in the head of the window list.
614 * Event handler contexts are associated for some objects
615 * (buttons, titlebar and resizebar)
617 *----------------------------------------------------------------
620 wManageWindow(WScreen
*scr
, Window window
)
624 unsigned width
, height
;
625 XWindowAttributes wattribs
;
626 XSetWindowAttributes attribs
;
627 WWindowState
*win_state
;
628 WWindow
*transientOwner
= NULL
;
634 Bool withdraw
= False
;
638 /* XGrabServer(dpy); */
640 /* make sure the window is still there */
641 if (!XGetWindowAttributes(dpy
, window
, &wattribs
)) {
646 /* if it's an override-redirect, ignore it */
647 if (wattribs
.override_redirect
) {
652 wm_state
= PropGetWindowState(window
);
654 /* if it's startup and the window is unmapped, don't manage it */
655 if (scr
->flags
.startup
&& wm_state
< 0 && wattribs
.map_state
==IsUnmapped
) {
660 if (!wFetchName(dpy
, window
, &title
)) {
665 if (title
&& !wKWMManageableClient(scr
, window
, title
)) {
670 #endif /* KWM_HINTS */
673 wwin
= wWindowCreate();
675 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
678 printf("managing window %x\n", (unsigned)window
);
682 if (wShapeSupported
) {
687 XShapeSelectInput(dpy
, window
, ShapeNotifyMask
);
688 XShapeQueryExtents(dpy
, window
, &b_shaped
, &junk
, &junk
, &ujunk
,
689 &ujunk
, &junk
, &junk
, &junk
, &ujunk
, &ujunk
);
690 wwin
->flags
.shaped
= b_shaped
;
695 *--------------------------------------------------
697 * Get hints and other information in properties
699 *--------------------------------------------------
701 PropGetWMClass(window
, &wwin
->wm_class
, &wwin
->wm_instance
);
703 /* setup descriptor */
704 wwin
->client_win
= window
;
705 wwin
->screen_ptr
= scr
;
707 wwin
->old_border_width
= wattribs
.border_width
;
709 wwin
->event_mask
= CLIENT_EVENTS
;
710 attribs
.event_mask
= CLIENT_EVENTS
;
711 attribs
.do_not_propagate_mask
= ButtonPressMask
| ButtonReleaseMask
;
712 attribs
.save_under
= False
;
713 XChangeWindowAttributes(dpy
, window
, CWEventMask
|CWDontPropagate
714 |CWSaveUnder
, &attribs
);
715 XSetWindowBorderWidth(dpy
, window
, 0);
717 /* get hints from GNUstep app */
718 if (wwin
->wm_class
!= 0 && strcmp(wwin
->wm_class
, "GNUstep") == 0) {
719 wwin
->flags
.is_gnustep
= 1;
721 if (!PropGetGNUstepWMAttr(window
, &wwin
->wm_gnustep_attr
)) {
722 wwin
->wm_gnustep_attr
= NULL
;
725 wwin
->client_leader
= PropGetClientLeader(window
);
726 if (wwin
->client_leader
!=None
)
727 wwin
->main_window
= wwin
->client_leader
;
729 wwin
->wm_hints
= XGetWMHints(dpy
, window
);
731 if (wwin
->wm_hints
) {
732 if (wwin
->wm_hints
->flags
& StateHint
) {
734 if (wwin
->wm_hints
->initial_state
== IconicState
) {
736 wwin
->flags
.miniaturized
= 1;
738 } else if (wwin
->wm_hints
->initial_state
== WithdrawnState
) {
744 if (wwin
->wm_hints
->flags
& WindowGroupHint
) {
745 wwin
->group_id
= wwin
->wm_hints
->window_group
;
746 /* window_group has priority over CLIENT_LEADER */
747 wwin
->main_window
= wwin
->group_id
;
749 wwin
->group_id
= None
;
752 if (wwin
->wm_hints
->flags
& UrgencyHint
)
753 wwin
->flags
.urgent
= 1;
755 wwin
->group_id
= None
;
758 PropGetProtocols(window
, &wwin
->protocols
);
760 if (!XGetTransientForHint(dpy
, window
, &wwin
->transient_for
)) {
761 wwin
->transient_for
= None
;
763 if (wwin
->transient_for
==None
|| wwin
->transient_for
==window
) {
764 wwin
->transient_for
= scr
->root_win
;
766 transientOwner
= wWindowFor(wwin
->transient_for
);
767 if (transientOwner
&& transientOwner
->main_window
!=None
) {
768 wwin
->main_window
= transientOwner
->main_window
;
770 wwin->main_window = None;
775 /* guess the focus mode */
776 wwin
->focus_mode
= getFocusMode(wwin
);
778 /* get geometry stuff */
779 wClientGetNormalHints(wwin
, &wattribs
, True
, &x
, &y
, &width
, &height
);
781 /* get colormap windows */
782 GetColormapWindows(wwin
);
785 *--------------------------------------------------
787 * Setup the decoration/window attributes and
790 *--------------------------------------------------
793 wWindowSetupInitialAttributes(wwin
, &window_level
, &workspace
);
796 if (wwin
->client_flags
.olwm_transient
&& wwin
->transient_for
==None
797 && wwin
->group_id
!= None
&& wwin
->group_id
!= window
) {
799 transientOwner
= wWindowFor(wwin
->group_id
);
801 if (transientOwner
) {
802 wwin
->transient_for
= wwin
->group_id
;
804 /* transients can't be iconified or maximized */
805 if (wwin
->transient_for
) {
806 WSETUFLAG(wwin
, no_miniaturizable
, 1);
807 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
811 #endif /* OLWM_HINTS */
813 /* Make broken apps behave as a nice app. */
814 if (WFLAGP(wwin
, emulate_appicon
)) {
815 wwin
->main_window
= wwin
->client_win
;
818 wwin
->orig_main_window
= wwin
->main_window
;
820 if (wwin
->flags
.is_gnustep
) {
821 WSETUFLAG(wwin
, shared_appicon
, 0);
824 if (wwin
->main_window
) {
825 extern Atom _XA_WINDOWMAKER_MENU
;
826 XTextProperty text_prop
;
828 if (XGetTextProperty(dpy
, wwin
->main_window
, &text_prop
,
829 _XA_WINDOWMAKER_MENU
)) {
830 WSETUFLAG(wwin
, shared_appicon
, 0);
834 if (!withdraw
&& wwin
->main_window
&& WFLAGP(wwin
, shared_appicon
)) {
835 char *buffer
, *instance
, *class;
836 WFakeGroupLeader
*fPtr
;
839 #define ADEQUATE(x) ((x)!=None && (x)!=wwin->client_win && (x)!=fPtr->leader)
842 PropGetWMClass(wwin
->main_window
, &class, &instance
);
843 buffer
= StrConcatDot(instance
, class);
845 index
= WMFindInArray(scr
->fakeGroupLeaders
, matchIdentifier
, (void*)buffer
);
846 if (index
!= WANotFound
) {
847 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
848 if (fPtr
->retainCount
== 0) {
849 fPtr
->leader
= createFakeWindowGroupLeader(scr
, wwin
->main_window
,
854 if (fPtr
->origLeader
==None
) {
856 if (ADEQUATE(wwin
->group_id
)) {
858 fPtr
->origLeader
= wwin
->group_id
;
859 } else if (ADEQUATE(wwin
->client_leader
)) {
861 fPtr
->origLeader
= wwin
->client_leader
;
862 } else if (ADEQUATE(wwin
->main_window
)) {
864 fPtr
->origLeader
= wwin
->main_window
;
867 if (ADEQUATE(wwin
->main_window
)) {
869 fPtr
->origLeader
= wwin
->main_window
;
873 wwin
->fake_group
= fPtr
;
874 /*wwin->group_id = fPtr->leader;*/
875 wwin
->main_window
= fPtr
->leader
;
878 fPtr
= (WFakeGroupLeader
*)wmalloc(sizeof(WFakeGroupLeader
));
880 fPtr
->identifier
= buffer
;
881 fPtr
->leader
= createFakeWindowGroupLeader(scr
, wwin
->main_window
,
883 fPtr
->origLeader
= None
;
884 fPtr
->retainCount
= 1;
886 WMAddToArray(scr
->fakeGroupLeaders
, fPtr
);
889 if (ADEQUATE(wwin
->group_id
)) {
891 fPtr
->origLeader
= wwin
->group_id
;
892 } else if (ADEQUATE(wwin
->client_leader
)) {
894 fPtr
->origLeader
= wwin
->client_leader
;
895 } else if (ADEQUATE(wwin
->main_window
)) {
897 fPtr
->origLeader
= wwin
->main_window
;
900 if (ADEQUATE(wwin
->main_window
)) {
902 fPtr
->origLeader
= wwin
->main_window
;
905 wwin
->fake_group
= fPtr
;
906 /*wwin->group_id = fPtr->leader;*/
907 wwin
->main_window
= fPtr
->leader
;
919 *------------------------------------------------------------
921 * Setup the initial state of the window
923 *------------------------------------------------------------
926 if (WFLAGP(wwin
, start_miniaturized
) && !WFLAGP(wwin
, no_miniaturizable
)) {
927 wwin
->flags
.miniaturized
= 1;
930 if (WFLAGP(wwin
, start_maximized
) && !WFLAGP(wwin
, no_resizable
)) {
931 wwin
->flags
.maximized
= MAX_VERTICAL
|MAX_HORIZONTAL
;
939 bla
= wGNOMECheckInitialClientState(wwin
);
943 wKWMCheckClientInitialState(wwin
);
947 /* apply previous state if it exists and we're in startup */
948 if (scr
->flags
.startup
&& wm_state
>= 0) {
950 if (wm_state
== IconicState
) {
952 wwin
->flags
.miniaturized
= 1;
954 } else if (wm_state
== WithdrawnState
) {
960 /* if there is a saved state (from file), restore it */
962 if (wwin
->main_window
!=None
/* && wwin->main_window!=window*/) {
963 win_state
= (WWindowState
*)wWindowGetSavedState(wwin
->main_window
);
965 win_state
= (WWindowState
*)wWindowGetSavedState(window
);
967 if (win_state
&& !withdraw
) {
969 if (win_state
->state
->hidden
>0)
970 wwin
->flags
.hidden
= win_state
->state
->hidden
;
972 if (win_state
->state
->shaded
>0 && !WFLAGP(wwin
, no_shadeable
))
973 wwin
->flags
.shaded
= win_state
->state
->shaded
;
975 if (win_state
->state
->miniaturized
>0 &&
976 !WFLAGP(wwin
, no_miniaturizable
)) {
977 wwin
->flags
.miniaturized
= win_state
->state
->miniaturized
;
980 if (!IS_OMNIPRESENT(wwin
)) {
981 int w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
,
983 if (w
< 0 || w
>= scr
->workspace_count
) {
984 workspace
= win_state
->state
->workspace
;
985 if (workspace
>= scr
->workspace_count
)
986 workspace
= scr
->current_workspace
;
991 workspace
= scr
->current_workspace
;
995 /* if we're restarting, restore saved state (from hints).
996 * This will overwrite previous */
1000 if (getSavedState(window
, &wstate
)) {
1001 wwin
->flags
.shaded
= wstate
->shaded
;
1002 wwin
->flags
.hidden
= wstate
->hidden
;
1003 wwin
->flags
.miniaturized
= wstate
->miniaturized
;
1004 wwin
->flags
.maximized
= wstate
->maximized
;
1005 if (wwin
->flags
.maximized
) {
1006 wwin
->old_geometry
.x
= wstate
->x
;
1007 wwin
->old_geometry
.y
= wstate
->y
;
1008 wwin
->old_geometry
.width
= wstate
->w
;
1009 wwin
->old_geometry
.height
= wstate
->h
;
1012 workspace
= wstate
->workspace
;
1017 /* restore window shortcut */
1018 if (wstate
!= NULL
|| win_state
!= NULL
) {
1021 if (win_state
!= NULL
)
1022 mask
= win_state
->state
->window_shortcuts
;
1024 if (wstate
!= NULL
&& mask
== 0)
1025 mask
= wstate
->window_shortcuts
;
1030 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
1031 if (mask
& (1<<i
)) {
1032 if (!scr
->shortcutWindows
[i
])
1033 scr
->shortcutWindows
[i
] = WMCreateArray(4);
1035 WMAddToArray(scr
->shortcutWindows
[i
], wwin
);
1040 if (wstate
!= NULL
) {
1045 /* don't let transients start miniaturized if their owners are not */
1046 if (transientOwner
&& !transientOwner
->flags
.miniaturized
1047 && wwin
->flags
.miniaturized
&& !withdraw
) {
1048 wwin
->flags
.miniaturized
= 0;
1050 wwin
->wm_hints
->initial_state
= NormalState
;
1053 /* set workspace on which the window starts */
1054 if (workspace
>= 0) {
1055 if (workspace
> scr
->workspace_count
-1) {
1056 workspace
= workspace
% scr
->workspace_count
;
1061 w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1063 if (w
>= 0 && w
< scr
->workspace_count
&& !(IS_OMNIPRESENT(wwin
))) {
1068 if (wPreferences
.open_transients_with_parent
&& transientOwner
) {
1070 workspace
= transientOwner
->frame
->workspace
;
1074 workspace
= scr
->current_workspace
;
1079 /* setup window geometry */
1080 if (win_state
&& win_state
->state
->w
> 0) {
1081 width
= win_state
->state
->w
;
1082 height
= win_state
->state
->h
;
1084 wWindowConstrainSize(wwin
, &width
, &height
);
1086 /* do not ask for window placement if the window is
1087 * transient, during startup, if the initial workspace is another one
1088 * or if the window wants to start iconic.
1089 * If geometry was saved, restore it. */
1091 Bool dontBring
= False
;
1093 if (win_state
&& win_state
->state
->w
> 0) {
1094 x
= win_state
->state
->x
;
1095 y
= win_state
->state
->y
;
1096 } else if ((wwin
->transient_for
==None
1097 || wPreferences
.window_placement
!=WPM_MANUAL
)
1098 && !scr
->flags
.startup
1099 && workspace
== scr
->current_workspace
1100 && !wwin
->flags
.miniaturized
1101 && !wwin
->flags
.maximized
1102 && !(wwin
->normal_hints
->flags
& (USPosition
|PPosition
))) {
1104 if (transientOwner
&& transientOwner
->flags
.mapped
) {
1105 int offs
= WMAX(20, 2*transientOwner
->frame
->top_width
);
1107 x
= transientOwner
->frame_x
+
1108 abs((transientOwner
->frame
->core
->width
- width
)/2) + offs
;
1109 y
= transientOwner
->frame_y
+
1110 abs((transientOwner
->frame
->core
->height
- height
)/3) + offs
;
1114 else if (x
+ width
> scr
->scr_width
)
1115 x
= scr
->scr_width
- width
;
1119 else if (y
+ height
> scr
->scr_height
)
1120 y
= scr
->scr_height
- height
;
1122 PlaceWindow(wwin
, &x
, &y
, width
, height
);
1124 if (wPreferences
.window_placement
== WPM_MANUAL
)
1128 if (WFLAGP(wwin
, dont_move_off
) && dontBring
)
1129 wScreenBringInside(scr
, &x
, &y
, width
, height
);
1132 if (wwin
->flags
.urgent
) {
1133 if (!IS_OMNIPRESENT(wwin
))
1134 wwin
->flags
.omnipresent
^= 1;
1138 *--------------------------------------------------
1140 * Create frame, borders and do reparenting
1142 *--------------------------------------------------
1144 foo
= WFF_LEFT_BUTTON
| WFF_RIGHT_BUTTON
;
1145 #ifdef XKB_BUTTON_HINT
1146 if (wPreferences
.modelock
)
1147 foo
|= WFF_LANGUAGE_BUTTON
;
1149 if (!WFLAGP(wwin
, no_titlebar
))
1150 foo
|= WFF_TITLEBAR
;
1151 if (!WFLAGP(wwin
, no_resizebar
))
1152 foo
|= WFF_RESIZEBAR
;
1153 if (!WFLAGP(wwin
, no_border
))
1156 wwin
->frame
= wFrameWindowCreate(scr
, window_level
,
1157 x
, y
, width
, height
,
1158 &wPreferences
.window_title_clearance
, foo
,
1159 scr
->window_title_texture
,
1160 scr
->resizebar_texture
,
1161 scr
->window_title_pixel
,
1162 &scr
->window_title_gc
,
1165 wwin
->frame
->flags
.is_client_window_frame
= 1;
1166 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
1168 /* setup button images */
1169 wWindowUpdateButtonImages(wwin
);
1171 /* hide unused buttons */
1173 if (WFLAGP(wwin
, no_close_button
))
1174 foo
|= WFF_RIGHT_BUTTON
;
1175 if (WFLAGP(wwin
, no_miniaturize_button
))
1176 foo
|= WFF_LEFT_BUTTON
;
1177 #ifdef XKB_BUTTON_HINT
1178 if (WFLAGP(wwin
, no_language_button
) || WFLAGP(wwin
, no_focusable
))
1179 foo
|= WFF_LANGUAGE_BUTTON
;
1182 wFrameWindowHideButton(wwin
->frame
, foo
);
1184 wwin
->frame
->child
= wwin
;
1187 /* emulate olwm push pin. Make the button look as pushed-in for
1188 * the pinned-out state. When the button is clicked, it will
1189 * revert to the normal position, which means the pin is pinned-in.
1191 if (wwin
->flags
.olwm_push_pin_out
)
1192 wFrameWindowUpdatePushButton(wwin
->frame
, True
);
1193 #endif /* OLWM_HINTS */
1196 wwin
->frame
->workspace
= workspace
;
1198 wwin
->frame
->on_click_left
= windowIconifyClick
;
1199 #ifdef XKB_BUTTON_HINT
1200 if (wPreferences
.modelock
)
1201 wwin
->frame
->on_click_language
= windowLanguageClick
;
1204 wwin
->frame
->on_click_right
= windowCloseClick
;
1205 wwin
->frame
->on_dblclick_right
= windowCloseDblClick
;
1207 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
1208 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
1210 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
1213 XSelectInput(dpy
, wwin
->client_win
,
1214 wwin
->event_mask
& ~StructureNotifyMask
);
1216 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
1217 0, wwin
->frame
->top_width
);
1219 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1225 wClientGetGravityOffsets(wwin
, &gx
, &gy
);
1227 /* if gravity is to the south, account for the border sizes */
1229 y
-= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1233 * wWindowConfigure() will init the client window's size
1234 * (wwin->client.{width,height}) and all other geometry
1235 * related variables (frame_x,frame_y)
1237 wWindowConfigure(wwin
, x
, y
, width
, height
);
1239 /* to make sure the window receives it's new position after reparenting */
1240 wWindowSynthConfigureNotify(wwin
);
1243 *--------------------------------------------------
1245 * Setup descriptors and save window to internal
1248 *--------------------------------------------------
1251 if (wwin
->main_window
!=None
) {
1255 /* Leader windows do not necessary set themselves as leaders.
1256 * If this is the case, point the leader of this window to
1258 leader
= wWindowFor(wwin
->main_window
);
1259 if (leader
&& leader
->main_window
==None
) {
1260 leader
->main_window
= leader
->client_win
;
1262 app
= wApplicationCreate(scr
, wwin
->main_window
);
1264 app
->last_workspace
= workspace
;
1266 app
->main_window_desc
->fake_group
= wwin
->fake_group
;
1269 * Do application specific stuff, like setting application
1273 if (wwin
->flags
.hidden
) {
1274 /* if the window was set to hidden because it was hidden
1275 * in a previous incarnation and that state was restored */
1276 app
->flags
.hidden
= 1;
1277 } else if (app
->flags
.hidden
) {
1278 if (WFLAGP(app
->main_window_desc
, start_hidden
)) {
1279 wwin
->flags
.hidden
= 1;
1281 wUnhideApplication(app
, False
, False
);
1288 /* setup the frame descriptor */
1289 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
1290 wwin
->frame
->core
->descriptor
.parent
= wwin
;
1291 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
1293 /* don't let windows go away if we die */
1294 XAddToSaveSet(dpy
, window
);
1296 XLowerWindow(dpy
, window
);
1298 /* if window is in this workspace and should be mapped, then map it */
1299 if (!wwin
->flags
.miniaturized
1300 && (workspace
== scr
->current_workspace
|| IS_OMNIPRESENT(wwin
))
1301 && !wwin
->flags
.hidden
&& !withdraw
) {
1303 /* The following "if" is to avoid crashing of clients that expect
1304 * WM_STATE set before they get mapped. Else WM_STATE is set later,
1305 * after the return from this function.
1307 if (wwin
->wm_hints
&& (wwin
->wm_hints
->flags
& StateHint
)) {
1308 wClientSetState(wwin
, wwin
->wm_hints
->initial_state
, None
);
1310 wClientSetState(wwin
, NormalState
, None
);
1314 /* if not auto focus, then map the window under the currently
1316 #define _WIDTH(w) (w)->frame->core->width
1317 #define _HEIGHT(w) (w)->frame->core->height
1318 if (!wPreferences
.auto_focus
&& scr
->focused_window
1319 && !scr
->flags
.startup
&& !transientOwner
1320 && ((wWindowObscuresWindow(wwin
, scr
->focused_window
)
1321 && (_WIDTH(wwin
) > (_WIDTH(scr
->focused_window
)*5)/3
1322 || _HEIGHT(wwin
) > (_HEIGHT(scr
->focused_window
)*5)/3)
1323 && WINDOW_LEVEL(scr
->focused_window
) == WINDOW_LEVEL(wwin
))
1324 || wwin
->flags
.maximized
)) {
1325 MoveInStackListUnder(scr
->focused_window
->frame
->core
,
1333 if (wPreferences
.superfluous
&& !wPreferences
.no_animations
1334 && !scr
->flags
.startup
&&
1335 (wwin
->transient_for
==None
|| wwin
->transient_for
==scr
->root_win
)
1337 * The brain damaged idiotic non-click to focus modes will
1338 * have trouble with this because:
1340 * 1. window is created and mapped by the client
1341 * 2. window is mapped by wmaker in small size
1342 * 3. window is animated to grow to normal size
1343 * 4. this function returns to normal event loop
1344 * 5. eventually, the EnterNotify event that would trigger
1345 * the window focusing (if the mouse is over that window)
1346 * will be processed by wmaker.
1347 * But since this event will be rather delayed
1348 * (step 3 has a large delay) the time when the event ocurred
1349 * and when it is processed, the client that owns that window
1350 * will reject the XSetInputFocus() for it.
1352 && (wPreferences
.focus_mode
==WKF_CLICK
1353 || wPreferences
.auto_focus
)) {
1354 DoWindowBirth(wwin
);
1360 /* setup stacking descriptor */
1361 if (transientOwner
) {
1362 wwin
->frame
->core
->stacking
->child_of
= transientOwner
->frame
->core
;
1364 wwin
->frame
->core
->stacking
->child_of
= NULL
;
1368 if (!scr
->focused_window
) {
1369 /* first window on the list */
1372 scr
->focused_window
= wwin
;
1376 /* add window at beginning of focus window list */
1377 tmp
= scr
->focused_window
;
1385 /* raise is set to true if we un-hid the app when this window was born.
1386 * we raise, else old windows of this app will be above this new one. */
1388 wRaiseFrame(wwin
->frame
->core
);
1391 /* Update name must come after WApplication stuff is done */
1392 wWindowUpdateName(wwin
, title
);
1399 *--------------------------------------------------
1401 * Final preparations before window is ready to go
1403 *--------------------------------------------------
1406 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1409 if (!wwin
->flags
.miniaturized
&& workspace
== scr
->current_workspace
1410 && !wwin
->flags
.hidden
) {
1411 if (((transientOwner
&& transientOwner
->flags
.focused
)
1412 || wPreferences
.auto_focus
) && !WFLAGP(wwin
, no_focusable
))
1413 wSetFocusTo(scr
, wwin
);
1415 wWindowResetMouseGrabs(wwin
);
1417 if (!WFLAGP(wwin
, no_bind_keys
)) {
1418 wWindowSetKeyGrabs(wwin
);
1422 WMPostNotificationName(WMNManaged
, wwin
, NULL
);
1425 wColormapInstallForWindow(scr
, scr
->cmap_window
);
1429 if (wwin
->client_flags
.olwm_warp_to_pin
&& wwin
->frame
->titlebar
!= NULL
1430 && !WFLAGP(wwin
, no_close_button
) && !withdraw
) {
1432 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0,
1433 wwin
->frame_x
+ width
- wwin
->frame
->titlebar
->height
* 2,
1439 *------------------------------------------------------------
1440 * Setup Notification Observers
1441 *------------------------------------------------------------
1443 WMAddNotificationObserver(appearanceObserver
, wwin
,
1444 WNWindowAppearanceSettingsChanged
, wwin
);
1448 *--------------------------------------------------
1450 * Cleanup temporary stuff
1452 *--------------------------------------------------
1456 wWindowDeleteSavedState(win_state
);
1458 /* If the window must be withdrawed, then do it now.
1459 * Must do some optimization, 'though */
1461 wwin
->flags
.mapped
= 0;
1462 wClientSetState(wwin
, WithdrawnState
, None
);
1463 wUnmanageWindow(wwin
, True
, False
);
1475 wManageInternalWindow(WScreen
*scr
, Window window
, Window owner
,
1476 char *title
, int x
, int y
, int width
, int height
)
1481 wwin
= wWindowCreate();
1483 WMAddNotificationObserver(appearanceObserver
, wwin
,
1484 WNWindowAppearanceSettingsChanged
, wwin
);
1486 wwin
->flags
.internal_window
= 1;
1488 WSETUFLAG(wwin
, omnipresent
, 1);
1489 WSETUFLAG(wwin
, no_shadeable
, 1);
1490 WSETUFLAG(wwin
, no_resizable
, 1);
1491 WSETUFLAG(wwin
, no_miniaturizable
, 1);
1493 wwin
->focus_mode
= WFM_PASSIVE
;
1495 wwin
->client_win
= window
;
1496 wwin
->screen_ptr
= scr
;
1498 wwin
->transient_for
= owner
;
1502 wwin
->client
.width
= width
;
1503 wwin
->client
.height
= height
;
1505 wwin
->frame_x
= wwin
->client
.x
;
1506 wwin
->frame_y
= wwin
->client
.y
;
1509 foo
= WFF_RIGHT_BUTTON
|WFF_BORDER
;
1510 foo
|= WFF_TITLEBAR
;
1511 #ifdef XKB_BUTTON_HINT
1512 foo
|= WFF_LANGUAGE_BUTTON
;
1515 wwin
->frame
= wFrameWindowCreate(scr
, WMFloatingLevel
,
1516 wwin
->frame_x
, wwin
->frame_y
,
1518 &wPreferences
.window_title_clearance
, foo
,
1519 scr
->window_title_texture
,
1520 scr
->resizebar_texture
,
1521 scr
->window_title_pixel
,
1522 &scr
->window_title_gc
,
1525 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
1527 wwin
->frame
->flags
.is_client_window_frame
= 1;
1528 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
1530 wFrameWindowChangeTitle(wwin
->frame
, title
);
1532 /* setup button images */
1533 wWindowUpdateButtonImages(wwin
);
1536 wFrameWindowHideButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1538 wwin
->frame
->child
= wwin
;
1540 wwin
->frame
->workspace
= wwin
->screen_ptr
->current_workspace
;
1542 #ifdef XKB_BUTTON_HINT
1543 if (wPreferences
.modelock
)
1544 wwin
->frame
->on_click_language
= windowLanguageClick
;
1547 wwin
->frame
->on_click_right
= windowCloseClick
;
1549 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
1550 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
1552 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
1554 wwin
->client
.y
+= wwin
->frame
->top_width
;
1555 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
1556 0, wwin
->frame
->top_width
);
1558 wWindowConfigure(wwin
, wwin
->frame_x
, wwin
->frame_y
,
1559 wwin
->client
.width
, wwin
->client
.height
);
1561 /* setup the frame descriptor */
1562 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
1563 wwin
->frame
->core
->descriptor
.parent
= wwin
;
1564 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
1567 XLowerWindow(dpy
, window
);
1568 XMapSubwindows(dpy
, wwin
->frame
->core
->window
);
1570 /* setup stacking descriptor */
1571 if (wwin
->transient_for
!=None
&& wwin
->transient_for
!=scr
->root_win
) {
1573 tmp
= wWindowFor(wwin
->transient_for
);
1575 wwin
->frame
->core
->stacking
->child_of
= tmp
->frame
->core
;
1577 wwin
->frame
->core
->stacking
->child_of
= NULL
;
1581 if (!scr
->focused_window
) {
1582 /* first window on the list */
1585 scr
->focused_window
= wwin
;
1589 /* add window at beginning of focus window list */
1590 tmp
= scr
->focused_window
;
1598 if (wwin
->flags
.is_gnustep
== 0)
1599 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1601 /* if (wPreferences.auto_focus)*/
1602 wSetFocusTo(scr
, wwin
);
1604 wWindowResetMouseGrabs(wwin
);
1606 wWindowSetKeyGrabs(wwin
);
1613 *----------------------------------------------------------------------
1615 * Removes the frame window from a window and destroys all data
1616 * related to it. The window will be reparented back to the root window
1617 * if restore is True.
1620 * Everything related to the window is destroyed and the window
1621 * is removed from the window lists. Focus is set to the previous on the
1623 *----------------------------------------------------------------------
1626 wUnmanageWindow(WWindow
*wwin
, Bool restore
, Bool destroyed
)
1628 WCoreWindow
*frame
= wwin
->frame
->core
;
1629 WWindow
*owner
= NULL
;
1630 WWindow
*newFocusedWindow
= NULL
;
1632 WScreen
*scr
= wwin
->screen_ptr
;
1635 /* First close attribute editor window if open */
1636 if (wwin
->flags
.inspector_open
) {
1637 wCloseInspectorForWindow(wwin
);
1640 /* Close window menu if it's open for this window */
1641 if (wwin
->flags
.menu_open_for_me
) {
1642 CloseWindowMenu(scr
);
1646 if (!wwin
->flags
.internal_window
)
1647 XRemoveFromSaveSet(dpy
, wwin
->client_win
);
1649 XSelectInput(dpy
, wwin
->client_win
, NoEventMask
);
1651 XUngrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
);
1652 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->client_win
);
1655 XUnmapWindow(dpy
, frame
->window
);
1657 XUnmapWindow(dpy
, wwin
->client_win
);
1659 /* deselect window */
1660 wSelectWindow(wwin
, False
);
1662 /* remove all pending events on window */
1663 /* I think this only matters for autoraise */
1664 if (wPreferences
.raise_delay
)
1665 WMDeleteTimerWithClientData(wwin
->frame
->core
);
1669 /* reparent the window back to the root */
1671 wClientRestore(wwin
);
1673 if (wwin
->transient_for
!=scr
->root_win
) {
1674 owner
= wWindowFor(wwin
->transient_for
);
1676 if (!owner
->flags
.semi_focused
) {
1679 owner
->flags
.semi_focused
= 0;
1684 wasFocused
= wwin
->flags
.focused
;
1686 /* remove from window focus list */
1687 if (!wwin
->prev
&& !wwin
->next
) {
1688 /* was the only window */
1689 scr
->focused_window
= NULL
;
1690 newFocusedWindow
= NULL
;
1695 wwin
->prev
->next
= wwin
->next
;
1697 wwin
->next
->prev
= wwin
->prev
;
1699 scr
->focused_window
= wwin
->prev
;
1700 scr
->focused_window
->next
= NULL
;
1703 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1705 /* if in click to focus mode and the window
1706 * was a transient, focus the owner window
1709 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1710 tmp
= wWindowFor(wwin
->transient_for
);
1711 if (tmp
&& (!tmp
->flags
.mapped
|| WFLAGP(tmp
, no_focusable
))) {
1715 /* otherwise, focus the next one in the focus list */
1717 tmp
= scr
->focused_window
;
1718 while (tmp
) { /* look for one in the window list first */
1719 if (!WFLAGP(tmp
, no_focusable
) && !WFLAGP(tmp
, skip_window_list
)
1720 && (tmp
->flags
.mapped
|| tmp
->flags
.shaded
))
1724 if (!tmp
) { /* if unsuccessful, choose any focusable window */
1725 tmp
= scr
->focused_window
;
1727 if (!WFLAGP(tmp
, no_focusable
)
1728 && (tmp
->flags
.mapped
|| tmp
->flags
.shaded
))
1735 newFocusedWindow
= tmp
;
1737 } else if (wPreferences
.focus_mode
==WKF_SLOPPY
) {
1742 /* This is to let the root window get the keyboard input
1743 * if Sloppy focus mode and no other window get focus.
1744 * This way keybindings will not freeze.
1747 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
,
1748 &foo
, &foo
, &foo
, &foo
, &mask
))
1749 tmp
= wWindowFor(win
);
1752 newFocusedWindow
= tmp
;
1754 newFocusedWindow
= NULL
;
1758 if (!wwin
->flags
.internal_window
) {
1759 WMPostNotificationName(WMNUnmanaged
, wwin
, NULL
);
1763 printf("destroying window %x frame %x\n", (unsigned)wwin
->client_win
,
1764 (unsigned)frame
->window
);
1768 if (newFocusedWindow
!= owner
&& owner
) {
1769 if (wwin
->flags
.is_gnustep
== 0)
1770 wFrameWindowChangeState(owner
->frame
, WS_UNFOCUSED
);
1772 wSetFocusTo(scr
, newFocusedWindow
);
1774 wWindowDestroy(wwin
);
1780 wWindowMap(WWindow
*wwin
)
1782 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1783 if (!wwin
->flags
.shaded
) {
1784 /* window will be remapped when getting MapNotify */
1785 XSelectInput(dpy
, wwin
->client_win
,
1786 wwin
->event_mask
& ~StructureNotifyMask
);
1787 XMapWindow(dpy
, wwin
->client_win
);
1788 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1790 wwin
->flags
.mapped
= 1;
1796 wWindowUnmap(WWindow
*wwin
)
1798 wwin
->flags
.mapped
= 0;
1800 /* prevent window withdrawal when getting UnmapNotify */
1801 XSelectInput(dpy
, wwin
->client_win
,
1802 wwin
->event_mask
& ~StructureNotifyMask
);
1803 XUnmapWindow(dpy
, wwin
->client_win
);
1804 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1806 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
1812 wWindowFocus(WWindow
*wwin
, WWindow
*owin
)
1817 #ifdef KEEP_XKB_LOCK_STATUS
1818 if (wPreferences
.modelock
) {
1819 XkbLockGroup(dpy
, XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1821 #endif /* KEEP_XKB_LOCK_STATUS */
1823 wwin
->flags
.semi_focused
= 0;
1825 if (wwin
->flags
.is_gnustep
== 0)
1826 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1828 wwin
->flags
.focused
= 1;
1830 wWindowResetMouseGrabs(wwin
);
1832 WMPostNotificationName(WMNChangedFocus
, wwin
, (void*)True
);
1834 if (owin
== wwin
|| !owin
)
1837 nowner
= wWindowFor(wwin
->transient_for
);
1839 /* new window is a transient for the old window */
1840 if (nowner
== owin
) {
1841 owin
->flags
.semi_focused
= 1;
1842 wWindowUnfocus(nowner
);
1846 oowner
= wWindowFor(owin
->transient_for
);
1848 /* new window is owner of old window */
1849 if (wwin
== oowner
) {
1850 wWindowUnfocus(owin
);
1855 wWindowUnfocus(owin
);
1859 /* new window has same owner of old window */
1860 if (oowner
== nowner
) {
1861 /* prevent unfocusing of owner */
1862 oowner
->flags
.semi_focused
= 0;
1863 wWindowUnfocus(owin
);
1864 oowner
->flags
.semi_focused
= 1;
1869 /* nowner != NULL && oowner != nowner */
1870 nowner
->flags
.semi_focused
= 1;
1871 wWindowUnfocus(nowner
);
1872 wWindowUnfocus(owin
);
1877 wWindowUnfocus(WWindow
*wwin
)
1879 CloseWindowMenu(wwin
->screen_ptr
);
1881 if (wwin
->flags
.is_gnustep
== 0)
1882 wFrameWindowChangeState(wwin
->frame
, wwin
->flags
.semi_focused
1883 ? WS_PFOCUSED
: WS_UNFOCUSED
);
1885 if (wwin
->transient_for
!=None
1886 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
1888 owner
= wWindowFor(wwin
->transient_for
);
1889 if (owner
&& owner
->flags
.semi_focused
) {
1890 owner
->flags
.semi_focused
= 0;
1891 if (owner
->flags
.mapped
|| owner
->flags
.shaded
) {
1892 wWindowUnfocus(owner
);
1893 wFrameWindowPaint(owner
->frame
);
1897 wwin
->flags
.focused
= 0;
1899 wWindowResetMouseGrabs(wwin
);
1901 WMPostNotificationName(WMNChangedFocus
, wwin
, (void*)False
);
1906 wWindowUpdateName(WWindow
*wwin
, char *newTitle
)
1913 wwin
->flags
.wm_name_changed
= 1;
1916 /* the hint was removed */
1917 title
= DEF_WINDOW_TITLE
;
1922 if (wFrameWindowChangeTitle(wwin
->frame
, title
)) {
1923 WMPostNotificationName(WMNChangedName
, wwin
, NULL
);
1930 *----------------------------------------------------------------------
1932 * wWindowConstrainSize--
1933 * Constrains size for the client window, taking the maximal size,
1934 * window resize increments and other size hints into account.
1937 * The closest size to what was given that the client window can
1940 *----------------------------------------------------------------------
1943 wWindowConstrainSize(WWindow
*wwin
, int *nwidth
, int *nheight
)
1945 int width
= *nwidth
;
1946 int height
= *nheight
;
1949 int minW
= 1, minH
= 1;
1950 int maxW
= wwin
->screen_ptr
->scr_width
*2;
1951 int maxH
= wwin
->screen_ptr
->scr_height
*2;
1952 int minAX
= -1, minAY
= -1;
1953 int maxAX
= -1, maxAY
= -1;
1957 if (wwin
->normal_hints
) {
1958 winc
= wwin
->normal_hints
->width_inc
;
1959 hinc
= wwin
->normal_hints
->height_inc
;
1960 minW
= wwin
->normal_hints
->min_width
;
1961 minH
= wwin
->normal_hints
->min_height
;
1962 maxW
= wwin
->normal_hints
->max_width
;
1963 maxH
= wwin
->normal_hints
->max_height
;
1964 if (wwin
->normal_hints
->flags
& PAspect
) {
1965 minAX
= wwin
->normal_hints
->min_aspect
.x
;
1966 minAY
= wwin
->normal_hints
->min_aspect
.y
;
1967 maxAX
= wwin
->normal_hints
->max_aspect
.x
;
1968 maxAY
= wwin
->normal_hints
->max_aspect
.y
;
1971 baseW
= wwin
->normal_hints
->base_width
;
1972 baseH
= wwin
->normal_hints
->base_height
;
1985 /* aspect ratio code borrowed from olwm */
1987 /* adjust max aspect ratio */
1988 if (!(maxAX
== 1 && maxAY
== 1) && width
* maxAY
> height
* maxAX
) {
1989 if (maxAX
> maxAY
) {
1990 height
= (width
* maxAY
) / maxAX
;
1991 if (height
> maxH
) {
1993 width
= (height
* maxAX
) / maxAY
;
1996 width
= (height
* maxAX
) / maxAY
;
1999 height
= (width
* maxAY
) / maxAX
;
2004 /* adjust min aspect ratio */
2005 if (!(minAX
== 1 && minAY
== 1) && width
* minAY
< height
* minAX
) {
2006 if (minAX
> minAY
) {
2007 height
= (width
* minAY
) / minAX
;
2008 if (height
< minH
) {
2010 width
= (height
* minAX
) / minAY
;
2013 width
= (height
* minAX
) / minAY
;
2016 height
= (width
* minAY
) / minAX
;
2023 width
= (((width
- baseW
) / winc
) * winc
) + baseW
;
2025 width
= (((width
- minW
) / winc
) * winc
) + minW
;
2029 height
= (((height
- baseH
) / hinc
) * hinc
) + baseH
;
2031 height
= (((height
- minH
) / hinc
) * hinc
) + minH
;
2034 /* broken stupid apps may cause preposterous values for these.. */
2043 wWindowCropSize(WWindow
*wwin
, int maxW
, int maxH
,
2044 int *width
, int *height
)
2046 int baseW
= 0, baseH
= 0;
2047 int winc
= 1, hinc
= 1;
2049 if (wwin
->normal_hints
) {
2050 baseW
= wwin
->normal_hints
->base_width
;
2051 baseH
= wwin
->normal_hints
->base_height
;
2053 winc
= wwin
->normal_hints
->width_inc
;
2054 hinc
= wwin
->normal_hints
->height_inc
;
2058 *width
= maxW
- (maxW
- baseW
) % winc
;
2061 *height
= maxH
- (maxH
- baseH
) % hinc
;
2066 wWindowChangeWorkspace(WWindow
*wwin
, int workspace
)
2068 WScreen
*scr
= wwin
->screen_ptr
;
2072 if (workspace
>= scr
->workspace_count
|| workspace
< 0
2073 || workspace
== wwin
->frame
->workspace
)
2076 if (workspace
!= scr
->current_workspace
) {
2077 /* Sent to other workspace. Unmap window */
2078 if ((wwin
->flags
.mapped
2079 || wwin
->flags
.shaded
2080 || (wwin
->flags
.miniaturized
&& !wPreferences
.sticky_icons
))
2081 && !IS_OMNIPRESENT(wwin
) && !wwin
->flags
.changing_workspace
) {
2083 wapp
= wApplicationOf(wwin
->main_window
);
2085 wapp
->last_workspace
= workspace
;
2087 if (wwin
->flags
.miniaturized
) {
2089 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
2090 wwin
->icon
->mapped
= 0;
2094 wSetFocusTo(scr
, NULL
);
2098 /* brought to current workspace. Map window */
2099 if (wwin
->flags
.miniaturized
&& !wPreferences
.sticky_icons
) {
2101 XMapWindow(dpy
, wwin
->icon
->core
->window
);
2102 wwin
->icon
->mapped
= 1;
2104 } else if (!wwin
->flags
.mapped
&&
2105 !(wwin
->flags
.miniaturized
|| wwin
->flags
.hidden
)) {
2109 if (!IS_OMNIPRESENT(wwin
)) {
2110 int oldWorkspace
= wwin
->frame
->workspace
;
2112 wwin
->frame
->workspace
= workspace
;
2114 WMPostNotificationName(WMNChangedWorkspace
, wwin
, (void*)oldWorkspace
);
2124 wWindowSynthConfigureNotify(WWindow
*wwin
)
2128 sevent
.type
= ConfigureNotify
;
2129 sevent
.xconfigure
.display
= dpy
;
2130 sevent
.xconfigure
.event
= wwin
->client_win
;
2131 sevent
.xconfigure
.window
= wwin
->client_win
;
2133 sevent
.xconfigure
.x
= wwin
->client
.x
;
2134 sevent
.xconfigure
.y
= wwin
->client
.y
;
2135 sevent
.xconfigure
.width
= wwin
->client
.width
;
2136 sevent
.xconfigure
.height
= wwin
->client
.height
;
2138 sevent
.xconfigure
.border_width
= wwin
->old_border_width
;
2139 if (WFLAGP(wwin
, no_titlebar
))
2140 sevent
.xconfigure
.above
= None
;
2142 sevent
.xconfigure
.above
= wwin
->frame
->titlebar
->window
;
2144 sevent
.xconfigure
.override_redirect
= False
;
2145 XSendEvent(dpy
, wwin
->client_win
, False
, StructureNotifyMask
, &sevent
);
2147 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
2154 *----------------------------------------------------------------------
2155 * wWindowConfigure--
2156 * Configures the frame, decorations and client window to the
2157 * specified geometry. The geometry is not checked for validity,
2158 * wWindowConstrainSize() must be used for that.
2159 * The size parameters are for the client window, but the position is
2161 * The client window receives a ConfigureNotify event, according
2162 * to what ICCCM says.
2168 * Window size and position are changed and client window receives
2169 * a ConfigureNotify event.
2170 *----------------------------------------------------------------------
2173 wWindowConfigure(wwin
, req_x
, req_y
, req_width
, req_height
)
2175 int req_x
, req_y
; /* new position of the frame */
2176 int req_width
, req_height
; /* new size of the client */
2178 int synth_notify
= False
;
2181 resize
= (req_width
!=wwin
->client
.width
2182 || req_height
!=wwin
->client
.height
);
2184 * if the window is being moved but not resized then
2185 * send a synthetic ConfigureNotify
2187 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
) && !resize
) {
2188 synth_notify
= True
;
2191 if (WFLAGP(wwin
, dont_move_off
))
2192 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
2193 req_width
, req_height
);
2195 if (req_width
< MIN_WINDOW_SIZE
)
2196 req_width
= MIN_WINDOW_SIZE
;
2197 if (req_height
< MIN_WINDOW_SIZE
)
2198 req_height
= MIN_WINDOW_SIZE
;
2200 /* If growing, resize inner part before frame,
2201 * if shrinking, resize frame before.
2202 * This will prevent the frame (that can have a different color)
2203 * to be exposed, causing flicker */
2204 if (req_height
> wwin
->frame
->core
->height
2205 || req_width
> wwin
->frame
->core
->width
)
2206 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
2208 if (wwin
->flags
.shaded
) {
2209 wFrameWindowConfigure(wwin
->frame
, req_x
, req_y
,
2210 req_width
, wwin
->frame
->core
->height
);
2211 wwin
->old_geometry
.height
= req_height
;
2215 h
= req_height
+ wwin
->frame
->top_width
2216 + wwin
->frame
->bottom_width
;
2218 wFrameWindowConfigure(wwin
->frame
, req_x
, req_y
, req_width
, h
);
2221 if (!(req_height
> wwin
->frame
->core
->height
2222 || req_width
> wwin
->frame
->core
->width
))
2223 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
2225 wwin
->client
.x
= req_x
;
2226 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2227 wwin
->client
.width
= req_width
;
2228 wwin
->client
.height
= req_height
;
2230 wwin
->client
.x
= req_x
;
2231 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2233 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
2235 wwin
->frame_x
= req_x
;
2236 wwin
->frame_y
= req_y
;
2237 if (!WFLAGP(wwin
, no_border
)) {
2238 wwin
->client
.x
+= FRAME_BORDER_WIDTH
;
2239 wwin
->client
.y
+= FRAME_BORDER_WIDTH
;
2243 if (wShapeSupported
&& wwin
->flags
.shaped
&& resize
) {
2244 wWindowSetShape(wwin
);
2249 wWindowSynthConfigureNotify(wwin
);
2255 wWindowMove(wwin
, req_x
, req_y
)
2257 int req_x
, req_y
; /* new position of the frame */
2259 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
2260 int synth_notify
= False
;
2262 /* Send a synthetic ConfigureNotify event for every window movement. */
2263 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
)) {
2264 synth_notify
= True
;
2267 /* A single synthetic ConfigureNotify event is sent at the end of
2268 * a completed (opaque) movement in moveres.c */
2271 if (WFLAGP(wwin
, dont_move_off
))
2272 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
2273 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
2275 wwin
->client
.x
= req_x
;
2276 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2277 if (!WFLAGP(wwin
, no_border
)) {
2278 wwin
->client
.x
+= FRAME_BORDER_WIDTH
;
2279 wwin
->client
.y
+= FRAME_BORDER_WIDTH
;
2282 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
2284 wwin
->frame_x
= req_x
;
2285 wwin
->frame_y
= req_y
;
2287 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
2289 wWindowSynthConfigureNotify(wwin
);
2295 wWindowUpdateButtonImages(WWindow
*wwin
)
2297 WScreen
*scr
= wwin
->screen_ptr
;
2298 Pixmap pixmap
, mask
;
2299 WFrameWindow
*fwin
= wwin
->frame
;
2301 if (WFLAGP(wwin
, no_titlebar
))
2304 /* miniaturize button */
2306 if (!WFLAGP(wwin
, no_miniaturize_button
)) {
2307 if (wwin
->wm_gnustep_attr
2308 && wwin
->wm_gnustep_attr
->flags
& GSMiniaturizePixmapAttr
) {
2309 pixmap
= wwin
->wm_gnustep_attr
->miniaturize_pixmap
;
2311 if (wwin
->wm_gnustep_attr
->flags
&GSMiniaturizeMaskAttr
) {
2312 mask
= wwin
->wm_gnustep_attr
->miniaturize_mask
;
2317 if (fwin
->lbutton_image
2318 && (fwin
->lbutton_image
->image
!= pixmap
2319 || fwin
->lbutton_image
->mask
!= mask
)) {
2320 wPixmapDestroy(fwin
->lbutton_image
);
2321 fwin
->lbutton_image
= NULL
;
2324 if (!fwin
->lbutton_image
) {
2325 fwin
->lbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
2326 fwin
->lbutton_image
->client_owned
= 1;
2327 fwin
->lbutton_image
->client_owned_mask
= 1;
2330 if (fwin
->lbutton_image
&& !fwin
->lbutton_image
->shared
) {
2331 wPixmapDestroy(fwin
->lbutton_image
);
2333 fwin
->lbutton_image
= scr
->b_pixmaps
[WBUT_ICONIFY
];
2337 #ifdef XKB_BUTTON_HINT
2338 if (!WFLAGP(wwin
, no_language_button
)) {
2339 if (fwin
->languagebutton_image
&&
2340 !fwin
->languagebutton_image
->shared
) {
2341 wPixmapDestroy(fwin
->languagebutton_image
);
2343 fwin
->languagebutton_image
=
2344 scr
->b_pixmaps
[WBUT_XKBGROUP1
+ fwin
->languagemode
];
2350 /* redefine WFLAGP to MGFLAGP to allow broken close operation */
2351 #define MGFLAGP(wwin, FLAG) (wwin)->client_flags.FLAG
2353 if (!WFLAGP(wwin
, no_close_button
)) {
2354 if (wwin
->wm_gnustep_attr
2355 && wwin
->wm_gnustep_attr
->flags
& GSClosePixmapAttr
) {
2356 pixmap
= wwin
->wm_gnustep_attr
->close_pixmap
;
2358 if (wwin
->wm_gnustep_attr
->flags
&GSCloseMaskAttr
)
2359 mask
= wwin
->wm_gnustep_attr
->close_mask
;
2363 if (fwin
->rbutton_image
&& (fwin
->rbutton_image
->image
!= pixmap
2364 || fwin
->rbutton_image
->mask
!= mask
)) {
2365 wPixmapDestroy(fwin
->rbutton_image
);
2366 fwin
->rbutton_image
= NULL
;
2369 if (!fwin
->rbutton_image
) {
2370 fwin
->rbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
2371 fwin
->rbutton_image
->client_owned
= 1;
2372 fwin
->rbutton_image
->client_owned_mask
= 1;
2375 } else if (WFLAGP(wwin
, kill_close
)) {
2377 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2378 wPixmapDestroy(fwin
->rbutton_image
);
2380 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_KILL
];
2382 } else if (MGFLAGP(wwin
, broken_close
)) {
2384 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2385 wPixmapDestroy(fwin
->rbutton_image
);
2387 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_BROKENCLOSE
];
2391 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2392 wPixmapDestroy(fwin
->rbutton_image
);
2394 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_CLOSE
];
2398 /* force buttons to be redrawn */
2399 fwin
->flags
.need_texture_change
= 1;
2400 wFrameWindowPaint(fwin
);
2405 *---------------------------------------------------------------------------
2406 * wWindowConfigureBorders--
2407 * Update window border configuration according to attribute flags.
2409 *---------------------------------------------------------------------------
2412 wWindowConfigureBorders(WWindow
*wwin
)
2418 flags
= WFF_LEFT_BUTTON
|WFF_RIGHT_BUTTON
;
2419 #ifdef XKB_BUTTON_HINT
2420 flags
|= WFF_LANGUAGE_BUTTON
;
2422 if (!WFLAGP(wwin
, no_titlebar
))
2423 flags
|= WFF_TITLEBAR
;
2424 if (!WFLAGP(wwin
, no_resizebar
))
2425 flags
|= WFF_RESIZEBAR
;
2426 if (!WFLAGP(wwin
, no_border
))
2427 flags
|= WFF_BORDER
;
2428 if (wwin
->flags
.shaded
)
2429 flags
|= WFF_IS_SHADED
;
2431 oldh
= wwin
->frame
->top_width
;
2432 wFrameWindowUpdateBorders(wwin
->frame
, flags
);
2433 if (oldh
!= wwin
->frame
->top_width
) {
2434 newy
= wwin
->frame_y
+ oldh
- wwin
->frame
->top_width
;
2436 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
2437 wWindowConfigure(wwin
, wwin
->frame_x
, newy
,
2438 wwin
->client
.width
, wwin
->client
.height
);
2442 if (!WFLAGP(wwin
, no_miniaturize_button
)
2443 && wwin
->frame
->flags
.hide_left_button
)
2444 flags
|= WFF_LEFT_BUTTON
;
2446 #ifdef XKB_BUTTON_HINT
2447 if (!WFLAGP(wwin
, no_language_button
)
2448 && wwin
->frame
->flags
.hide_language_button
)
2449 flags
|= WFF_LANGUAGE_BUTTON
;
2452 if (!WFLAGP(wwin
, no_close_button
)
2453 && wwin
->frame
->flags
.hide_right_button
)
2454 flags
|= WFF_RIGHT_BUTTON
;
2457 wWindowUpdateButtonImages(wwin
);
2458 wFrameWindowShowButton(wwin
->frame
, flags
);
2462 if (WFLAGP(wwin
, no_miniaturize_button
)
2463 && !wwin
->frame
->flags
.hide_left_button
)
2464 flags
|= WFF_LEFT_BUTTON
;
2466 #ifdef XKB_BUTTON_HINT
2467 if (WFLAGP(wwin
, no_language_button
)
2468 && !wwin
->frame
->flags
.hide_language_button
)
2469 flags
|= WFF_LANGUAGE_BUTTON
;
2472 if (WFLAGP(wwin
, no_close_button
)
2473 && !wwin
->frame
->flags
.hide_right_button
)
2474 flags
|= WFF_RIGHT_BUTTON
;
2477 wFrameWindowHideButton(wwin
->frame
, flags
);
2480 if (wShapeSupported
&& wwin
->flags
.shaped
) {
2481 wWindowSetShape(wwin
);
2489 wWindowSaveState(WWindow
*wwin
)
2494 memset(data
, 0, sizeof(CARD32
)*10);
2495 data
[0] = wwin
->frame
->workspace
;
2496 data
[1] = wwin
->flags
.miniaturized
;
2497 data
[2] = wwin
->flags
.shaded
;
2498 data
[3] = wwin
->flags
.hidden
;
2499 data
[4] = wwin
->flags
.maximized
;
2500 if (wwin
->flags
.maximized
== 0) {
2501 data
[5] = wwin
->frame_x
;
2502 data
[6] = wwin
->frame_y
;
2503 data
[7] = wwin
->frame
->core
->width
;
2504 data
[8] = wwin
->frame
->core
->height
;
2506 data
[5] = wwin
->old_geometry
.x
;
2507 data
[6] = wwin
->old_geometry
.y
;
2508 data
[7] = wwin
->old_geometry
.width
;
2509 data
[8] = wwin
->old_geometry
.height
;
2512 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
2513 if (wwin
->screen_ptr
->shortcutWindows
[i
] &&
2514 WMCountInArray(wwin
->screen_ptr
->shortcutWindows
[i
], wwin
))
2517 XChangeProperty(dpy
, wwin
->client_win
, _XA_WINDOWMAKER_STATE
,
2518 _XA_WINDOWMAKER_STATE
, 32, PropModeReplace
,
2519 (unsigned char *)data
, 10);
2524 getSavedState(Window window
, WSavedState
**state
)
2528 unsigned long nitems_ret
;
2529 unsigned long bytes_after_ret
;
2532 if (XGetWindowProperty(dpy
, window
, _XA_WINDOWMAKER_STATE
, 0, 10,
2533 True
, _XA_WINDOWMAKER_STATE
,
2534 &type_ret
, &fmt_ret
, &nitems_ret
, &bytes_after_ret
,
2535 (unsigned char **)&data
)!=Success
|| !data
)
2538 *state
= wmalloc(sizeof(WSavedState
));
2540 (*state
)->workspace
= data
[0];
2541 (*state
)->miniaturized
= data
[1];
2542 (*state
)->shaded
= data
[2];
2543 (*state
)->hidden
= data
[3];
2544 (*state
)->maximized
= data
[4];
2545 (*state
)->x
= data
[5];
2546 (*state
)->y
= data
[6];
2547 (*state
)->w
= data
[7];
2548 (*state
)->h
= data
[8];
2549 (*state
)->window_shortcuts
= data
[9];
2553 if (*state
&& type_ret
==_XA_WINDOWMAKER_STATE
)
2562 wWindowClearShape(WWindow
*wwin
)
2564 XShapeCombineMask(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2565 0, wwin
->frame
->top_width
, None
, ShapeSet
);
2570 wWindowSetShape(WWindow
*wwin
)
2574 #ifdef OPTIMIZE_SHAPE
2579 /* only shape is the client's */
2580 if (WFLAGP(wwin
, no_titlebar
) && WFLAGP(wwin
, no_resizebar
)) {
2584 /* Get array of rectangles describing the shape mask */
2585 rects
= XShapeGetRectangles(dpy
, wwin
->client_win
, ShapeBounding
,
2591 urec
= malloc(sizeof(XRectangle
)*(count
+2));
2597 /* insert our decoration rectangles in the rect list */
2598 memcpy(urec
, rects
, sizeof(XRectangle
)*count
);
2601 if (!WFLAGP(wwin
, no_titlebar
)) {
2603 urec
[count
].y
= -1 - wwin
->frame
->top_width
;
2604 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
2605 urec
[count
].height
= wwin
->frame
->top_width
+ 1;
2608 if (!WFLAGP(wwin
, no_resizebar
)) {
2610 urec
[count
].y
= wwin
->frame
->core
->height
2611 - wwin
->frame
->bottom_width
- wwin
->frame
->top_width
;
2612 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
2613 urec
[count
].height
= wwin
->frame
->bottom_width
+ 1;
2617 /* shape our frame window */
2618 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2619 0, wwin
->frame
->top_width
, urec
, count
,
2620 ShapeSet
, Unsorted
);
2626 #endif /* OPTIMIZE_SHAPE */
2628 if (!WFLAGP(wwin
, no_titlebar
)) {
2631 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
2632 rect
[count
].height
= wwin
->frame
->top_width
+ 1;
2635 if (!WFLAGP(wwin
, no_resizebar
)) {
2637 rect
[count
].y
= wwin
->frame
->core
->height
- wwin
->frame
->bottom_width
;
2638 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
2639 rect
[count
].height
= wwin
->frame
->bottom_width
+ 1;
2643 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2644 0, 0, rect
, count
, ShapeSet
, Unsorted
);
2646 XShapeCombineShape(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2647 0, wwin
->frame
->top_width
, wwin
->client_win
,
2648 ShapeBounding
, (count
> 0 ? ShapeUnion
: ShapeSet
));
2653 /* ====================================================================== */
2656 getFocusMode(WWindow
*wwin
)
2660 if ((wwin
->wm_hints
) && (wwin
->wm_hints
->flags
& InputHint
)) {
2661 if (wwin
->wm_hints
->input
== True
) {
2662 if (wwin
->protocols
.TAKE_FOCUS
)
2663 mode
= WFM_LOCALLY_ACTIVE
;
2667 if (wwin
->protocols
.TAKE_FOCUS
)
2668 mode
= WFM_GLOBALLY_ACTIVE
;
2670 mode
= WFM_NO_INPUT
;
2680 wWindowSetKeyGrabs(WWindow
*wwin
)
2685 for (i
=0; i
<WKBD_LAST
; i
++) {
2686 key
= &wKeyBindings
[i
];
2688 if (key
->keycode
==0)
2690 if (key
->modifier
!=AnyModifier
) {
2691 XGrabKey(dpy
, key
->keycode
, key
->modifier
|LockMask
,
2692 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2694 /* Also grab all modifier combinations possible that include,
2695 * LockMask, ScrollLockMask and NumLockMask, so that keygrabs
2696 * work even if the NumLock/ScrollLock key is on.
2698 wHackedGrabKey(key
->keycode
, key
->modifier
,
2699 wwin
->frame
->core
->window
, True
, GrabModeAsync
,
2703 XGrabKey(dpy
, key
->keycode
, key
->modifier
,
2704 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2708 wRootMenuBindShortcuts(wwin
->frame
->core
->window
);
2715 wWindowResetMouseGrabs(WWindow
*wwin
)
2717 /* Mouse grabs can't be done on the client window because of
2718 * ICCCM and because clients that try to do the same will crash.
2720 * But there is a problem wich makes tbar buttons of unfocused
2721 * windows not usable as the click goes to the frame window instead
2722 * of the button itself. Must figure a way to fix that.
2725 XUngrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
);
2727 if (!WFLAGP(wwin
, no_bind_mouse
)) {
2728 /* grabs for Meta+drag */
2729 wHackedGrabButton(AnyButton
, MOD_MASK
, wwin
->client_win
,
2730 True
, ButtonPressMask
, GrabModeSync
,
2731 GrabModeAsync
, None
, None
);
2734 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
)
2735 && !wwin
->flags
.is_gnustep
) {
2736 /* the passive grabs to focus the window */
2737 /* if (wPreferences.focus_mode == WKF_CLICK) */
2738 XGrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
,
2739 True
, ButtonPressMask
, GrabModeSync
, GrabModeAsync
,
2747 wWindowUpdateGNUstepAttr(WWindow
*wwin
, GNUstepWMAttributes
*attr
)
2749 if (attr
->flags
& GSExtraFlagsAttr
) {
2750 if (MGFLAGP(wwin
, broken_close
) !=
2751 (attr
->extra_flags
& GSDocumentEditedFlag
)) {
2752 wwin
->client_flags
.broken_close
= !MGFLAGP(wwin
, broken_close
);
2753 wWindowUpdateButtonImages(wwin
);
2760 wWindowAddSavedState(char *instance
, char *class, char *command
,
2761 pid_t pid
, WSavedState
*state
)
2763 WWindowState
*wstate
;
2765 wstate
= malloc(sizeof(WWindowState
));
2769 memset(wstate
, 0, sizeof(WWindowState
));
2772 wstate
->instance
= wstrdup(instance
);
2774 wstate
->class = wstrdup(class);
2776 wstate
->command
= wstrdup(command
);
2777 wstate
->state
= state
;
2779 wstate
->next
= windowState
;
2780 windowState
= wstate
;
2783 printf("Added WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2791 #define SAME(x, y) (((x) && (y) && !strcmp((x), (y))) || (!(x) && !(y)))
2795 wWindowGetSavedState(Window win
)
2797 char *instance
, *class, *command
=NULL
;
2798 WWindowState
*wstate
= windowState
;
2805 if (XGetCommand(dpy
, win
, &argv
, &argc
)) {
2807 command
= wtokenjoin(argv
, argc
);
2808 XFreeStringList(argv
);
2813 if (PropGetWMClass(win
, &class, &instance
)) {
2815 if (SAME(instance
, wstate
->instance
) &&
2816 SAME(class, wstate
->class) &&
2817 SAME(command
, wstate
->command
)) {
2820 wstate
= wstate
->next
;
2827 printf("Read WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2831 if (command
) wfree(command
);
2832 if (instance
) XFree(instance
);
2833 if (class) XFree(class);
2840 wWindowDeleteSavedState(WMagicNumber id
)
2842 WWindowState
*tmp
, *wstate
=(WWindowState
*)id
;
2844 if (!wstate
|| !windowState
)
2849 windowState
= wstate
->next
;
2851 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2852 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2854 if (wstate
->instance
) wfree(wstate
->instance
);
2855 if (wstate
->class) wfree(wstate
->class);
2856 if (wstate
->command
) wfree(wstate
->command
);
2857 wfree(wstate
->state
);
2861 if (tmp
->next
==wstate
) {
2862 tmp
->next
=wstate
->next
;
2864 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2865 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2867 if (wstate
->instance
) wfree(wstate
->instance
);
2868 if (wstate
->class) wfree(wstate
->class);
2869 if (wstate
->command
) wfree(wstate
->command
);
2870 wfree(wstate
->state
);
2881 wWindowDeleteSavedStatesForPID(pid_t pid
)
2883 WWindowState
*tmp
, *wstate
;
2889 if (tmp
->pid
== pid
) {
2890 wstate
= windowState
;
2891 windowState
= tmp
->next
;
2893 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2894 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2896 if (wstate
->instance
) wfree(wstate
->instance
);
2897 if (wstate
->class) wfree(wstate
->class);
2898 if (wstate
->command
) wfree(wstate
->command
);
2899 wfree(wstate
->state
);
2903 if (tmp
->next
->pid
==pid
) {
2905 tmp
->next
= wstate
->next
;
2907 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2908 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2910 if (wstate
->instance
) wfree(wstate
->instance
);
2911 if (wstate
->class) wfree(wstate
->class);
2912 if (wstate
->command
) wfree(wstate
->command
);
2913 wfree(wstate
->state
);
2924 wWindowSetOmnipresent(WWindow
*wwin
, Bool flag
)
2926 wwin
->flags
.omnipresent
= flag
;
2928 WMPostNotificationName(WMNChangedState
, wwin
, "omnipresent");
2932 /* ====================================================================== */
2935 resizebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2937 WWindow
*wwin
= data
;
2939 #ifndef NUMLOCK_HACK
2940 if ((event
->xbutton
.state
& ValidModMask
)
2941 != (event
->xbutton
.state
& ~LockMask
)) {
2942 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
2943 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
2947 event
->xbutton
.state
&= ValidModMask
;
2949 CloseWindowMenu(wwin
->screen_ptr
);
2951 if (wPreferences
.focus_mode
==WKF_CLICK
2952 && !(event
->xbutton
.state
&ControlMask
)
2953 && !WFLAGP(wwin
, no_focusable
)) {
2954 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2957 if (event
->xbutton
.button
== Button1
)
2958 wRaiseFrame(wwin
->frame
->core
);
2960 if (event
->xbutton
.window
!= wwin
->frame
->resizebar
->window
) {
2961 if (XGrabPointer(dpy
, wwin
->frame
->resizebar
->window
, True
,
2962 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
2963 GrabModeAsync
, GrabModeAsync
, None
,
2964 None
, CurrentTime
)!=GrabSuccess
) {
2966 wwarning("pointer grab failed for window move");
2972 if (event
->xbutton
.state
& MOD_MASK
) {
2973 /* move the window */
2974 wMouseMoveWindow(wwin
, event
);
2975 XUngrabPointer(dpy
, CurrentTime
);
2977 wMouseResizeWindow(wwin
, event
);
2978 XUngrabPointer(dpy
, CurrentTime
);
2985 titlebarDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2987 WWindow
*wwin
= data
;
2989 event
->xbutton
.state
&= ValidModMask
;
2991 if (event
->xbutton
.button
==Button1
) {
2992 if (event
->xbutton
.state
== 0) {
2993 if (!WFLAGP(wwin
, no_shadeable
)) {
2995 if (wwin
->flags
.shaded
)
2996 wUnshadeWindow(wwin
);
3003 if (event
->xbutton
.state
& ControlMask
)
3004 dir
|= MAX_VERTICAL
;
3006 if (event
->xbutton
.state
& ShiftMask
) {
3007 dir
|= MAX_HORIZONTAL
;
3008 if (!(event
->xbutton
.state
& ControlMask
))
3009 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3012 /* maximize window */
3013 if (dir
!=0 && !WFLAGP(wwin
, no_resizable
)) {
3014 int ndir
= dir
^ wwin
->flags
.maximized
;
3015 if (wwin
->flags
.maximized
!= 0)
3016 wUnmaximizeWindow(wwin
);
3018 wMaximizeWindow(wwin
, ndir
);
3021 } else if (event
->xbutton
.button
==Button3
) {
3022 if (event
->xbutton
.state
& MOD_MASK
) {
3023 wHideOtherApplications(wwin
);
3025 } else if (event
->xbutton
.button
==Button2
) {
3026 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3027 } else if (event
->xbutton
.button
== WINGsConfiguration
.mouseWheelUp
) {
3029 } else if (event
->xbutton
.button
== WINGsConfiguration
.mouseWheelDown
) {
3030 wUnshadeWindow(wwin
);
3036 frameMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
3038 WWindow
*wwin
= desc
->parent
;
3040 event
->xbutton
.state
&= ValidModMask
;
3042 CloseWindowMenu(wwin
->screen_ptr
);
3044 if (/*wPreferences.focus_mode==WKF_CLICK
3045 &&*/ !(event
->xbutton
.state
&ControlMask
)
3046 && !WFLAGP(wwin
, no_focusable
)) {
3047 wSetFocusTo(wwin
->screen_ptr
, wwin
);
3049 if (event
->xbutton
.button
== Button1
) {
3050 wRaiseFrame(wwin
->frame
->core
);
3053 if (event
->xbutton
.state
& MOD_MASK
) {
3054 /* move the window */
3055 if (XGrabPointer(dpy
, wwin
->client_win
, False
,
3056 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3057 GrabModeAsync
, GrabModeAsync
, None
,
3058 None
, CurrentTime
)!=GrabSuccess
) {
3060 wwarning("pointer grab failed for window move");
3064 if (event
->xbutton
.button
== Button3
&& !WFLAGP(wwin
, no_resizable
))
3065 wMouseResizeWindow(wwin
, event
);
3067 wMouseMoveWindow(wwin
, event
);
3068 XUngrabPointer(dpy
, CurrentTime
);
3074 titlebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3076 WWindow
*wwin
= (WWindow
*)data
;
3078 #ifndef NUMLOCK_HACK
3079 if ((event
->xbutton
.state
& ValidModMask
)
3080 != (event
->xbutton
.state
& ~LockMask
)) {
3081 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
3082 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
3085 event
->xbutton
.state
&= ValidModMask
;
3087 CloseWindowMenu(wwin
->screen_ptr
);
3089 if (wPreferences
.focus_mode
==WKF_CLICK
3090 && !(event
->xbutton
.state
&ControlMask
)
3091 && !WFLAGP(wwin
, no_focusable
)) {
3092 wSetFocusTo(wwin
->screen_ptr
, wwin
);
3095 if (event
->xbutton
.button
== Button1
3096 || event
->xbutton
.button
== Button2
) {
3098 if (event
->xbutton
.button
== Button1
) {
3099 if (event
->xbutton
.state
& MOD_MASK
) {
3100 wLowerFrame(wwin
->frame
->core
);
3102 wRaiseFrame(wwin
->frame
->core
);
3105 if ((event
->xbutton
.state
& ShiftMask
)
3106 && !(event
->xbutton
.state
& ControlMask
)) {
3107 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3110 if (event
->xbutton
.window
!= wwin
->frame
->titlebar
->window
3111 && XGrabPointer(dpy
, wwin
->frame
->titlebar
->window
, False
,
3112 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3113 GrabModeAsync
, GrabModeAsync
, None
,
3114 None
, CurrentTime
)!=GrabSuccess
) {
3116 wwarning("pointer grab failed for window move");
3121 /* move the window */
3122 wMouseMoveWindow(wwin
, event
);
3124 XUngrabPointer(dpy
, CurrentTime
);
3125 } else if (event
->xbutton
.button
== Button3
&& event
->xbutton
.state
==0
3126 && !wwin
->flags
.internal_window
3127 && !WCHECK_STATE(WSTATE_MODAL
)) {
3128 WObjDescriptor
*desc
;
3130 if (event
->xbutton
.window
!= wwin
->frame
->titlebar
->window
3131 && XGrabPointer(dpy
, wwin
->frame
->titlebar
->window
, False
,
3132 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3133 GrabModeAsync
, GrabModeAsync
, None
,
3134 None
, CurrentTime
)!=GrabSuccess
) {
3136 wwarning("pointer grab failed for window move");
3141 OpenWindowMenu(wwin
, event
->xbutton
.x_root
,
3142 wwin
->frame_y
+wwin
->frame
->top_width
, False
);
3144 /* allow drag select */
3145 desc
= &wwin
->screen_ptr
->window_menu
->menu
->descriptor
;
3146 event
->xany
.send_event
= True
;
3147 (*desc
->handle_mousedown
)(desc
, event
);
3149 XUngrabPointer(dpy
, CurrentTime
);
3156 windowCloseClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3158 WWindow
*wwin
= data
;
3160 event
->xbutton
.state
&= ValidModMask
;
3162 CloseWindowMenu(wwin
->screen_ptr
);
3164 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3167 /* if control-click, kill the client */
3168 if (event
->xbutton
.state
& ControlMask
) {
3172 if (wwin
->flags
.olwm_push_pin_out
) {
3174 wwin
->flags
.olwm_push_pin_out
= 0;
3176 wOLWMChangePushpinState(wwin
, True
);
3178 wFrameWindowUpdatePushButton(wwin
->frame
, False
);
3183 if (wwin
->protocols
.DELETE_WINDOW
&& event
->xbutton
.state
==0) {
3184 /* send delete message */
3185 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
3192 windowCloseDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3194 WWindow
*wwin
= data
;
3196 CloseWindowMenu(wwin
->screen_ptr
);
3198 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3201 /* send delete message */
3202 if (wwin
->protocols
.DELETE_WINDOW
) {
3203 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
3210 #ifdef XKB_BUTTON_HINT
3212 windowLanguageClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3214 WWindow
*wwin
= data
;
3215 WFrameWindow
*fwin
= wwin
->frame
;
3216 WScreen
*scr
= fwin
->screen_ptr
;
3217 XkbStateRec staterec
;
3220 if (event
->xbutton
.button
!= Button1
&& event
->xbutton
.button
!= Button3
)
3222 tl
= wwin
->frame
->languagemode
;
3223 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
3224 wwin
->frame
->last_languagemode
= tl
;
3225 wSetFocusTo(scr
, wwin
);
3226 wwin
->frame
->languagebutton_image
=
3227 wwin
->frame
->screen_ptr
->b_pixmaps
[WBUT_XKBGROUP1
+
3228 wwin
->frame
->languagemode
];
3229 wFrameWindowUpdateLanguageButton(wwin
->frame
);
3230 if (event
->xbutton
.button
== Button3
)
3232 wRaiseFrame(fwin
->core
);
3238 windowIconifyClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3240 WWindow
*wwin
= data
;
3242 event
->xbutton
.state
&= ValidModMask
;
3244 CloseWindowMenu(wwin
->screen_ptr
);
3246 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3249 if (wwin
->protocols
.MINIATURIZE_WINDOW
&& event
->xbutton
.state
==0) {
3250 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
3254 if ((event
->xbutton
.state
& ControlMask
) ||
3255 (event
->xbutton
.button
== Button3
)) {
3257 wapp
= wApplicationOf(wwin
->main_window
);
3258 if (wapp
&& !WFLAGP(wwin
, no_appicon
))
3259 wHideApplication(wapp
);
3260 } else if (event
->xbutton
.state
==0) {
3261 wIconifyWindow(wwin
);