From e65a966d807e6b9b961817a3b160af1d4a765e0d Mon Sep 17 00:00:00 2001 From: Hendrik Iben Date: Sun, 18 Nov 2012 20:09:35 +0100 Subject: [PATCH] Added option for focus revert to stay on current head --- nls/de_DE/Translation.m | 2 ++ nls/fluxbox-nls.hh | 1 + src/FocusControl.cc | 12 ++++++++++++ src/FocusControl.hh | 7 +++++++ src/Screen.cc | 11 +++++++++++ 5 files changed, 33 insertions(+) diff --git a/nls/de_DE/Translation.m b/nls/de_DE/Translation.m index 454de0ed..9149c10b 100644 --- a/nls/de_DE/Translation.m +++ b/nls/de_DE/Translation.m @@ -78,6 +78,8 @@ $set 4 #Configmenu 27 Resize-Increment nicht beachten 28 Position fixieren 29 Größe fixieren +30 Fokus folgt Maus (strikt) +31 Gleicher Head $set 5 #Ewmh diff --git a/nls/fluxbox-nls.hh b/nls/fluxbox-nls.hh index 7ddc9782..13db6b61 100644 --- a/nls/fluxbox-nls.hh +++ b/nls/fluxbox-nls.hh @@ -85,6 +85,7 @@ enum { ConfigmenuMaxDisableMove = 28, ConfigmenuMaxDisableResize = 29, ConfigmenuStrictMouseFocus = 30, + ConfigmenuFocusSameHead = 31, EwmhSet = 5, EwmhOutOfMemoryClientList = 1, diff --git a/src/FocusControl.cc b/src/FocusControl.cc index 383de612..2dbf289d 100644 --- a/src/FocusControl.cc +++ b/src/FocusControl.cc @@ -76,6 +76,11 @@ FocusControl::FocusControl(BScreen &screen): m_focus_new(screen.resourceManager(), true, screen.name()+".focusNewWindows", screen.altName()+".FocusNewWindows"), +#ifdef XINERAMA + m_focus_same_head(screen.resourceManager(), false, + screen.name()+".focusSameHead", + screen.altName()+".FocusSameHead"), +#endif // XINERAMA m_focused_list(screen), m_creation_order_list(screen), m_focused_win_list(screen), m_creation_order_win_list(screen), m_cycling_list(0), @@ -251,11 +256,18 @@ Focusable *FocusControl::lastFocusedWindow(int workspace) { if (workspace < 0 || workspace >= (int) m_screen.numberOfWorkspaces()) return m_focused_list.clientList().front(); +#ifdef XINERAMA + int cur_head = focusSameHead() ? m_screen.getCurrHead() : (-1); +#endif // XINERAMA + Focusables::iterator it = m_focused_list.clientList().begin(); Focusables::iterator it_end = m_focused_list.clientList().end(); for (; it != it_end; ++it) { if ((*it)->fbwindow() && (*it)->acceptsFocus() && (*it)->fbwindow()->winClient().validateClient() && +#ifdef XINERAMA + ( (cur_head == -1) || ((*it)->fbwindow()->getOnHead() == cur_head) ) && +#endif // XINERAMA ((((int)(*it)->fbwindow()->workspaceNumber()) == workspace || (*it)->fbwindow()->isStuck()) && !(*it)->fbwindow()->isIconic())) return *it; diff --git a/src/FocusControl.hh b/src/FocusControl.hh index c2652532..d583d160 100644 --- a/src/FocusControl.hh +++ b/src/FocusControl.hh @@ -124,6 +124,10 @@ public: TabFocusModel tabFocusModel() const { return *m_tab_focus_model; } /// @return true if newly created windows are focused bool focusNew() const { return *m_focus_new; } +#ifdef XINERAMA + /// @return true if focus reverts to same head only + bool focusSameHead() const { return *m_focus_same_head; } +#endif // XINERAMA /// @return last focused client in a specific workspace, or NULL. Focusable *lastFocusedWindow(int workspace); @@ -161,6 +165,9 @@ private: FbTk::Resource m_focus_model; FbTk::Resource m_tab_focus_model; FbTk::Resource m_focus_new; +#ifdef XINERAMA + FbTk::Resource m_focus_same_head; +#endif // XINERAMA // This list keeps the order of window focusing for this screen // Screen global so it works for sticky windows too. diff --git a/src/Screen.cc b/src/Screen.cc index 6757af08..b2e57edd 100644 --- a/src/Screen.cc +++ b/src/Screen.cc @@ -1600,6 +1600,17 @@ void BScreen::setupConfigmenu(FbTk::Menu &menu) { } catch (FbTk::ResourceException & e) { cerr<insert(new FbTk::BoolMenuItem(_FB_XTEXT(Configmenu, FocusSameHead, + "Keep Head", "Only revert focus on same head"), + m_resource_manager.getResource(name() + ".focusSameHead"), + saverc_cmd)); + } catch (FbTk::ResourceException e) { + cerr<