From 61bb3f039afd5a29ae655666fbc2fe7943eab8e2 Mon Sep 17 00:00:00 2001
From: simonb <simonb>
Date: Tue, 4 Jan 2005 10:51:38 +0000
Subject: fix some initialisation, especially relating to placement and
 decoration/handler hints

---
 ChangeLog     |  4 ++++
 src/Ewmh.cc   |  5 +----
 src/Screen.cc | 33 +++++++++++++++++----------------
 src/Window.cc | 11 +++++++----
 src/Window.hh |  2 +-
 5 files changed, 30 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 8c3ab58..7d24471 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 (Format: Year/Month/Day)
 Changes for 0.9.12
+*05/01/04:
+  * Fix some initialisation states, especially window placement with no 
+    decorations through apps (e.g. aterm)
+    Window.hh/cc Screen.cc Ewmh.cc
 *05/01/02:
   * Fix for #996298, Windows dont respect toolbar.border.width (Mathias)
     Toolbar.cc
diff --git a/src/Ewmh.cc b/src/Ewmh.cc
index 78ea63e..2d744f7 100644
--- a/src/Ewmh.cc
+++ b/src/Ewmh.cc
@@ -238,14 +238,11 @@ void Ewmh::setupFrame(FluxboxWindow &win) {
         if (desktop == 0xFFFFFFFF && !win.isStuck())
             win.stick();
         else
-            win.screen().sendToWorkspace(desktop, &win, false);
+            win.setWorkspace(desktop, false);
 
         XFree(data);
     }
 
-    updateWorkspace(win);
-
-
 }
 
 void Ewmh::updateFrameClose(FluxboxWindow &win) {
diff --git a/src/Screen.cc b/src/Screen.cc
index 10921e0..dee150b 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -1220,9 +1220,9 @@ FluxboxWindow *BScreen::createWindow(Window client) {
     else
         focused_list.push_back(&win->winClient());
     
-    if (new_win) {
-        Fluxbox::instance()->attachSignals(*win);
-    }
+//    if (new_win) {
+//        Fluxbox::instance()->attachSignals(*win);
+//    }
 
     // we also need to check if another window expects this window to the left
     // and if so, then join it.
@@ -1240,27 +1240,28 @@ FluxboxWindow *BScreen::createWindow(Window client) {
 
 
 FluxboxWindow *BScreen::createWindow(WinClient &client) {
+
+    if (isKdeDockapp(client.window()) && addKdeDockapp(client.window())) {
+        // we need to save old handler and readd it later
+// I think rearranging the logic negates the need for this - sb 04jan2005
+//        FbTk::EventManager *evm = FbTk::EventManager::instance();
+//        FbTk::EventHandler *evh = evm->find(client.window());
+//        evm->add(*evh, client.window());
+        return 0;
+    }
+
     FluxboxWindow *win = new FluxboxWindow(client,
                                            winFrameTheme(),
                                            *layerManager().getLayer(Fluxbox::instance()->getNormalLayer()));
 
-    if (isKdeDockapp(client.window())) {
-        if (addKdeDockapp(client.window())) {
-            // we need to save old handler and readd it later
-            FbTk::EventManager *evm = FbTk::EventManager::instance();
-            FbTk::EventHandler *evh = evm->find(client.window());
-            delete win;
-            evm->add(*evh, client.window());
-            return 0;
-        }
-    } else {
-
+// Why not KDE? - sb 04jan2005
+//    if (!isKdeDockapp(client.window())) {
 #ifdef SLIT
         if (win->initialState() == WithdrawnState && slit() != 0) {
             slit()->addClient(win->clientWindow());
         }
 #endif // SLIT
-    }
+//    }
                  
 
     if (!win->isManaged()) {
@@ -1270,7 +1271,7 @@ FluxboxWindow *BScreen::createWindow(WinClient &client) {
     // don't add to focused_list, as it should already be in there (since the
     // WinClient already exists).
     
-    Fluxbox::instance()->attachSignals(*win);
+//    Fluxbox::instance()->attachSignals(*win);
 
     m_clientlist_sig.notify();
 
diff --git a/src/Window.cc b/src/Window.cc
index 0e2e72e..fdb636d 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -485,6 +485,7 @@ void FluxboxWindow::init() {
     m_timer.setCommand(raise_cmd);
     m_timer.fireOnce(true);
 
+    // Slit client?
     if (m_client->initial_state == WithdrawnState) {
         return;
     }
@@ -492,6 +493,7 @@ void FluxboxWindow::init() {
     m_managed = true; //this window is managed
 
     Fluxbox::instance()->saveWindowSearchGroup(frame().window().window(), this);
+    Fluxbox::instance()->attachSignals(*this);
 
     // update transient infomation
     m_client->updateTransientInfo();
@@ -518,11 +520,11 @@ void FluxboxWindow::init() {
 
     grabButtons();
 
+    restoreAttributes();
+
     if (m_workspace_number < 0 || m_workspace_number >= screen().getCount())
         m_workspace_number = screen().currentWorkspaceID();
 
-    restoreAttributes();
-
     bool place_window = true;
     if (fluxbox.isStartup() || m_client->isTransient() ||
         m_client->normal_hint_flags & (PPosition|USPosition)) {
@@ -569,6 +571,7 @@ void FluxboxWindow::init() {
 
 
     screen().getWorkspace(m_workspace_number)->addWindow(*this, place_window);
+    setWorkspace(m_workspace_number, true);
 
     if (shaded) { // start shaded
         shaded = false;
@@ -1745,7 +1748,7 @@ void FluxboxWindow::maximizeFull() {
 }
 
 
-void FluxboxWindow::setWorkspace(int n) {
+void FluxboxWindow::setWorkspace(int n, bool notify) {
     unsigned int old_wkspc = m_workspace_number;
 
     m_workspace_number = n;
@@ -1754,7 +1757,7 @@ void FluxboxWindow::setWorkspace(int n) {
     m_blackbox_attrib.workspace = m_workspace_number;
 
     // notify workspace change
-    if (!stuck && old_wkspc != m_workspace_number) {
+    if (notify && !stuck && old_wkspc != m_workspace_number) {
 #ifdef DEBUG
         cerr<<this<<" notify workspace signal"<<endl;
 #endif // DEBUG
diff --git a/src/Window.hh b/src/Window.hh
index aa6de85..020fd88 100644
--- a/src/Window.hh
+++ b/src/Window.hh
@@ -234,7 +234,7 @@ public:
     /// move and resize frame to pox x,y and size width, height
     void moveResize(int x, int y, unsigned int width, unsigned int height, int gravity = ForgetGravity);
 
-    void setWorkspace(int n);
+    void setWorkspace(int n, bool notify = true);
     void changeBlackboxHints(const BlackboxHints &bh);
     void updateFunctions();
     void restoreAttributes();
-- 
cgit v0.11.2