]> Dogcows Code - chaz/openbox/blobdiff - src/blackbox.cc
switch workspaces if neccessary for a NET_WM_ACTIVE_WINDOW ClientMessage
[chaz/openbox] / src / blackbox.cc
index 3cc12bc4523e65333d00e6ab719efd728d7b2114..ba0b07478d2b79a12fa5b369aec9fef442711d00 100644 (file)
@@ -145,6 +145,12 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc, char *menu)
 
   ::blackbox = this;
   argv = m_argv;
+
+  // try to make sure the ~/.openbox directory exists
+  mkdir(expandTilde("~/.openbox").c_str(), S_IREAD | S_IWRITE | S_IEXEC |
+                                           S_IRGRP | S_IWGRP | S_IXGRP |
+                                           S_IROTH | S_IWOTH | S_IXOTH);
+  
   if (! rc) rc = "~/.openbox/rc";
   rc_file = expandTilde(rc);
   config.setFile(rc_file);  
@@ -158,7 +164,6 @@ Blackbox::Blackbox(char **m_argv, char *dpy_name, char *rc, char *menu)
   active_screen = 0;
   focused_window = changing_window = (BlackboxWindow *) 0;
 
-  XrmInitialize();
   load_rc();
 
   xatom = new XAtom(getXDisplay());
@@ -322,7 +327,20 @@ void Blackbox::process_event(XEvent *e) {
 
     BlackboxWindow *win = searchWindow(e->xmaprequest.window);
 
-    if (! win) {
+    if (win) {
+      bool focus = False;
+      if (win->isIconic()) {
+        win->deiconify();
+        focus = True;
+      }
+      if (win->isShaded()) {
+        win->shade();
+        focus = True;
+      }
+
+      if (focus && (win->isTransient() || win->getScreen()->doFocusNew()))
+        win->setInputFocus();
+    } else {
       BScreen *screen = searchScreen(e->xmaprequest.parent);
 
       if (! screen) {
@@ -444,13 +462,13 @@ void Blackbox::process_event(XEvent *e) {
   case PropertyNotify: {
     last_time = e->xproperty.time;
 
-    if (e->xproperty.state != PropertyDelete) {
-      BlackboxWindow *win = searchWindow(e->xproperty.window);
-
-      if (win)
-        win->propertyNotifyEvent(e->xproperty.atom);
-    }
+    BlackboxWindow *win = (BlackboxWindow *) 0;
+    BScreen *screen = (BScreen *) 0;
 
+    if ((win = searchWindow(e->xproperty.window)))
+      win->propertyNotifyEvent(&e->xproperty);
+    else if ((screen = searchScreen(e->xproperty.window)))
+      screen->propertyNotifyEvent(&e->xproperty);
     break;
   }
 
@@ -687,18 +705,29 @@ void Blackbox::process_event(XEvent *e) {
         if (screen && workspace < screen->getWorkspaceCount())
           screen->changeWorkspaceID(workspace);
       } else if (e->xclient.message_type == 
-                 xatom->getAtom(XAtom::blackbox_change_window_focus) ||
-                 e->xclient.message_type == 
+                 xatom->getAtom(XAtom::blackbox_change_window_focus)) {
+        // TEMP HACK TO KEEP BBKEYS WORKING
+        BlackboxWindow *win = searchWindow(e->xclient.window);
+
+        if (win && win->isVisible() && win->setInputFocus())
+          win->installColormap(True);
+      } else if (e->xclient.message_type == 
                  xatom->getAtom(XAtom::net_active_window)) {
         // NET_ACTIVE_WINDOW
         BlackboxWindow *win = searchWindow(e->xclient.window);
 
         if (win) {
+          BScreen *screen = win->getScreen();
+
           if (win->isIconic())
             win->deiconify(False, True);
+          if (win->isShaded())
+            win->shade();
+          if (win->getWorkspaceNumber() != screen->getCurrentWorkspaceID())
+            screen->changeWorkspaceID(win->getWorkspaceNumber());
           if (win->isVisible() && win->setInputFocus()) {
-            //win->getScreen()->getWorkspace(win->getWorkspaceNumber())->
-            //  raiseWindow(win);
+            win->getScreen()->getWorkspace(win->getWorkspaceNumber())->
+              raiseWindow(win);
             win->installColormap(True);
           }
         }
@@ -958,6 +987,9 @@ void Blackbox::process_event(XEvent *e) {
 bool Blackbox::handleSignal(int sig) {
   switch (sig) {
   case SIGHUP:
+    restart();
+    break;
+
   case SIGUSR1:
     reconfigure();
     break;
@@ -1143,6 +1175,7 @@ void Blackbox::restart(const char *prog) {
   shutdown();
 
   if (prog) {
+    putenv(const_cast<char *>(screenList.front()->displayString().c_str()));
     execlp(prog, prog, NULL);
     perror(prog);
   }
@@ -1194,7 +1227,7 @@ void Blackbox::save_rc(void) {
 
 void Blackbox::load_rc(void) {
   if (! config.load())
-        config.create();
+    config.create();
   
   string s;
 
This page took 0.023822 seconds and 4 git commands to generate.