diff options
author | Thomas Lübking <thomas.luebking@gmail.com> | 2016-06-19 15:45:41 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2016-06-26 14:35:16 (GMT) |
commit | 1a61881ec34a5f3691df1159f63a4b5afb1f53c4 (patch) | |
tree | 8ab844e8790c75a0e9dcc2ea44143dea47649758 /src/Window.cc | |
parent | 69b0f0fa97f53f601a250dc1b5a6876f64796a91 (diff) | |
download | fluxbox-1a61881ec34a5f3691df1159f63a4b5afb1f53c4.zip fluxbox-1a61881ec34a5f3691df1159f63a4b5afb1f53c4.tar.bz2 |
Add FocusProtection features
The apps file gets a new key
FocusProtection
supporting a comma separated list.
* None : regular behavior
* Lock : If this window has the focus, no other may claim it
* Deny : This window is not allowed to focus itself
I addition there's preparation for a follow-up patch to incorporate and
substitute the present FocusNewWindow feature:
* Gain : Pass focus to new window
* Refuse : Do not pass focus to new window
rationale:
clients stealing the focus sucks badly and while there's an input driven
timeout, that only protects actual typing flow, but if eg. vlc proceeds on
the playlist, you'll suddenly control vlc instead of your browser
(ie. typing ctrl+w doesn't close the tab, but the playlist ...)
Diffstat (limited to 'src/Window.cc')
-rw-r--r-- | src/Window.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/Window.cc b/src/Window.cc index ac76aee..929cec8 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -291,6 +291,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client): | |||
291 | m_client(&client), | 291 | m_client(&client), |
292 | m_toggled_decos(false), | 292 | m_toggled_decos(false), |
293 | m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)), | 293 | m_focus_new(BoolAcc(screen().focusControl(), &FocusControl::focusNew)), |
294 | m_focus_protection(Focus::NoProtection), | ||
294 | m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), | 295 | m_mouse_focus(BoolAcc(screen().focusControl(), &FocusControl::isMouseFocus)), |
295 | m_click_focus(true), | 296 | m_click_focus(true), |
296 | m_last_button_x(0), m_last_button_y(0), | 297 | m_last_button_x(0), m_last_button_y(0), |
@@ -563,7 +564,10 @@ void FluxboxWindow::init() { | |||
563 | // check if we should prevent this window from gaining focus | 564 | // check if we should prevent this window from gaining focus |
564 | m_focused = false; // deiconify sets this | 565 | m_focused = false; // deiconify sets this |
565 | if (!Fluxbox::instance()->isStartup() && m_focus_new) { | 566 | if (!Fluxbox::instance()->isStartup() && m_focus_new) { |
567 | Focus::Protection fp = m_focus_protection; | ||
568 | m_focus_protection &= ~Focus::Deny; // new windows run as "Refuse" | ||
566 | m_focused = focusRequestFromClient(*m_client); | 569 | m_focused = focusRequestFromClient(*m_client); |
570 | m_focus_protection = fp; | ||
567 | if (!m_focused) | 571 | if (!m_focused) |
568 | lower(); | 572 | lower(); |
569 | } | 573 | } |
@@ -2025,7 +2029,10 @@ void FluxboxWindow::mapRequestEvent(XMapRequestEvent &re) { | |||
2025 | 2029 | ||
2026 | if (m_focus_new) { | 2030 | if (m_focus_new) { |
2027 | m_focused = false; // deiconify sets this | 2031 | m_focused = false; // deiconify sets this |
2032 | Focus::Protection fp = m_focus_protection; | ||
2033 | m_focus_protection &= ~Focus::Deny; // goes by "Refuse" | ||
2028 | m_focused = focusRequestFromClient(*client); | 2034 | m_focused = focusRequestFromClient(*client); |
2035 | m_focus_protection = fp; | ||
2029 | if (!m_focused) | 2036 | if (!m_focused) |
2030 | lower(); | 2037 | lower(); |
2031 | } | 2038 | } |
@@ -2041,9 +2048,13 @@ bool FluxboxWindow::focusRequestFromClient(WinClient &from) { | |||
2041 | 2048 | ||
2042 | FluxboxWindow *cur = FocusControl::focusedFbWindow(); | 2049 | FluxboxWindow *cur = FocusControl::focusedFbWindow(); |
2043 | WinClient *client = FocusControl::focusedWindow(); | 2050 | WinClient *client = FocusControl::focusedWindow(); |
2044 | if (cur && getRootTransientFor(&from) != getRootTransientFor(client)) | 2051 | if ((from.fbwindow() && (from.fbwindow()->focusProtection() & Focus::Deny)) || |
2052 | (cur && (cur->focusProtection() & Focus::Lock))) { | ||
2053 | ret = false; | ||
2054 | } else if (cur && getRootTransientFor(&from) != getRootTransientFor(client)) { | ||
2045 | ret = !(cur->isFullscreen() && getOnHead() == cur->getOnHead()) && | 2055 | ret = !(cur->isFullscreen() && getOnHead() == cur->getOnHead()) && |
2046 | !cur->isTyping(); | 2056 | !cur->isTyping(); |
2057 | } | ||
2047 | 2058 | ||
2048 | if (!ret) | 2059 | if (!ret) |
2049 | Fluxbox::instance()->attentionHandler().addAttention(from); | 2060 | Fluxbox::instance()->attentionHandler().addAttention(from); |