~ubuntu-branches/ubuntu/trusty/fluxbox/trusty-proposed

« back to all changes in this revision

Viewing changes to src/Xinerama.hh

  • Committer: Bazaar Package Importer
  • Author(s): Dmitry E. Oboukhov
  • Date: 2008-07-01 10:38:14 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080701103814-khx2b6il152x9p93
Tags: 1.0.0+deb1-8
* x-dev has been removed from build-depends (out-of-date package).
* Standards-Version bumped to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// Xinerama.hh for Fluxbox - helpful tools for multiple heads
2
 
// Copyright (c) 2003 - 2005 Henrik Kinnunen (fluxgen at fluxbox dot org)
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 3865 2005-01-24 18:34:57Z mathias $
24
 
 
25
 
#ifndef XINERAMA_HH
26
 
#define XINERAMA_HH
27
 
 
28
 
#include "MenuItem.hh"
29
 
#include "FbMenu.hh"
30
 
#include "RefCount.hh"
31
 
#include "SimpleCommand.hh"
32
 
 
33
 
#include "fluxbox.hh"
34
 
 
35
 
// provides a generic way for giving an object a xinerama head menu
36
 
// The object must have two functions:
37
 
// int getOnHead(), and
38
 
// void setOnHead(int)
39
 
 
40
 
/// this class holds the xinerama items
41
 
template <typename ItemType> 
42
 
class XineramaHeadMenuItem : public FbTk::MenuItem {
43
 
public:
44
 
    XineramaHeadMenuItem(const char *label, ItemType &object, int headnum,
45
 
                  FbTk::RefCount<FbTk::Command> &cmd):
46
 
        FbTk::MenuItem(label,cmd), m_object(object), m_headnum(headnum) {}
47
 
    XineramaHeadMenuItem(const char *label, ItemType &object, int headnum):
48
 
        FbTk::MenuItem(label), m_object(object), m_headnum(headnum) {}
49
 
 
50
 
    bool isEnabled() const { return m_object.getOnHead() != m_headnum; } 
51
 
    void click(int button, int time) {
52
 
        m_object.saveOnHead(m_headnum);
53
 
        FbTk::MenuItem::click(button, time);
54
 
    }
55
 
    
56
 
private:
57
 
    ItemType &m_object;
58
 
    int m_headnum;
59
 
};
60
 
 
61
 
 
62
 
/// Create a xinerama menu
63
 
template <typename ItemType>
64
 
class XineramaHeadMenu : public FbMenu {
65
 
public:
66
 
    XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl,
67
 
                     FbTk::XLayer &layer, ItemType &item, const char * title = 0);
68
 
 
69
 
private:
70
 
    ItemType &m_object;
71
 
};
72
 
 
73
 
 
74
 
template <typename ItemType>
75
 
XineramaHeadMenu<ItemType>::XineramaHeadMenu(MenuTheme &tm, BScreen &screen, FbTk::ImageControl &imgctrl,
76
 
                               FbTk::XLayer &layer, ItemType &item, const char * title):
77
 
    FbMenu(tm, imgctrl, layer), 
78
 
    m_object(item) 
79
 
{
80
 
    if (title)
81
 
        setLabel(title);
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
 
    updateMenu();
103
 
}
104
 
 
105
 
#endif // XINERAMA_HH