summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDana Jansens <danakj@orodu.net>2002-05-13 00:23:59 +0000
committerDana Jansens <danakj@orodu.net>2002-05-13 00:23:59 +0000
commit6d16679486a9268a17f3bfd03b05febf1644a87e (patch)
tree69cd3092ed2e8a7b13c4af852cd80b9fbfae8b6d /src
parent6486b6457693414862fdc34ea07457ed5cbf0a0d (diff)
focus code updates
Diffstat (limited to 'src')
-rw-r--r--src/Screen.cc3
-rw-r--r--src/Toolbar.cc6
-rw-r--r--src/Window.cc55
-rw-r--r--src/Window.h4
-rw-r--r--src/Workspace.cc2
-rw-r--r--src/openbox.cc10
6 files changed, 38 insertions, 42 deletions
diff --git a/src/Screen.cc b/src/Screen.cc
index 5e52e10e..1d4ae1ff 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -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());
}
diff --git a/src/Toolbar.cc b/src/Toolbar.cc
index fd219144..7ce387eb 100644
--- a/src/Toolbar.cc
+++ b/src/Toolbar.cc
@@ -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.
diff --git a/src/Window.cc b/src/Window.cc
index ec042c30..c9c5ce94 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -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;
}
diff --git a/src/Window.h b/src/Window.h
index fb988e23..3c9fa867 100644
--- a/src/Window.h
+++ b/src/Window.h
@@ -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();
diff --git a/src/Workspace.cc b/src/Workspace.cc
index 89ea8e7b..d42f6c2d 100644
--- a/src/Workspace.cc
+++ b/src/Workspace.cc
@@ -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);
}
}
}
diff --git a/src/openbox.cc b/src/openbox.cc
index 8d3b1af1..7c25bc62 100644
--- a/src/openbox.cc
+++ b/src/openbox.cc
@@ -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)