Fix double click on title bar maximize.

Improvements, made ​​some changes, this fix works in master branch.

Att,

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

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

diff --git a/WPrefs.app/Expert.c b/WPrefs.app/Expert.c
index d82bc6f..0d27599 100644
--- a/WPrefs.app/Expert.c
+++ b/WPrefs.app/Expert.c
@@ -70,6 +70,8 @@ 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."),
diff --git a/src/WindowMaker.h b/src/WindowMaker.h
index ee6dbf9..9ec331a 100644
--- a/src/WindowMaker.h
+++ b/src/WindowMaker.h
@@ -425,6 +425,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 52fa64b..9d5551a 100644
--- a/src/defaults.c
+++ b/src/defaults.c
@@ -450,6 +450,8 @@ WDefaultEntry optionList[] = {
 	    &wPreferences.dont_blink, getBool, NULL, NULL, NULL},
 	{"SingleClickLaunch",	"NO",	NULL,
 	    &wPreferences.single_click, 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 47d280c..faab858 100644
--- a/src/window.c
+++ b/src/window.c
@@ -2701,14 +2701,25 @@ 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) 
+                        wUnmaximizeWindow(wwin);
+                else
+			handleMaximize(wwin, 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