aboutsummaryrefslogtreecommitdiff
path: root/src/Xinerama.hh
diff options
context:
space:
mode:
authorrathnor <rathnor>2003-05-19 14:26:30 (GMT)
committerrathnor <rathnor>2003-05-19 14:26:30 (GMT)
commitcc9c7960c1c5413002c3a6c456650e59ee1ff501 (patch)
treedb11494b3cbd61619229328b722f2c47c6b0a916 /src/Xinerama.hh
parent68e9677bbb9ebe8f7c1a5edea25f236c09ed3460 (diff)
downloadfluxbox-cc9c7960c1c5413002c3a6c456650e59ee1ff501.zip
fluxbox-cc9c7960c1c5413002c3a6c456650e59ee1ff501.tar.bz2
add back some xinerama support (toolbar, slit (+menu), screen)
Diffstat (limited to 'src/Xinerama.hh')
-rw-r--r--src/Xinerama.hh105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/Xinerama.hh b/src/Xinerama.hh
new file mode 100644
index 0000000..eebd431
--- /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.1 2003/05/19 14:26:30 rathnor 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
42template <typename ItemType>
43class XineramaHeadMenuItem : public FbTk::MenuItem {
44public:
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 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
57private:
58 ItemType *m_object;
59 int m_headnum;
60};
61
62
63/// Create a xinerama menu
64template <typename ItemType>
65class XineramaHeadMenu : public FbMenu {
66public:
67 XineramaHeadMenu(FbTk::MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl,
68 FbTk::XLayer &layer, ItemType *item);
69
70private:
71 ItemType *m_object;
72};
73
74
75template <typename ItemType>
76XineramaHeadMenu<ItemType>::XineramaHeadMenu(FbTk::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