From fd1dd9c7eae188aa67bb3592b4f0037bdafc8ef9 Mon Sep 17 00:00:00 2001 From: Christophe CURIS Date: Sun, 10 May 2015 19:56:03 +0200 Subject: [PATCH] wmaker: fix misuse of 'user_flags' instead of 'client_flags' for window attributes The structure containing the information on windows contains 2 sets of attributes, client_flags which contains those asked by the application through Hints (like MWM Hints and others) and user_flags which was defined to allow the user to override them. Unfortunately many places of the code was using the wrong structure to save the attributes to (for example by using the WSETUFLAG macro) which was merely ok as the user_flags have priority, but when we want to provide a clean consistent behaviour to users, we need to get things in the right place. Signed-off-by: Christophe CURIS --- src/client.c | 12 +++++------ src/motif.c | 56 +++++++++++++++++++++++++----------------------- src/window.c | 38 +++++++++++++++++--------------- src/winspector.c | 4 ++-- 4 files changed, 58 insertions(+), 52 deletions(-) diff --git a/src/client.c b/src/client.c index 9af875c1..92912b95 100644 --- a/src/client.c +++ b/src/client.c @@ -524,14 +524,14 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) wwin->transient_for = new_owner; if (new_owner == None) { if (WFLAGP(wwin, no_miniaturizable)) { - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_miniaturize_button, 0); + wwin->client_flags.no_miniaturizable = 0; + wwin->client_flags.no_miniaturize_button = 0; if (wwin->frame) wWindowConfigureBorders(wwin); } } else if (!WFLAGP(wwin, no_miniaturizable)) { - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); + wwin->client_flags.no_miniaturizable = 1; + wwin->client_flags.no_miniaturize_button = 1; if (wwin->frame) wWindowConfigureBorders(wwin); } @@ -544,7 +544,7 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) PropGetProtocols(wwin->client_win, &wwin->protocols); - WSETUFLAG(wwin, kill_close, !wwin->protocols.DELETE_WINDOW); + wwin->client_flags.kill_close = !wwin->protocols.DELETE_WINDOW; if (wwin->frame) wWindowUpdateButtonImages(wwin); @@ -572,7 +572,7 @@ void wClientCheckProperty(WWindow * wwin, XPropertyEvent * event) wApplicationDestroy(wapp); while (foo) { if (foo->fake_group && foo->fake_group == fPtr) { - WSETUFLAG(foo, shared_appicon, 0); + foo->client_flags.shared_appicon = 0; foo->fake_group = NULL; if (foo->group_id != None) diff --git a/src/motif.c b/src/motif.c index b649f829..65370387 100644 --- a/src/motif.c +++ b/src/motif.c @@ -75,19 +75,21 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) */ if (mwm_hints->flags & MWM_HINTS_DECORATIONS) { - WSETUFLAG(wwin, no_titlebar, 1); - WSETUFLAG(wwin, no_close_button, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); - WSETUFLAG(wwin, no_resizebar, 1); + wwin->client_flags.no_titlebar = 1; + wwin->client_flags.no_close_button = 1; + wwin->client_flags.no_miniaturize_button = 1; + wwin->client_flags.no_resizebar = 1; + wwin->client_flags.no_border = 1; if (mwm_hints->decorations & MWM_DECOR_ALL) { - WSETUFLAG(wwin, no_titlebar, 0); - WSETUFLAG(wwin, no_close_button, 0); - WSETUFLAG(wwin, no_closable, 0); - WSETUFLAG(wwin, no_miniaturize_button, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_resizebar, 0); - WSETUFLAG(wwin, no_resizable, 0); + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_close_button = 0; + wwin->client_flags.no_closable = 0; + wwin->client_flags.no_miniaturize_button = 0; + wwin->client_flags.no_miniaturizable = 0; + wwin->client_flags.no_resizebar = 0; + wwin->client_flags.no_resizable = 0; + wwin->client_flags.no_border = 0; } if (mwm_hints->decorations & MWM_DECOR_BORDER) { @@ -101,12 +103,12 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) } if (mwm_hints->decorations & MWM_DECOR_RESIZEH) - WSETUFLAG(wwin, no_resizebar, 0); + wwin->client_flags.no_resizebar = 0; if (mwm_hints->decorations & MWM_DECOR_TITLE) { - WSETUFLAG(wwin, no_titlebar, 0); - WSETUFLAG(wwin, no_close_button, 0); - WSETUFLAG(wwin, no_closable, 0); + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_close_button = 0; + wwin->client_flags.no_closable = 0; } if (mwm_hints->decorations * MWM_DECOR_MENU) { @@ -119,8 +121,8 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) } if (mwm_hints->decorations & MWM_DECOR_MINIMIZE) { - WSETUFLAG(wwin, no_miniaturize_button, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); + wwin->client_flags.no_miniaturize_button = 0; + wwin->client_flags.no_miniaturizable = 0; } if (mwm_hints->decorations & MWM_DECOR_MAXIMIZE) { @@ -132,17 +134,17 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) } if (mwm_hints->flags & MWM_HINTS_FUNCTIONS) { - WSETUFLAG(wwin, no_closable, 1); - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_resizable, 1); + wwin->client_flags.no_closable = 1; + wwin->client_flags.no_miniaturizable = 1; + wwin->client_flags.no_resizable = 1; if (mwm_hints->functions & MWM_FUNC_ALL) { - WSETUFLAG(wwin, no_closable, 0); - WSETUFLAG(wwin, no_miniaturizable, 0); - WSETUFLAG(wwin, no_resizable, 0); + wwin->client_flags.no_closable = 0; + wwin->client_flags.no_miniaturizable = 0; + wwin->client_flags.no_resizable = 0; } if (mwm_hints->functions & MWM_FUNC_RESIZE) - WSETUFLAG(wwin, no_resizable, 0); + wwin->client_flags.no_resizable = 0; if (mwm_hints->functions & MWM_FUNC_MOVE) { /* @@ -152,14 +154,14 @@ static void setupMWMHints(WWindow *wwin, MWMHints *mwm_hints) } if (mwm_hints->functions & MWM_FUNC_MINIMIZE) - WSETUFLAG(wwin, no_miniaturizable, 0); + wwin->client_flags.no_miniaturizable = 0; if (mwm_hints->functions & MWM_FUNC_MAXIMIZE) { /* a window must be resizable to be maximizable */ - WSETUFLAG(wwin, no_resizable, 0); + wwin->client_flags.no_resizable = 0; } if (mwm_hints->functions & MWM_FUNC_CLOSE) - WSETUFLAG(wwin, no_closable, 0); + wwin->client_flags.no_closable = 0; } } diff --git a/src/window.c b/src/window.c index 7cbad9cf..b1cbd30f 100644 --- a/src/window.c +++ b/src/window.c @@ -293,7 +293,9 @@ void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) WScreen *scr = wwin->screen_ptr; /* sets global default stuff */ - wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->client_flags, NULL, True); + wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->user_flags, NULL, True); + wwin->defined_user_flags = wwin->user_flags; + /* * Decoration setting is done in this precedence (lower to higher) * - use global default in the resource database @@ -302,25 +304,25 @@ void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) * - set hints specified for the app in the resource DB * */ - WSETUFLAG(wwin, broken_close, 0); + wwin->client_flags.broken_close = 0; if (wwin->protocols.DELETE_WINDOW) - WSETUFLAG(wwin, kill_close, 0); + wwin->client_flags.kill_close = 0; else - WSETUFLAG(wwin, kill_close, 1); + wwin->client_flags.kill_close = 1; /* transients can't be iconified or maximized */ if (wwin->transient_for != None && wwin->transient_for != scr->root_win) { - WSETUFLAG(wwin, no_miniaturizable, 1); - WSETUFLAG(wwin, no_miniaturize_button, 1); + wwin->client_flags.no_miniaturizable = 1; + wwin->client_flags.no_miniaturize_button = 1; } /* if the window can't be resized, remove the resizebar */ if (wwin->normal_hints->flags & (PMinSize | PMaxSize) && (wwin->normal_hints->min_width == wwin->normal_hints->max_width) && (wwin->normal_hints->min_height == wwin->normal_hints->max_height)) { - WSETUFLAG(wwin, no_resizable, 1); - WSETUFLAG(wwin, no_resizebar, 1); + wwin->client_flags.no_resizable = 1; + wwin->client_flags.no_resizebar = 1; } /* set GNUstep window attributes */ @@ -401,7 +403,9 @@ void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) && wwin->user_flags.floating && wwin->defined_user_flags.floating) wwin->user_flags.sunken = 0; - WSETUFLAG(wwin, no_shadeable, WFLAGP(wwin, no_titlebar)); + /* A window that does not have a title cannot be Shaded and we don't let user override this */ + wwin->client_flags.no_shadeable = WFLAGP(wwin, no_titlebar); + wwin->defined_user_flags.no_shadeable = 0; /* windows that have takefocus=False shouldn't take focus at all */ if (wwin->focus_mode == WFM_NO_INPUT) @@ -724,22 +728,22 @@ WWindow *wManageWindow(WScreen *scr, Window window) wwin->orig_main_window = wwin->main_window; if (wwin->flags.is_gnustep) - WSETUFLAG(wwin, shared_appicon, 0); + wwin->client_flags.shared_appicon = 0; if (wwin->main_window) { XTextProperty text_prop; if (XGetTextProperty(dpy, wwin->main_window, &text_prop, w_global.atom.wmaker.menu)) - WSETUFLAG(wwin, shared_appicon, 0); + wwin->client_flags.shared_appicon = 0; } if (wwin->flags.is_dockapp) - WSETUFLAG(wwin, shared_appicon, 0); + wwin->client_flags.shared_appicon = 0; if (wwin->main_window) { WApplication *app = wApplicationOf(wwin->main_window); if (app && app->app_icon) - WSETUFLAG(wwin, shared_appicon, 0); + wwin->client_flags.shared_appicon = 0; } if (!withdraw && wwin->main_window && WFLAGP(wwin, shared_appicon)) { @@ -1320,10 +1324,10 @@ WWindow *wManageInternalWindow(WScreen *scr, Window window, Window owner, wwin->flags.internal_window = 1; - WSETUFLAG(wwin, omnipresent, 1); - WSETUFLAG(wwin, no_shadeable, 1); - WSETUFLAG(wwin, no_resizable, 1); - WSETUFLAG(wwin, no_miniaturizable, 1); + wwin->client_flags.omnipresent = 1; + wwin->client_flags.no_shadeable = 1; + wwin->client_flags.no_resizable = 1; + wwin->client_flags.no_miniaturizable = 1; wwin->focus_mode = WFM_PASSIVE; wwin->client_win = window; diff --git a/src/winspector.c b/src/winspector.c index f6b1d5c1..0d6d57d9 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -1241,8 +1241,8 @@ static InspectorPanel *createInspectorForWindow(WWindow *wwin, int xpos, int ypo /* kluge to know who should get the key events */ panel->frame->client_leader = WMWidgetXID(panel->win); - WSETUFLAG(panel->frame, no_closable, 0); - WSETUFLAG(panel->frame, no_close_button, 0); + panel->frame->client_flags.no_closable = 0; + panel->frame->client_flags.no_close_button = 0; wWindowUpdateButtonImages(panel->frame); wFrameWindowShowButton(panel->frame->frame, WFF_RIGHT_BUTTON); panel->frame->frame->on_click_right = destroyInspector;