From f1fe336ceadeeadb9cf56efb11d9d3d48c92fc51 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sat, 12 May 2007 20:36:38 +0000
Subject: changed interpretation of maximize horz/vert on a maximized window

---
 ChangeLog     |  3 +++
 src/Window.cc | 50 ++++++++++++++------------------------------------
 2 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 269cef2..49a29d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,9 @@
  (Format: Year/Month/Day)
 Changes for 1.0.0:
 *07/05/12:
+   * Changed interpretation of Horizontal/Vertical maximization of a window that
+     is already maximized (Mark)
+     Window.cc
    * Fixed tabs disappearing with [Deco] {TAB} and tabs in titlebar (Mark)
      Window.cc Screen.cc
 *07/05/04:
diff --git a/src/Window.cc b/src/Window.cc
index 87d8d15..9f79649 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -1611,7 +1611,8 @@ void FluxboxWindow::setFullscreen(bool flag) {
 */
 void FluxboxWindow::maximize(int type) {
 
-    if (isFullscreen())
+    // doesn't make sense to maximize
+    if (isFullscreen() || type == MAX_NONE)
         return;
 
     if (isIconic())
@@ -1640,26 +1641,11 @@ void FluxboxWindow::maximize(int type) {
     // Worst case being that some action will toggle the wrong way, but
     // we still won't lose the state in that case.
 
-    // NOTE: There is one option to the way this works - what it does when
-    // fully maximised and maximise(vert, horz) is selected.
-    // There are 2 options here - either:
-    // 1) maximiseVertical results in a vertically (not horz) maximised window, or
-    // 2) " toggles vertical maximisation, thus resulting in a horizontally
-    //      maximised window.
-    //
-    // The current implementation uses style 1, to change this, removed the
-    // item corresponding to the [[ ]] comment
-
     // toggle maximize vertically?
     // when _don't_ we want to toggle?
-    // - type is horizontal maximise, [[and we aren't fully maximised]] or
-    // - [[ type is vertical maximise and we are fully maximised ]]
-    // - type is none and we are not vertically maximised, or
-    // - type is full and we are not horizontally maximised, but already vertically
-    if (!(type == MAX_HORZ && orig_max != MAX_FULL ||
-          type == MAX_VERT && orig_max == MAX_FULL ||
-          type == MAX_NONE && !(orig_max & MAX_VERT) ||
-          type == MAX_FULL && orig_max == MAX_VERT)) {
+    // - type is horizontal maximise, or
+    // - type is full and we are not maximised horz but already vertically
+    if (type != MAX_HORZ && !(type == MAX_FULL && orig_max == MAX_VERT)) {
         // already maximized in that direction?
         if (orig_max & MAX_VERT) {
             new_y = m_old_pos_y;
@@ -1678,10 +1664,7 @@ void FluxboxWindow::maximize(int type) {
     }
 
     // maximize horizontally?
-    if (!(type == MAX_VERT && orig_max != MAX_FULL ||
-          type == MAX_HORZ && orig_max == MAX_FULL ||
-          type == MAX_NONE && !(orig_max & MAX_HORZ) ||
-          type == MAX_FULL && orig_max == MAX_HORZ)) {
+    if (type != MAX_VERT && !(type == MAX_FULL && orig_max == MAX_HORZ)) {
         // already maximized in that direction?
         if (orig_max & MAX_HORZ) {
             new_x = m_old_pos_x;
@@ -1717,6 +1700,7 @@ void FluxboxWindow::maximize(int type) {
     // notify listeners that we changed state
     stateSig().notify();
 }
+
 /**
  * Maximize window horizontal
  */
@@ -3738,22 +3722,16 @@ void FluxboxWindow::changeBlackboxHints(const BlackboxHints &net) {
             want_max |= MAX_HORZ;
 
         if (want_max == MAX_NONE && maximized != MAX_NONE) {
-            maximize(MAX_NONE);
+            maximize(maximized);
         } else if (want_max == MAX_FULL && maximized != MAX_FULL) {
             maximize(MAX_FULL);
-            // horz and vert are a little trickier to morph
-        }
-            // to toggle vert
+        } else {
             // either we want vert and aren't
-            // or we want horizontal, and are vertically (or full) at present
-        if (want_max == MAX_VERT && !(maximized & MAX_VERT) ||
-            want_max == MAX_HORZ && (maximized & MAX_VERT)) {
-            maximize(MAX_VERT);
-        }
-        // note that if we want horz, it WONT be vert any more from above
-        if (want_max == MAX_HORZ && !(maximized & MAX_HORZ) ||
-            want_max == MAX_VERT && (maximized & MAX_HORZ)) {
-            maximize(MAX_HORZ);
+            // or we want horizontal and aren't
+            if (want_max == MAX_VERT ^ (bool)(maximized & MAX_VERT))
+                maximize(MAX_VERT);
+            if (want_max == MAX_HORZ ^ (bool)(maximized & MAX_HORZ))
+                maximize(MAX_HORZ);
         }
     }
 
-- 
cgit v0.11.2