From cf6e471fbf027a1ba08693d6562ae5d63aaa9e24 Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Sun, 4 Feb 2007 18:44:28 +0000
Subject: fix remembered layer and layer menu

---
 ChangeLog        |  4 ++++
 src/LayerMenu.cc |  7 +++++++
 src/LayerMenu.hh |  9 +++++----
 src/Window.cc    | 10 +++++-----
 src/Window.hh    |  2 +-
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index a5235b2..328f320 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
  (Format: Year/Month/Day)
 Changes for 1.0rc3:
 *07/02/04:
+   * Layer wasn't set properly on remembered windows, and the layer menu
+     wasn't getting updated properly, bugs #1535304, #1572683, #1646740
+     (Mark)
+     Window.cc/hh LayerMenu.cc/hh
    * Clicking on the edge of a button didn't work, bugs #1060891, #1517747
      (Mark)
      FbTk/Button.cc
diff --git a/src/LayerMenu.cc b/src/LayerMenu.cc
index 86e6dec..4a02214 100644
--- a/src/LayerMenu.cc
+++ b/src/LayerMenu.cc
@@ -65,3 +65,10 @@ LayerMenu::LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
     }
     updateMenu();
 }
+
+// update which items appear disabled whenever we show the menu
+void LayerMenu::show() {
+    frameWindow().updateBackground(false);
+    clearWindow();
+    FbTk::Menu::show();
+}
diff --git a/src/LayerMenu.hh b/src/LayerMenu.hh
index 3f8330f..fcc4edb 100644
--- a/src/LayerMenu.hh
+++ b/src/LayerMenu.hh
@@ -41,11 +41,12 @@ public:
 /// this class holds the layermenu items
 class LayerMenuItem : public FbTk::MenuItem {
 public:
-    LayerMenuItem(const FbTk::FbString &label, LayerObject *object, int layernum,
-                  FbTk::RefCount<FbTk::Command> &cmd):
+    LayerMenuItem(const FbTk::FbString &label, LayerObject *object,
+                  int layernum, FbTk::RefCount<FbTk::Command> &cmd):
         FbTk::MenuItem(label, cmd), m_object(object), m_layernum(layernum) {}
 
-    LayerMenuItem(const FbTk::FbString &label, LayerObject *object, int layernum):
+    LayerMenuItem(const FbTk::FbString &label, LayerObject *object,
+                  int layernum):
         FbTk::MenuItem(label), m_object(object), m_layernum(layernum) {}
 
     bool isEnabled() const { return m_object->layerNumber() != m_layernum; }
@@ -65,7 +66,7 @@ class LayerMenu : public ToggleMenu {
 public:
     LayerMenu(MenuTheme &tm, FbTk::ImageControl &imgctrl,
               FbTk::XLayer &layer, LayerObject *item, bool save_rc);
-
+    void show();
 };
 
 #endif // LAYERMENU_HH
diff --git a/src/Window.cc b/src/Window.cc
index df08744..1b3ef2f 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -497,7 +497,7 @@ void FluxboxWindow::init() {
         m_client->transientFor()->fbwindow() != this)
         layerItem().setLayer(m_client->transientFor()->fbwindow()->layerItem().getLayer());
     else // if no parent then set default layer
-        moveToLayer(m_layernum);
+        moveToLayer(m_layernum, m_layernum != ::Layer::NORMAL);
 #ifdef DEBUG
     cerr<<"FluxboxWindow::init("<<title()<<") transientFor: "<<
         m_client->transientFor()<<endl;
@@ -1934,7 +1934,7 @@ void FluxboxWindow::lowerLayer() {
 }
 
 
-void FluxboxWindow::moveToLayer(int layernum) {
+void FluxboxWindow::moveToLayer(int layernum, bool force) {
 #ifdef DEBUG
     cerr<<"FluxboxWindow("<<title()<<")::moveToLayer("<<layernum<<")"<<endl;
 #endif // DEBUG
@@ -1948,7 +1948,7 @@ void FluxboxWindow::moveToLayer(int layernum) {
     if (!m_initialized)
         m_layernum = layernum;
 
-    if (m_layernum == layernum)
+    if (m_layernum == layernum && !force)
         return;
 
     // get root window
@@ -1963,9 +1963,9 @@ void FluxboxWindow::moveToLayer(int layernum) {
 
     if (!win->isIconic()) {
         if (layernum > m_layernum)
-            screen().updateNetizenWindowRaise(client->window());
-        else
             screen().updateNetizenWindowLower(client->window());
+        else
+            screen().updateNetizenWindowRaise(client->window());
     }
     win->layerItem().moveToLayer(layernum);
     // remember number just in case a transient happens to revisit this window
diff --git a/src/Window.hh b/src/Window.hh
index 50f756d..2cec115 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -245,7 +245,7 @@ public:
     void tempRaise();
     void raiseLayer();
     void lowerLayer();
-    void moveToLayer(int layernum);
+    void moveToLayer(int layernum, bool force = false);
     void setFocusHidden(bool value);
     void setIconHidden(bool value);
     void reconfigure();
-- 
cgit v0.11.2