add more spacing
[personal-kdebase.git] / workspace / libs / kephal / xrandr12 / randroutput.h
blob192f50d8eb12ad06b7bae9d663906504ad909770
1 /*
2 * Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
3 * Copyright (c) 2007, 2008 Harry Bock <hbock@providence.edu>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __RANDROUTPUT_H__
21 #define __RANDROUTPUT_H__
23 #include <QDebug>
24 #include <QObject>
25 #include <QString>
26 #include <QRect>
28 #include "randr.h"
29 #include "randrmode.h"
32 /** Class representing an RROutput identifier. This class is used
33 * to control a particular output's configuration (i.e., the mode or
34 * refresh rate of a DVI-I port, or the resolution of a VGA port). */
35 class RandROutput : public QObject
37 Q_OBJECT
39 public:
40 RandROutput(RandRScreen *parent, RROutput id);
41 ~RandROutput();
43 /** Returns the internal RANDR identifier for a particular output. */
44 RROutput id() const;
46 /** Return the screen that this output belongs to. */
47 RandRScreen *screen() const;
49 void loadSettings(bool notify = false);
51 /** Handle an event from RANDR signifying a change in this output's
52 * configuration. */
53 void handleEvent(XRROutputChangeNotifyEvent *event);
54 void handlePropertyEvent(XRROutputPropertyNotifyEvent *event);
56 /** The name of this output, as returned by the X device driver.
57 * Examples may be VGA, TMDS, DVI-I_2/digital, etc. Note:
58 * this is usually NOT the name returned in the EDID of your
59 * display. */
60 QString name() const;
62 /** Return the icon name according to the device type. */
63 QString icon() const;
65 /** List possible CRT controllers for this output. */
66 CrtcList possibleCrtcs() const;
68 /** Returns the current CRTC for this output. */
69 RandRCrtc *crtc() const;
71 /** Returns a list of all RRModes supported by this output. */
72 ModeList modes() const;
74 /** Returns the current mode for this output. */
75 RandRMode mode() const;
77 /** Returns the preferred mode for this output. */
78 RandRMode preferredMode(void) const;
80 /** The list of supported sizes */
81 SizeList sizes() const;
82 QRect rect() const;
84 /** The list of refresh rates for the given size.
85 * If no size is specified, it will use the current size */
86 RateList refreshRates(const QSize &s = QSize()) const;
88 /** The current refresh rate. */
89 float refreshRate() const;
91 /** Return all possible rotations for all CRTCs this output can be connected
92 * to. */
93 int rotations() const;
95 /** Returns the curent rotation of the CRTC this output is currently
96 * connected to */
97 int rotation() const;
99 /** Determines whether this output is connected to a display device.
100 * It is not necessarily active. */
101 bool isConnected() const;
103 /** Determines whether this output is currently driving a display
104 * device. */
105 bool isActive() const;
107 bool applyProposed(int changes = 0xffffff);
108 void proposeOriginal();
110 // proposal functions
111 void proposeRefreshRate(float rate);
112 void proposeRect(const QRect &r);
113 void proposeRotation(int rotation);
115 public slots:
116 void slotDisable();
117 void slotEnable();
119 private slots:
120 void slotCrtcChanged(RRCrtc c, int changes);
122 signals:
123 /** This signal is emitted when any relevant change
124 * occurs in an output (mode, CRTC, resolution,
125 * connection, etc.) */
126 void outputChanged(RROutput o, int changes);
128 protected:
129 /** Query Xrandr for information about this output, and set
130 * up this instance accordingly. */
131 bool queryOutputInfo(void);
133 /** Find the first CRTC that is not controlling any
134 * display devices. */
135 RandRCrtc *findEmptyCrtc(void);
136 bool tryCrtc(RandRCrtc *crtc, int changes);
138 /** Set the current CRT controller for this output.
139 * The CRTC should never be set directly; it should be added through
140 * this function to properly manage signals related to this output. */
141 bool setCrtc(RandRCrtc *crtc, bool applyNow = true);
143 private:
144 RROutput m_id;
145 XRROutputInfo* m_info;
146 QString m_name;
147 QString m_alias;
149 CrtcList m_possibleCrtcs;
151 RandRScreen *m_screen;
152 RandRCrtc *m_crtc;
154 //proposed stuff (mostly to read from the configuration)
155 QRect m_proposedRect;
156 int m_proposedRotation;
157 float m_proposedRate;
159 QRect m_originalRect;
160 int m_originalRotation;
161 float m_originalRate;
163 ModeList m_modes;
164 RandRMode m_preferredMode;
166 int m_rotations;
167 bool m_connected;
169 #endif