aboutsummaryrefslogtreecommitdiff
path: root/src/fluxbox.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-05-04 23:38:06 (GMT)
committerrathnor <rathnor>2003-05-04 23:38:06 (GMT)
commit2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1 (patch)
treeacb6c82d00dd1258773c45ef539f38b2f093e191 /src/fluxbox.cc
parent65bbfbe51b9d8531490708e83ba422c7dc53dc1a (diff)
downloadfluxbox_pavel-2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1.zip
fluxbox_pavel-2ac0d82e451abd3cdc92df2a02c0da4eb8638ba1.tar.bz2
fix up focus problems
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r--src/fluxbox.cc60
1 files changed, 58 insertions, 2 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc
index d26d8b3..19580d9 100644
--- a/src/fluxbox.cc
+++ b/src/fluxbox.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: fluxbox.cc,v 1.127 2003/05/04 16:55:40 rathnor Exp $ 25// $Id: fluxbox.cc,v 1.128 2003/05/04 23:38:06 rathnor Exp $
26 26
27#include "fluxbox.hh" 27#include "fluxbox.hh"
28 28
@@ -902,7 +902,7 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
902 client = 0; // it's invalid now when win destroyed the client 902 client = 0; // it's invalid now when win destroyed the client
903 903
904 if (win == m_focused_window) 904 if (win == m_focused_window)
905 m_focused_window = 0; 905 revertFocus(&win->getScreen());
906 906
907 // finaly destroy window if empty 907 // finaly destroy window if empty
908 if (win->numClients() == 0) { 908 if (win->numClients() == 0) {
@@ -1492,6 +1492,8 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
1492 // make sure each workspace get this 1492 // make sure each workspace get this
1493 BScreen &scr = win.getScreen(); 1493 BScreen &scr = win.getScreen();
1494 scr.removeWindow(&win); 1494 scr.removeWindow(&win);
1495 if (m_focused_window == &win)
1496 revertFocus(&scr);
1495 1497
1496 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal 1498 } else if ((&(win.workspaceSig())) == changedsub) { // workspace signal
1497 for (size_t i=0; i<m_atomhandler.size(); ++i) { 1499 for (size_t i=0; i<m_atomhandler.size(); ++i) {
@@ -2276,6 +2278,60 @@ void Fluxbox::setFocusedWindow(FluxboxWindow *win) {
2276 2278
2277} 2279}
2278 2280
2281/**
2282 * This function is called whenever we aren't quite sure what
2283 * focus is meant to be, it'll make things right ;-)
2284 * last_focused is set to something if we want to make use of the
2285 * previously focused window (it must NOT be set focused now, it
2286 * is probably dying).
2287 */
2288void Fluxbox::revertFocus(BScreen *screen) {
2289 // Relevant resources:
2290 // resource.focus_last = whether we focus last focused when changing workspace
2291 // Fluxbox::FocusModel = sloppy, click, whatever
2292
2293 // if no given screen, get it from the mouse
2294 if (screen == 0) {
2295 Window root = 0, ignorew;
2296 int ignored;
2297 BScreen *tempscr = m_screen_list.front();
2298 XQueryPointer(FbTk::App::instance()->display(),
2299 tempscr->getRootWindow(), &root, &ignorew, &ignored,
2300 &ignored, &ignored, &ignored, &((unsigned int) ignored));
2301 screen = searchScreen(root);
2302 if (screen == 0) {
2303#ifdef DEBUG
2304 cerr<<"No screen to base focus revert on!"<<endl;
2305#endif // DEBUG
2306 // flounder
2307 XSetInputFocus(FbTk::App::instance()->display(),
2308 PointerRoot, None, CurrentTime);
2309 return;
2310 }
2311 }
2312
2313 WinClient *next_focus = screen->getLastFocusedWindow(screen->getCurrentWorkspaceID());
2314
2315 if (next_focus && next_focus->fbwindow()) {
2316 next_focus->fbwindow()->setInputFocus();
2317 } else {
2318 switch (screen->getFocusModel()) {
2319 case SLOPPYFOCUS:
2320 case SEMISLOPPYFOCUS:
2321 XSetInputFocus(FbTk::App::instance()->display(),
2322 PointerRoot, None, CurrentTime);
2323 break;
2324 case CLICKTOFOCUS:
2325 XSetInputFocus(FbTk::App::instance()->display(),
2326 screen->getRootWindow(),
2327 RevertToPointerRoot, CurrentTime);
2328 break;
2329 }
2330 }
2331}
2332
2333
2334
2279void Fluxbox::watchKeyRelease(BScreen *screen, unsigned int mods) { 2335void Fluxbox::watchKeyRelease(BScreen *screen, unsigned int mods) {
2280 if (mods == 0) { 2336 if (mods == 0) {
2281 cerr<<"WARNING: attempt to grab without modifiers!"<<endl; 2337 cerr<<"WARNING: attempt to grab without modifiers!"<<endl;