diff options
Diffstat (limited to 'src/Xinerama.hh')
-rw-r--r-- | src/Xinerama.hh | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/src/Xinerama.hh b/src/Xinerama.hh new file mode 100644 index 0000000..ad4b3c0 --- /dev/null +++ b/src/Xinerama.hh | |||
@@ -0,0 +1,105 @@ | |||
1 | // Xinerama.hh for Fluxbox - helpful tools for multiple heads | ||
2 | // Copyright (c) 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) | ||
3 | // and Simon Bowden (rathnor at users.sourceforge.net) | ||
4 | // | ||
5 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
6 | // copy of this software and associated documentation files (the "Software"), | ||
7 | // to deal in the Software without restriction, including without limitation | ||
8 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
9 | // and/or sell copies of the Software, and to permit persons to whom the | ||
10 | // Software is furnished to do so, subject to the following conditions: | ||
11 | // | ||
12 | // The above copyright notice and this permission notice shall be included in | ||
13 | // all copies or substantial portions of the Software. | ||
14 | // | ||
15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
18 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
20 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
21 | // DEALINGS IN THE SOFTWARE. | ||
22 | |||
23 | // $Id: Xinerama.hh,v 1.3 2003/07/10 11:58:36 fluxgen Exp $ | ||
24 | |||
25 | #ifndef XINERAMA_HH | ||
26 | #define XINERAMA_HH | ||
27 | |||
28 | #include "MenuItem.hh" | ||
29 | #include "FbMenu.hh" | ||
30 | #include "FbCommands.hh" | ||
31 | #include "RefCount.hh" | ||
32 | #include "SimpleCommand.hh" | ||
33 | |||
34 | #include "fluxbox.hh" | ||
35 | |||
36 | // provides a generic way for giving an object a xinerama head menu | ||
37 | // The object must have two functions: | ||
38 | // int getOnHead(), and | ||
39 | // void setOnHead(int) | ||
40 | |||
41 | /// this class holds the xinerama items | ||
42 | template <typename ItemType> | ||
43 | class XineramaHeadMenuItem : public FbTk::MenuItem { | ||
44 | public: | ||
45 | XineramaHeadMenuItem(const char *label, ItemType *object, int headnum, | ||
46 | FbTk::RefCount<FbTk::Command> &cmd): | ||
47 | FbTk::MenuItem(label,cmd), m_object(object), m_headnum(headnum) {} | ||
48 | XineramaHeadMenuItem(const char *label, ItemType *object, int headnum): | ||
49 | FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {} | ||
50 | |||
51 | bool isEnabled() const { return true; } //m_object->screen().getOnHead(*m_object) != m_headnum; } ; | ||
52 | void click(int button, int time) { | ||
53 | // m_object->screen().setOnHead(*m_object, m_headnum); | ||
54 | FbTk::MenuItem::click(button, time); | ||
55 | } | ||
56 | |||
57 | private: | ||
58 | ItemType *m_object; | ||
59 | int m_headnum; | ||
60 | }; | ||
61 | |||
62 | |||
63 | /// Create a xinerama menu | ||
64 | template <typename ItemType> | ||
65 | class XineramaHeadMenu : public FbMenu { | ||
66 | public: | ||
67 | XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl, | ||
68 | FbTk::XLayer &layer, ItemType *item); | ||
69 | |||
70 | private: | ||
71 | ItemType *m_object; | ||
72 | }; | ||
73 | |||
74 | |||
75 | template <typename ItemType> | ||
76 | XineramaHeadMenu<ItemType>::XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl, | ||
77 | FbTk::XLayer &layer, ItemType *item): | ||
78 | FbMenu(tm, screen.screenNumber(), imgctrl, layer), | ||
79 | m_object(item) | ||
80 | { | ||
81 | |||
82 | FbTk::RefCount<FbTk::Command> saverc_cmd(new FbTk::SimpleCommand<Fluxbox>( | ||
83 | *Fluxbox::instance(), | ||
84 | &Fluxbox::save_rc)); | ||
85 | char tname[128]; | ||
86 | for (int i=1; i <= screen.numHeads(); ++i) { | ||
87 | // TODO: nls | ||
88 | /* | ||
89 | sprintf(tname, I18n::instance()-> | ||
90 | getMessage( | ||
91 | FBNLS::ScreenSet, | ||
92 | FBNLS::XineramaDefaultHeadFormat, | ||
93 | "Head %d"), i); //m_id starts at 0 | ||
94 | */ | ||
95 | sprintf(tname, "Head %d", i); | ||
96 | insert(new XineramaHeadMenuItem<ItemType>( | ||
97 | tname, m_object, i, saverc_cmd)); | ||
98 | } | ||
99 | // TODO: nls | ||
100 | insert(new XineramaHeadMenuItem<ItemType>( | ||
101 | "All Heads", m_object, 0, saverc_cmd)); | ||
102 | update(); | ||
103 | } | ||
104 | |||
105 | #endif // XINERAMA_HH | ||