]> Dogcows Code - chaz/openbox/blobdiff - src/screen.cc
fixed condition that could cause 2 windows to look focused, and bad things to occur
[chaz/openbox] / src / screen.cc
index 657705565893fa6c0e89bdb3dcb524ef2e405993..7f15b243a4a2d62a246ff75368ac7a2a4b3c7a67 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);
 
@@ -525,12 +535,6 @@ 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(_number, window, EventNewWindow, 0);
   Openbox::instance->bindings()->fireEvent(data);
@@ -554,19 +558,9 @@ void OBScreen::unmanageWindow(OBClient *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();
-  }
+
+  // unfocus the client
+  client->unfocus();
 
   // remove from the wm's map
   Openbox::instance->removeClient(client->window());
@@ -650,7 +644,7 @@ void OBScreen::changeDesktop(long desktop)
                                      _desktop);
 
   if (old == _desktop) return;
-  
+
   OBClient::List::iterator it, end = clients.end();
   for (it = clients.begin(); it != end; ++it) {
     if ((*it)->desktop() == old) {
@@ -659,6 +653,9 @@ void OBScreen::changeDesktop(long desktop)
       (*it)->frame->show();
     }
   }
+
+  // force the callbacks to fire
+  Openbox::instance->setFocusedClient(0);
 }
 
 void OBScreen::changeNumDesktops(long num)
This page took 0.027447 seconds and 4 git commands to generate.