diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-26 21:31:55 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2007-12-26 21:31:55 (GMT) |
commit | b2546389a50ff370036590d799cfb640329160c5 (patch) | |
tree | ac86f4f4333728b9c1791b09a893b3a5724430b0 /src | |
parent | 396c6fe40f71450b3621554317695a689f46471d (diff) | |
download | fluxbox_pavel-b2546389a50ff370036590d799cfb640329160c5.zip fluxbox_pavel-b2546389a50ff370036590d799cfb640329160c5.tar.bz2 |
changing focusnew/mousefocus should affect windows that are already open
Diffstat (limited to 'src')
-rw-r--r-- | src/FbTk/DefaultValue.hh | 82 | ||||
-rw-r--r-- | src/FbTk/Makefile.am | 2 | ||||
-rw-r--r-- | src/Window.cc | 4 | ||||
-rw-r--r-- | src/Window.hh | 8 |
4 files changed, 91 insertions, 5 deletions
diff --git a/src/FbTk/DefaultValue.hh b/src/FbTk/DefaultValue.hh new file mode 100644 index 0000000..a89ad0a --- /dev/null +++ b/src/FbTk/DefaultValue.hh | |||
@@ -0,0 +1,82 @@ | |||
1 | // DefaultValue.hh | ||
2 | // Copyright (c) 2007 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 | #ifndef FBTK_DEFAULTVALUE_HH | ||
23 | #define FBTK_DEFAULTVALUE_HH | ||
24 | |||
25 | namespace FbTk { | ||
26 | |||
27 | // classes for overriding default values without having to listen for changes | ||
28 | template <typename T> | ||
29 | class DefaultValue { | ||
30 | public: | ||
31 | DefaultValue(const T &def): | ||
32 | m_default(def), m_actual(def), m_use_default(true) { } | ||
33 | |||
34 | inline const T &get() const { return m_use_default ? m_default : m_actual; } | ||
35 | inline void set(const T &val) { m_use_default = false; m_actual = val; } | ||
36 | inline void restoreDefault() { m_use_default = true; } | ||
37 | inline void isDefault() const { return m_use_default; } | ||
38 | |||
39 | inline DefaultValue<T> &operator =(const T &val) { | ||
40 | set(val); return *this; | ||
41 | } | ||
42 | |||
43 | inline operator T() const { return get(); } | ||
44 | |||
45 | private: | ||
46 | const T &m_default; | ||
47 | T m_actual; | ||
48 | bool m_use_default; | ||
49 | }; | ||
50 | |||
51 | // designed for use with built-in types T, thus no need to return references | ||
52 | template <typename T, typename Receiver> | ||
53 | class DefaultAccessor { | ||
54 | public: | ||
55 | typedef T (Receiver:: *Accessor)() const; | ||
56 | DefaultAccessor(const Receiver &r, Accessor a): | ||
57 | m_receiver(r), m_accessor(a), m_actual((r.*a)()), | ||
58 | m_use_default(true) { } | ||
59 | |||
60 | inline const T get() const { | ||
61 | return m_use_default ? (m_receiver.*m_accessor)() : m_actual; | ||
62 | } | ||
63 | inline void set(const T &val) { m_use_default = false; m_actual = val; } | ||
64 | inline void restoreDefault() { m_use_default = true; } | ||
65 | inline void isDefault() const { return m_use_default; } | ||
66 | |||
67 | inline DefaultAccessor<T, Receiver> &operator =(const T &val) { | ||
68 | set(val); return *this; | ||
69 | } | ||
70 | |||
71 | inline operator T() const { return get(); } | ||
72 | |||
73 | private: | ||
74 | const Receiver &m_receiver; | ||
75 | Accessor &m_accessor; | ||
76 | T m_actual; | ||
77 | bool m_use_default; | ||
78 | }; | ||
79 | |||
80 | }; // end namespace FbTk | ||
81 | |||
82 | #endif // FBTK_DEFAULTVALUE_HH | ||
diff --git a/src/FbTk/Makefile.am b/src/FbTk/Makefile.am index 081bd07..0de5475 100644 --- a/src/FbTk/Makefile.am +++ b/src/FbTk/Makefile.am | |||
@@ -16,7 +16,7 @@ imlib2_SOURCE= ImageImlib2.hh ImageImlib2.cc | |||
16 | endif | 16 | endif |
17 | 17 | ||
18 | libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ | 18 | libFbTk_a_SOURCES = App.hh App.cc Color.cc Color.hh Command.hh \ |
19 | ObjectRegistry.hh \ | 19 | ObjectRegistry.hh DefaultValue.hh \ |
20 | FileUtil.hh FileUtil.cc \ | 20 | FileUtil.hh FileUtil.cc \ |
21 | EventHandler.hh EventManager.hh EventManager.cc \ | 21 | EventHandler.hh EventManager.hh EventManager.cc \ |
22 | FbWindow.hh FbWindow.cc Font.cc Font.hh FontImp.hh \ | 22 | FbWindow.hh FbWindow.cc Font.cc Font.hh FontImp.hh \ |
diff --git a/src/Window.cc b/src/Window.cc index 5eb380e..8126e9e 100644 --- a/src/Window.cc +++ b/src/Window.cc | |||
@@ -264,8 +264,8 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm, | |||
264 | m_toggled_decos(false), | 264 | m_toggled_decos(false), |
265 | m_icon_hidden(false), | 265 | m_icon_hidden(false), |
266 | m_focus_hidden(false), | 266 | m_focus_hidden(false), |
267 | m_focus_new(screen().focusControl().focusNew()), | 267 | m_focus_new(screen().focusControl(), &FocusControl::focusNew), |
268 | m_mouse_focus(screen().focusControl().isMouseFocus()), | 268 | m_mouse_focus(screen().focusControl(), &FocusControl::isMouseFocus), |
269 | m_click_focus(true), | 269 | m_click_focus(true), |
270 | m_old_pos_x(0), m_old_pos_y(0), | 270 | m_old_pos_x(0), m_old_pos_y(0), |
271 | m_old_width(1), m_old_height(1), | 271 | m_old_width(1), m_old_height(1), |
diff --git a/src/Window.hh b/src/Window.hh index d0db606..5dbe055 100644 --- a/src/Window.hh +++ b/src/Window.hh | |||
@@ -27,6 +27,7 @@ | |||
27 | #ifndef WINDOW_HH | 27 | #ifndef WINDOW_HH |
28 | #define WINDOW_HH | 28 | #define WINDOW_HH |
29 | 29 | ||
30 | #include "FbTk/DefaultValue.hh" | ||
30 | #include "FbTk/Timer.hh" | 31 | #include "FbTk/Timer.hh" |
31 | #include "FbTk/Subject.hh" | 32 | #include "FbTk/Subject.hh" |
32 | #include "FbTk/Observer.hh" | 33 | #include "FbTk/Observer.hh" |
@@ -49,6 +50,7 @@ class WinClient; | |||
49 | class FbWinFrameTheme; | 50 | class FbWinFrameTheme; |
50 | class BScreen; | 51 | class BScreen; |
51 | class FbWinFrame; | 52 | class FbWinFrame; |
53 | class FocusControl; | ||
52 | 54 | ||
53 | namespace FbTk { | 55 | namespace FbTk { |
54 | class TextButton; | 56 | class TextButton; |
@@ -609,8 +611,10 @@ private: | |||
609 | 611 | ||
610 | bool m_icon_hidden; ///< if the window is in the iconbar | 612 | bool m_icon_hidden; ///< if the window is in the iconbar |
611 | bool m_focus_hidden; ///< if the window is in the NextWindow list | 613 | bool m_focus_hidden; ///< if the window is in the NextWindow list |
612 | bool m_focus_new; ///< if the window is normally focused when mapped | 614 | /// if the window is normally focused when mapped |
613 | bool m_mouse_focus; ///< if the window is focused with EnterNotify | 615 | FbTk::DefaultAccessor<bool, FocusControl> m_focus_new; |
616 | /// if the window is focused with EnterNotify | ||
617 | FbTk::DefaultAccessor<bool, FocusControl> m_mouse_focus; | ||
614 | bool m_click_focus; ///< if the window is focused by clicking | 618 | bool m_click_focus; ///< if the window is focused by clicking |
615 | int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized | 619 | int m_old_pos_x, m_old_pos_y; ///< old position so we can restore from maximized |
616 | unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state | 620 | unsigned int m_old_width, m_old_height; ///< old size so we can restore from maximized state |