]> Dogcows Code - chaz/openbox/commitdiff
focus code updates
authorDana Jansens <danakj@orodu.net>
Mon, 13 May 2002 00:23:59 +0000 (00:23 +0000)
committerDana Jansens <danakj@orodu.net>
Mon, 13 May 2002 00:23:59 +0000 (00:23 +0000)
src/Screen.cc
src/Toolbar.cc
src/Window.cc
src/Window.h
src/Workspace.cc
src/openbox.cc

index 5e52e10eca4698c074f27e38e85a9db083dd7050..1d4ae1ff1728863bf26fb77c7d3c7b1a3e2c19f9 100644 (file)
@@ -483,9 +483,6 @@ BScreen::BScreen(Openbox &ob, int scrn, Resource &conf) : ScreenInfo(ob, scrn),
     }
   }
 
-  XSetInputFocus(getBaseDisplay().getXDisplay(),
-                 PointerRoot, None, CurrentTime);
-
   XFree(children);
   XFlush(getBaseDisplay().getXDisplay());
 }
index fd2191445da5f34b08fa59107f91f6394f301eb8..7ce387eb5c6ea1ba226cadc2a7cf25251879da3a 100644 (file)
@@ -1154,9 +1154,9 @@ void Toolbar::keyPressEvent(XKeyEvent *ke) {
       if (openbox.focusedWindow()) {
         openbox.focusedWindow()->setInputFocus();
         openbox.focusedWindow()->setFocusFlag(True);
-      } else {
-        XSetInputFocus(display, PointerRoot, None, CurrentTime);
-      }
+      } else
+        openbox.focusWindow((OpenboxWindow *) 0);
+
       // check to make sure that new_name[0] != 0... otherwise we have a null
       // workspace name which causes serious problems, especially for the
       // Openbox::LoadRC() method.
index ec042c305ae77e80cb253bdddbb40d7f9ed4afd7..c9c5ce94f1e5ea1bc41e3df9947c7dca583e0c81 100644 (file)
@@ -1353,7 +1353,7 @@ void OpenboxWindow::configure(int dx, int dy,
 }
 
 
-Bool OpenboxWindow::setInputFocus(void) {
+bool OpenboxWindow::setInputFocus(void) {
   if (((signed) (frame.x + frame.width)) < 0) {
     if (((signed) (frame.y + frame.y_border)) < 0)
       configure(frame.border_w, frame.border_w, frame.width, frame.height);
@@ -1378,39 +1378,36 @@ Bool OpenboxWindow::setInputFocus(void) {
   openbox.grab();
   if (! validateClient()) return False;
 
-  Bool ret = False;
+  bool ret = false;
 
   if (client.transient && flags.modal) {
     ret = client.transient->setInputFocus();
   } else if (! flags.focused) {
-    if (focus_mode == F_LocallyActive || focus_mode == F_Passive)
+    if (focus_mode == F_LocallyActive || focus_mode == F_Passive) {
       XSetInputFocus(display, client.window,
                       RevertToPointerRoot, CurrentTime);
-    else
-      XSetInputFocus(display, screen->getRootWindow(),
-                    RevertToNone, CurrentTime);
-
-    openbox.focusWindow(this);
-
-    if (flags.send_focus_message) {
-      XEvent ce;
-      ce.xclient.type = ClientMessage;
-      ce.xclient.message_type = openbox.getWMProtocolsAtom();
-      ce.xclient.display = display;
-      ce.xclient.window = client.window;
-      ce.xclient.format = 32;
-      ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
-      ce.xclient.data.l[1] = openbox.getLastTime();
-      ce.xclient.data.l[2] = 0l;
-      ce.xclient.data.l[3] = 0l;
-      ce.xclient.data.l[4] = 0l;
-      XSendEvent(display, client.window, False, NoEventMask, &ce);
-    }
+      openbox.focusWindow(this);
+
+      if (flags.send_focus_message) {
+        XEvent ce;
+        ce.xclient.type = ClientMessage;
+        ce.xclient.message_type = openbox.getWMProtocolsAtom();
+        ce.xclient.display = display;
+        ce.xclient.window = client.window;
+        ce.xclient.format = 32;
+        ce.xclient.data.l[0] = openbox.getWMTakeFocusAtom();
+        ce.xclient.data.l[1] = openbox.getLastTime();
+        ce.xclient.data.l[2] = 0l;
+        ce.xclient.data.l[3] = 0l;
+        ce.xclient.data.l[4] = 0l;
+        XSendEvent(display, client.window, False, NoEventMask, &ce);
+      }
 
-    if (screen->sloppyFocus() && screen->autoRaise())
-      timer->start();
+      if (screen->sloppyFocus() && screen->autoRaise())
+        timer->start();
 
-    ret = True;
+      ret = true;
+    }
   }
 
   openbox.ungrab();
@@ -3015,7 +3012,7 @@ void OpenboxWindow::shapeEvent(XShapeEvent *) {
 #endif // SHAPE
 
 
-Bool OpenboxWindow::validateClient(void) {
+bool OpenboxWindow::validateClient(void) {
   XSync(display, False);
 
   XEvent e;
@@ -3024,10 +3021,10 @@ Bool OpenboxWindow::validateClient(void) {
     XPutBackEvent(display, &e);
     openbox.ungrab();
 
-    return False;
+    return false;
   }
 
-  return True;
+  return true;
 }
 
 
index fb988e234a1224b53320b8ee15f65aebe8c75e27..3c9fa86729b1136a83bf7db69eed65715b180cdc 100644 (file)
@@ -316,8 +316,8 @@ public:
   
   inline void setWindowNumber(int n) { window_number = n; }
   
-  Bool validateClient();
-  Bool setInputFocus();
+  bool validateClient();
+  bool setInputFocus();
 
   void setFocusFlag(Bool);
   void iconify();
index 89ea8e7bc9fa31742555909c87c9178f1b6a38af..d42f6c2db7634f381123f674c0d4300b45c11cb6 100644 (file)
@@ -119,8 +119,6 @@ const int Workspace::removeWindow(OpenboxWindow *w) {
           _zorder.empty() ||                    // click focus but no windows
           !_zorder.front()->setInputFocus()) {  // tried window, but wont focus
        screen.getOpenbox().focusWindow((OpenboxWindow *) 0);
-        XSetInputFocus(screen.getOpenbox().getXDisplay(),
-                       PointerRoot, None, CurrentTime);
       }
     }
   }
index 8d3b1af1df03bca836f88dca2c1b04958a2c02f8..7c25bc624d9eecc9b7685e487da78fbfed87c866 100644 (file)
@@ -227,6 +227,8 @@ Openbox::Openbox(int m_argc, char **m_argv, char *dpy_name, char *rc)
   timer->fireOnce(True);
 
   ungrab();
+
+  focusWindow((OpenboxWindow *) 0);
 }
 
 
@@ -865,7 +867,7 @@ void Openbox::restart(const char *prog) {
 void Openbox::shutdown() {
   BaseDisplay::shutdown();
 
-  XSetInputFocus(getXDisplay(), PointerRoot, None, CurrentTime);
+  focusWindow((OpenboxWindow *) 0);
 
   std::for_each(screenList.begin(), screenList.end(),
                 std::mem_fun(&BScreen::shutdown));
@@ -1094,8 +1096,10 @@ void Openbox::focusWindow(OpenboxWindow *win) {
     if (tbar)
       tbar->redrawWindowLabel(true);
     focused_screen->updateNetizenWindowFocus();
-  //} else {
-  //  focused_window = (OpenboxWindow *) 0;
+  } else {
+    ASSERT(focused_screen != (BScreen *) 0);
+    XSetInputFocus(getXDisplay(), focused_screen->getRootWindow(),
+                   None, CurrentTime);
   }
 
   if (old_tbar && old_tbar != tbar)
This page took 0.033282 seconds and 4 git commands to generate.