]> Dogcows Code - chaz/openbox/blobdiff - src/screen.cc
only focus new 'normal' windows
[chaz/openbox] / src / screen.cc
index bebc82d17705d59763ed827038b478b4e4e3d9b4..8ea1b49ea8a0432f48bf86ed50278a9434cbb880 100644 (file)
@@ -518,6 +518,15 @@ void OBScreen::manageWindow(Window window)
   setClientList();
 
   Openbox::instance->bindings()->grabButtons(true, client);
+
+  // 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);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_DECREF((PyObject*)data);
 }
 
 
@@ -525,6 +534,11 @@ void OBScreen::unmanageWindow(OBClient *client)
 {
   OBFrame *frame = client->frame;
 
+  // call the python CLOSEWINDOW binding 
+  EventData *data = new_event_data(client->window(), EventCloseWindow, 0);
+  Openbox::instance->bindings()->fireEvent(data);
+  Py_DECREF((PyObject*)data);
+
   Openbox::instance->bindings()->grabButtons(false, client);
 
   // remove from the stacking order
@@ -533,9 +547,13 @@ void OBScreen::unmanageWindow(OBClient *client)
   // pass around focus if this window was focused XXX do this better!
   if (Openbox::instance->focusedClient() == client) {
     OBClient *newfocus = 0;
-    if (!_stacking.empty())
-      newfocus = _stacking.front();
-    if (! (newfocus && newfocus->focus()))
+    ClientList::iterator it, end = _stacking.end();
+    for (it = _stacking.begin(); it != end; ++it)
+      if ((*it)->normal() && (*it)->focus()) {
+        newfocus = *it;
+        break;
+      }
+    if (!newfocus)
       client->unfocus();
   }
 
This page took 0.022923 seconds and 4 git commands to generate.