]> Dogcows Code - chaz/openbox/blobdiff - src/screen.cc
don't place the window magically if we're starting (the window was already placed)
[chaz/openbox] / src / screen.cc
index d925ff5c603803b360a0b9d0db55ac34e41fd165..2dcc110f5b668381ec791716af77f2dbf0833a31 100644 (file)
@@ -138,6 +138,11 @@ OBScreen::OBScreen(int screen)
 
   // register this class as the event handler for the root window
   Openbox::instance->registerHandler(_info->rootWindow(), this);
+
+  // call the python Startup callbacks
+  EventData *data = new_event_data(_number, 0, EventShutdown, 0);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_XDECREF((PyObject*)data);
 }
 
 
@@ -151,6 +156,11 @@ OBScreen::~OBScreen()
   while (!clients.empty())
     unmanageWindow(clients.front());
 
+  // call the python Shutdown callbacks
+  EventData *data = new_event_data(_number, 0, EventShutdown, 0);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_XDECREF((PyObject*)data);
+
   XDestroyWindow(otk::OBDisplay::display, _focuswindow);
   XDestroyWindow(otk::OBDisplay::display, _supportwindow);
 
@@ -482,8 +492,13 @@ void OBScreen::manageWindow(Window window)
   // reparented back to root automatically
   XChangeSaveSet(otk::OBDisplay::display, window, SetModeInsert);
 
-  if (!client->positionRequested()) {
-    // XXX: position the window intelligenty
+  if (!(Openbox::instance->state() == Openbox::State_Starting ||
+        client->positionRequested())) {
+    // position the window intelligenty .. hopefully :)
+    // call the python PLACEWINDOW binding
+    EventData *data = new_event_data(_number, window, EventPlaceWindow, 0);
+    Openbox::instance->bindings()->fireEvent(data);
+    Py_DECREF((PyObject*)data);
   }
 
   // create the decoration frame for the client window
@@ -525,14 +540,8 @@ void OBScreen::manageWindow(Window window)
 
   Openbox::instance->bindings()->grabButtons(true, client);
 
-  if (shown) {
-    // XXX: make this optional or more intelligent
-    if (client->normal())
-      client->focus();
-  }
-
   // call the python NEWWINDOW binding
-  EventData *data = new_event_data(window, EventNewWindow, 0);
+  EventData *data = new_event_data(_number, window, EventNewWindow, 0);
   Openbox::instance->bindings()->fireEvent(data);
   Py_DECREF((PyObject*)data);
 
@@ -545,28 +554,13 @@ void OBScreen::unmanageWindow(OBClient *client)
   OBFrame *frame = client->frame;
 
   // call the python CLOSEWINDOW binding 
-  EventData *data = new_event_data(client->window(), EventCloseWindow, 0);
+  EventData *data = new_event_data(_number, client->window(),
+                                   EventCloseWindow, 0);
   Openbox::instance->bindings()->fireEvent(data);
   Py_DECREF((PyObject*)data);
 
   Openbox::instance->bindings()->grabButtons(false, client);
 
-  // remove from the stacking order
-  _stacking.remove(client);
-  
-  // pass around focus if this window was focused XXX do this better!
-  if (Openbox::instance->focusedClient() == client) {
-    OBClient *newfocus = 0;
-    OBClient::List::iterator it, end = _stacking.end();
-    for (it = _stacking.begin(); it != end; ++it)
-      if ((*it)->desktop() == _desktop && (*it)->normal() && (*it)->focus()) {
-        newfocus = *it;
-        break;
-      }
-    if (!newfocus)
-      client->unfocus();
-  }
-
   // remove from the wm's map
   Openbox::instance->removeClient(client->window());
   Openbox::instance->removeClient(frame->window());
@@ -597,8 +591,15 @@ void OBScreen::unmanageWindow(OBClient *client)
   delete client->frame;
   client->frame = 0;
 
+  // remove from the stacking order
+  _stacking.remove(client);
+
   // remove from the screen's list
   clients.remove(client);
+
+  // unfocus the client (calls the focus callbacks)
+  client->unfocus();
+
   delete client;
 
   // update the root properties
@@ -648,6 +649,8 @@ void OBScreen::changeDesktop(long desktop)
                                      otk::OBProperty::Atom_Cardinal,
                                      _desktop);
 
+  if (old == _desktop) return;
+
   OBClient::List::iterator it, end = clients.end();
   for (it = clients.begin(); it != end; ++it) {
     if ((*it)->desktop() == old) {
@@ -656,6 +659,10 @@ void OBScreen::changeDesktop(long desktop)
       (*it)->frame->show();
     }
   }
+
+  // force the callbacks to fire
+  if (!Openbox::instance->focusedClient())
+    Openbox::instance->setFocusedClient(0);
 }
 
 void OBScreen::changeNumDesktops(long num)
This page took 0.024802 seconds and 4 git commands to generate.