From 6e2075f3dfb7c9f8ca7ac447d47c715b945dd9c0 Mon Sep 17 00:00:00 2001 From: Alexander Komarov Date: Mon, 10 Aug 2020 13:47:23 +0300 Subject: [PATCH] Double click on titlebar maximize a window to fullscreen --- WPrefs.app/Expert.c | 5 ++++- src/WindowMaker.h | 1 + src/defaults.c | 4 +++- src/window.c | 22 ++++++++++++++++++---- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c index f2cbe09c..b1a8e9bd 100644 --- a/WPrefs.app/Expert.c +++ b/WPrefs.app/Expert.c @@ -113,7 +113,10 @@ static const struct { /* default: */ False, OPTION_WMAKER, "OpenTransientOnOwnerWorkspace" }, { N_("Wrap dock-attached icons around the screen edges."), - /* default: */ True, OPTION_WMAKER, "WrapAppiconsInDock" } + /* default: */ True, OPTION_WMAKER, "WrapAppiconsInDock" }, + + { N_("Double click on titlebar maximize a window to full screen."), + /* default: */ False, OPTION_WMAKER, "DbClickFullScreen" } }; diff --git a/src/WindowMaker.h b/src/WindowMaker.h index 4b718ec4..b4f3a885 100644 --- a/src/WindowMaker.h +++ b/src/WindowMaker.h @@ -453,6 +453,7 @@ extern struct WPreferences { int history_lines; /* history of "Run..." dialog */ char cycle_active_head_only; /* Cycle only windows on the active head */ char cycle_ignore_minimized; /* Ignore minimized windows when cycling */ + char double_click_fullscreen; /* Double click on titlebar maximize a window to full screen*/ char strict_windoze_cycle; /* don't close switch panel when shift is released */ char panel_only_open; /* Only open the switch panel; don't switch */ int minipreview_size; /* Size of Mini-Previews in pixels */ diff --git a/src/defaults.c b/src/defaults.c index 3caa5047..11c438f2 100644 --- a/src/defaults.c +++ b/src/defaults.c @@ -825,7 +825,9 @@ WDefaultEntry optionList[] = { {"CycleActiveHeadOnly", "NO", NULL, &wPreferences.cycle_active_head_only, getBool, NULL, NULL, NULL}, {"CycleIgnoreMinimized", "NO", NULL, - &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL} + &wPreferences.cycle_ignore_minimized, getBool, NULL, NULL, NULL}, + {"DbClickFullScreen", "NO", NULL, + &wPreferences.double_click_fullscreen, getBool, NULL, NULL, NULL} }; static void initDefaults(void) diff --git a/src/window.c b/src/window.c index a276f483..bf6e6e39 100644 --- a/src/window.c +++ b/src/window.c @@ -2849,15 +2849,28 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event) event->xbutton.state &= w_global.shortcut.modifiers_mask; - if (event->xbutton.button == Button1) { - if (event->xbutton.state == 0) { - if (!WFLAGP(wwin, no_shadeable)) { + if (event->xbutton.button == Button1 ) { + if (event->xbutton.state == 0 ) { + if (!WFLAGP(wwin, no_shadeable) & !wPreferences.double_click_fullscreen) { /* shade window */ if (wwin->flags.shaded) wUnshadeWindow(wwin); else wShadeWindow(wwin); - } + } + } + + if (wPreferences.double_click_fullscreen){ + int dir = 0; + if (event->xbutton.state == 0) { + /* maximize window full screen*/ + dir |= (MAX_VERTICAL|MAX_HORIZONTAL); + int ndir = dir ^ wwin->flags.maximized; + wMaximizeWindow(wwin, ndir, wGetHeadForWindow(wwin)); + + } + + } else { int dir = 0; @@ -2871,6 +2884,7 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event) } /* maximize window */ + if (dir != 0 && IS_RESIZABLE(wwin)) { int ndir = dir ^ wwin->flags.maximized;