2 * Copyright (c) 2007 Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
3 * Copyright (c) 2007, 2008 Harry Bock <hbock@providence.edu>
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__
28 #include "randrmode.h"
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
41 RandROutput(RandRScreen
*parent
, RROutput id
);
44 /** Returns the internal RANDR identifier for a particular output. */
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
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
63 /** Return the icon name according to the device type. */
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;
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
95 int rotations() const;
97 /** Returns the curent rotation of the CRTC this output is currently
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
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
);
121 void slotChangeSize(QAction
*action
);
122 void slotChangeRotation(QAction
*action
);
123 void slotChangeRefreshRate(QAction
*action
);
128 void slotCrtcChanged(RRCrtc c
, int changes
);
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
);
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);
153 XRROutputInfo
* m_info
;
157 CrtcList m_possibleCrtcs
;
159 RandRScreen
*m_screen
;
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
;
172 RandRMode m_preferredMode
;