]> Dogcows Code - chaz/openbox/commitdiff
manages windows that exist before running.
authorDana Jansens <danakj@orodu.net>
Mon, 11 Nov 2002 11:25:40 +0000 (11:25 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 11 Nov 2002 11:25:40 +0000 (11:25 +0000)
otk/display.cc
otk/display.hh
src/client.cc
src/client.hh
src/frame.cc
src/frame.hh
src/screen.cc
src/screen.hh
src/xeventhandler.cc

index 4613b9ba9a5b5da75b8a5b5a43d5fdfeeb2c96e8..77111d3cbb4f5398d5f121ba896c138cc5986053 100644 (file)
@@ -51,6 +51,7 @@ int  OBDisplay::_xinerama_event_basep = 0;
 unsigned int OBDisplay::_mask_list[8];
 OBDisplay::ScreenInfoList OBDisplay::_screenInfoList;
 BGCCache *OBDisplay::_gccache = (BGCCache*) 0;
+int OBDisplay::_grab_count = 0;
 
 
 int OBDisplay::xerrorHandler(Display *d, XErrorEvent *e)
@@ -172,6 +173,21 @@ const ScreenInfo* OBDisplay::screenInfo(int snum) {
 }
 
 
+void OBDisplay::grab()
+{
+  if (_grab_count == 0)
+    XGrabServer(display);
+  _grab_count++;
+}
+
+
+void OBDisplay::ungrab()
+{
+  if (_grab_count == 0) return;
+  _grab_count--;
+  if (_grab_count == 0)
+    XUngrabServer(display);
+}
 
 
 
index e8f91ae946dcd1bec090d643b2313ac5b82d78af..7f5ab02d0b55daf96385ab430152de3e60129361 100644 (file)
@@ -42,6 +42,9 @@ private:
   //! A list of all possible combinations of keyboard lock masks
   static unsigned int _mask_list[8];
 
+  //! The number of requested grabs on the display
+  static int _grab_count;
+
   //! A list of information for all screens on the display
   static ScreenInfoList _screenInfoList;
 
@@ -94,7 +97,11 @@ public:
   //! Returns if the display has the xinerama extention available
   inline static bool xinerama() { return _xinerama; }
 
+  //! Grabs the display
+  static void grab();
 
+  //! Ungrabs the display
+  static void ungrab();
 
 
   
index 32532f20fc5f41d9cc746baf0d80044dab4891f4..57bf5161cf75614765292d8400f17e7d18ef5eae 100644 (file)
@@ -27,6 +27,8 @@ OBClient::OBClient(int screen, Window window)
 {
   assert(window);
 
+  ignore_unmaps = 0;
+  
   // update EVERYTHING the first time!!
 
   // the state is kinda assumed to be normal. is this right? XXX
index b4e01effe74b095e29fba7f39fe31e79ac9cc6fa..5ccf5fd51efd8c518bdd517bc3a5ef2859c13983 100644 (file)
@@ -119,9 +119,11 @@ public:
   };
 
   //! The event mask to grab on client windows
-  static const long event_mask = PropertyChangeMask | FocusChangeMask |
-                                 StructureNotifyMask;
+  static const long event_mask = PropertyChangeMask | FocusChangeMask;
 
+  //! The number of unmap events to ignore on the window
+  int ignore_unmaps;
+  
 private:
   //! The screen number on which the client resides
   int      _screen;
index 1fed17684e92b7449bbbb8262b8056f17149cd80..20e81ebd192d928a034c03aefe81367228ed8fa2 100644 (file)
@@ -18,7 +18,7 @@ extern "C" {
 
 namespace ob {
 
-OBFrame::OBFrame(const OBClient *client, const otk::Style *style)
+OBFrame::OBFrame(OBClient *client, const otk::Style *style)
   : _client(client),
     _screen(otk::OBDisplay::screenInfo(client->screen()))
 {
@@ -392,28 +392,19 @@ void OBFrame::updateShape()
 void OBFrame::grabClient()
 {
   
-  XGrabServer(otk::OBDisplay::display);
-
   // select the event mask on the frame
-  XSelectInput(otk::OBDisplay::display, _window, SubstructureRedirectMask);
+  //XSelectInput(otk::OBDisplay::display, _window, SubstructureRedirectMask);
 
   // reparent the client to the frame
-  XSelectInput(otk::OBDisplay::display, _client->window(),
-               OBClient::event_mask & ~StructureNotifyMask);
   XReparentWindow(otk::OBDisplay::display, _client->window(), _window, 0, 0);
-  XSelectInput(otk::OBDisplay::display, _client->window(),
-               OBClient::event_mask);
+  _client->ignore_unmaps++;
 
   // raise the client above the frame
   //XRaiseWindow(otk::OBDisplay::display, _client->window());
   // map the client so it maps when the frame does
   XMapWindow(otk::OBDisplay::display, _client->window());
   
-  XUngrabServer(otk::OBDisplay::display);
-
   update();
-
-  XMapWindow(otk::OBDisplay::display, _window);
 }
 
 
index f163298180e6249f999f060044cd130953e41dee..0c3a93f2a8d885dcc4d713857f6dfee23c3e7594 100644 (file)
@@ -24,7 +24,7 @@ namespace ob {
 */
 class OBFrame {
 private:
-  const OBClient *_client;
+  OBClient *_client;
   const otk::ScreenInfo *_screen;
 
   //! The style to use for size and display the decorations
@@ -89,7 +89,7 @@ public:
     @param client The client window which will be decorated by the new OBFrame
     @param style The style to use to decorate the frame
   */
-  OBFrame(const OBClient *client, const otk::Style *style);
+  OBFrame(OBClient *client, const otk::Style *style);
   //! Destroys the OBFrame object
   virtual ~OBFrame();
 
index 9d316ce4852f1f31d867341a3ad4e27e4dce1a9e..7413b163438d17376f736c8bc94ea75c22b2d429 100644 (file)
@@ -101,7 +101,7 @@ OBScreen::~OBScreen()
 
   // unmanage all windows
   while (!_clients.empty())
-    unmanageWindow(_clients[0]);
+    unmanageWindow(_clients.front());
 
   delete _image_control;
 }
@@ -338,6 +338,8 @@ void OBScreen::manageWindow(Window window)
     XFree(wmhint);
   }
 
+  otk::OBDisplay::grab();
+
   // choose the events we want to receive on the CLIENT window
   attrib_set.event_mask = OBClient::event_mask;
   attrib_set.do_not_propagate_mask = ButtonPressMask | ButtonReleaseMask |
@@ -362,7 +364,15 @@ void OBScreen::manageWindow(Window window)
   // create the decoration frame for the client window
   client->frame = new OBFrame(client, &_style);
 
-  // add all the client's decoration windows as event handlers for the client
+  // XXX: if on the current desktop..
+  XMapWindow(otk::OBDisplay::display, client->frame->window());
+  // XXX: handle any requested states such as shaded/maximized
+
+  otk::OBDisplay::ungrab();
+
+  // add all the client's windows as event handlers for the client
+  Openbox::instance->addClient(window, client);
   Openbox::instance->addClient(client->frame->window(), client);
   Openbox::instance->addClient(client->frame->titlebar(), client);
   Openbox::instance->addClient(client->frame->buttonIconify(), client);
@@ -373,14 +383,10 @@ void OBScreen::manageWindow(Window window)
   Openbox::instance->addClient(client->frame->handle(), client);
   Openbox::instance->addClient(client->frame->gripLeft(), client);
   Openbox::instance->addClient(client->frame->gripRight(), client);
-  
-  // XXX: if on the current desktop..
-  XMapWindow(otk::OBDisplay::display, client->frame->window());
-  // XXX: handle any requested states such as shaded/maximized
-
 
+  // add to the screen's list
   _clients.push_back(client);
+  // update the root properties
   setClientList();
 }
 
@@ -420,14 +426,11 @@ void OBScreen::unmanageWindow(OBClient *client)
   delete client->frame;
   client->frame = 0;
 
-  ClientList::iterator it = _clients.begin(), end = _clients.end();
-  for (; it != end; ++it)
-    if (*it == client) {
-      _clients.erase(it);
-      break;
-    }
+  // remove from the screen's list
+  _clients.remove(client);
   delete client;
 
+  // update the root properties
   setClientList();
 }
 
index 516632ac265f768fa70ca2f96f564a18cf28a54c..8d7bc6b07db5db71509f7e22798a9bf064ab9242 100644 (file)
@@ -29,7 +29,7 @@ class OBClient;
 class OBScreen {
 public:
   //! Holds a list of OBClient objects
-  typedef std::vector<OBClient*> ClientList;
+  typedef std::list<OBClient*> ClientList;
   //! Holds a list of otk::Strut objects
   typedef std::list<otk::Strut*> StrutList;
 
index 7cd5257abe86a832be9579f40332e2af0f2abf78..5d5273779200eb1c4aaa27bbba1c8e5f8fb5b1eb 100644 (file)
@@ -231,8 +231,11 @@ void OBXEventHandler::unmapNotify(const XUnmapEvent &e)
 {
   OBClient *client = Openbox::instance->findClient(e.window);
   if (!client) return;
-  
-  Openbox::instance->screen(client->screen())->unmanageWindow(client);
+
+  if (client->ignore_unmaps == 0)
+    Openbox::instance->screen(client->screen())->unmanageWindow(client);
+  else
+    client->ignore_unmaps--;
 }
 
 
This page took 0.033121 seconds and 4 git commands to generate.