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
));
503 wWindowCanReceiveFocus(WWindow
*wwin
)
505 if (!wwin
->flags
.mapped
&& (!wwin
->flags
.shaded
|| wwin
->flags
.hidden
))
507 if (WFLAGP(wwin
, no_focusable
) || wwin
->flags
.miniaturized
)
509 if (wwin
->frame
->workspace
!= wwin
->screen_ptr
->current_workspace
)
517 wWindowObscuresWindow(WWindow
*wwin
, WWindow
*obscured
)
521 w1
= wwin
->frame
->core
->width
;
522 h1
= wwin
->frame
->core
->height
;
523 w2
= obscured
->frame
->core
->width
;
524 h2
= obscured
->frame
->core
->height
;
526 if (!IS_OMNIPRESENT(wwin
) && !IS_OMNIPRESENT(obscured
)
527 && wwin
->frame
->workspace
!= obscured
->frame
->workspace
)
530 if (wwin
->frame_x
+ w1
< obscured
->frame_x
531 || wwin
->frame_y
+ h1
< obscured
->frame_y
532 || wwin
->frame_x
> obscured
->frame_x
+ w2
533 || wwin
->frame_y
> obscured
->frame_y
+ h2
) {
542 createFakeWindowGroupLeader(WScreen
*scr
, Window win
, char *instance
, char *class)
544 XClassHint
*classHint
;
550 leader
= XCreateSimpleWindow(dpy
, scr
->root_win
, 10, 10, 10, 10, 0, 0, 0);
552 classHint
= XAllocClassHint();
553 classHint
->res_name
= instance
;
554 classHint
->res_class
= class;
555 XSetClassHint(dpy
, leader
, classHint
);
558 /* inherit these from the original leader if available */
559 hints
= XGetWMHints(dpy
, win
);
561 hints
= XAllocWMHints();
564 /* set window group leader to self */
565 hints
->window_group
= leader
;
566 hints
->flags
|= WindowGroupHint
;
567 XSetWMHints(dpy
, leader
, hints
);
570 if (XGetCommand(dpy
, win
, &argv
, &argc
)!=0 && argc
> 0) {
571 XSetCommand(dpy
, leader
, argv
, argc
);
572 XFreeStringList(argv
);
580 matchIdentifier(void *item
, void *cdata
)
582 return (strcmp(((WFakeGroupLeader
*)item
)->identifier
, (char*)cdata
)==0);
587 *----------------------------------------------------------------
589 * reparents the window and allocates a descriptor for it.
590 * Window manager hints and other hints are fetched to configure
591 * the window decoration attributes and others. User preferences
592 * for the window are used if available, to configure window
593 * decorations and some behaviour.
594 * If in startup, windows that are override redirect,
595 * unmapped and never were managed and are Withdrawn are not
599 * the new window descriptor
602 * The window is reparented and appropriate notification
603 * is done to the client. Input mask for the window is setup.
604 * The window descriptor is also associated with various window
605 * contexts and inserted in the head of the window list.
606 * Event handler contexts are associated for some objects
607 * (buttons, titlebar and resizebar)
609 *----------------------------------------------------------------
612 wManageWindow(WScreen
*scr
, Window window
)
616 unsigned width
, height
;
617 XWindowAttributes wattribs
;
618 XSetWindowAttributes attribs
;
619 WWindowState
*win_state
;
620 WWindow
*transientOwner
= NULL
;
626 Bool withdraw
= False
;
630 /* XGrabServer(dpy); */
632 /* make sure the window is still there */
633 if (!XGetWindowAttributes(dpy
, window
, &wattribs
)) {
638 /* if it's an override-redirect, ignore it */
639 if (wattribs
.override_redirect
) {
644 wm_state
= PropGetWindowState(window
);
646 /* if it's startup and the window is unmapped, don't manage it */
647 if (scr
->flags
.startup
&& wm_state
< 0 && wattribs
.map_state
==IsUnmapped
) {
652 if (!wFetchName(dpy
, window
, &title
)) {
657 if (title
&& !wKWMManageableClient(scr
, window
, title
)) {
662 #endif /* KWM_HINTS */
665 wwin
= wWindowCreate();
667 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
670 printf("managing window %x\n", (unsigned)window
);
674 if (wShapeSupported
) {
679 XShapeSelectInput(dpy
, window
, ShapeNotifyMask
);
680 XShapeQueryExtents(dpy
, window
, &b_shaped
, &junk
, &junk
, &ujunk
,
681 &ujunk
, &junk
, &junk
, &junk
, &ujunk
, &ujunk
);
682 wwin
->flags
.shaped
= b_shaped
;
687 *--------------------------------------------------
689 * Get hints and other information in properties
691 *--------------------------------------------------
693 PropGetWMClass(window
, &wwin
->wm_class
, &wwin
->wm_instance
);
695 /* setup descriptor */
696 wwin
->client_win
= window
;
697 wwin
->screen_ptr
= scr
;
699 wwin
->old_border_width
= wattribs
.border_width
;
701 wwin
->event_mask
= CLIENT_EVENTS
;
702 attribs
.event_mask
= CLIENT_EVENTS
;
703 attribs
.do_not_propagate_mask
= ButtonPressMask
| ButtonReleaseMask
;
704 attribs
.save_under
= False
;
705 XChangeWindowAttributes(dpy
, window
, CWEventMask
|CWDontPropagate
706 |CWSaveUnder
, &attribs
);
707 XSetWindowBorderWidth(dpy
, window
, 0);
709 /* get hints from GNUstep app */
710 if (wwin
->wm_class
!= 0 && strcmp(wwin
->wm_class
, "GNUstep") == 0) {
711 wwin
->flags
.is_gnustep
= 1;
713 if (!PropGetGNUstepWMAttr(window
, &wwin
->wm_gnustep_attr
)) {
714 wwin
->wm_gnustep_attr
= NULL
;
717 wwin
->client_leader
= PropGetClientLeader(window
);
718 if (wwin
->client_leader
!=None
)
719 wwin
->main_window
= wwin
->client_leader
;
721 wwin
->wm_hints
= XGetWMHints(dpy
, window
);
723 if (wwin
->wm_hints
) {
724 if (wwin
->wm_hints
->flags
& StateHint
) {
726 if (wwin
->wm_hints
->initial_state
== IconicState
) {
728 wwin
->flags
.miniaturized
= 1;
730 } else if (wwin
->wm_hints
->initial_state
== WithdrawnState
) {
736 if (wwin
->wm_hints
->flags
& WindowGroupHint
) {
737 wwin
->group_id
= wwin
->wm_hints
->window_group
;
738 /* window_group has priority over CLIENT_LEADER */
739 wwin
->main_window
= wwin
->group_id
;
741 wwin
->group_id
= None
;
744 if (wwin
->wm_hints
->flags
& UrgencyHint
)
745 wwin
->flags
.urgent
= 1;
747 wwin
->group_id
= None
;
750 PropGetProtocols(window
, &wwin
->protocols
);
752 if (!XGetTransientForHint(dpy
, window
, &wwin
->transient_for
)) {
753 wwin
->transient_for
= None
;
755 if (wwin
->transient_for
==None
|| wwin
->transient_for
==window
) {
756 wwin
->transient_for
= scr
->root_win
;
758 transientOwner
= wWindowFor(wwin
->transient_for
);
759 if (transientOwner
&& transientOwner
->main_window
!=None
) {
760 wwin
->main_window
= transientOwner
->main_window
;
762 wwin->main_window = None;
767 /* guess the focus mode */
768 wwin
->focus_mode
= getFocusMode(wwin
);
770 /* get geometry stuff */
771 wClientGetNormalHints(wwin
, &wattribs
, True
, &x
, &y
, &width
, &height
);
773 /* get colormap windows */
774 GetColormapWindows(wwin
);
777 *--------------------------------------------------
779 * Setup the decoration/window attributes and
782 *--------------------------------------------------
785 wWindowSetupInitialAttributes(wwin
, &window_level
, &workspace
);
788 if (wwin
->client_flags
.olwm_transient
&& wwin
->transient_for
==None
789 && wwin
->group_id
!= None
&& wwin
->group_id
!= window
) {
791 transientOwner
= wWindowFor(wwin
->group_id
);
793 if (transientOwner
) {
794 wwin
->transient_for
= wwin
->group_id
;
796 /* transients can't be iconified or maximized */
797 if (wwin
->transient_for
) {
798 WSETUFLAG(wwin
, no_miniaturizable
, 1);
799 WSETUFLAG(wwin
, no_miniaturize_button
, 1);
803 #endif /* OLWM_HINTS */
805 /* Make broken apps behave as a nice app. */
806 if (WFLAGP(wwin
, emulate_appicon
)) {
807 wwin
->main_window
= wwin
->client_win
;
810 if (wwin
->flags
.is_gnustep
) {
811 WSETUFLAG(wwin
, shared_appicon
, 0);
814 if (wwin
->main_window
) {
815 extern Atom _XA_WINDOWMAKER_MENU
;
816 XTextProperty text_prop
;
818 if (XGetTextProperty(dpy
, wwin
->main_window
, &text_prop
,
819 _XA_WINDOWMAKER_MENU
)) {
820 WSETUFLAG(wwin
, shared_appicon
, 0);
824 if (!withdraw
&& wwin
->main_window
&& WFLAGP(wwin
, shared_appicon
)) {
825 char *buffer
, *instance
, *class;
826 WFakeGroupLeader
*fPtr
;
829 #define ADEQUATE(x) ((x)!=None && (x)!=wwin->client_win && (x)!=fPtr->leader)
831 PropGetWMClass(wwin
->main_window
, &class, &instance
);
832 buffer
= wmalloc(strlen(instance
)+strlen(class)+2);
833 sprintf(buffer
, "%s.%s", instance
, class);
835 index
= WMFindInArray(scr
->fakeGroupLeaders
, matchIdentifier
, (void*)buffer
);
836 if (index
!= WANotFound
) {
837 fPtr
= WMGetFromArray(scr
->fakeGroupLeaders
, index
);
838 if (fPtr
->retainCount
== 0) {
839 fPtr
->leader
= createFakeWindowGroupLeader(scr
, wwin
->main_window
,
844 if (fPtr
->origLeader
==None
) {
846 if (ADEQUATE(wwin
->group_id
)) {
848 fPtr
->origLeader
= wwin
->group_id
;
849 } else if (ADEQUATE(wwin
->client_leader
)) {
851 fPtr
->origLeader
= wwin
->client_leader
;
852 } else if (ADEQUATE(wwin
->main_window
)) {
854 fPtr
->origLeader
= wwin
->main_window
;
857 if (ADEQUATE(wwin
->main_window
)) {
859 fPtr
->origLeader
= wwin
->main_window
;
863 wwin
->fake_group
= fPtr
;
864 /*wwin->group_id = fPtr->leader;*/
865 wwin
->main_window
= fPtr
->leader
;
868 fPtr
= (WFakeGroupLeader
*)wmalloc(sizeof(WFakeGroupLeader
));
870 fPtr
->identifier
= buffer
;
871 fPtr
->leader
= createFakeWindowGroupLeader(scr
, wwin
->main_window
,
873 fPtr
->origLeader
= None
;
874 fPtr
->retainCount
= 1;
876 WMAddToArray(scr
->fakeGroupLeaders
, fPtr
);
879 if (ADEQUATE(wwin
->group_id
)) {
881 fPtr
->origLeader
= wwin
->group_id
;
882 } else if (ADEQUATE(wwin
->client_leader
)) {
884 fPtr
->origLeader
= wwin
->client_leader
;
885 } else if (ADEQUATE(wwin
->main_window
)) {
887 fPtr
->origLeader
= wwin
->main_window
;
890 if (ADEQUATE(wwin
->main_window
)) {
892 fPtr
->origLeader
= wwin
->main_window
;
895 wwin
->fake_group
= fPtr
;
896 /*wwin->group_id = fPtr->leader;*/
897 wwin
->main_window
= fPtr
->leader
;
909 *------------------------------------------------------------
911 * Setup the initial state of the window
913 *------------------------------------------------------------
916 if (WFLAGP(wwin
, start_miniaturized
) && !WFLAGP(wwin
, no_miniaturizable
)) {
917 wwin
->flags
.miniaturized
= 1;
920 if (WFLAGP(wwin
, start_maximized
) && !WFLAGP(wwin
, no_resizable
)) {
921 wwin
->flags
.maximized
= MAX_VERTICAL
|MAX_HORIZONTAL
;
929 bla
= wGNOMECheckInitialClientState(wwin
);
933 wKWMCheckClientInitialState(wwin
);
937 /* apply previous state if it exists and we're in startup */
938 if (scr
->flags
.startup
&& wm_state
>= 0) {
940 if (wm_state
== IconicState
) {
942 wwin
->flags
.miniaturized
= 1;
944 } else if (wm_state
== WithdrawnState
) {
950 /* if there is a saved state (from file), restore it */
952 if (wwin
->main_window
!=None
/* && wwin->main_window!=window*/) {
953 win_state
= (WWindowState
*)wWindowGetSavedState(wwin
->main_window
);
955 win_state
= (WWindowState
*)wWindowGetSavedState(window
);
957 if (win_state
&& !withdraw
) {
959 if (win_state
->state
->hidden
>0)
960 wwin
->flags
.hidden
= win_state
->state
->hidden
;
962 if (win_state
->state
->shaded
>0 && !WFLAGP(wwin
, no_shadeable
))
963 wwin
->flags
.shaded
= win_state
->state
->shaded
;
965 if (win_state
->state
->miniaturized
>0 &&
966 !WFLAGP(wwin
, no_miniaturizable
)) {
967 wwin
->flags
.miniaturized
= win_state
->state
->miniaturized
;
970 if (!IS_OMNIPRESENT(wwin
)) {
971 int w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
,
973 if (w
< 0 || w
>= scr
->workspace_count
) {
974 workspace
= win_state
->state
->workspace
;
975 if (workspace
>= scr
->workspace_count
)
976 workspace
= scr
->current_workspace
;
981 workspace
= scr
->current_workspace
;
985 /* if we're restarting, restore saved state (from hints).
986 * This will overwrite previous */
990 if (getSavedState(window
, &wstate
)) {
991 wwin
->flags
.shaded
= wstate
->shaded
;
992 wwin
->flags
.hidden
= wstate
->hidden
;
993 wwin
->flags
.miniaturized
= wstate
->miniaturized
;
994 wwin
->flags
.maximized
= wstate
->maximized
;
995 if (wwin
->flags
.maximized
) {
996 wwin
->old_geometry
.x
= wstate
->x
;
997 wwin
->old_geometry
.y
= wstate
->y
;
998 wwin
->old_geometry
.width
= wstate
->w
;
999 wwin
->old_geometry
.height
= wstate
->h
;
1002 workspace
= wstate
->workspace
;
1007 /* restore window shortcut */
1008 if (wstate
!= NULL
|| win_state
!= NULL
) {
1011 if (win_state
!= NULL
)
1012 mask
= win_state
->state
->window_shortcuts
;
1014 if (wstate
!= NULL
&& mask
== 0)
1015 mask
= wstate
->window_shortcuts
;
1020 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
1021 if (mask
& (1<<i
)) {
1022 if (!scr
->shortcutWindows
[i
])
1023 scr
->shortcutWindows
[i
] = WMCreateArray(4);
1025 WMAddToArray(scr
->shortcutWindows
[i
], wwin
);
1030 if (wstate
!= NULL
) {
1035 /* don't let transients start miniaturized if their owners are not */
1036 if (transientOwner
&& !transientOwner
->flags
.miniaturized
1037 && wwin
->flags
.miniaturized
&& !withdraw
) {
1038 wwin
->flags
.miniaturized
= 0;
1040 wwin
->wm_hints
->initial_state
= NormalState
;
1043 /* set workspace on which the window starts */
1044 if (workspace
>= 0) {
1045 if (workspace
> scr
->workspace_count
-1) {
1046 workspace
= workspace
% scr
->workspace_count
;
1051 w
= wDefaultGetStartWorkspace(scr
, wwin
->wm_instance
, wwin
->wm_class
);
1053 if (w
>= 0 && w
< scr
->workspace_count
&& !(IS_OMNIPRESENT(wwin
))) {
1058 if (wPreferences
.open_transients_with_parent
&& transientOwner
) {
1060 workspace
= transientOwner
->frame
->workspace
;
1064 workspace
= scr
->current_workspace
;
1069 /* setup window geometry */
1070 if (win_state
&& win_state
->state
->w
> 0) {
1071 width
= win_state
->state
->w
;
1072 height
= win_state
->state
->h
;
1074 wWindowConstrainSize(wwin
, &width
, &height
);
1076 /* do not ask for window placement if the window is
1077 * transient, during startup, if the initial workspace is another one
1078 * or if the window wants to start iconic.
1079 * If geometry was saved, restore it. */
1081 Bool dontBring
= False
;
1083 if (win_state
&& win_state
->state
->w
> 0) {
1084 x
= win_state
->state
->x
;
1085 y
= win_state
->state
->y
;
1086 } else if ((wwin
->transient_for
==None
1087 || wPreferences
.window_placement
!=WPM_MANUAL
)
1088 && !scr
->flags
.startup
1089 && workspace
== scr
->current_workspace
1090 && !wwin
->flags
.miniaturized
1091 && !wwin
->flags
.maximized
1092 && !(wwin
->normal_hints
->flags
& (USPosition
|PPosition
))) {
1094 if (transientOwner
&& transientOwner
->flags
.mapped
) {
1095 int offs
= WMAX(20, 2*transientOwner
->frame
->top_width
);
1097 x
= transientOwner
->frame_x
+
1098 abs((transientOwner
->frame
->core
->width
- width
)/2) + offs
;
1099 y
= transientOwner
->frame_y
+
1100 abs((transientOwner
->frame
->core
->height
- height
)/3) + offs
;
1104 else if (x
+ width
> scr
->scr_width
)
1105 x
= scr
->scr_width
- width
;
1109 else if (y
+ height
> scr
->scr_height
)
1110 y
= scr
->scr_height
- height
;
1112 PlaceWindow(wwin
, &x
, &y
, width
, height
);
1114 if (wPreferences
.window_placement
== WPM_MANUAL
)
1118 if (WFLAGP(wwin
, dont_move_off
) && dontBring
)
1119 wScreenBringInside(scr
, &x
, &y
, width
, height
);
1122 if (wwin
->flags
.urgent
) {
1123 if (!IS_OMNIPRESENT(wwin
))
1124 wwin
->flags
.omnipresent
^= 1;
1128 *--------------------------------------------------
1130 * Create frame, borders and do reparenting
1132 *--------------------------------------------------
1134 foo
= WFF_LEFT_BUTTON
| WFF_RIGHT_BUTTON
;
1135 #ifdef XKB_BUTTON_HINT
1136 if (wPreferences
.modelock
)
1137 foo
|= WFF_LANGUAGE_BUTTON
;
1139 if (!WFLAGP(wwin
, no_titlebar
))
1140 foo
|= WFF_TITLEBAR
;
1141 if (!WFLAGP(wwin
, no_resizebar
))
1142 foo
|= WFF_RESIZEBAR
;
1143 if (!WFLAGP(wwin
, no_border
))
1146 wwin
->frame
= wFrameWindowCreate(scr
, window_level
,
1147 x
, y
, width
, height
,
1148 &wPreferences
.window_title_clearance
, foo
,
1149 scr
->window_title_texture
,
1150 scr
->resizebar_texture
,
1151 scr
->window_title_pixel
,
1152 &scr
->window_title_gc
,
1155 wwin
->frame
->flags
.is_client_window_frame
= 1;
1156 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
1158 /* setup button images */
1159 wWindowUpdateButtonImages(wwin
);
1161 /* hide unused buttons */
1163 if (WFLAGP(wwin
, no_close_button
))
1164 foo
|= WFF_RIGHT_BUTTON
;
1165 if (WFLAGP(wwin
, no_miniaturize_button
))
1166 foo
|= WFF_LEFT_BUTTON
;
1167 #ifdef XKB_BUTTON_HINT
1168 if (WFLAGP(wwin
, no_language_button
) || WFLAGP(wwin
, no_focusable
))
1169 foo
|= WFF_LANGUAGE_BUTTON
;
1172 wFrameWindowHideButton(wwin
->frame
, foo
);
1174 wwin
->frame
->child
= wwin
;
1177 /* emulate olwm push pin. Make the button look as pushed-in for
1178 * the pinned-out state. When the button is clicked, it will
1179 * revert to the normal position, which means the pin is pinned-in.
1181 if (wwin
->flags
.olwm_push_pin_out
)
1182 wFrameWindowUpdatePushButton(wwin
->frame
, True
);
1183 #endif /* OLWM_HINTS */
1186 wwin
->frame
->workspace
= workspace
;
1188 wwin
->frame
->on_click_left
= windowIconifyClick
;
1189 #ifdef XKB_BUTTON_HINT
1190 if (wPreferences
.modelock
)
1191 wwin
->frame
->on_click_language
= windowLanguageClick
;
1194 wwin
->frame
->on_click_right
= windowCloseClick
;
1195 wwin
->frame
->on_dblclick_right
= windowCloseDblClick
;
1197 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
1198 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
1200 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
1203 XSelectInput(dpy
, wwin
->client_win
,
1204 wwin
->event_mask
& ~StructureNotifyMask
);
1206 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
1207 0, wwin
->frame
->top_width
);
1209 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1215 wClientGetGravityOffsets(wwin
, &gx
, &gy
);
1217 /* if gravity is to the south, account for the border sizes */
1219 y
-= wwin
->frame
->top_width
+ wwin
->frame
->bottom_width
;
1223 * wWindowConfigure() will init the client window's size
1224 * (wwin->client.{width,height}) and all other geometry
1225 * related variables (frame_x,frame_y)
1227 wWindowConfigure(wwin
, x
, y
, width
, height
);
1229 /* to make sure the window receives it's new position after reparenting */
1230 wWindowSynthConfigureNotify(wwin
);
1233 *--------------------------------------------------
1235 * Setup descriptors and save window to internal
1238 *--------------------------------------------------
1241 if (wwin
->main_window
!=None
) {
1245 /* Leader windows do not necessary set themselves as leaders.
1246 * If this is the case, point the leader of this window to
1248 leader
= wWindowFor(wwin
->main_window
);
1249 if (leader
&& leader
->main_window
==None
) {
1250 leader
->main_window
= leader
->client_win
;
1252 app
= wApplicationCreate(scr
, wwin
->main_window
);
1254 app
->last_workspace
= workspace
;
1256 app
->main_window_desc
->fake_group
= wwin
->fake_group
;
1259 * Do application specific stuff, like setting application
1263 if (wwin
->flags
.hidden
) {
1264 /* if the window was set to hidden because it was hidden
1265 * in a previous incarnation and that state was restored */
1266 app
->flags
.hidden
= 1;
1267 } else if (app
->flags
.hidden
) {
1268 if (WFLAGP(app
->main_window_desc
, start_hidden
)) {
1269 wwin
->flags
.hidden
= 1;
1271 wUnhideApplication(app
, False
, False
);
1278 /* setup the frame descriptor */
1279 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
1280 wwin
->frame
->core
->descriptor
.parent
= wwin
;
1281 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
1283 /* don't let windows go away if we die */
1284 XAddToSaveSet(dpy
, window
);
1286 XLowerWindow(dpy
, window
);
1288 /* if window is in this workspace and should be mapped, then map it */
1289 if (!wwin
->flags
.miniaturized
1290 && (workspace
== scr
->current_workspace
|| IS_OMNIPRESENT(wwin
))
1291 && !wwin
->flags
.hidden
&& !withdraw
) {
1293 /* The following "if" is to avoid crashing of clients that expect
1294 * WM_STATE set before they get mapped. Else WM_STATE is set later,
1295 * after the return from this function.
1297 if (wwin
->wm_hints
&& (wwin
->wm_hints
->flags
& StateHint
)) {
1298 wClientSetState(wwin
, wwin
->wm_hints
->initial_state
, None
);
1300 wClientSetState(wwin
, NormalState
, None
);
1304 /* if not auto focus, then map the window under the currently
1306 #define _WIDTH(w) (w)->frame->core->width
1307 #define _HEIGHT(w) (w)->frame->core->height
1308 if (!wPreferences
.auto_focus
&& scr
->focused_window
1309 && !scr
->flags
.startup
&& !transientOwner
1310 && ((wWindowObscuresWindow(wwin
, scr
->focused_window
)
1311 && (_WIDTH(wwin
) > (_WIDTH(scr
->focused_window
)*5)/3
1312 || _HEIGHT(wwin
) > (_HEIGHT(scr
->focused_window
)*5)/3)
1313 && WINDOW_LEVEL(scr
->focused_window
) == WINDOW_LEVEL(wwin
))
1314 || wwin
->flags
.maximized
)) {
1315 MoveInStackListUnder(scr
->focused_window
->frame
->core
,
1323 if (wPreferences
.superfluous
&& !wPreferences
.no_animations
1324 && !scr
->flags
.startup
&&
1325 (wwin
->transient_for
==None
|| wwin
->transient_for
==scr
->root_win
)
1327 * The brain damaged idiotic non-click to focus modes will
1328 * have trouble with this because:
1330 * 1. window is created and mapped by the client
1331 * 2. window is mapped by wmaker in small size
1332 * 3. window is animated to grow to normal size
1333 * 4. this function returns to normal event loop
1334 * 5. eventually, the EnterNotify event that would trigger
1335 * the window focusing (if the mouse is over that window)
1336 * will be processed by wmaker.
1337 * But since this event will be rather delayed
1338 * (step 3 has a large delay) the time when the event ocurred
1339 * and when it is processed, the client that owns that window
1340 * will reject the XSetInputFocus() for it.
1342 && (wPreferences
.focus_mode
==WKF_CLICK
1343 || wPreferences
.auto_focus
)) {
1344 DoWindowBirth(wwin
);
1350 /* setup stacking descriptor */
1351 if (transientOwner
) {
1352 wwin
->frame
->core
->stacking
->child_of
= transientOwner
->frame
->core
;
1354 wwin
->frame
->core
->stacking
->child_of
= NULL
;
1358 if (!scr
->focused_window
) {
1359 /* first window on the list */
1362 scr
->focused_window
= wwin
;
1366 /* add window at beginning of focus window list */
1367 tmp
= scr
->focused_window
;
1375 /* raise is set to true if we un-hid the app when this window was born.
1376 * we raise, else old windows of this app will be above this new one. */
1378 wRaiseFrame(wwin
->frame
->core
);
1381 /* Update name must come after WApplication stuff is done */
1382 wWindowUpdateName(wwin
, title
);
1389 *--------------------------------------------------
1391 * Final preparations before window is ready to go
1393 *--------------------------------------------------
1396 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1399 if (!wwin
->flags
.miniaturized
&& workspace
== scr
->current_workspace
1400 && !wwin
->flags
.hidden
) {
1401 if (((transientOwner
&& transientOwner
->flags
.focused
)
1402 || wPreferences
.auto_focus
) && !WFLAGP(wwin
, no_focusable
))
1403 wSetFocusTo(scr
, wwin
);
1405 wWindowResetMouseGrabs(wwin
);
1407 if (!WFLAGP(wwin
, no_bind_keys
)) {
1408 wWindowSetKeyGrabs(wwin
);
1412 WMPostNotificationName(WMNManaged
, wwin
, NULL
);
1415 wColormapInstallForWindow(scr
, scr
->cmap_window
);
1419 if (wwin
->client_flags
.olwm_warp_to_pin
&& wwin
->frame
->titlebar
!= NULL
1420 && !WFLAGP(wwin
, no_close_button
) && !withdraw
) {
1422 XWarpPointer(dpy
, None
, None
, 0, 0, 0, 0,
1423 wwin
->frame_x
+ width
- wwin
->frame
->titlebar
->height
* 2,
1429 *------------------------------------------------------------
1430 * Setup Notification Observers
1431 *------------------------------------------------------------
1433 WMAddNotificationObserver(appearanceObserver
, wwin
,
1434 WNWindowAppearanceSettingsChanged
, wwin
);
1438 *--------------------------------------------------
1440 * Cleanup temporary stuff
1442 *--------------------------------------------------
1446 wWindowDeleteSavedState(win_state
);
1448 /* If the window must be withdrawed, then do it now.
1449 * Must do some optimization, 'though */
1451 wwin
->flags
.mapped
= 0;
1452 wClientSetState(wwin
, WithdrawnState
, None
);
1453 wUnmanageWindow(wwin
, True
, False
);
1465 wManageInternalWindow(WScreen
*scr
, Window window
, Window owner
,
1466 char *title
, int x
, int y
, int width
, int height
)
1471 wwin
= wWindowCreate();
1473 WMAddNotificationObserver(appearanceObserver
, wwin
,
1474 WNWindowAppearanceSettingsChanged
, wwin
);
1476 wwin
->flags
.internal_window
= 1;
1478 WSETUFLAG(wwin
, omnipresent
, 1);
1479 WSETUFLAG(wwin
, no_shadeable
, 1);
1480 WSETUFLAG(wwin
, no_resizable
, 1);
1481 WSETUFLAG(wwin
, no_miniaturizable
, 1);
1483 wwin
->focus_mode
= WFM_PASSIVE
;
1485 wwin
->client_win
= window
;
1486 wwin
->screen_ptr
= scr
;
1488 wwin
->transient_for
= owner
;
1492 wwin
->client
.width
= width
;
1493 wwin
->client
.height
= height
;
1495 wwin
->frame_x
= wwin
->client
.x
;
1496 wwin
->frame_y
= wwin
->client
.y
;
1499 foo
= WFF_RIGHT_BUTTON
|WFF_BORDER
;
1500 foo
|= WFF_TITLEBAR
;
1501 #ifdef XKB_BUTTON_HINT
1502 foo
|= WFF_LANGUAGE_BUTTON
;
1505 wwin
->frame
= wFrameWindowCreate(scr
, WMFloatingLevel
,
1506 wwin
->frame_x
, wwin
->frame_y
,
1508 &wPreferences
.window_title_clearance
, foo
,
1509 scr
->window_title_texture
,
1510 scr
->resizebar_texture
,
1511 scr
->window_title_pixel
,
1512 &scr
->window_title_gc
,
1515 XSaveContext(dpy
, window
, wWinContext
, (XPointer
)&wwin
->client_descriptor
);
1517 wwin
->frame
->flags
.is_client_window_frame
= 1;
1518 wwin
->frame
->flags
.justification
= wPreferences
.title_justification
;
1520 wFrameWindowChangeTitle(wwin
->frame
, title
);
1522 /* setup button images */
1523 wWindowUpdateButtonImages(wwin
);
1526 wFrameWindowHideButton(wwin
->frame
, WFF_RIGHT_BUTTON
);
1528 wwin
->frame
->child
= wwin
;
1530 wwin
->frame
->workspace
= wwin
->screen_ptr
->current_workspace
;
1532 #ifdef XKB_BUTTON_HINT
1533 if (wPreferences
.modelock
)
1534 wwin
->frame
->on_click_language
= windowLanguageClick
;
1537 wwin
->frame
->on_click_right
= windowCloseClick
;
1539 wwin
->frame
->on_mousedown_titlebar
= titlebarMouseDown
;
1540 wwin
->frame
->on_dblclick_titlebar
= titlebarDblClick
;
1542 wwin
->frame
->on_mousedown_resizebar
= resizebarMouseDown
;
1544 wwin
->client
.y
+= wwin
->frame
->top_width
;
1545 XReparentWindow(dpy
, wwin
->client_win
, wwin
->frame
->core
->window
,
1546 0, wwin
->frame
->top_width
);
1548 wWindowConfigure(wwin
, wwin
->frame_x
, wwin
->frame_y
,
1549 wwin
->client
.width
, wwin
->client
.height
);
1551 /* setup the frame descriptor */
1552 wwin
->frame
->core
->descriptor
.handle_mousedown
= frameMouseDown
;
1553 wwin
->frame
->core
->descriptor
.parent
= wwin
;
1554 wwin
->frame
->core
->descriptor
.parent_type
= WCLASS_WINDOW
;
1557 XLowerWindow(dpy
, window
);
1558 XMapSubwindows(dpy
, wwin
->frame
->core
->window
);
1560 /* setup stacking descriptor */
1561 if (wwin
->transient_for
!=None
&& wwin
->transient_for
!=scr
->root_win
) {
1563 tmp
= wWindowFor(wwin
->transient_for
);
1565 wwin
->frame
->core
->stacking
->child_of
= tmp
->frame
->core
;
1567 wwin
->frame
->core
->stacking
->child_of
= NULL
;
1571 if (!scr
->focused_window
) {
1572 /* first window on the list */
1575 scr
->focused_window
= wwin
;
1579 /* add window at beginning of focus window list */
1580 tmp
= scr
->focused_window
;
1588 if (wwin
->flags
.is_gnustep
== 0)
1589 wFrameWindowChangeState(wwin
->frame
, WS_UNFOCUSED
);
1591 /* if (wPreferences.auto_focus)*/
1592 wSetFocusTo(scr
, wwin
);
1594 wWindowResetMouseGrabs(wwin
);
1596 wWindowSetKeyGrabs(wwin
);
1603 *----------------------------------------------------------------------
1605 * Removes the frame window from a window and destroys all data
1606 * related to it. The window will be reparented back to the root window
1607 * if restore is True.
1610 * Everything related to the window is destroyed and the window
1611 * is removed from the window lists. Focus is set to the previous on the
1613 *----------------------------------------------------------------------
1616 wUnmanageWindow(WWindow
*wwin
, Bool restore
, Bool destroyed
)
1618 WCoreWindow
*frame
= wwin
->frame
->core
;
1619 WWindow
*owner
= NULL
;
1620 WWindow
*newFocusedWindow
= NULL
;
1622 WScreen
*scr
= wwin
->screen_ptr
;
1625 /* First close attribute editor window if open */
1626 if (wwin
->flags
.inspector_open
) {
1627 wCloseInspectorForWindow(wwin
);
1630 /* Close window menu if it's open for this window */
1631 if (wwin
->flags
.menu_open_for_me
) {
1632 CloseWindowMenu(scr
);
1636 if (!wwin
->flags
.internal_window
)
1637 XRemoveFromSaveSet(dpy
, wwin
->client_win
);
1639 XSelectInput(dpy
, wwin
->client_win
, NoEventMask
);
1641 XUngrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
);
1642 XUngrabKey(dpy
, AnyKey
, AnyModifier
, wwin
->client_win
);
1645 XUnmapWindow(dpy
, frame
->window
);
1647 XUnmapWindow(dpy
, wwin
->client_win
);
1649 /* deselect window */
1650 wSelectWindow(wwin
, False
);
1652 /* remove all pending events on window */
1653 /* I think this only matters for autoraise */
1654 if (wPreferences
.raise_delay
)
1655 WMDeleteTimerWithClientData(wwin
->frame
->core
);
1659 /* reparent the window back to the root */
1661 wClientRestore(wwin
);
1663 if (wwin
->transient_for
!=scr
->root_win
) {
1664 owner
= wWindowFor(wwin
->transient_for
);
1666 if (!owner
->flags
.semi_focused
) {
1669 owner
->flags
.semi_focused
= 0;
1674 wasFocused
= wwin
->flags
.focused
;
1676 /* remove from window focus list */
1677 if (!wwin
->prev
&& !wwin
->next
) {
1678 /* was the only window */
1679 scr
->focused_window
= NULL
;
1680 newFocusedWindow
= NULL
;
1685 wwin
->prev
->next
= wwin
->next
;
1687 wwin
->next
->prev
= wwin
->prev
;
1689 scr
->focused_window
= wwin
->prev
;
1690 scr
->focused_window
->next
= NULL
;
1693 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1695 /* if in click to focus mode and the window
1696 * was a transient, focus the owner window
1699 if (wPreferences
.focus_mode
==WKF_CLICK
) {
1700 tmp
= wWindowFor(wwin
->transient_for
);
1701 if (tmp
&& (!tmp
->flags
.mapped
|| WFLAGP(tmp
, no_focusable
))) {
1705 /* otherwise, focus the next one in the focus list */
1707 tmp
= scr
->focused_window
;
1708 while (tmp
) { /* look for one in the window list first */
1709 if (!WFLAGP(tmp
, no_focusable
) && !WFLAGP(tmp
, skip_window_list
)
1710 && (tmp
->flags
.mapped
|| tmp
->flags
.shaded
))
1714 if (!tmp
) { /* if unsuccessful, choose any focusable window */
1715 tmp
= scr
->focused_window
;
1717 if (!WFLAGP(tmp
, no_focusable
)
1718 && (tmp
->flags
.mapped
|| tmp
->flags
.shaded
))
1725 newFocusedWindow
= tmp
;
1727 } else if (wPreferences
.focus_mode
==WKF_SLOPPY
) {
1732 /* This is to let the root window get the keyboard input
1733 * if Sloppy focus mode and no other window get focus.
1734 * This way keybindings will not freeze.
1737 if (XQueryPointer(dpy
, scr
->root_win
, &bar
, &win
,
1738 &foo
, &foo
, &foo
, &foo
, &mask
))
1739 tmp
= wWindowFor(win
);
1742 newFocusedWindow
= tmp
;
1744 newFocusedWindow
= NULL
;
1748 if (!wwin
->flags
.internal_window
) {
1749 WMPostNotificationName(WMNUnmanaged
, wwin
, NULL
);
1753 printf("destroying window %x frame %x\n", (unsigned)wwin
->client_win
,
1754 (unsigned)frame
->window
);
1758 if (newFocusedWindow
!= owner
&& owner
) {
1759 if (wwin
->flags
.is_gnustep
== 0)
1760 wFrameWindowChangeState(owner
->frame
, WS_UNFOCUSED
);
1762 wSetFocusTo(scr
, newFocusedWindow
);
1764 wWindowDestroy(wwin
);
1770 wWindowMap(WWindow
*wwin
)
1772 XMapWindow(dpy
, wwin
->frame
->core
->window
);
1773 if (!wwin
->flags
.shaded
) {
1774 /* window will be remapped when getting MapNotify */
1775 XSelectInput(dpy
, wwin
->client_win
,
1776 wwin
->event_mask
& ~StructureNotifyMask
);
1777 XMapWindow(dpy
, wwin
->client_win
);
1778 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1780 wwin
->flags
.mapped
= 1;
1786 wWindowUnmap(WWindow
*wwin
)
1788 wwin
->flags
.mapped
= 0;
1790 /* prevent window withdrawal when getting UnmapNotify */
1791 XSelectInput(dpy
, wwin
->client_win
,
1792 wwin
->event_mask
& ~StructureNotifyMask
);
1793 XUnmapWindow(dpy
, wwin
->client_win
);
1794 XSelectInput(dpy
, wwin
->client_win
, wwin
->event_mask
);
1796 XUnmapWindow(dpy
, wwin
->frame
->core
->window
);
1802 wWindowFocus(WWindow
*wwin
, WWindow
*owin
)
1807 #ifdef KEEP_XKB_LOCK_STATUS
1808 if (wPreferences
.modelock
) {
1809 XkbLockGroup(dpy
, XkbUseCoreKbd
, wwin
->frame
->languagemode
);
1811 #endif /* KEEP_XKB_LOCK_STATUS */
1813 wwin
->flags
.semi_focused
= 0;
1815 if (wwin
->flags
.is_gnustep
== 0)
1816 wFrameWindowChangeState(wwin
->frame
, WS_FOCUSED
);
1818 wwin
->flags
.focused
= 1;
1820 wWindowResetMouseGrabs(wwin
);
1822 WMPostNotificationName(WMNChangedFocus
, wwin
, (void*)True
);
1824 if (owin
== wwin
|| !owin
)
1827 nowner
= wWindowFor(wwin
->transient_for
);
1829 /* new window is a transient for the old window */
1830 if (nowner
== owin
) {
1831 owin
->flags
.semi_focused
= 1;
1832 wWindowUnfocus(nowner
);
1836 oowner
= wWindowFor(owin
->transient_for
);
1838 /* new window is owner of old window */
1839 if (wwin
== oowner
) {
1840 wWindowUnfocus(owin
);
1845 wWindowUnfocus(owin
);
1849 /* new window has same owner of old window */
1850 if (oowner
== nowner
) {
1851 /* prevent unfocusing of owner */
1852 oowner
->flags
.semi_focused
= 0;
1853 wWindowUnfocus(owin
);
1854 oowner
->flags
.semi_focused
= 1;
1859 /* nowner != NULL && oowner != nowner */
1860 nowner
->flags
.semi_focused
= 1;
1861 wWindowUnfocus(nowner
);
1862 wWindowUnfocus(owin
);
1867 wWindowUnfocus(WWindow
*wwin
)
1869 CloseWindowMenu(wwin
->screen_ptr
);
1871 if (wwin
->flags
.is_gnustep
== 0)
1872 wFrameWindowChangeState(wwin
->frame
, wwin
->flags
.semi_focused
1873 ? WS_PFOCUSED
: WS_UNFOCUSED
);
1875 if (wwin
->transient_for
!=None
1876 && wwin
->transient_for
!=wwin
->screen_ptr
->root_win
) {
1878 owner
= wWindowFor(wwin
->transient_for
);
1879 if (owner
&& owner
->flags
.semi_focused
) {
1880 owner
->flags
.semi_focused
= 0;
1881 if (owner
->flags
.mapped
|| owner
->flags
.shaded
) {
1882 wWindowUnfocus(owner
);
1883 wFrameWindowPaint(owner
->frame
);
1887 wwin
->flags
.focused
= 0;
1889 wWindowResetMouseGrabs(wwin
);
1891 WMPostNotificationName(WMNChangedFocus
, wwin
, (void*)False
);
1896 wWindowUpdateName(WWindow
*wwin
, char *newTitle
)
1903 wwin
->flags
.wm_name_changed
= 1;
1906 /* the hint was removed */
1907 title
= DEF_WINDOW_TITLE
;
1912 if (wFrameWindowChangeTitle(wwin
->frame
, title
)) {
1913 WMPostNotificationName(WMNChangedName
, wwin
, NULL
);
1920 *----------------------------------------------------------------------
1922 * wWindowConstrainSize--
1923 * Constrains size for the client window, taking the maximal size,
1924 * window resize increments and other size hints into account.
1927 * The closest size to what was given that the client window can
1930 *----------------------------------------------------------------------
1933 wWindowConstrainSize(WWindow
*wwin
, int *nwidth
, int *nheight
)
1935 int width
= *nwidth
;
1936 int height
= *nheight
;
1939 int minW
= 1, minH
= 1;
1940 int maxW
= wwin
->screen_ptr
->scr_width
*2;
1941 int maxH
= wwin
->screen_ptr
->scr_height
*2;
1942 int minAX
= -1, minAY
= -1;
1943 int maxAX
= -1, maxAY
= -1;
1947 if (wwin
->normal_hints
) {
1948 winc
= wwin
->normal_hints
->width_inc
;
1949 hinc
= wwin
->normal_hints
->height_inc
;
1950 minW
= wwin
->normal_hints
->min_width
;
1951 minH
= wwin
->normal_hints
->min_height
;
1952 maxW
= wwin
->normal_hints
->max_width
;
1953 maxH
= wwin
->normal_hints
->max_height
;
1954 if (wwin
->normal_hints
->flags
& PAspect
) {
1955 minAX
= wwin
->normal_hints
->min_aspect
.x
;
1956 minAY
= wwin
->normal_hints
->min_aspect
.y
;
1957 maxAX
= wwin
->normal_hints
->max_aspect
.x
;
1958 maxAY
= wwin
->normal_hints
->max_aspect
.y
;
1961 baseW
= wwin
->normal_hints
->base_width
;
1962 baseH
= wwin
->normal_hints
->base_height
;
1975 /* aspect ratio code borrowed from olwm */
1977 /* adjust max aspect ratio */
1978 if (!(maxAX
== 1 && maxAY
== 1) && width
* maxAY
> height
* maxAX
) {
1979 if (maxAX
> maxAY
) {
1980 height
= (width
* maxAY
) / maxAX
;
1981 if (height
> maxH
) {
1983 width
= (height
* maxAX
) / maxAY
;
1986 width
= (height
* maxAX
) / maxAY
;
1989 height
= (width
* maxAY
) / maxAX
;
1994 /* adjust min aspect ratio */
1995 if (!(minAX
== 1 && minAY
== 1) && width
* minAY
< height
* minAX
) {
1996 if (minAX
> minAY
) {
1997 height
= (width
* minAY
) / minAX
;
1998 if (height
< minH
) {
2000 width
= (height
* minAX
) / minAY
;
2003 width
= (height
* minAX
) / minAY
;
2006 height
= (width
* minAY
) / minAX
;
2013 width
= (((width
- baseW
) / winc
) * winc
) + baseW
;
2015 width
= (((width
- minW
) / winc
) * winc
) + minW
;
2019 height
= (((height
- baseH
) / hinc
) * hinc
) + baseH
;
2021 height
= (((height
- minH
) / hinc
) * hinc
) + minH
;
2024 /* broken stupid apps may cause preposterous values for these.. */
2033 wWindowCropSize(WWindow
*wwin
, int maxW
, int maxH
,
2034 int *width
, int *height
)
2036 int baseW
= 0, baseH
= 0;
2037 int winc
= 1, hinc
= 1;
2039 if (wwin
->normal_hints
) {
2040 baseW
= wwin
->normal_hints
->base_width
;
2041 baseH
= wwin
->normal_hints
->base_height
;
2043 winc
= wwin
->normal_hints
->width_inc
;
2044 hinc
= wwin
->normal_hints
->height_inc
;
2048 *width
= maxW
- (maxW
- baseW
) % winc
;
2051 *height
= maxH
- (maxH
- baseH
) % hinc
;
2056 wWindowChangeWorkspace(WWindow
*wwin
, int workspace
)
2058 WScreen
*scr
= wwin
->screen_ptr
;
2062 if (workspace
>= scr
->workspace_count
|| workspace
< 0
2063 || workspace
== wwin
->frame
->workspace
)
2066 if (workspace
!= scr
->current_workspace
) {
2067 /* Sent to other workspace. Unmap window */
2068 if ((wwin
->flags
.mapped
2069 || wwin
->flags
.shaded
2070 || (wwin
->flags
.miniaturized
&& !wPreferences
.sticky_icons
))
2071 && !IS_OMNIPRESENT(wwin
) && !wwin
->flags
.changing_workspace
) {
2073 wapp
= wApplicationOf(wwin
->main_window
);
2075 wapp
->last_workspace
= workspace
;
2077 if (wwin
->flags
.miniaturized
) {
2079 XUnmapWindow(dpy
, wwin
->icon
->core
->window
);
2080 wwin
->icon
->mapped
= 0;
2084 wSetFocusTo(scr
, NULL
);
2088 /* brought to current workspace. Map window */
2089 if (wwin
->flags
.miniaturized
&& !wPreferences
.sticky_icons
) {
2091 XMapWindow(dpy
, wwin
->icon
->core
->window
);
2092 wwin
->icon
->mapped
= 1;
2094 } else if (!wwin
->flags
.mapped
&&
2095 !(wwin
->flags
.miniaturized
|| wwin
->flags
.hidden
)) {
2099 if (!IS_OMNIPRESENT(wwin
)) {
2100 int oldWorkspace
= wwin
->frame
->workspace
;
2102 wwin
->frame
->workspace
= workspace
;
2104 WMPostNotificationName(WMNChangedWorkspace
, wwin
, (void*)oldWorkspace
);
2114 wWindowSynthConfigureNotify(WWindow
*wwin
)
2118 sevent
.type
= ConfigureNotify
;
2119 sevent
.xconfigure
.display
= dpy
;
2120 sevent
.xconfigure
.event
= wwin
->client_win
;
2121 sevent
.xconfigure
.window
= wwin
->client_win
;
2123 sevent
.xconfigure
.x
= wwin
->client
.x
;
2124 sevent
.xconfigure
.y
= wwin
->client
.y
;
2125 sevent
.xconfigure
.width
= wwin
->client
.width
;
2126 sevent
.xconfigure
.height
= wwin
->client
.height
;
2128 sevent
.xconfigure
.border_width
= wwin
->old_border_width
;
2129 if (WFLAGP(wwin
, no_titlebar
))
2130 sevent
.xconfigure
.above
= None
;
2132 sevent
.xconfigure
.above
= wwin
->frame
->titlebar
->window
;
2134 sevent
.xconfigure
.override_redirect
= False
;
2135 XSendEvent(dpy
, wwin
->client_win
, False
, StructureNotifyMask
, &sevent
);
2137 wKWMSendEventMessage(wwin
, WKWMChangedClient
);
2144 *----------------------------------------------------------------------
2145 * wWindowConfigure--
2146 * Configures the frame, decorations and client window to the
2147 * specified geometry. The geometry is not checked for validity,
2148 * wWindowConstrainSize() must be used for that.
2149 * The size parameters are for the client window, but the position is
2151 * The client window receives a ConfigureNotify event, according
2152 * to what ICCCM says.
2158 * Window size and position are changed and client window receives
2159 * a ConfigureNotify event.
2160 *----------------------------------------------------------------------
2163 wWindowConfigure(wwin
, req_x
, req_y
, req_width
, req_height
)
2165 int req_x
, req_y
; /* new position of the frame */
2166 int req_width
, req_height
; /* new size of the client */
2168 int synth_notify
= False
;
2171 resize
= (req_width
!=wwin
->client
.width
2172 || req_height
!=wwin
->client
.height
);
2174 * if the window is being moved but not resized then
2175 * send a synthetic ConfigureNotify
2177 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
) && !resize
) {
2178 synth_notify
= True
;
2181 if (WFLAGP(wwin
, dont_move_off
))
2182 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
2183 req_width
, req_height
);
2185 if (req_width
< MIN_WINDOW_SIZE
)
2186 req_width
= MIN_WINDOW_SIZE
;
2187 if (req_height
< MIN_WINDOW_SIZE
)
2188 req_height
= MIN_WINDOW_SIZE
;
2190 /* If growing, resize inner part before frame,
2191 * if shrinking, resize frame before.
2192 * This will prevent the frame (that can have a different color)
2193 * to be exposed, causing flicker */
2194 if (req_height
> wwin
->frame
->core
->height
2195 || req_width
> wwin
->frame
->core
->width
)
2196 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
2198 if (wwin
->flags
.shaded
) {
2199 wFrameWindowConfigure(wwin
->frame
, req_x
, req_y
,
2200 req_width
, wwin
->frame
->core
->height
);
2201 wwin
->old_geometry
.height
= req_height
;
2205 h
= req_height
+ wwin
->frame
->top_width
2206 + wwin
->frame
->bottom_width
;
2208 wFrameWindowConfigure(wwin
->frame
, req_x
, req_y
, req_width
, h
);
2211 if (!(req_height
> wwin
->frame
->core
->height
2212 || req_width
> wwin
->frame
->core
->width
))
2213 XResizeWindow(dpy
, wwin
->client_win
, req_width
, req_height
);
2215 wwin
->client
.x
= req_x
;
2216 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2217 wwin
->client
.width
= req_width
;
2218 wwin
->client
.height
= req_height
;
2220 wwin
->client
.x
= req_x
;
2221 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2223 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
2225 wwin
->frame_x
= req_x
;
2226 wwin
->frame_y
= req_y
;
2227 if (!WFLAGP(wwin
, no_border
)) {
2228 wwin
->client
.x
+= FRAME_BORDER_WIDTH
;
2229 wwin
->client
.y
+= FRAME_BORDER_WIDTH
;
2233 if (wShapeSupported
&& wwin
->flags
.shaped
&& resize
) {
2234 wWindowSetShape(wwin
);
2239 wWindowSynthConfigureNotify(wwin
);
2245 wWindowMove(wwin
, req_x
, req_y
)
2247 int req_x
, req_y
; /* new position of the frame */
2249 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
2250 int synth_notify
= False
;
2252 /* Send a synthetic ConfigureNotify event for every window movement. */
2253 if ((req_x
!=wwin
->frame_x
|| req_y
!=wwin
->frame_y
)) {
2254 synth_notify
= True
;
2257 /* A single synthetic ConfigureNotify event is sent at the end of
2258 * a completed (opaque) movement in moveres.c */
2261 if (WFLAGP(wwin
, dont_move_off
))
2262 wScreenBringInside(wwin
->screen_ptr
, &req_x
, &req_y
,
2263 wwin
->frame
->core
->width
, wwin
->frame
->core
->height
);
2265 wwin
->client
.x
= req_x
;
2266 wwin
->client
.y
= req_y
+ wwin
->frame
->top_width
;
2267 if (!WFLAGP(wwin
, no_border
)) {
2268 wwin
->client
.x
+= FRAME_BORDER_WIDTH
;
2269 wwin
->client
.y
+= FRAME_BORDER_WIDTH
;
2272 XMoveWindow(dpy
, wwin
->frame
->core
->window
, req_x
, req_y
);
2274 wwin
->frame_x
= req_x
;
2275 wwin
->frame_y
= req_y
;
2277 #ifdef CONFIGURE_WINDOW_WHILE_MOVING
2279 wWindowSynthConfigureNotify(wwin
);
2285 wWindowUpdateButtonImages(WWindow
*wwin
)
2287 WScreen
*scr
= wwin
->screen_ptr
;
2288 Pixmap pixmap
, mask
;
2289 WFrameWindow
*fwin
= wwin
->frame
;
2291 if (WFLAGP(wwin
, no_titlebar
))
2294 /* miniaturize button */
2296 if (!WFLAGP(wwin
, no_miniaturize_button
)) {
2297 if (wwin
->wm_gnustep_attr
2298 && wwin
->wm_gnustep_attr
->flags
& GSMiniaturizePixmapAttr
) {
2299 pixmap
= wwin
->wm_gnustep_attr
->miniaturize_pixmap
;
2301 if (wwin
->wm_gnustep_attr
->flags
&GSMiniaturizeMaskAttr
) {
2302 mask
= wwin
->wm_gnustep_attr
->miniaturize_mask
;
2307 if (fwin
->lbutton_image
2308 && (fwin
->lbutton_image
->image
!= pixmap
2309 || fwin
->lbutton_image
->mask
!= mask
)) {
2310 wPixmapDestroy(fwin
->lbutton_image
);
2311 fwin
->lbutton_image
= NULL
;
2314 if (!fwin
->lbutton_image
) {
2315 fwin
->lbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
2316 fwin
->lbutton_image
->client_owned
= 1;
2317 fwin
->lbutton_image
->client_owned_mask
= 1;
2320 if (fwin
->lbutton_image
&& !fwin
->lbutton_image
->shared
) {
2321 wPixmapDestroy(fwin
->lbutton_image
);
2323 fwin
->lbutton_image
= scr
->b_pixmaps
[WBUT_ICONIFY
];
2327 #ifdef XKB_BUTTON_HINT
2328 if (!WFLAGP(wwin
, no_language_button
)) {
2329 if (fwin
->languagebutton_image
&&
2330 !fwin
->languagebutton_image
->shared
) {
2331 wPixmapDestroy(fwin
->languagebutton_image
);
2333 fwin
->languagebutton_image
=
2334 scr
->b_pixmaps
[WBUT_XKBGROUP1
+ fwin
->languagemode
];
2340 /* redefine WFLAGP to MGFLAGP to allow broken close operation */
2341 #define MGFLAGP(wwin, FLAG) (wwin)->client_flags.FLAG
2343 if (!WFLAGP(wwin
, no_close_button
)) {
2344 if (wwin
->wm_gnustep_attr
2345 && wwin
->wm_gnustep_attr
->flags
& GSClosePixmapAttr
) {
2346 pixmap
= wwin
->wm_gnustep_attr
->close_pixmap
;
2348 if (wwin
->wm_gnustep_attr
->flags
&GSCloseMaskAttr
)
2349 mask
= wwin
->wm_gnustep_attr
->close_mask
;
2353 if (fwin
->rbutton_image
&& (fwin
->rbutton_image
->image
!= pixmap
2354 || fwin
->rbutton_image
->mask
!= mask
)) {
2355 wPixmapDestroy(fwin
->rbutton_image
);
2356 fwin
->rbutton_image
= NULL
;
2359 if (!fwin
->rbutton_image
) {
2360 fwin
->rbutton_image
= wPixmapCreate(scr
, pixmap
, mask
);
2361 fwin
->rbutton_image
->client_owned
= 1;
2362 fwin
->rbutton_image
->client_owned_mask
= 1;
2365 } else if (WFLAGP(wwin
, kill_close
)) {
2367 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2368 wPixmapDestroy(fwin
->rbutton_image
);
2370 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_KILL
];
2372 } else if (MGFLAGP(wwin
, broken_close
)) {
2374 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2375 wPixmapDestroy(fwin
->rbutton_image
);
2377 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_BROKENCLOSE
];
2381 if (fwin
->rbutton_image
&& !fwin
->rbutton_image
->shared
)
2382 wPixmapDestroy(fwin
->rbutton_image
);
2384 fwin
->rbutton_image
= scr
->b_pixmaps
[WBUT_CLOSE
];
2388 /* force buttons to be redrawn */
2389 fwin
->flags
.need_texture_change
= 1;
2390 wFrameWindowPaint(fwin
);
2395 *---------------------------------------------------------------------------
2396 * wWindowConfigureBorders--
2397 * Update window border configuration according to attribute flags.
2399 *---------------------------------------------------------------------------
2402 wWindowConfigureBorders(WWindow
*wwin
)
2408 flags
= WFF_LEFT_BUTTON
|WFF_RIGHT_BUTTON
;
2409 #ifdef XKB_BUTTON_HINT
2410 flags
|= WFF_LANGUAGE_BUTTON
;
2412 if (!WFLAGP(wwin
, no_titlebar
))
2413 flags
|= WFF_TITLEBAR
;
2414 if (!WFLAGP(wwin
, no_resizebar
))
2415 flags
|= WFF_RESIZEBAR
;
2416 if (!WFLAGP(wwin
, no_border
))
2417 flags
|= WFF_BORDER
;
2418 if (wwin
->flags
.shaded
)
2419 flags
|= WFF_IS_SHADED
;
2421 oldh
= wwin
->frame
->top_width
;
2422 wFrameWindowUpdateBorders(wwin
->frame
, flags
);
2423 if (oldh
!= wwin
->frame
->top_width
) {
2424 newy
= wwin
->frame_y
+ oldh
- wwin
->frame
->top_width
;
2426 XMoveWindow(dpy
, wwin
->client_win
, 0, wwin
->frame
->top_width
);
2427 wWindowConfigure(wwin
, wwin
->frame_x
, newy
,
2428 wwin
->client
.width
, wwin
->client
.height
);
2432 if (!WFLAGP(wwin
, no_miniaturize_button
)
2433 && wwin
->frame
->flags
.hide_left_button
)
2434 flags
|= WFF_LEFT_BUTTON
;
2436 #ifdef XKB_BUTTON_HINT
2437 if (!WFLAGP(wwin
, no_language_button
)
2438 && wwin
->frame
->flags
.hide_language_button
)
2439 flags
|= WFF_LANGUAGE_BUTTON
;
2442 if (!WFLAGP(wwin
, no_close_button
)
2443 && wwin
->frame
->flags
.hide_right_button
)
2444 flags
|= WFF_RIGHT_BUTTON
;
2447 wWindowUpdateButtonImages(wwin
);
2448 wFrameWindowShowButton(wwin
->frame
, flags
);
2452 if (WFLAGP(wwin
, no_miniaturize_button
)
2453 && !wwin
->frame
->flags
.hide_left_button
)
2454 flags
|= WFF_LEFT_BUTTON
;
2456 #ifdef XKB_BUTTON_HINT
2457 if (WFLAGP(wwin
, no_language_button
)
2458 && !wwin
->frame
->flags
.hide_language_button
)
2459 flags
|= WFF_LANGUAGE_BUTTON
;
2462 if (WFLAGP(wwin
, no_close_button
)
2463 && !wwin
->frame
->flags
.hide_right_button
)
2464 flags
|= WFF_RIGHT_BUTTON
;
2467 wFrameWindowHideButton(wwin
->frame
, flags
);
2470 if (wShapeSupported
&& wwin
->flags
.shaped
) {
2471 wWindowSetShape(wwin
);
2479 wWindowSaveState(WWindow
*wwin
)
2484 memset(data
, 0, sizeof(CARD32
)*10);
2485 data
[0] = wwin
->frame
->workspace
;
2486 data
[1] = wwin
->flags
.miniaturized
;
2487 data
[2] = wwin
->flags
.shaded
;
2488 data
[3] = wwin
->flags
.hidden
;
2489 data
[4] = wwin
->flags
.maximized
;
2490 if (wwin
->flags
.maximized
== 0) {
2491 data
[5] = wwin
->frame_x
;
2492 data
[6] = wwin
->frame_y
;
2493 data
[7] = wwin
->frame
->core
->width
;
2494 data
[8] = wwin
->frame
->core
->height
;
2496 data
[5] = wwin
->old_geometry
.x
;
2497 data
[6] = wwin
->old_geometry
.y
;
2498 data
[7] = wwin
->old_geometry
.width
;
2499 data
[8] = wwin
->old_geometry
.height
;
2502 for (i
= 0; i
< MAX_WINDOW_SHORTCUTS
; i
++) {
2503 if (wwin
->screen_ptr
->shortcutWindows
[i
] &&
2504 WMCountInArray(wwin
->screen_ptr
->shortcutWindows
[i
], wwin
))
2507 XChangeProperty(dpy
, wwin
->client_win
, _XA_WINDOWMAKER_STATE
,
2508 _XA_WINDOWMAKER_STATE
, 32, PropModeReplace
,
2509 (unsigned char *)data
, 10);
2514 getSavedState(Window window
, WSavedState
**state
)
2518 unsigned long nitems_ret
;
2519 unsigned long bytes_after_ret
;
2522 if (XGetWindowProperty(dpy
, window
, _XA_WINDOWMAKER_STATE
, 0, 10,
2523 True
, _XA_WINDOWMAKER_STATE
,
2524 &type_ret
, &fmt_ret
, &nitems_ret
, &bytes_after_ret
,
2525 (unsigned char **)&data
)!=Success
|| !data
)
2528 *state
= wmalloc(sizeof(WSavedState
));
2530 (*state
)->workspace
= data
[0];
2531 (*state
)->miniaturized
= data
[1];
2532 (*state
)->shaded
= data
[2];
2533 (*state
)->hidden
= data
[3];
2534 (*state
)->maximized
= data
[4];
2535 (*state
)->x
= data
[5];
2536 (*state
)->y
= data
[6];
2537 (*state
)->w
= data
[7];
2538 (*state
)->h
= data
[8];
2539 (*state
)->window_shortcuts
= data
[9];
2543 if (*state
&& type_ret
==_XA_WINDOWMAKER_STATE
)
2552 wWindowClearShape(WWindow
*wwin
)
2554 XShapeCombineMask(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2555 0, wwin
->frame
->top_width
, None
, ShapeSet
);
2560 wWindowSetShape(WWindow
*wwin
)
2564 #ifdef OPTIMIZE_SHAPE
2569 /* only shape is the client's */
2570 if (WFLAGP(wwin
, no_titlebar
) && WFLAGP(wwin
, no_resizebar
)) {
2574 /* Get array of rectangles describing the shape mask */
2575 rects
= XShapeGetRectangles(dpy
, wwin
->client_win
, ShapeBounding
,
2581 urec
= malloc(sizeof(XRectangle
)*(count
+2));
2587 /* insert our decoration rectangles in the rect list */
2588 memcpy(urec
, rects
, sizeof(XRectangle
)*count
);
2591 if (!WFLAGP(wwin
, no_titlebar
)) {
2593 urec
[count
].y
= -1 - wwin
->frame
->top_width
;
2594 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
2595 urec
[count
].height
= wwin
->frame
->top_width
+ 1;
2598 if (!WFLAGP(wwin
, no_resizebar
)) {
2600 urec
[count
].y
= wwin
->frame
->core
->height
2601 - wwin
->frame
->bottom_width
- wwin
->frame
->top_width
;
2602 urec
[count
].width
= wwin
->frame
->core
->width
+ 2;
2603 urec
[count
].height
= wwin
->frame
->bottom_width
+ 1;
2607 /* shape our frame window */
2608 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2609 0, wwin
->frame
->top_width
, urec
, count
,
2610 ShapeSet
, Unsorted
);
2616 #endif /* OPTIMIZE_SHAPE */
2618 if (!WFLAGP(wwin
, no_titlebar
)) {
2621 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
2622 rect
[count
].height
= wwin
->frame
->top_width
+ 1;
2625 if (!WFLAGP(wwin
, no_resizebar
)) {
2627 rect
[count
].y
= wwin
->frame
->core
->height
- wwin
->frame
->bottom_width
;
2628 rect
[count
].width
= wwin
->frame
->core
->width
+ 2;
2629 rect
[count
].height
= wwin
->frame
->bottom_width
+ 1;
2633 XShapeCombineRectangles(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2634 0, 0, rect
, count
, ShapeSet
, Unsorted
);
2636 XShapeCombineShape(dpy
, wwin
->frame
->core
->window
, ShapeBounding
,
2637 0, wwin
->frame
->top_width
, wwin
->client_win
,
2638 ShapeBounding
, (count
> 0 ? ShapeUnion
: ShapeSet
));
2643 /* ====================================================================== */
2646 getFocusMode(WWindow
*wwin
)
2650 if ((wwin
->wm_hints
) && (wwin
->wm_hints
->flags
& InputHint
)) {
2651 if (wwin
->wm_hints
->input
== True
) {
2652 if (wwin
->protocols
.TAKE_FOCUS
)
2653 mode
= WFM_LOCALLY_ACTIVE
;
2657 if (wwin
->protocols
.TAKE_FOCUS
)
2658 mode
= WFM_GLOBALLY_ACTIVE
;
2660 mode
= WFM_NO_INPUT
;
2670 wWindowSetKeyGrabs(WWindow
*wwin
)
2675 for (i
=0; i
<WKBD_LAST
; i
++) {
2676 key
= &wKeyBindings
[i
];
2678 if (key
->keycode
==0)
2680 if (key
->modifier
!=AnyModifier
) {
2681 XGrabKey(dpy
, key
->keycode
, key
->modifier
|LockMask
,
2682 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2684 /* Also grab all modifier combinations possible that include,
2685 * LockMask, ScrollLockMask and NumLockMask, so that keygrabs
2686 * work even if the NumLock/ScrollLock key is on.
2688 wHackedGrabKey(key
->keycode
, key
->modifier
,
2689 wwin
->frame
->core
->window
, True
, GrabModeAsync
,
2693 XGrabKey(dpy
, key
->keycode
, key
->modifier
,
2694 wwin
->frame
->core
->window
, True
, GrabModeAsync
, GrabModeAsync
);
2698 wRootMenuBindShortcuts(wwin
->frame
->core
->window
);
2705 wWindowResetMouseGrabs(WWindow
*wwin
)
2707 /* Mouse grabs can't be done on the client window because of
2708 * ICCCM and because clients that try to do the same will crash.
2710 * But there is a problem wich makes tbar buttons of unfocused
2711 * windows not usable as the click goes to the frame window instead
2712 * of the button itself. Must figure a way to fix that.
2715 XUngrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
);
2717 if (!WFLAGP(wwin
, no_bind_mouse
)) {
2718 /* grabs for Meta+drag */
2719 wHackedGrabButton(AnyButton
, MOD_MASK
, wwin
->client_win
,
2720 True
, ButtonPressMask
, GrabModeSync
,
2721 GrabModeAsync
, None
, None
);
2724 if (!wwin
->flags
.focused
&& !WFLAGP(wwin
, no_focusable
)
2725 && !wwin
->flags
.is_gnustep
) {
2726 /* the passive grabs to focus the window */
2727 /* if (wPreferences.focus_mode == WKF_CLICK) */
2728 XGrabButton(dpy
, AnyButton
, AnyModifier
, wwin
->client_win
,
2729 True
, ButtonPressMask
, GrabModeSync
, GrabModeAsync
,
2737 wWindowUpdateGNUstepAttr(WWindow
*wwin
, GNUstepWMAttributes
*attr
)
2739 if (attr
->flags
& GSExtraFlagsAttr
) {
2740 if (MGFLAGP(wwin
, broken_close
) !=
2741 (attr
->extra_flags
& GSDocumentEditedFlag
)) {
2742 wwin
->client_flags
.broken_close
= !MGFLAGP(wwin
, broken_close
);
2743 wWindowUpdateButtonImages(wwin
);
2750 wWindowAddSavedState(char *instance
, char *class, char *command
,
2751 pid_t pid
, WSavedState
*state
)
2753 WWindowState
*wstate
;
2755 wstate
= malloc(sizeof(WWindowState
));
2759 memset(wstate
, 0, sizeof(WWindowState
));
2762 wstate
->instance
= wstrdup(instance
);
2764 wstate
->class = wstrdup(class);
2766 wstate
->command
= wstrdup(command
);
2767 wstate
->state
= state
;
2769 wstate
->next
= windowState
;
2770 windowState
= wstate
;
2773 printf("Added WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2781 #define SAME(x, y) (((x) && (y) && !strcmp((x), (y))) || (!(x) && !(y)))
2785 wWindowGetSavedState(Window win
)
2787 char *instance
, *class, *command
=NULL
;
2788 WWindowState
*wstate
= windowState
;
2795 if (XGetCommand(dpy
, win
, &argv
, &argc
)) {
2797 command
= wtokenjoin(argv
, argc
);
2798 XFreeStringList(argv
);
2803 if (PropGetWMClass(win
, &class, &instance
)) {
2805 if (SAME(instance
, wstate
->instance
) &&
2806 SAME(class, wstate
->class) &&
2807 SAME(command
, wstate
->command
)) {
2810 wstate
= wstate
->next
;
2817 printf("Read WindowState with ID %p, for %s.%s : \"%s\"\n", wstate
, instance
,
2821 if (command
) wfree(command
);
2822 if (instance
) XFree(instance
);
2823 if (class) XFree(class);
2830 wWindowDeleteSavedState(WMagicNumber id
)
2832 WWindowState
*tmp
, *wstate
=(WWindowState
*)id
;
2834 if (!wstate
|| !windowState
)
2839 windowState
= wstate
->next
;
2841 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2842 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2844 if (wstate
->instance
) wfree(wstate
->instance
);
2845 if (wstate
->class) wfree(wstate
->class);
2846 if (wstate
->command
) wfree(wstate
->command
);
2847 wfree(wstate
->state
);
2851 if (tmp
->next
==wstate
) {
2852 tmp
->next
=wstate
->next
;
2854 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2855 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2857 if (wstate
->instance
) wfree(wstate
->instance
);
2858 if (wstate
->class) wfree(wstate
->class);
2859 if (wstate
->command
) wfree(wstate
->command
);
2860 wfree(wstate
->state
);
2871 wWindowDeleteSavedStatesForPID(pid_t pid
)
2873 WWindowState
*tmp
, *wstate
;
2879 if (tmp
->pid
== pid
) {
2880 wstate
= windowState
;
2881 windowState
= tmp
->next
;
2883 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2884 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2886 if (wstate
->instance
) wfree(wstate
->instance
);
2887 if (wstate
->class) wfree(wstate
->class);
2888 if (wstate
->command
) wfree(wstate
->command
);
2889 wfree(wstate
->state
);
2893 if (tmp
->next
->pid
==pid
) {
2895 tmp
->next
= wstate
->next
;
2897 printf("Deleted WindowState with ID %p, for %s.%s : \"%s\"\n",
2898 wstate
, wstate
->instance
, wstate
->class, wstate
->command
);
2900 if (wstate
->instance
) wfree(wstate
->instance
);
2901 if (wstate
->class) wfree(wstate
->class);
2902 if (wstate
->command
) wfree(wstate
->command
);
2903 wfree(wstate
->state
);
2914 wWindowSetOmnipresent(WWindow
*wwin
, Bool flag
)
2916 wwin
->flags
.omnipresent
= flag
;
2918 WMPostNotificationName(WMNChangedState
, wwin
, "omnipresent");
2922 /* ====================================================================== */
2925 resizebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2927 WWindow
*wwin
= data
;
2929 #ifndef NUMLOCK_HACK
2930 if ((event
->xbutton
.state
& ValidModMask
)
2931 != (event
->xbutton
.state
& ~LockMask
)) {
2932 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
2933 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
2937 event
->xbutton
.state
&= ValidModMask
;
2939 CloseWindowMenu(wwin
->screen_ptr
);
2941 if (wPreferences
.focus_mode
==WKF_CLICK
2942 && !(event
->xbutton
.state
&ControlMask
)
2943 && !WFLAGP(wwin
, no_focusable
)) {
2944 wSetFocusTo(wwin
->screen_ptr
, wwin
);
2947 if (event
->xbutton
.button
== Button1
)
2948 wRaiseFrame(wwin
->frame
->core
);
2950 if (event
->xbutton
.window
!= wwin
->frame
->resizebar
->window
) {
2951 if (XGrabPointer(dpy
, wwin
->frame
->resizebar
->window
, True
,
2952 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
2953 GrabModeAsync
, GrabModeAsync
, None
,
2954 None
, CurrentTime
)!=GrabSuccess
) {
2956 wwarning("pointer grab failed for window move");
2962 if (event
->xbutton
.state
& MOD_MASK
) {
2963 /* move the window */
2964 wMouseMoveWindow(wwin
, event
);
2965 XUngrabPointer(dpy
, CurrentTime
);
2967 wMouseResizeWindow(wwin
, event
);
2968 XUngrabPointer(dpy
, CurrentTime
);
2975 titlebarDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
2977 WWindow
*wwin
= data
;
2979 event
->xbutton
.state
&= ValidModMask
;
2981 if (event
->xbutton
.button
==Button1
) {
2982 if (event
->xbutton
.state
== 0) {
2983 if (!WFLAGP(wwin
, no_shadeable
)) {
2985 if (wwin
->flags
.shaded
)
2986 wUnshadeWindow(wwin
);
2993 if (event
->xbutton
.state
& ControlMask
)
2994 dir
|= MAX_VERTICAL
;
2996 if (event
->xbutton
.state
& ShiftMask
) {
2997 dir
|= MAX_HORIZONTAL
;
2998 if (!(event
->xbutton
.state
& ControlMask
))
2999 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3002 /* maximize window */
3003 if (dir
!=0 && !WFLAGP(wwin
, no_resizable
)) {
3004 int ndir
= dir
^ wwin
->flags
.maximized
;
3005 if (wwin
->flags
.maximized
!= 0)
3006 wUnmaximizeWindow(wwin
);
3008 wMaximizeWindow(wwin
, ndir
);
3011 } else if (event
->xbutton
.button
==Button3
) {
3012 if (event
->xbutton
.state
& MOD_MASK
) {
3013 wHideOtherApplications(wwin
);
3015 } else if (event
->xbutton
.button
==Button2
) {
3016 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3017 } else if (event
->xbutton
.button
== WINGsConfiguration
.mouseWheelUp
) {
3019 } else if (event
->xbutton
.button
== WINGsConfiguration
.mouseWheelDown
) {
3020 wUnshadeWindow(wwin
);
3026 frameMouseDown(WObjDescriptor
*desc
, XEvent
*event
)
3028 WWindow
*wwin
= desc
->parent
;
3030 event
->xbutton
.state
&= ValidModMask
;
3032 CloseWindowMenu(wwin
->screen_ptr
);
3034 if (/*wPreferences.focus_mode==WKF_CLICK
3035 &&*/ !(event
->xbutton
.state
&ControlMask
)
3036 && !WFLAGP(wwin
, no_focusable
)) {
3037 wSetFocusTo(wwin
->screen_ptr
, wwin
);
3039 if (event
->xbutton
.button
== Button1
) {
3040 wRaiseFrame(wwin
->frame
->core
);
3043 if (event
->xbutton
.state
& MOD_MASK
) {
3044 /* move the window */
3045 if (XGrabPointer(dpy
, wwin
->client_win
, False
,
3046 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3047 GrabModeAsync
, GrabModeAsync
, None
,
3048 None
, CurrentTime
)!=GrabSuccess
) {
3050 wwarning("pointer grab failed for window move");
3054 if (event
->xbutton
.button
== Button3
&& !WFLAGP(wwin
, no_resizable
))
3055 wMouseResizeWindow(wwin
, event
);
3057 wMouseMoveWindow(wwin
, event
);
3058 XUngrabPointer(dpy
, CurrentTime
);
3064 titlebarMouseDown(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3066 WWindow
*wwin
= (WWindow
*)data
;
3068 #ifndef NUMLOCK_HACK
3069 if ((event
->xbutton
.state
& ValidModMask
)
3070 != (event
->xbutton
.state
& ~LockMask
)) {
3071 wwarning(_("the NumLock, ScrollLock or similar key seems to be turned on.\n"\
3072 "Turn it off or some mouse actions and keyboard shortcuts will not work."));
3075 event
->xbutton
.state
&= ValidModMask
;
3077 CloseWindowMenu(wwin
->screen_ptr
);
3079 if (wPreferences
.focus_mode
==WKF_CLICK
3080 && !(event
->xbutton
.state
&ControlMask
)
3081 && !WFLAGP(wwin
, no_focusable
)) {
3082 wSetFocusTo(wwin
->screen_ptr
, wwin
);
3085 if (event
->xbutton
.button
== Button1
3086 || event
->xbutton
.button
== Button2
) {
3088 if (event
->xbutton
.button
== Button1
) {
3089 if (event
->xbutton
.state
& MOD_MASK
) {
3090 wLowerFrame(wwin
->frame
->core
);
3092 wRaiseFrame(wwin
->frame
->core
);
3095 if ((event
->xbutton
.state
& ShiftMask
)
3096 && !(event
->xbutton
.state
& ControlMask
)) {
3097 wSelectWindow(wwin
, !wwin
->flags
.selected
);
3100 if (event
->xbutton
.window
!= wwin
->frame
->titlebar
->window
3101 && XGrabPointer(dpy
, wwin
->frame
->titlebar
->window
, False
,
3102 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3103 GrabModeAsync
, GrabModeAsync
, None
,
3104 None
, CurrentTime
)!=GrabSuccess
) {
3106 wwarning("pointer grab failed for window move");
3111 /* move the window */
3112 wMouseMoveWindow(wwin
, event
);
3114 XUngrabPointer(dpy
, CurrentTime
);
3115 } else if (event
->xbutton
.button
== Button3
&& event
->xbutton
.state
==0
3116 && !wwin
->flags
.internal_window
3117 && !WCHECK_STATE(WSTATE_MODAL
)) {
3118 WObjDescriptor
*desc
;
3120 if (event
->xbutton
.window
!= wwin
->frame
->titlebar
->window
3121 && XGrabPointer(dpy
, wwin
->frame
->titlebar
->window
, False
,
3122 ButtonMotionMask
|ButtonReleaseMask
|ButtonPressMask
,
3123 GrabModeAsync
, GrabModeAsync
, None
,
3124 None
, CurrentTime
)!=GrabSuccess
) {
3126 wwarning("pointer grab failed for window move");
3131 OpenWindowMenu(wwin
, event
->xbutton
.x_root
,
3132 wwin
->frame_y
+wwin
->frame
->top_width
, False
);
3134 /* allow drag select */
3135 desc
= &wwin
->screen_ptr
->window_menu
->menu
->descriptor
;
3136 event
->xany
.send_event
= True
;
3137 (*desc
->handle_mousedown
)(desc
, event
);
3139 XUngrabPointer(dpy
, CurrentTime
);
3146 windowCloseClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3148 WWindow
*wwin
= data
;
3150 event
->xbutton
.state
&= ValidModMask
;
3152 CloseWindowMenu(wwin
->screen_ptr
);
3154 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3157 /* if control-click, kill the client */
3158 if (event
->xbutton
.state
& ControlMask
) {
3162 if (wwin
->flags
.olwm_push_pin_out
) {
3164 wwin
->flags
.olwm_push_pin_out
= 0;
3166 wOLWMChangePushpinState(wwin
, True
);
3168 wFrameWindowUpdatePushButton(wwin
->frame
, False
);
3173 if (wwin
->protocols
.DELETE_WINDOW
&& event
->xbutton
.state
==0) {
3174 /* send delete message */
3175 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
3182 windowCloseDblClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3184 WWindow
*wwin
= data
;
3186 CloseWindowMenu(wwin
->screen_ptr
);
3188 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3191 /* send delete message */
3192 if (wwin
->protocols
.DELETE_WINDOW
) {
3193 wClientSendProtocol(wwin
, _XA_WM_DELETE_WINDOW
, LastTimestamp
);
3200 #ifdef XKB_BUTTON_HINT
3202 windowLanguageClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3204 WWindow
*wwin
= data
;
3205 WFrameWindow
*fwin
= wwin
->frame
;
3206 WScreen
*scr
= fwin
->screen_ptr
;
3207 XkbStateRec staterec
;
3210 if (event
->xbutton
.button
!= Button1
&& event
->xbutton
.button
!= Button3
)
3212 tl
= wwin
->frame
->languagemode
;
3213 wwin
->frame
->languagemode
= wwin
->frame
->last_languagemode
;
3214 wwin
->frame
->last_languagemode
= tl
;
3215 wSetFocusTo(scr
, wwin
);
3216 wwin
->frame
->languagebutton_image
=
3217 wwin
->frame
->screen_ptr
->b_pixmaps
[WBUT_XKBGROUP1
+
3218 wwin
->frame
->languagemode
];
3219 wFrameWindowUpdateLanguageButton(wwin
->frame
);
3220 if (event
->xbutton
.button
== Button3
)
3222 wRaiseFrame(fwin
->core
);
3228 windowIconifyClick(WCoreWindow
*sender
, void *data
, XEvent
*event
)
3230 WWindow
*wwin
= data
;
3232 event
->xbutton
.state
&= ValidModMask
;
3234 CloseWindowMenu(wwin
->screen_ptr
);
3236 if (event
->xbutton
.button
< Button1
|| event
->xbutton
.button
> Button3
)
3239 if (wwin
->protocols
.MINIATURIZE_WINDOW
&& event
->xbutton
.state
==0) {
3240 wClientSendProtocol(wwin
, _XA_GNUSTEP_WM_MINIATURIZE_WINDOW
,
3244 if ((event
->xbutton
.state
& ControlMask
) ||
3245 (event
->xbutton
.button
== Button3
)) {
3247 wapp
= wApplicationOf(wwin
->main_window
);
3248 if (wapp
&& !WFLAGP(wwin
, no_appicon
))
3249 wHideApplication(wapp
);
3250 } else if (event
->xbutton
.state
==0) {
3251 wIconifyWindow(wwin
);