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

« back to all changes in this revision

Viewing changes to kcontrol/randr/randroutput.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 (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.
 
9
 *
 
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.
 
14
 *
 
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.
 
18
 */
 
19
 
 
20
#ifndef __RANDROUTPUT_H__
 
21
#define __RANDROUTPUT_H__
 
22
 
 
23
#include <QObject>
 
24
#include <QString>
 
25
#include <QRect>
 
26
 
 
27
#include "randr.h"
 
28
#include "randrmode.h"
 
29
 
 
30
class QAction;
 
31
class KConfig;
 
32
        
 
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
 
37
{
 
38
        Q_OBJECT
 
39
 
 
40
public:
 
41
        RandROutput(RandRScreen *parent, RROutput id);
 
42
        ~RandROutput();
 
43
        
 
44
        /** Returns the internal RANDR identifier for a particular output. */
 
45
        RROutput id() const;
 
46
        
 
47
        /** Return the screen that this output belongs to. */
 
48
        RandRScreen *screen() const;
 
49
        
 
50
        void loadSettings(bool notify = false);
 
51
        
 
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);
 
56
 
 
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;
 
62
 
 
63
        /** Return the icon name according to the device type. */
 
64
        QString icon() const;
 
65
 
 
66
        /** List possible CRT controllers for this output. */
 
67
        CrtcList possibleCrtcs() const;
 
68
        
 
69
        /** Returns the current CRTC for this output. */
 
70
        RandRCrtc *crtc() const;
 
71
 
 
72
        void disconnectFromCrtc();
 
73
 
 
74
        /** Returns a list of all RRModes supported by this output. */
 
75
        ModeList modes() const;
 
76
 
 
77
        /** Returns the current mode for this output. */
 
78
        RandRMode mode() const;
 
79
 
 
80
        /** Returns the preferred mode for this output,
 
81
         * or an invalid mode if no preferred mode is known. */
 
82
        RandRMode preferredMode() const;
 
83
        
 
84
        /** The list of supported sizes */
 
85
        SizeList sizes() const;
 
86
        QRect rect() const;
 
87
 
 
88
        /** The list of refresh rates for the given size.
 
89
         * If no size is specified, it will use the current size */
 
90
        RateList refreshRates(const QSize &s = QSize()) const;
 
91
 
 
92
        /** The current refresh rate. */
 
93
        float refreshRate() const;
 
94
 
 
95
        /** Return all possible rotations for all CRTCs this output can be connected
 
96
         * to. */
 
97
        int rotations() const;
 
98
 
 
99
        /** Returns the curent rotation of the CRTC this output is currently 
 
100
         * connected to */
 
101
        int rotation() const;
 
102
 
 
103
        /** Determines whether this output is connected to a display device.
 
104
         * It is not necessarily active. */
 
105
        bool isConnected() const;
 
106
        
 
107
        /** Determines whether this output is currently driving a display
 
108
         * device. */
 
109
        bool isActive() const;
 
110
 
 
111
        bool applyProposed(int changes = 0xffffff, bool confirm = false);
 
112
        void proposeOriginal();
 
113
 
 
114
        // proposal functions
 
115
        void proposeRefreshRate(float rate);
 
116
        void proposeRect(const QRect &r);
 
117
        void proposeRotation(int rotation);
 
118
 
 
119
        void load(KConfig &config);
 
120
        void save(KConfig &config);
 
121
        QStringList startupCommands() const;
 
122
 
 
123
public slots:
 
124
        void slotChangeSize(QAction *action);
 
125
        void slotChangeRotation(QAction *action);
 
126
        void slotChangeRefreshRate(QAction *action);
 
127
        void slotDisable();
 
128
        void slotEnable();
 
129
        void slotSetAsPrimary(bool primary);
 
130
 
 
131
private slots:
 
132
        void slotCrtcChanged(RRCrtc c, int changes);
 
133
 
 
134
signals:
 
135
        /** This signal is emitted when any relevant change
 
136
         * occurs in an output (mode, CRTC, resolution,
 
137
         * connection, etc.) */
 
138
        void outputChanged(RROutput o, int changes);
 
139
 
 
140
protected:
 
141
        /** Query Xrandr for information about this output, and set
 
142
         * up this instance accordingly. */
 
143
        void queryOutputInfo(void);
 
144
        
 
145
        /** Find the first CRTC that is not controlling any
 
146
         * display devices. */
 
147
        RandRCrtc *findEmptyCrtc(void);
 
148
        bool tryCrtc(RandRCrtc *crtc, int changes);
 
149
 
 
150
        /** Set the current CRT controller for this output.
 
151
         * The CRTC should never be set directly; it should be added through 
 
152
         * this function to properly manage signals related to this output. */
 
153
        bool setCrtc(RandRCrtc *crtc, bool applyNow = true);
 
154
        
 
155
private:        
 
156
        RROutput m_id;
 
157
        XRROutputInfo* m_info;
 
158
        QString m_name;
 
159
        QString m_alias;
 
160
 
 
161
        CrtcList m_possibleCrtcs;
 
162
 
 
163
        RandRScreen *m_screen;
 
164
        RandRCrtc *m_crtc;
 
165
        
 
166
        //proposed stuff (mostly to read from the configuration)
 
167
        QRect m_proposedRect;
 
168
        int   m_proposedRotation;
 
169
        float m_proposedRate;
 
170
 
 
171
        QRect m_originalRect;
 
172
        int   m_originalRotation;
 
173
        float m_originalRate;
 
174
 
 
175
        ModeList m_modes;
 
176
        RandRMode m_preferredMode;
 
177
 
 
178
        int m_rotations;
 
179
        bool m_connected;
 
180
};
 
181
#endif
 
182
// vim:noet:sts=8:sw=8: