From 79aec8465f8a1e618034ac08fa2d55fcca09eb5a Mon Sep 17 00:00:00 2001
From: rathnor <rathnor>
Date: Sun, 16 Feb 2003 17:57:54 +0000
Subject: Fixed gnome init problems (Simon)

---
 ChangeLog     |  2 ++
 src/Gnome.cc  |  9 +++++----
 src/Screen.cc | 13 ++++++++-----
 src/Window.cc | 20 +++++++++++++-------
 src/Window.hh |  8 ++++++--
 5 files changed, 34 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 38eff68..99586a4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,8 @@ Changes for 0.1.15:
 *03/02/16:
    * Added layer submenu to window menu + small fix (Simon)
      Screen.cc Window.hh/cc fluxbox.hh     
+   * Fixed gnome workspace initialisation issues (Simon)
+     Gnome.cc Window.hh/cc Screen.cc
 *03/02/15:
    * Added Style menu and fixed theme listeners for FbWinFrame, Menu and Toolbar (Henrik)
      ToolbarTheme.hh/cc, Toolbar.hh/cc, FbTk Menu.hh/cc, FbTk MenuTheme.hh/cc,
diff --git a/src/Gnome.cc b/src/Gnome.cc
index 40b81da..b79d535 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.9 2003/02/09 14:11:12 rathnor Exp $
+// $Id: Gnome.cc,v 1.10 2003/02/16 17:57:54 rathnor Exp $
 
 #include "Gnome.hh"
 
@@ -107,13 +107,14 @@ void Gnome::setupWindow(FluxboxWindow &win) {
         XFree (data);
     }
 
-    // load gnome layer atom
+    // load gnome workspace atom
     if (XGetWindowProperty(disp, win.getClientWindow(), 
                            m_gnome_wm_win_workspace, 0, 1, False, XA_CARDINAL, 
                            &ret_type, &fmt, &nitems, &bytes_after, 
                            (unsigned char **) &data) ==  Success && data) {
-        flags = *data;
-        win.getScreen()->reassociateWindow(&win, flags ,false);
+        unsigned int workspace_num = *data;
+        if (win.getWorkspaceNumber() != workspace_num) 
+            win.getScreen()->reassociateWindow(&win, workspace_num, false);
         XFree (data);
     }
 
diff --git a/src/Screen.cc b/src/Screen.cc
index 4650fad..85b2e12 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.108 2003/02/16 16:45:23 fluxgen Exp $
+// $Id: Screen.cc,v 1.109 2003/02/16 17:57:54 rathnor Exp $
 
 
 #include "Screen.hh"
@@ -1105,7 +1105,11 @@ FluxboxWindow *BScreen::createWindow(Window client) {
         Fluxbox::instance()->saveWindowSearch(client, win);
         Fluxbox::instance()->attachSignals(*win);
         setupWindowActions(*win);
-     }
+    }
+    if (win->getWorkspaceNumber() == getCurrentWorkspaceID() || win->isStuck()) {
+        win->show();
+        XSync(FbTk::App::instance()->display(), False);
+    }
     return win;
 }
 
@@ -1127,8 +1131,8 @@ void BScreen::setupWindowActions(FluxboxWindow &win) {
     CommandRef close_cmd(new WindowCmd(win, &FluxboxWindow::close));
     CommandRef shade_cmd(new WindowCmd(win, &FluxboxWindow::shade));
     CommandRef raise_cmd(new WindowCmd(win, &FluxboxWindow::raise));
+    CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::lower));
     CommandRef raise_and_focus_cmd(new WindowCmd(win, &FluxboxWindow::raiseAndFocus));
-    CommandRef lower_cmd(new WindowCmd(win, &FluxboxWindow::raise));
     CommandRef stick_cmd(new WindowCmd(win, &FluxboxWindow::stick));
     CommandRef show_menu_cmd(new WindowCmd(win, &FluxboxWindow::popupMenu));
 
@@ -1138,7 +1142,6 @@ void BScreen::setupWindowActions(FluxboxWindow &win) {
     // get titlebar configuration
     const vector<Fluxbox::Titlebar> *dir = &Fluxbox::instance()->getTitlebarLeft();
     for (char c=0; c<2; c++) {
-
         for (size_t i=0; i< dir->size(); ++i) {
             //create new buttons
             FbTk::Button *newbutton = 0;
@@ -1324,7 +1327,6 @@ void BScreen::reassociateGroup(FluxboxWindow *w, unsigned int wkspc_id, bool ign
     }
 }
 
-
 void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ignore_sticky) {
     if (! w) return;
 
@@ -1338,6 +1340,7 @@ void BScreen::reassociateWindow(FluxboxWindow *w, unsigned int wkspc_id, bool ig
     if (w->getWorkspaceNumber() == wkspc_id)
         return;
 
+
     if (w->isIconic()) {
         removeIcon(w);
         getWorkspace(wkspc_id)->addWindow(w);
diff --git a/src/Window.cc b/src/Window.cc
index a8d3f8a..517074d 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.116 2003/02/16 15:12:07 rathnor Exp $
+// $Id: Window.cc,v 1.117 2003/02/16 17:57:53 rathnor Exp $
 
 #include "Window.hh"
 
@@ -261,7 +261,7 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num,
     if (workspace_number < 0 || workspace_number >= screen->getCount())
         workspace_number = screen->getCurrentWorkspaceID();
 
-    restoreAttributes(place_window);
+    restoreAttributes();
 
     moveToLayer(m_layernum);
     screen->getWorkspace(workspace_number)->addWindow(this, place_window);
@@ -289,10 +289,6 @@ FluxboxWindow::FluxboxWindow(Window w, BScreen *s, int screen_num,
     // no focus default
     setFocusFlag(false);
 
-    // finaly show the frame and the client window
-
-    m_frame.show();
-    XSync(display, False);
 }
 
 
@@ -931,6 +927,15 @@ void FluxboxWindow::setTab(bool flag) {
     */
 }
 
+void FluxboxWindow::hide() {
+    m_windowmenu.hide();
+    m_frame.hide();
+}
+
+void FluxboxWindow::show() {
+    m_frame.show();
+}
+
 /**
    Unmaps the window and removes it from workspace list
 */
@@ -1103,6 +1108,7 @@ void FluxboxWindow::maximizeVertical() {
 
 
 void FluxboxWindow::setWorkspace(int n) {
+
     workspace_number = n;
 
     blackbox_attrib.flags |= BaseDisplay::ATTRIB_WORKSPACE;
@@ -1501,7 +1507,7 @@ void FluxboxWindow::setGravityOffsets() {
  * but doesn't change the actual state
  * (so the caller can set defaults etc as well)
  */
-void FluxboxWindow::restoreAttributes(bool place_window) {
+void FluxboxWindow::restoreAttributes() {
     if (!getState())
         current_state = NormalState;
 
diff --git a/src/Window.hh b/src/Window.hh
index 4eec867..18e9128 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.47 2003/02/16 16:43:00 fluxgen Exp $
+// $Id: Window.hh,v 1.48 2003/02/16 17:57:53 rathnor Exp $
 
 #ifndef	 WINDOW_HH
 #define	 WINDOW_HH
@@ -111,6 +111,10 @@ public:
     void raiseAndFocus() { raise(); setInputFocus(); }
     void setTab(bool flag);
     void setFocusFlag(bool flag);
+    // map this window
+    void show();
+    // unmap this window
+    void hide();
     void iconify();
     void deiconify(bool = true, bool = true);
     /// destroy this window
@@ -145,7 +149,7 @@ public:
 
     void setWorkspace(int n);
     void changeBlackboxHints(const BaseDisplay::BlackboxHints &bh);
-    void restoreAttributes(bool place_window);
+    void restoreAttributes();
     void showMenu(int mx, int my);
     // popup menu on last button press position
     void popupMenu();
-- 
cgit v0.11.2