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

« back to all changes in this revision

Viewing changes to libs/kephal/kephal/outputs.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_OUTPUTS_H
 
22
#define KEPHAL_OUTPUTS_H
 
23
 
 
24
#include <QMap>
 
25
#include <QObject>
 
26
#include <QRect>
 
27
 
 
28
#include "kephal.h"
 
29
 
 
30
namespace Kephal {
 
31
 
 
32
    class Screen;
 
33
 
 
34
 
 
35
    /**
 
36
     * An Output is the actual connector and a
 
37
     * possibly connected monitor, such as
 
38
     * VGA, LVDS, TMDS-1.
 
39
     * This is most important for changing any
 
40
     * settings of the current setup.
 
41
     */
 
42
    class Output : public QObject {
 
43
        Q_OBJECT
 
44
        public:
 
45
            Output(QObject * parent);
 
46
 
 
47
            /**
 
48
             * Returns the id of the Output.
 
49
             *
 
50
             * In case of XRandR 1.2 these will
 
51
             * be the names such as: VGA, LVDS,
 
52
             * TMDS-1.
 
53
             */
 
54
            virtual QString id() const = 0;
 
55
 
 
56
            /**
 
57
             * Returns the actual size in pixels
 
58
             * if the Output is active.
 
59
             */
 
60
            virtual QSize size() const = 0;
 
61
 
 
62
            /**
 
63
             * Returns the actual position in
 
64
             * pixels if the Output is active.
 
65
             */
 
66
            virtual QPoint position() const = 0;
 
67
 
 
68
            /**
 
69
             * Returns whether this Output is
 
70
             * currently connected to a
 
71
             * monitor.
 
72
             */
 
73
            virtual bool isConnected() const = 0;
 
74
 
 
75
            /**
 
76
             * Returns whether this Output is
 
77
             * currently activated and part
 
78
             * of a Screen.
 
79
             */
 
80
            virtual bool isActivated() const = 0;
 
81
 
 
82
            /**
 
83
             * Returns a list of sizes, which
 
84
             * are supported by this Output.
 
85
             * This depends on the connected
 
86
             * monitor.
 
87
             */
 
88
            virtual QList<QSize> availableSizes() const = 0;
 
89
 
 
90
            /**
 
91
             * Returns the vendor-code as
 
92
             * it is part of the EDID-block.
 
93
             */
 
94
            virtual QString vendor() const = 0;
 
95
 
 
96
            /**
 
97
             * Returns the product-id as
 
98
             * it is part of the EDID-block.
 
99
             */
 
100
            virtual int productId() const = 0;
 
101
 
 
102
            /**
 
103
             * Returns the serial-number as
 
104
             * it is part of the EDID-block.
 
105
             */
 
106
            virtual unsigned int serialNumber() const = 0;
 
107
 
 
108
            /**
 
109
             * Returns the preferred size of
 
110
             * this Output. This depends on
 
111
             * the connected monitor.
 
112
             */
 
113
            virtual QSize preferredSize() const = 0;
 
114
 
 
115
            /**
 
116
             * Returns the current rotation of
 
117
             * this Output.
 
118
             */
 
119
            virtual Rotation rotation() const = 0;
 
120
 
 
121
            /**
 
122
             * Returns whether this Output is
 
123
             * currently reflected over the
 
124
             * x-axis.
 
125
             */
 
126
            virtual bool reflectX() const = 0;
 
127
 
 
128
            /**
 
129
             * Returns whether this Output is
 
130
             * currently reflected over the
 
131
             * y-axis.
 
132
             */
 
133
            virtual bool reflectY() const = 0;
 
134
 
 
135
            /**
 
136
             * Returns the current refresh-rate
 
137
             * of this Output.
 
138
             */
 
139
            virtual float rate() const = 0;
 
140
 
 
141
            /**
 
142
             * Returns all possible refresh-rates
 
143
             * of this Output.
 
144
             * This depends on the connected
 
145
             * monitor.
 
146
             */
 
147
            virtual QList<float> availableRates() const = 0;
 
148
 
 
149
            /**
 
150
             * This is just a convenience
 
151
             * method for looking up the
 
152
             * Screen this Output belongs to.
 
153
             * Returns 0 if not active.
 
154
             * WILL Outputs should not know about Screens
 
155
             */
 
156
            Screen * screen() const;
 
157
 
 
158
            /**
 
159
             * This convenience method
 
160
             * returns size and position of
 
161
             * this Output if active.
 
162
             */
 
163
            QRect geom() const;
 
164
 
 
165
            /**
 
166
             * Returns all available
 
167
             * positions for this Output.
 
168
             * This depends on the
 
169
             * Configuration used and
 
170
             * the positions of the other
 
171
             * active Outputs.
 
172
             */
 
173
            QList<QPoint> availablePositions();
 
174
 
 
175
            virtual void resize(const QSize & size) = 0;
 
176
 
 
177
            virtual void rotate(Rotation rotation) = 0;
 
178
 
 
179
            virtual void setReflectX(bool reflect) = 0;
 
180
 
 
181
            virtual void setReflectY(bool reflect) = 0;
 
182
 
 
183
            virtual void changeRate(double rate) = 0;
 
184
    };
 
185
 
 
186
 
 
187
 
 
188
    /**
 
189
     * Outputs is the entrance-point to all Output
 
190
     * related operations.
 
191
     * Use: Outputs::self() to obtain the currently
 
192
     * active instance.
 
193
     */
 
194
    class Outputs : public QObject {
 
195
        Q_OBJECT
 
196
        public:
 
197
            /**
 
198
             * Returns the currently active
 
199
             * instance.
 
200
             */
 
201
            static Outputs * self();
 
202
 
 
203
            Outputs(QObject * parent);
 
204
            virtual ~Outputs();
 
205
 
 
206
            /**
 
207
             * Returns a list of all known Outputs,
 
208
             * even if they are inactive or
 
209
             * disconnected.
 
210
             */
 
211
            virtual QList<Output *> outputs() = 0;
 
212
 
 
213
            /**
 
214
             * Find an Output by its id.
 
215
             * Returns 0 if the id is not known.
 
216
             */
 
217
            virtual Output * output(const QString & id);
 
218
 
 
219
        Q_SIGNALS:
 
220
            /**
 
221
             * This signal is emitted when an Output
 
222
             * is connected.
 
223
             */
 
224
            void outputConnected(Kephal::Output * o);
 
225
 
 
226
            /**
 
227
             * This signal is emitted when an Output
 
228
             * is disconnected.
 
229
             */
 
230
            void outputDisconnected(Kephal::Output * o);
 
231
 
 
232
            /**
 
233
             * This signal is emitted when an Output
 
234
             * is activated.
 
235
             */
 
236
            void outputActivated(Kephal::Output * o);
 
237
 
 
238
            /**
 
239
             * This signal is emitted when an Output
 
240
             * is deactivated.
 
241
             */
 
242
            void outputDeactivated(Kephal::Output * o);
 
243
 
 
244
            /**
 
245
             * This signal is emitted when an Output
 
246
             * is resized from oldSize to newSize.
 
247
             */
 
248
            void outputResized(Kephal::Output * o, QSize oldSize, QSize newSize);
 
249
 
 
250
            /**
 
251
             * This signal is emitted when an Output
 
252
             * is moved on the framebuffer from
 
253
             * oldPosition to newPosition.
 
254
             */
 
255
            void outputMoved(Kephal::Output * o, QPoint oldPosition, QPoint newPosition);
 
256
 
 
257
            /**
 
258
             * This signal is emitted when the refresh-rate
 
259
             * of Output o changes.
 
260
             */
 
261
            void outputRateChanged(Kephal::Output * o, float oldRate, float newRate);
 
262
 
 
263
            /**
 
264
             * This signal is emitted when the rotation of
 
265
             * Output o changes.
 
266
             */
 
267
            void outputRotated(Kephal::Output * o, Kephal::Rotation oldRotation, Kephal::Rotation newRotation);
 
268
 
 
269
            /**
 
270
             * This signal is emitted when the reflection
 
271
             * state of Output o is changed.
 
272
             */
 
273
            void outputReflected(Kephal::Output * o, bool oldX, bool oldY, bool newX, bool newY);
 
274
 
 
275
        protected:
 
276
            static Outputs * s_instance;
 
277
    };
 
278
 
 
279
}
 
280
 
 
281
 
 
282
#endif // KEPHAL_OUTPUTS_H
 
283