~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to libs/kephal/kephal/screens.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2008 Aike J Sommer <dev@aikesommer.name>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU General Public License as
 
6
 *   published by the Free Software Foundation; either version 2,
 
7
 *   or (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
 
 
21
#ifndef KEPHAL_SCREENS_H
 
22
#define KEPHAL_SCREENS_H
 
23
 
 
24
#include <QObject>
 
25
#include <QRect>
 
26
 
 
27
#include "kephal_export.h"
 
28
 
 
29
namespace Kephal {
 
30
 
 
31
    class Output;
 
32
 
 
33
 
 
34
    /**
 
35
     * A Screen is the area that is significant for
 
36
     * displaying windows. or panels.
 
37
     * Every activated Output belongs to exactly one
 
38
     * Screen and is completely contained within that
 
39
     * Screen. No two Screens overlap each other.
 
40
     *
 
41
     * Hence:
 
42
     * 1 Output -> 1 Screen
 
43
     * 2 Non-overlapping Outputs -> 2 Screen
 
44
     * 2 Overlapping Outputs -> 1 Screen
 
45
     */
 
46
    class KEPHAL_EXPORT Screen : public QObject {
 
47
        Q_OBJECT
 
48
        public:
 
49
            Screen(QObject * parent = 0);
 
50
 
 
51
            /**
 
52
             * Returns the id of this Screen. The id
 
53
             * is part of the Configuration and will
 
54
             * be the same whenever the same Outputs
 
55
             * are used with the same Configuration.
 
56
             */
 
57
            virtual int id() = 0;
 
58
 
 
59
            /**
 
60
             * The actual size of the screen in pixels.
 
61
             * This is the smallest area possible, so
 
62
             * that all Outputs are completely
 
63
             * contained.
 
64
             */
 
65
            virtual QSize size() = 0;
 
66
 
 
67
            /**
 
68
             * The actual position on the framebuffer
 
69
             * in pixels.
 
70
             */
 
71
            virtual QPoint position() = 0;
 
72
 
 
73
            /**
 
74
             * Returns whether this Screen is to be
 
75
             * considered in privacy-mode.
 
76
             * In this mode no content should be
 
77
             * displayed on that screen unless the
 
78
             * user forces this.
 
79
             */
 
80
            virtual bool isPrivacyMode() = 0;
 
81
 
 
82
            /**
 
83
             * Sets the state of the privacy-mode.
 
84
             */
 
85
            virtual void setPrivacyMode(bool b) = 0;
 
86
 
 
87
            /**
 
88
             * Return a list of Outputs that are
 
89
             * currently part of this Screen.
 
90
             */
 
91
            virtual QList<Output *> outputs() = 0;
 
92
 
 
93
            /**
 
94
             * Returns whether this screen is the
 
95
             * current primary screen.
 
96
             * This is just a convenience method,
 
97
             * since the real value is determined
 
98
             * by the configuration used.
 
99
             */
 
100
            bool isPrimary() const;
 
101
 
 
102
            /**
 
103
             * Make this Screen the primary one.
 
104
             * This just calls the appropriate
 
105
             * method in the Configuration.
 
106
             */
 
107
            void setAsPrimary();
 
108
 
 
109
            /**
 
110
             * Returns the position and size of the
 
111
             * Screen as QRect.
 
112
             * This is just a convenience method.
 
113
             */
 
114
            QRect geom();
 
115
    };
 
116
 
 
117
 
 
118
 
 
119
    /**
 
120
     * Screens is the entrance-point for all Screen-
 
121
     * related operations.
 
122
     * Use: Screens::self() for the currently
 
123
     * active instance.
 
124
     */
 
125
    class KEPHAL_EXPORT Screens : public QObject {
 
126
        Q_OBJECT
 
127
        public:
 
128
            /**
 
129
             * Returns the currently active instance.
 
130
             */
 
131
            static Screens * self();
 
132
 
 
133
            Screens(QObject * parent);
 
134
            virtual ~Screens();
 
135
 
 
136
            /**
 
137
             * Returns the list of all current
 
138
             * Screens.
 
139
             * Every Screen has at least one Output
 
140
             * and a non-zero size.
 
141
             */
 
142
            virtual QList<Screen *> screens() = 0;
 
143
 
 
144
            /**
 
145
             * Find a Screen by its id.
 
146
             */
 
147
            virtual Screen * screen(int id);
 
148
 
 
149
            /**
 
150
             * Returns the current primary Screen.
 
151
             */
 
152
            Screen * primaryScreen();
 
153
 
 
154
        Q_SIGNALS:
 
155
            /**
 
156
             * This signal is emitted when a new
 
157
             * Screen appears, due to an Output
 
158
             * being activated or the Configuration
 
159
             * being changed.
 
160
             */
 
161
            // QDW::screenCountChanged
 
162
            void screenAdded(Kephal::Screen * s);
 
163
 
 
164
            /**
 
165
             * This signal is emitted when a
 
166
             * Screen disappears, due to an Output
 
167
             * being deactivated or the
 
168
             * Configuration being changed.
 
169
             */
 
170
            // QDW::screenCountChanged
 
171
            void screenRemoved(int id);
 
172
 
 
173
            /**
 
174
             * This signal is emitted when the size
 
175
             * of the Screen changes.
 
176
             */
 
177
            // QDW::resized
 
178
            // TODO: move to Screen and replace with no args version
 
179
            void screenResized(Kephal::Screen * s, QSize oldSize, QSize newSize);
 
180
 
 
181
            /**
 
182
             * This signal is emitted when the
 
183
             * position of the Screen changes.
 
184
             */
 
185
            // QDW::resized emitted when position changes too - but not documented.
 
186
            // TODO: move to Screen and replace with no args version
 
187
            void screenMoved(Kephal::Screen * s, QPoint oldPosition, QPoint newPosition);
 
188
 
 
189
        protected:
 
190
            static Screens * s_instance;
 
191
    };
 
192
 
 
193
    /**
 
194
     * Defines a handful help methods for common tasks
 
195
     */
 
196
    class KEPHAL_EXPORT ScreenUtils {
 
197
        public:
 
198
            /** Returns the number of screens. */
 
199
            // PASSTHRU to QDW
 
200
            static int numScreens();
 
201
 
 
202
            /** Returns the geometry of the given screen */
 
203
            // PASSTHRU to QDW
 
204
            static QRect screenGeometry(int id);
 
205
 
 
206
            /** Returns the size of the given screen */
 
207
            // SYNTACTIC SUGAR around QDW
 
208
            static QSize screenSize(int id);
 
209
 
 
210
            /** Returns the geometry of the whole desktop */
 
211
            // SYNTACTIC SUGAR around QApplication::desktop()->geometry()
 
212
            static QRect desktopGeometry();
 
213
 
 
214
            /** Returns the id of the screen that contains the given point */
 
215
            // SYNTACTIC SUGAR around QDW::screenNumber()
 
216
            static int screenId(QPoint p);
 
217
 
 
218
            /** Returns the id of the primary screen */
 
219
            // SYNTACTIC SUGAR around QDW::primaryScreen
 
220
            static int primaryScreenId();
 
221
 
 
222
        private:
 
223
            static int distance(const QRect & r, const QPoint & p);
 
224
    };
 
225
 
 
226
}
 
227
 
 
228
 
 
229
#endif // KEPHAL_SCREENS_H
 
230