aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FocusControl.hh67
1 files changed, 52 insertions, 15 deletions
diff --git a/src/FocusControl.hh b/src/FocusControl.hh
index 9ab19e2..69660f9 100644
--- a/src/FocusControl.hh
+++ b/src/FocusControl.hh
@@ -42,72 +42,109 @@ class FocusControl {
42public: 42public:
43 typedef std::list<WinClient *> FocusedWindows; 43 typedef std::list<WinClient *> FocusedWindows;
44 typedef std::list<Focusable *> Focusables; 44 typedef std::list<Focusable *> Focusables;
45 45 /// main focus model
46 enum FocusModel { 46 enum FocusModel {
47 MOUSEFOCUS = 0, ///< focus follows 47 MOUSEFOCUS = 0, ///< focus follows mouse
48 CLICKFOCUS ///< focus on click 48 CLICKFOCUS ///< focus on click
49 }; 49 };
50 /// focus model for tabs
50 enum TabFocusModel { 51 enum TabFocusModel {
51 MOUSETABFOCUS = 0, ///< tab focus follows mouse 52 MOUSETABFOCUS = 0, ///< tab focus follows mouse
52 CLICKTABFOCUS ///< tab focus on click 53 CLICKTABFOCUS ///< tab focus on click
53 }; 54 };
54 55
56 /// focus direction for windows
55 enum FocusDir { 57 enum FocusDir {
56 FOCUSUP, 58 FOCUSUP, ///< window is above
57 FOCUSDOWN, 59 FOCUSDOWN, ///< window is down
58 FOCUSLEFT, 60 FOCUSLEFT, ///< window is left
59 FOCUSRIGHT 61 FOCUSRIGHT ///< window is right
60 }; 62 };
61 63
62 // prevFocus/nextFocus option bits 64 /// prevFocus/nextFocus option bits
63 enum { 65 enum {
64 CYCLEGROUPS = 0x01, 66 CYCLEGROUPS = 0x01, //< cycle through groups
65 CYCLELINEAR = 0x08, 67 CYCLELINEAR = 0x08, ///< linear cycle
66 }; 68 };
67 69
68 explicit FocusControl(BScreen &screen); 70 explicit FocusControl(BScreen &screen);
69 71 /// cycle previous focuable
70 void prevFocus() { cycleFocus(m_focused_list, 0, true); } 72 void prevFocus() { cycleFocus(m_focused_list, 0, true); }
73 /// cycle next focusable
71 void nextFocus() { cycleFocus(m_focused_list, 0, false); } 74 void nextFocus() { cycleFocus(m_focused_list, 0, false); }
75 /**
76 * Cycle focus for a set of windows.
77 * @param winlist the windowlist to cycle through
78 * @param pat pattern for matching focusables
79 * @param reverse reverse the cycle order
80 */
72 void cycleFocus(Focusables &winlist, const ClientPattern *pat = 0, 81 void cycleFocus(Focusables &winlist, const ClientPattern *pat = 0,
73 bool reverse = false); 82 bool reverse = false);
83
84 /**
85 * Cycle focus for a set of windows.
86 * @param winlist the windowlist to cycle through
87 * @param pat pattern for matching focusables
88 * @param reverse reverse the cycle order
89 */
74 void cycleFocus(FocusedWindows &winlist, const ClientPattern *pat = 0, 90 void cycleFocus(FocusedWindows &winlist, const ClientPattern *pat = 0,
75 bool reverse = false); 91 bool reverse = false);
76 void goToWindowNumber(Focusables &winlist, int num, 92 void goToWindowNumber(Focusables &winlist, int num,
77 const ClientPattern *pat = 0); 93 const ClientPattern *pat = 0);
78 94 /// sets the focused window on a screen
79 void setScreenFocusedWindow(WinClient &win_client); 95 void setScreenFocusedWindow(WinClient &win_client);
96 /// sets the main focus model
80 void setFocusModel(FocusModel model); 97 void setFocusModel(FocusModel model);
98 /// sets tab focus model
81 void setTabFocusModel(TabFocusModel model); 99 void setTabFocusModel(TabFocusModel model);
82 100 /// stop cycling mode
83 void stopCyclingFocus(); 101 void stopCyclingFocus();
84 102 /**
103 * Do directional focus mode.
104 * @param win current window
105 * @param dir direction from current window to focus.
106 */
85 void dirFocus(FluxboxWindow &win, FocusDir dir); 107 void dirFocus(FluxboxWindow &win, FocusDir dir);
108 /// @return true if focus mode is mouse focus
86 bool isMouseFocus() const { return focusModel() == MOUSEFOCUS; } 109 bool isMouseFocus() const { return focusModel() == MOUSEFOCUS; }
110 /// @return true if tab focus mode is mouse tab focus
87 bool isMouseTabFocus() const { return tabFocusModel() == MOUSETABFOCUS; } 111 bool isMouseTabFocus() const { return tabFocusModel() == MOUSETABFOCUS; }
112 /// @return true if cycling is in progress
88 bool isCycling() const { return m_cycling_list != 0; } 113 bool isCycling() const { return m_cycling_list != 0; }
114 /// Appends a client to the front of the focus list
89 void addFocusBack(WinClient &client); 115 void addFocusBack(WinClient &client);
116 /// Appends a client to the front of the focus list
90 void addFocusFront(WinClient &client); 117 void addFocusFront(WinClient &client);
91 void addFocusWinBack(Focusable &win); 118 void addFocusWinBack(Focusable &win);
92 void addFocusWinFront(Focusable &win); 119 void addFocusWinFront(Focusable &win);
93 void setFocusBack(FluxboxWindow *fbwin); 120 void setFocusBack(FluxboxWindow *fbwin);
94 121 /// @return main focus model
95 FocusModel focusModel() const { return *m_focus_model; } 122 FocusModel focusModel() const { return *m_focus_model; }
123 /// @return tab focus model
96 TabFocusModel tabFocusModel() const { return *m_tab_focus_model; } 124 TabFocusModel tabFocusModel() const { return *m_tab_focus_model; }
125 /// @return true if newly created windows are focused
97 bool focusNew() const { return *m_focus_new; } 126 bool focusNew() const { return *m_focus_new; }
98 127
128 /// @return last focused client in a specific workspace, or NULL.
99 Focusable *lastFocusedWindow(int workspace); 129 Focusable *lastFocusedWindow(int workspace);
130
100 WinClient *lastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client = 0); 131 WinClient *lastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client = 0);
101 132
133 /// @return focus list in creation order
102 Focusables &creationOrderList() { return m_creation_order_list; } 134 Focusables &creationOrderList() { return m_creation_order_list; }
135 /// @return the focus list in focused order
103 Focusables &focusedOrderList() { return m_focused_list; } 136 Focusables &focusedOrderList() { return m_focused_list; }
104 Focusables &creationOrderWinList() { return m_creation_order_win_list; } 137 Focusables &creationOrderWinList() { return m_creation_order_win_list; }
105 Focusables &focusedOrderWinList() { return m_focused_win_list; } 138 Focusables &focusedOrderWinList() { return m_focused_win_list; }
106 139
140 /// remove client from focus list
107 void removeClient(WinClient &client); 141 void removeClient(WinClient &client);
142 /// remove window from focus list
108 void removeWindow(Focusable &win); 143 void removeWindow(Focusable &win);
144 /// starts terminating this control
109 void shutdown(); 145 void shutdown();
110 146
147 /// do fallback focus for screen if normal focus control failed.
111 static void revertFocus(BScreen &screen); 148 static void revertFocus(BScreen &screen);
112 // like revertFocus, but specifically related to this window (transients etc) 149 // like revertFocus, but specifically related to this window (transients etc)
113 static void unfocusWindow(WinClient &client, bool full_revert = true, bool unfocus_frame = false); 150 static void unfocusWindow(WinClient &client, bool full_revert = true, bool unfocus_frame = false);