diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-13 00:47:40 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-13 00:47:40 (GMT) |
commit | b302dab2f187e364df36237c44b8e48f1e892f04 (patch) | |
tree | 207955232ddf7aef1b4a13ccb5ae85a2404aa509 /src/fluxbox.cc | |
parent | f66d446a94450d509748afe28a95f48b8fdfcfc5 (diff) | |
download | fluxbox-b302dab2f187e364df36237c44b8e48f1e892f04.zip fluxbox-b302dab2f187e364df36237c44b8e48f1e892f04.tar.bz2 |
fix some issues with reverting focus
Diffstat (limited to 'src/fluxbox.cc')
-rw-r--r-- | src/fluxbox.cc | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index e93f363..110123c 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -749,11 +749,6 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
749 | FluxboxWindow *win = winclient->fbwindow(); | 749 | FluxboxWindow *win = winclient->fbwindow(); |
750 | if (win) | 750 | if (win) |
751 | win->destroyNotifyEvent(e->xdestroywindow); | 751 | win->destroyNotifyEvent(e->xdestroywindow); |
752 | |||
753 | delete winclient; | ||
754 | |||
755 | if (win && win->numClients() == 0) | ||
756 | delete win; | ||
757 | } | 752 | } |
758 | 753 | ||
759 | } | 754 | } |
@@ -835,10 +830,11 @@ void Fluxbox::handleEvent(XEvent * const e) { | |||
835 | break; | 830 | break; |
836 | 831 | ||
837 | WinClient *winclient = searchWindow(e->xfocus.window); | 832 | WinClient *winclient = searchWindow(e->xfocus.window); |
838 | if (winclient && (winclient == FocusControl::focusedWindow() || | 833 | if ((winclient == FocusControl::focusedWindow() || |
839 | FocusControl::focusedWindow() == 0) && | 834 | FocusControl::focusedWindow() == 0) && |
840 | // we don't unfocus a moving window | 835 | // we don't unfocus a moving window |
841 | (winclient->fbwindow() == 0 || !winclient->fbwindow()->isMoving())) | 836 | (!winclient || !winclient->fbwindow() || |
837 | !winclient->fbwindow()->isMoving())) | ||
842 | revertFocus(); | 838 | revertFocus(); |
843 | } | 839 | } |
844 | break; | 840 | break; |
@@ -884,13 +880,6 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { | |||
884 | // this should delete client and adjust m_focused_window if necessary | 880 | // this should delete client and adjust m_focused_window if necessary |
885 | win->unmapNotifyEvent(ue); | 881 | win->unmapNotifyEvent(ue); |
886 | 882 | ||
887 | winclient = 0; // it's invalid now when win destroyed the client | ||
888 | |||
889 | // finally destroy window if empty | ||
890 | if (win->numClients() == 0) { | ||
891 | delete win; | ||
892 | win = 0; | ||
893 | } | ||
894 | } | 883 | } |
895 | 884 | ||
896 | // according to http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 | 885 | // according to http://tronche.com/gui/x/icccm/sec-4.html#s-4.1.4 |
@@ -1077,6 +1066,9 @@ void Fluxbox::update(FbTk::Subject *changedsub) { | |||
1077 | FocusControl::unfocusWindow(*client); | 1066 | FocusControl::unfocusWindow(*client); |
1078 | // make sure nothing else uses this window before focus reverts | 1067 | // make sure nothing else uses this window before focus reverts |
1079 | FocusControl::setFocusedWindow(0); | 1068 | FocusControl::setFocusedWindow(0); |
1069 | } else if (FocusControl::expectingFocus() == client) { | ||
1070 | FocusControl::setExpectingFocus(0); | ||
1071 | revertFocus(); | ||
1080 | } | 1072 | } |
1081 | 1073 | ||
1082 | screen.removeClient(*client); | 1074 | screen.removeClient(*client); |
@@ -1555,22 +1547,18 @@ void Fluxbox::revertFocus() { | |||
1555 | if (revert) { | 1547 | if (revert) { |
1556 | // see if there are any more focus events in the queue | 1548 | // see if there are any more focus events in the queue |
1557 | XEvent ev; | 1549 | XEvent ev; |
1558 | while (XCheckMaskEvent(display(), FocusChangeMask, &ev)) { | 1550 | while (XCheckMaskEvent(display(), FocusChangeMask, &ev)) |
1559 | handleEvent(&ev); | 1551 | handleEvent(&ev); |
1560 | revert = false; | 1552 | if (FocusControl::focusedWindow() || FocusControl::expectingFocus()) |
1561 | } | ||
1562 | if (!revert) | ||
1563 | return; // already handled | 1553 | return; // already handled |
1564 | } | ||
1565 | 1554 | ||
1566 | if (revert) { | ||
1567 | Window win; | 1555 | Window win; |
1568 | int blah; | 1556 | int blah; |
1569 | XGetInputFocus(display(), &win, &blah); | 1557 | XGetInputFocus(display(), &win, &blah); |
1570 | 1558 | ||
1571 | // we only want to revert focus if it's left dangling, as some other | 1559 | // we only want to revert focus if it's left dangling, as some other |
1572 | // application may have set the focus to an unmanaged window | 1560 | // application may have set the focus to an unmanaged window |
1573 | if (win != None && win != PointerRoot && | 1561 | if (win != None && win != PointerRoot && !searchWindow(win) && |
1574 | win != m_keyscreen->rootWindow().window()) | 1562 | win != m_keyscreen->rootWindow().window()) |
1575 | revert = false; | 1563 | revert = false; |
1576 | } | 1564 | } |