From 9bd64010135e26f97fa4d4d551737847fedfbcdd Mon Sep 17 00:00:00 2001
From: Mark Tiefenbruck <mark@fluxbox.org>
Date: Tue, 14 Oct 2008 19:40:33 -0700
Subject: ignore XRandr events that don't actually change the screen size

---
 ChangeLog            |  3 +++
 src/FbRootWindow.cc  |  4 ----
 src/FbRootWindow.hh  |  1 -
 src/FbTk/FbWindow.cc | 13 +++++++++----
 src/FbTk/FbWindow.hh |  6 +++---
 src/Screen.cc        | 20 ++++++++++----------
 6 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 675b073..5eeda89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
  (Format: Year/Month/Day)
 Changes for 1.1.2
+*08/10/15:
+   * Ignore XRandr events that don't change the screen size (Mark)
+     Screen.cc FbTk/FbWindow.cc/hh
 *08/10/13:
    * Merge menuDelay and menuDelayClose options in init (Mark)
      Screen.cc/hh FbTk/MenuTheme.cc/hh FbTk/Menu.cc
diff --git a/src/FbRootWindow.cc b/src/FbRootWindow.cc
index a3e4bc3..7e2b77e 100644
--- a/src/FbRootWindow.cc
+++ b/src/FbRootWindow.cc
@@ -60,7 +60,3 @@ FbRootWindow::FbRootWindow(int screen_num):
         m_colormap = DefaultColormap(disp, screen_num);
     }
 }
-
-void FbRootWindow::updateGeometry() {
-    FbTk::FbWindow::updateGeometry();
-}
diff --git a/src/FbRootWindow.hh b/src/FbRootWindow.hh
index 325bab3..34b8219 100644
--- a/src/FbRootWindow.hh
+++ b/src/FbRootWindow.hh
@@ -35,7 +35,6 @@ public:
     void hide() { }
     // we should not assign a new window to this
     FbTk::FbWindow &operator = (Window win) { return *this; }
-    void updateGeometry();
     Visual *visual() const { return m_visual; }
     Colormap colormap() const { return m_colormap; } 
 
diff --git a/src/FbTk/FbWindow.cc b/src/FbTk/FbWindow.cc
index 56f354b..2ef24fa 100644
--- a/src/FbTk/FbWindow.cc
+++ b/src/FbTk/FbWindow.cc
@@ -583,16 +583,21 @@ void FbWindow::setOpaque(unsigned char alpha) {
 #endif // HAVE_XRENDER
 }
 
-void FbWindow::updateGeometry() {
+bool FbWindow::updateGeometry() {
     if (m_window == 0)
-        return;
+        return false;
+
+    int old_x = m_x, old_y = m_y;
+    unsigned int old_width = m_width, old_height = m_height;
 
     Window root;
     unsigned int border_width, depth;
     if (XGetGeometry(display(), m_window, &root, &m_x, &m_y,
-                     (unsigned int *)&m_width, (unsigned int *)&m_height,
-                     &border_width, &depth))
+                     &m_width, &m_height, &border_width, &depth))
         m_depth = depth;
+
+    return (old_x != m_x || old_y != m_y || old_width != m_width ||
+            old_height != m_height);
 }
 
 void FbWindow::create(Window parent, int x, int y,
diff --git a/src/FbTk/FbWindow.hh b/src/FbTk/FbWindow.hh
index a80a5b0..edeffe1 100644
--- a/src/FbTk/FbWindow.hh
+++ b/src/FbTk/FbWindow.hh
@@ -199,13 +199,13 @@ public:
 
     static void updatedAlphaBackground(int screen);
 
+    /// updates x,y, width, height and screen num from X window
+    bool updateGeometry();
+
 protected:
     /// creates a window with x window client (m_window = client)
     explicit FbWindow(Window client);
 
-    /// updates x,y, width, height and screen num from X window
-    void updateGeometry();
-
 private:
     /// sets new X window and destroys old
     void setNew(Window win);
diff --git a/src/Screen.cc b/src/Screen.cc
index 776dd29..8b605e7 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1868,18 +1868,18 @@ void BScreen::updateSize() {
     // update xinerama layout
     initXinerama();
 
-    // force update geometry
-    rootWindow().updateGeometry();
+    // check if window geometry has changed
+    if (rootWindow().updateGeometry()) {
+        // reset background
+        m_root_theme->reset();
 
-    // reset background
-    m_root_theme->reset();
-
-    // send resize notify
-    m_resize_sig.emit(*this);
-    m_workspace_area_sig.emit(*this);
+        // send resize notify
+        m_resize_sig.emit(*this);
+        m_workspace_area_sig.emit(*this);
 
-    // move windows out of inactive heads
-    clearHeads();
+        // move windows out of inactive heads
+        clearHeads();
+    }
 }
 
 
-- 
cgit v0.11.2