aboutsummaryrefslogtreecommitdiff
path: root/src/FocusControl.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2006-02-18 09:20:50 (GMT)
committerfluxgen <fluxgen>2006-02-18 09:20:50 (GMT)
commit43f690ff7bd11637e0a7a91bcd99fe6b451ac6e5 (patch)
treecf0db195f1b9e926417c07787d3f4d9fbeaf664a /src/FocusControl.hh
parentae05ad9a01243d13138ea986d095e8e93a920e00 (diff)
downloadfluxbox-43f690ff7bd11637e0a7a91bcd99fe6b451ac6e5.zip
fluxbox-43f690ff7bd11637e0a7a91bcd99fe6b451ac6e5.tar.bz2
moved all focus handling to class FocusControl
Diffstat (limited to 'src/FocusControl.hh')
-rw-r--r--src/FocusControl.hh120
1 files changed, 120 insertions, 0 deletions
diff --git a/src/FocusControl.hh b/src/FocusControl.hh
new file mode 100644
index 0000000..4870c1f
--- /dev/null
+++ b/src/FocusControl.hh
@@ -0,0 +1,120 @@
1// FocusControl.hh
2// Copyright (c) 2006 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id$
23
24#ifndef FOCUSCONTROL_HH
25#define FOCUSCONTROL_HH
26
27#include <list>
28
29#include "FbTk/Resource.hh"
30
31class WinClient;
32class FluxboxWindow;
33class BScreen;
34
35/**
36 * Handles window focus for a specific screen.
37 * It also holds the static "global" focused window
38 */
39class FocusControl {
40public:
41 typedef std::list<WinClient *> FocusedWindows;
42
43 enum FocusModel {
44 MOUSEFOCUS = 0, ///< focus follows
45 CLICKFOCUS ///< focus on click
46 };
47 enum TabFocusModel {
48 MOUSETABFOCUS = 0, ///< tab focus follows mouse
49 CLICKTABFOCUS ///< tab focus on click
50 };
51
52 enum FocusDir {
53 FOCUSUP,
54 FOCUSDOWN,
55 FOCUSLEFT,
56 FOCUSRIGHT
57 };
58
59 // prevFocus/nextFocus option bits
60 enum {
61 CYCLEGROUPS = 0x01,
62 CYCLESKIPSTUCK = 0x02,
63 CYCLESKIPSHADED = 0x04,
64 CYCLELINEAR = 0x08,
65 CYCLEDEFAULT = 0x00
66 };
67
68 explicit FocusControl(BScreen &screen);
69
70 void prevFocus() { prevFocus(0); }
71 void nextFocus() { nextFocus(0); }
72 void prevFocus(int options);
73 void nextFocus(int options);
74 void raiseFocus();
75
76 void setScreenFocusedWindow(WinClient &win_client);
77 void setFocusModel(FocusModel model);
78 void setTabFocusModel(TabFocusModel model);
79
80 void stopCyclingFocus();
81
82 void dirFocus(FluxboxWindow &win, FocusDir dir);
83 bool isMouseFocus() const { return focusModel() == MOUSEFOCUS; }
84 bool isMouseTabFocus() const { return tabFocusModel() == MOUSETABFOCUS; }
85 void addFocusFront(WinClient &client);
86 void addFocusBack(WinClient &client);
87
88 FocusModel focusModel() const { return *m_focus_model; }
89 TabFocusModel tabFocusModel() const { return *m_tab_focus_model; }
90 bool focusLast() const { return *m_focus_last; }
91 bool focusNew() const { return *m_focus_new; }
92
93 WinClient *lastFocusedWindow(int workspace);
94 WinClient *lastFocusedWindow(FluxboxWindow &group, WinClient *ignore_client);
95
96 void removeClient(WinClient &client);
97
98 static void revertFocus(BScreen &screen);
99 static void unfocusWindow(WinClient &client, bool full_revert, bool unfocus_frame);
100 static void setFocusedWindow(WinClient *focus_to);
101 static WinClient *focusedWindow() { return s_focused_window; }
102private:
103
104 BScreen &m_screen;
105
106 FbTk::Resource<FocusModel> m_focus_model;
107 FbTk::Resource<TabFocusModel> m_tab_focus_model;
108 FbTk::Resource<bool> m_focus_last, m_focus_new;
109
110 // This list keeps the order of window focusing for this screen
111 // Screen global so it works for sticky windows too.
112 FocusedWindows m_focused_list;
113 FocusedWindows::iterator m_cycling_window;
114 bool m_cycling_focus;
115 WinClient *m_cycling_last;
116
117 static WinClient *s_focused_window;
118};
119
120#endif // FOCUSCONTROL_HH