not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / kcontrol / randr / randroutput.h
blobf9369c2f5d881144b6a421e5f6cd1d4c4a069d56
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 <QObject>
24 #include <QString>
25 #include <QRect>
27 #include "randr.h"
28 #include "randrmode.h"
30 class QAction;
31 class KConfig;
33 /** Class representing an RROutput identifier. This class is used
34 * to control a particular output's configuration (i.e., the mode or
35 * refresh rate of a DVI-I port, or the resolution of a VGA port). */
36 class RandROutput : public QObject
38 Q_OBJECT
40 public:
41 RandROutput(RandRScreen *parent, RROutput id);
42 ~RandROutput();
44 /** Returns the internal RANDR identifier for a particular output. */
45 RROutput id() const;
47 /** Return the screen that this output belongs to. */
48 RandRScreen *screen() const;
50 void loadSettings(bool notify = false);
52 /** Handle an event from RANDR signifying a change in this output's
53 * configuration. */
54 void handleEvent(XRROutputChangeNotifyEvent *event);
55 void handlePropertyEvent(XRROutputPropertyNotifyEvent *event);
57 /** The name of this output, as returned by the X device driver.
58 * Examples may be VGA, TMDS, DVI-I_2/digital, etc. Note:
59 * this is usually NOT the name returned in the EDID of your
60 * display. */
61 QString name() const;
63 /** Return the icon name according to the device type. */
64 QString icon() const;
66 /** List possible CRT controllers for this output. */
67 CrtcList possibleCrtcs() const;
69 /** Returns the current CRTC for this output. */
70 RandRCrtc *crtc() const;
72 /** Returns a list of all RRModes supported by this output. */
73 ModeList modes() const;
75 /** Returns the current mode for this output. */
76 RandRMode mode() const;
78 /** Returns the preferred mode for this output,
79 * or an invalid mode if no preferred mode is known. */
80 RandRMode preferredMode() const;
82 /** The list of supported sizes */
83 SizeList sizes() const;
84 QRect rect() const;
86 /** The list of refresh rates for the given size.
87 * If no size is specified, it will use the current size */
88 RateList refreshRates(const QSize &s = QSize()) const;
90 /** The current refresh rate. */
91 float refreshRate() const;
93 /** Return all possible rotations for all CRTCs this output can be connected
94 * to. */
95 int rotations() const;
97 /** Returns the curent rotation of the CRTC this output is currently
98 * connected to */
99 int rotation() const;
101 /** Determines whether this output is connected to a display device.
102 * It is not necessarily active. */
103 bool isConnected() const;
105 /** Determines whether this output is currently driving a display
106 * device. */
107 bool isActive() const;
109 bool applyProposed(int changes = 0xffffff, bool confirm = false);
110 void proposeOriginal();
112 // proposal functions
113 void proposeRefreshRate(float rate);
114 void proposeRect(const QRect &r);
115 void proposeRotation(int rotation);
117 void load(KConfig &config);
118 void save(KConfig &config);
120 public slots:
121 void slotChangeSize(QAction *action);
122 void slotChangeRotation(QAction *action);
123 void slotChangeRefreshRate(QAction *action);
124 void slotDisable();
125 void slotEnable();
127 private slots:
128 void slotCrtcChanged(RRCrtc c, int changes);
130 signals:
131 /** This signal is emitted when any relevant change
132 * occurs in an output (mode, CRTC, resolution,
133 * connection, etc.) */
134 void outputChanged(RROutput o, int changes);
136 protected:
137 /** Query Xrandr for information about this output, and set
138 * up this instance accordingly. */
139 void queryOutputInfo(void);
141 /** Find the first CRTC that is not controlling any
142 * display devices. */
143 RandRCrtc *findEmptyCrtc(void);
144 bool tryCrtc(RandRCrtc *crtc, int changes);
146 /** Set the current CRT controller for this output.
147 * The CRTC should never be set directly; it should be added through
148 * this function to properly manage signals related to this output. */
149 bool setCrtc(RandRCrtc *crtc, bool applyNow = true);
151 private:
152 RROutput m_id;
153 XRROutputInfo* m_info;
154 QString m_name;
155 QString m_alias;
157 CrtcList m_possibleCrtcs;
159 RandRScreen *m_screen;
160 RandRCrtc *m_crtc;
162 //proposed stuff (mostly to read from the configuration)
163 QRect m_proposedRect;
164 int m_proposedRotation;
165 float m_proposedRate;
167 QRect m_originalRect;
168 int m_originalRotation;
169 float m_originalRate;
171 ModeList m_modes;
172 RandRMode m_preferredMode;
174 int m_rotations;
175 bool m_connected;
177 #endif