From 569fbff07cc3956e2c05e321856213dfbf0c26d0 Mon Sep 17 00:00:00 2001 From: Bad Sector Date: Sun, 14 Jan 2018 08:59:42 +0200 Subject: [PATCH] wmaker: Add new advanced option to ignore decoration changes from clients. This adds an option (IgnoreDecorationChanges in plist) for windows to ignore any requests from the clients for changing decorations. Since the default state for any window pre-request is to have all decorations visible this basically means that applications cannot hide any of the titlebar, sizing bar, titlebar buttons, etc and any hint that causes these elements to be hidden will be followed by a restoration if this option is set. This is useful for broken clients (e.g. Steam) and clients that force subpar client side decorations. It is basically a per-window setting of the global advanced option to ignore Gtk hints, except that it also applies to non-Gtk applications. --- src/wdefaults.c | 5 +++++ src/window.c | 14 ++++++++++++++ src/window.h | 2 ++ src/winspector.c | 6 +++++- src/wmspec.c | 11 +++++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/wdefaults.c b/src/wdefaults.c index b57b0167..7aad3db5 100644 --- a/src/wdefaults.c +++ b/src/wdefaults.c @@ -82,6 +82,7 @@ static WMPropList *ASharedAppIcon; /* app */ static WMPropList *ANoLanguageButton; #endif static WMPropList *AStartWorkspace; +static WMPropList *AIgnoreDecorationChanges; static WMPropList *AIcon; static WMPropList *AnyWindow; static WMPropList *No; @@ -121,6 +122,7 @@ static void init_wdefaults(void) #endif AStartWorkspace = WMCreatePLString("StartWorkspace"); + AIgnoreDecorationChanges = WMCreatePLString("IgnoreDecorationChanges"); AnyWindow = WMCreatePLString("*"); No = WMCreatePLString("No"); @@ -301,6 +303,9 @@ void wDefaultFillAttributes(const char *instance, const char *class, value = get_value(dw, dc, dn, da, AFullMaximize, No, useGlobalDefault); APPLY_VAL(value, full_maximize, AFullMaximize); + value = get_value(dw, dc, dn, da, AIgnoreDecorationChanges, No, useGlobalDefault); + APPLY_VAL(value, ignore_decoration_changes, AIgnoreDecorationChanges); + #ifdef XKB_BUTTON_HINT value = get_value(dw, dc, dn, da, ANoLanguageButton, No, useGlobalDefault); APPLY_VAL(value, no_language_button, ANoLanguageButton); diff --git a/src/window.c b/src/window.c index d1e351ef..cb4ff4e7 100644 --- a/src/window.c +++ b/src/window.c @@ -412,6 +412,20 @@ void wWindowSetupInitialAttributes(WWindow *wwin, int *level, int *workspace) */ wDefaultFillAttributes(wwin->wm_instance, wwin->wm_class, &wwin->user_flags, &wwin->defined_user_flags, False); + + /* Restore decoration if the user has enabled the + * IgnoreDecorationChanges option */ + if (wwin->user_flags.ignore_decoration_changes) { + WSETUFLAG(wwin, no_titlebar, 0); + WSETUFLAG(wwin, no_resizable, 0); + WSETUFLAG(wwin, no_miniaturizable, 0); + WSETUFLAG(wwin, no_resizebar, 0); + WSETUFLAG(wwin, no_close_button, 0); + WSETUFLAG(wwin, no_miniaturize_button, 0); + WSETUFLAG(wwin, no_border, 0); + WSETUFLAG(wwin, no_movable, 0); + } + /* * Sanity checks for attributes that depend on other attributes */ diff --git a/src/window.h b/src/window.h index 1a4de2cb..6decb9b4 100644 --- a/src/window.h +++ b/src/window.h @@ -142,6 +142,8 @@ typedef struct { * generate their own appicons and for apps that have no_appicon=1 */ unsigned int emulate_appicon:1; + /* Ignore any changes to the decoration elements (titlebar, etc) */ + unsigned int ignore_decoration_changes:1; } WWindowAttributes; diff --git a/src/winspector.c b/src/winspector.c index e3d8f7f1..4f12e5ab 100644 --- a/src/winspector.c +++ b/src/winspector.c @@ -156,7 +156,11 @@ static const struct { { "NoMiniaturizable", { .no_miniaturizable = 1 }, N_("Do not let it be minimized"), N_("Do not let the window of this application be\n" - "minimized.\n") } + "minimized.\n") }, + + { "IgnoreDecorationChanges", { .ignore_decoration_changes = 1 }, N_("Ignore decoration changes"), + N_("Ignore any request from the application to change\n" + "window decorations (like hiding the titlebar).\n") } #ifdef XKB_BUTTON_HINT ,{ "NoLanguageButton", { .no_language_button = 1 }, N_("Disable language button"), diff --git a/src/wmspec.c b/src/wmspec.c index 0249c642..f6e74378 100644 --- a/src/wmspec.c +++ b/src/wmspec.c @@ -1325,6 +1325,17 @@ static Bool handleWindowType(WWindow *wwin, Atom type, int *layer) ret = False; } + /* Restore decoration if the user has enabled the + * IgnoreDecorationChanges option */ + if (WFLAGP(wwin, ignore_decoration_changes)) { + wwin->client_flags.no_titlebar = 0; + wwin->client_flags.no_resizable = 0; + wwin->client_flags.no_miniaturizable = 0; + wwin->client_flags.no_resizebar = 0; + wwin->client_flags.no_border = 0; + wwin->client_flags.no_movable = 0; + } + wwin->type = type; *layer = getWindowLayer(wwin);