From cbc1075dde0276956aca1753a229097bcc7bac87 Mon Sep 17 00:00:00 2001
From: Mark Tiefenbruck <mark@fluxbox.org>
Date: Wed, 27 Aug 2008 13:47:16 -0400
Subject: move decoration handling for non-resizable windows to SizeHint class

---
 src/Window.cc      | 23 +++++------------------
 src/WindowState.cc |  8 +++++++-
 src/WindowState.hh |  2 ++
 3 files changed, 14 insertions(+), 19 deletions(-)

diff --git a/src/Window.cc b/src/Window.cc
index 25a6baf..98c10f4 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -451,11 +451,8 @@ void FluxboxWindow::init() {
         }
     }
 
-    if (m_client->maxWidth() != 0 && m_client->maxHeight() != 0 &&
-        m_client->maxWidth() <= m_client->minWidth() &&
-        m_client->maxHeight() <= m_client->minHeight()) {
-        decorations.maximize = decorations.handle =
-            functions.resize = functions.maximize = false;
+    if (!m_client->sizeHints().isResizable()) {
+        functions.resize = functions.maximize = false;
         decorations.tab = false; //no tab for this window
     }
 
@@ -2187,27 +2184,17 @@ void FluxboxWindow::propertyNotifyEvent(WinClient &client, Atom atom) {
             client.maxWidth() != old_max_width ||
             client.minHeight() != old_min_height ||
             client.maxHeight() != old_max_height) {
-            if (client.maxWidth() != 0 && client.maxHeight() != 0 &&
-                client.maxWidth() <= client.minWidth() &&
-                client.maxHeight() <= client.minHeight()) {
-                if (decorations.maximize ||
-                    decorations.handle ||
-                    functions.resize ||
+            if (!client.sizeHints().isResizable()) {
+                if (functions.resize ||
                     functions.maximize)
                     changed = true;
-                decorations.maximize = false;
-                decorations.handle = false;
                 functions.resize=false;
                 functions.maximize=false;
             } else {
                 // TODO: is broken while handled by FbW, needs to be in WinClient
                 if (!client.isTransient() || screen().decorateTransient()) {
-                    if (!decorations.maximize ||
-                        !decorations.handle ||
-                        !functions.maximize)
+                    if (!functions.maximize)
                         changed = true;
-                    decorations.maximize = true;
-                    decorations.handle = true;
                     functions.maximize = true;
                 }
                 if (!functions.resize)
diff --git a/src/WindowState.cc b/src/WindowState.cc
index 2f8fd4e..f4df136 100644
--- a/src/WindowState.cc
+++ b/src/WindowState.cc
@@ -30,7 +30,8 @@ bool WindowState::useBorder() const {
 }
 
 bool WindowState::useHandle() const {
-    return !fullscreen && !shaded && deco_mask & DECORM_HANDLE;
+    return !fullscreen && !shaded && deco_mask & DECORM_HANDLE &&
+           size_hints.isResizable();
 }
 
 bool WindowState::useTabs() const {
@@ -78,6 +79,11 @@ int WindowState::getDecoMaskFromString(const std::string &str_label) {
     return mask;
 }
 
+bool SizeHints::isResizable() const {
+    return max_width == 0 || max_height == 0 ||
+           max_width > min_width || max_height > min_height;
+}
+
 void SizeHints::reset(const XSizeHints &sizehint) {
     if (sizehint.flags & PMinSize) {
         min_width = sizehint.min_width;
diff --git a/src/WindowState.hh b/src/WindowState.hh
index fa17eb6..3bc5d24 100644
--- a/src/WindowState.hh
+++ b/src/WindowState.hh
@@ -43,6 +43,8 @@ public:
     void displaySize(unsigned int &i, unsigned int &j,
                      unsigned int width, unsigned int height) const;
 
+    bool isResizable() const;
+
     unsigned int min_width, max_width, min_height, max_height,
                  width_inc, height_inc, base_width, base_height,
                  min_aspect_x, max_aspect_x, min_aspect_y, max_aspect_y;
-- 
cgit v0.11.2