From 3c78d753c0c1b293d20ad52e38586929bf47f13e Mon Sep 17 00:00:00 2001
From: fluxgen <fluxgen>
Date: Fri, 20 Feb 2004 09:07:27 +0000
Subject: fixed focus issues with remember hidden, patch from Mathias Gumz

---
 src/Ewmh.cc        | 11 +++++++----
 src/Gnome.cc       |  7 +++++--
 src/IconbarTool.cc |  6 +++---
 src/Remember.cc    | 53 +++++++++++++++++++++++++++++++++++++++--------------
 src/Remember.hh    | 22 ++++++++++++++--------
 src/Screen.cc      |  4 ++--
 src/Window.cc      | 11 +++++++++--
 src/Window.hh      | 10 ++++++----
 8 files changed, 85 insertions(+), 39 deletions(-)

diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 014976a..7f23302 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Ewmh.cc,v 1.43 2004/02/14 12:15:35 fluxgen Exp $
+// $Id: Ewmh.cc,v 1.44 2004/02/20 09:05:38 fluxgen Exp $
 
 #include "Ewmh.hh" 
 
@@ -174,7 +174,8 @@ void Ewmh::setupFrame(FluxboxWindow &win) {
              */
             if (atoms[l] == m_net_wm_window_type_dock) {
                 // we also assume it shouldn't be visible in any toolbar
-                win.setHidden(true);
+                win.setFocusHidden(true);
+                win.setIconHidden(true);
                 break;
             }
 
@@ -722,7 +723,8 @@ void Ewmh::setState(FluxboxWindow &win, Atom state, bool value) {
         setFullscreen(win, value);
     } else if (state == m_net_wm_state_hidden ||
                state == m_net_wm_state_skip_taskbar) {        
-        win.setHidden(value);
+        win.setFocusHidden(value);
+        win.setIconHidden(win.isFocusHidden());
     } else if (state == m_net_wm_state_below) {
         if (value)
             win.moveToLayer(Fluxbox::instance()->getBottomLayer());
@@ -752,7 +754,8 @@ void Ewmh::toggleState(FluxboxWindow &win, Atom state) {
         setFullscreen(win, getState(win) == 0); // toggle current state
     } else if (state == m_net_wm_state_hidden ||
                state == m_net_wm_state_skip_taskbar) {
-        win.setHidden(!win.isHidden());
+        win.setFocusHidden(!win.isFocusHidden());
+        win.setIconHidden(!win.isIconHidden());
     } else if (state == m_net_wm_state_below) {
         if (win.layerNum() == Fluxbox::instance()->getBottomLayer())
             win.moveToLayer(Fluxbox::instance()->getNormalLayer());
diff --git a/src/Gnome.cc b/src/Gnome.cc
index c046184..dcfb029 100644
--- a/src/Gnome.cc
+++ b/src/Gnome.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Gnome.cc,v 1.33 2004/01/19 18:36:27 fluxgen Exp $
+// $Id: Gnome.cc,v 1.34 2004/02/20 09:05:38 fluxgen Exp $
 
 #include "Gnome.hh"
 
@@ -369,7 +369,10 @@ void Gnome::setState(FluxboxWindow *win, int state) {
         win->shade();
 
     if (state & WIN_STATE_HIDDEN)
-        win->setHidden(! win->isHidden());
+    {
+        win->setFocusHidden(! win->isFocusHidden());
+        win->setIconHidden(! win->isIconHidden());
+    }
 
 
     /*   
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index d1292c4..16b51e9 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -20,7 +20,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: IconbarTool.cc,v 1.33 2004/02/16 10:26:03 fluxgen Exp $
+// $Id: IconbarTool.cc,v 1.34 2004/02/20 09:05:24 fluxgen Exp $
 
 #include "IconbarTool.hh"
 
@@ -211,7 +211,7 @@ inline bool checkAddWindow(IconbarTool::Mode mode, const FluxboxWindow &win) {
         break;
     }
 
-    if (win.isHidden())
+    if (win.isIconHidden())
         ret_val = false;
 
     return ret_val;
@@ -682,7 +682,7 @@ void IconbarTool::removeWindow(FluxboxWindow &win) {
 
 void IconbarTool::addWindow(FluxboxWindow &win) {
     // we just want windows that has clients
-    if (win.clientList().empty() || win.isHidden() )
+    if (win.clientList().empty() || win.isIconHidden() )
         return;
 
     IconButton *button = new IconButton(m_icon_container, m_theme.focusedText().font(), win);
diff --git a/src/Remember.cc b/src/Remember.cc
index 5f1787f..630428b 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -21,7 +21,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Remember.cc,v 1.34 2004/02/16 10:25:33 fluxgen Exp $
+// $Id: Remember.cc,v 1.35 2004/02/20 09:05:38 fluxgen Exp $
 
 #include "Remember.hh"
 #include "ClientPattern.hh"
@@ -210,7 +210,8 @@ Application::Application(bool grouped)
 {
 	decostate_remember     = 
 	dimensions_remember =
-	hiddenstate_remember   = 
+	focushiddenstate_remember = 
+  iconhiddenstate_remember =
 	jumpworkspace_remember = 
 	layer_remember         = 
 	position_remember =
@@ -364,8 +365,13 @@ int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
                 app.rememberShadedstate((str_label=="yes"));
             } else if (str_key == "Tab") {
                 app.rememberTabstate((str_label=="yes"));
+            } else if (str_key == "FocusHidden") {
+                app.rememberFocusHiddenstate((str_label=="yes")); 
+            } else if (str_key == "IconHidden") {
+                app.rememberIconHiddenstate((str_label=="yes")); 
             } else if (str_key == "Hidden") {
-                app.rememberHiddenstate((str_label=="yes")); 
+                app.rememberIconHiddenstate((str_label=="yes"));
+                app.rememberFocusHiddenstate((str_label=="yes"));
             } else if (str_key == "Deco") {
                 if (str_label == "NONE") {
                     app.rememberDecostate((unsigned int) 0);
@@ -548,9 +554,6 @@ void Remember::save() {
         if (a.tabstate_remember) {
             apps_file << "  [Tab]\t\t{" << ((a.tabstate)?"yes":"no") << "}" << endl;
         }
-        if (a.hiddenstate_remember) {
-            apps_file << "  [Hidden]\t\t{" << ((a.tabstate)?"yes":"no") << "}" << endl;
-        }
         if (a.decostate_remember) {
             switch (a.decostate) {
             case (0) :
@@ -578,6 +581,17 @@ void Remember::save() {
                 break;
             }
         }
+
+        if (a.focushiddenstate_remember || a.iconhiddenstate_remember) {
+            if (a.focushiddenstate_remember && a.iconhiddenstate_remember &&
+                a.focushiddenstate && a.iconhiddenstate) 
+                apps_file << "  [Hidden]\t{" << ((a.focushiddenstate)?"yes":"no") << "}" << endl;
+            else if (a.focushiddenstate_remember) {
+                apps_file << "  [FocusHidden]\t{" << ((a.focushiddenstate)?"yes":"no") << "}" << endl;
+            } else if (a.iconhiddenstate_remember) {
+                apps_file << "  [IconHidden]\t{" << ((a.iconhiddenstate)?"yes":"no") << "}" << endl;
+            }
+        }
         if (a.stuckstate_remember) {
             apps_file << "  [Sticky]\t{" << ((a.stuckstate)?"yes":"no") << "}" << endl;
         }
@@ -607,8 +621,11 @@ bool Remember::isRemembered(WinClient &winclient, Attribute attrib) {
     case REM_POSITION:
         return app->position_remember;
         break;
-    case REM_HIDDENSTATE:
-        return app->hiddenstate_remember;
+    case REM_FOCUSHIDDENSTATE:
+        return app->focushiddenstate_remember;
+        break;
+    case REM_ICONHIDDENSTATE:
+        return app->iconhiddenstate_remember;
         break;
     case REM_STUCKSTATE:
         return app->stuckstate_remember;
@@ -655,8 +672,11 @@ void Remember::rememberAttrib(WinClient &winclient, Attribute attrib) {
     case REM_POSITION:
         app->rememberPosition(win->x(), win->y());
         break;
-    case REM_HIDDENSTATE:
-        app->rememberHiddenstate(win->isHidden());
+    case REM_FOCUSHIDDENSTATE:
+        app->rememberFocusHiddenstate(win->isFocusHidden());
+        break;
+    case REM_ICONHIDDENSTATE:
+        app->rememberIconHiddenstate(win->isIconHidden());
         break;
     case REM_SHADEDSTATE:
         app->rememberShadedstate(win->isShaded());
@@ -703,8 +723,11 @@ void Remember::forgetAttrib(WinClient &winclient, Attribute attrib) {
     case REM_POSITION:
         app->forgetPosition();
         break;
-    case REM_HIDDENSTATE:
-        app->forgetHiddenstate();
+    case REM_FOCUSHIDDENSTATE:
+        app->forgetFocusHiddenstate();
+        break;
+    case REM_ICONHIDDENSTATE:
+        app->forgetIconHiddenstate();
         break;
     case REM_STUCKSTATE:
         app->forgetStuckstate();
@@ -809,8 +832,10 @@ void Remember::setupFrame(FluxboxWindow &win) {
         if (win.isStuck() && !app->stuckstate ||
             !win.isStuck() && app->stuckstate)
             win.stick(); // toggles
-    if (app->hiddenstate_remember)
-        win.setHidden(true);
+    if (app->focushiddenstate_remember)
+        win.setFocusHidden(true);
+    if (app->iconhiddenstate_remember)
+        win.setIconHidden(true);
 
     if (app->layer_remember)
         win.moveToLayer(app->layer);
diff --git a/src/Remember.hh b/src/Remember.hh
index 2e92e42..e1a4db5 100644
--- a/src/Remember.hh
+++ b/src/Remember.hh
@@ -21,7 +21,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Remember.hh,v 1.15 2004/02/16 10:25:34 fluxgen Exp $
+// $Id: Remember.hh,v 1.16 2004/02/20 09:05:38 fluxgen Exp $
 
 /* Based on the original "Remember patch" by Xavier Brouckaert */
 
@@ -50,7 +50,8 @@ public:
     inline void forgetShadedstate() { shadedstate_remember = false; }
     inline void forgetTabstate() { tabstate_remember = false; }
     inline void forgetDecostate() { decostate_remember = false; }
-    inline void forgetHiddenstate() { hiddenstate_remember= false; }
+    inline void forgetFocusHiddenstate() { focushiddenstate_remember= false; }
+    inline void forgetIconHiddenstate() { iconhiddenstate_remember= false; }
     inline void forgetStuckstate() { stuckstate_remember = false; }
     inline void forgetJumpworkspace() { jumpworkspace_remember = false; }
     inline void forgetLayer() { layer_remember = false; }
@@ -60,9 +61,10 @@ public:
         { workspace = ws; workspace_remember = true; }
     inline void rememberDimensions(int width, int height) 
         { w = width; h = height; dimensions_remember = true; }
-
-    inline void rememberHiddenstate(bool state)
-        { hiddenstate= state; hiddenstate_remember= true; }
+    inline void rememberFocusHiddenstate(bool state)
+        { focushiddenstate= state; focushiddenstate_remember= true; }
+    inline void rememberIconHiddenstate(bool state)
+        { iconhiddenstate= state; iconhiddenstate_remember= true; }
     inline void rememberPosition(int posx, int posy, unsigned char rfc= 0 )
         { x = posx; y = posy; refc = rfc; position_remember = true; }
     inline void rememberShadedstate(bool state)
@@ -106,8 +108,11 @@ public:
     bool stuckstate_remember;
     bool stuckstate;
 
-    bool hiddenstate_remember;
-    bool hiddenstate;
+    bool focushiddenstate_remember;
+    bool focushiddenstate;
+
+    bool iconhiddenstate_remember;
+    bool iconhiddenstate;
 
     bool jumpworkspace_remember;
     bool jumpworkspace;
@@ -138,7 +143,8 @@ public:
     enum Attribute {
         REM_DECOSTATE= 0,
         REM_DIMENSIONS,
-        REM_HIDDENSTATE,
+        REM_FOCUSHIDDENSTATE,
+        REM_ICONHIDDENSTATE,
         REM_JUMPWORKSPACE,
         REM_LAYER,
         REM_POSITION,
diff --git a/src/Screen.cc b/src/Screen.cc
index 7402f49..319852c 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Screen.cc,v 1.266 2004/02/10 18:53:37 fluxgen Exp $
+// $Id: Screen.cc,v 1.267 2004/02/20 09:06:19 fluxgen Exp $
 
 
 #include "Screen.hh"
@@ -2411,7 +2411,7 @@ bool BScreen::doSkipWindow(const WinClient &winclient, int opts) {
             // skip if not active client (i.e. only visit each fbwin once)
             (opts & CYCLEGROUPS) != 0 && win->winClient().window() != winclient.window() ||
             (opts & CYCLESKIPSHADED) != 0 && win->isShaded() || // skip if shaded
-            win->isHidden()
+            win->isFocusHidden()
             ); 
 }
 
diff --git a/src/Window.cc b/src/Window.cc
index 0a5c948..f7d7bf2 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Window.cc,v 1.267 2004/02/16 09:19:45 fluxgen Exp $
+// $Id: Window.cc,v 1.268 2004/02/20 09:07:27 fluxgen Exp $
 
 #include "Window.hh"
 
@@ -265,6 +265,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
     m_focussig(*this),
     m_titlesig(*this),
     m_themelistener(*this),
+    m_icon_hidden(false),
     moving(false), resizing(false), shaded(false), 
     iconic(false), focused(false),
     stuck(false), m_managed(false),
@@ -1688,7 +1689,7 @@ void FluxboxWindow::moveToLayer(int layernum) {
     }
 }
 
-void FluxboxWindow::setHidden(bool value) {
+void FluxboxWindow::setFocusHidden(bool value) {
     if(value) 
         m_blackbox_attrib.flags |= ATTRIB_HIDDEN;
     else
@@ -1697,6 +1698,12 @@ void FluxboxWindow::setHidden(bool value) {
     m_statesig.notify();
 }
 
+void FluxboxWindow::setIconHidden(bool value) {
+    m_icon_hidden= value;
+    m_statesig.notify();
+}
+
+
 // window has actually RECEIVED focus (got a FocusIn event)
 // so now we make it a focused frame etc
 void FluxboxWindow::setFocusFlag(bool focus) {
diff --git a/src/Window.hh b/src/Window.hh
index 2a4d507..f6cb3d0 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Window.hh,v 1.108 2004/02/16 20:47:51 fluxgen Exp $
+// $Id: Window.hh,v 1.109 2004/02/20 09:07:27 fluxgen Exp $
 
 #ifndef	 WINDOW_HH
 #define	 WINDOW_HH
@@ -207,7 +207,8 @@ public:
     void raiseLayer();
     void lowerLayer();
     void moveToLayer(int layernum);
-    void setHidden(bool value);
+    void setFocusHidden(bool value);
+    void setIconHidden(bool value);
     void reconfigure();
 
 
@@ -262,7 +263,8 @@ public:
        @name accessors		
     */
     //@{
-    inline bool isHidden() const { return (m_blackbox_attrib.flags & ATTRIB_HIDDEN); }
+    inline bool isFocusHidden() const { return (m_blackbox_attrib.flags & ATTRIB_HIDDEN); }
+    inline bool isIconHidden() const { return m_icon_hidden; } 
     inline bool isManaged() const { return m_managed; }
     inline bool isFocused() const { return focused; }
     bool isVisible() const;
@@ -468,7 +470,7 @@ private:
     } functions;
 
     bool m_shaped; ///< if the window is shaped with a mask
-
+    bool m_icon_hidden;  ///< if the window is in the iconbar 
     int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized
     unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state
     int m_last_button_x, ///< last known x position of the mouse button
-- 
cgit v0.11.2