Fix double click on title bar maximize.

This is annoying, most window managers, by clicking on the title bar maximizes and minimizes. In WPrefs.app added an option to fix this.

Att,

Leandro Vital
>From 424c58aa58dedc5b9dd5719d986b22a0ee5a2568 Mon Sep 17 00:00:00 2001
From: Leandro Vital <leandro.vi...@yahoo.com.br>
Date: Mon, 20 May 2013 20:04:14 -0300
Subject: [PATCH] Fix double click on title bar maximize

---
 WPrefs.app/Expert.c |  3 +++
 src/WindowMaker.h   |  1 +
 src/defaults.c      |  2 ++
 src/window.c        | 31 +++++++++++++++++++++++--------
 4 files changed, 29 insertions(+), 8 deletions(-)

diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c
index e170bbd..1033b14 100644
--- a/WPrefs.app/Expert.c
+++ b/WPrefs.app/Expert.c
@@ -71,6 +71,9 @@ static const struct {
 	{ N_("Highlight the icon of the application when it has the focus."),
 	  /* default: */ True, OPTION_WMAKER, "HighlightActiveApp" },
 
+        { N_("Double click on title bar maximize."),
+          /* default: */ True, OPTION_WMAKER, "DCMaximize" },
+
 #ifdef XKB_MODELOCK
 	{ N_("Enable keyboard language switch button in window titlebars."),
 	  /* default: */ False, OPTION_WMAKER, "KbdModeLock" }
diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index bc034d9..8544693 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -415,6 +415,7 @@ typedef struct WPreferences {
     unsigned int workspace_border_size; /* Size in pixels of the workspace border */
     char workspace_border_position;     /* Where to leave a workspace border */
     char single_click;                  /* single click to lauch applications */
+    char dc_maximize;                   /* double click on title bar maximize */
     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 */
diff --git a/src/defaults.c b/src/defaults.c
index 8d2fe22..e4fd2b5 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -476,6 +476,8 @@ WDefaultEntry optionList[] = {
 	    &wPreferences.single_click, getBool, NULL, NULL, NULL},
 	{"StrictWindozeCycle",	"YES",	NULL,
 	    &wPreferences.strict_windoze_cycle, getBool, NULL, NULL, NULL},
+	{"DCMaximize", "YES",		NULL,
+	   &wPreferences.dc_maximize, getBool, NULL},
 
 	/* style options */
 
diff --git a/src/window.c b/src/window.c
index 9ac5e78..077f236 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2728,14 +2728,29 @@ static void titlebarDblClick(WCoreWindow *sender, void *data, XEvent *event)
 
 	if (event->xbutton.button == Button1) {
 		if (event->xbutton.state == 0) {
-			if (!WFLAGP(wwin, no_shadeable)) {
-				/* shade window */
-				if (wwin->flags.shaded)
-					wUnshadeWindow(wwin);
-				else
-					wShadeWindow(wwin);
-			}
-		} else {
+	    /* check preferences, maximize or shade */
+            if (wPreferences.dc_maximize) {
+		if (!WFLAGP(wwin, no_resizable)) {
+		    /* maximize window */
+                    if (wwin->flags.maximized != 0) {
+                        wUnmaximizeWindow(wwin);
+                        wwin->flags.maximized = 0;
+                    }
+		    else {
+                        wMaximizeWindow(wwin, MAX_VERTICAL|MAX_HORIZONTAL);
+                        wwin->flags.maximized = MAX_VERTICAL|MAX_HORIZONTAL;
+                    }
+                }
+	    } else {
+	        if (!WFLAGP(wwin, no_shadeable)) {
+		    /* shade window */
+		    if (wwin->flags.shaded)
+		        wUnshadeWindow(wwin);
+		    else
+		        wShadeWindow(wwin);
+	        }
+            }
+        } else {
 			int dir = 0;
 
 			if (event->xbutton.state & ControlMask)
-- 
1.8.1.4

Reply via email to