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

« back to all changes in this revision

Viewing changes to libs/kephal/service/xrandr12/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 <QDebug>
 
24
#include <QObject>
 
25
#include <QString>
 
26
#include <QRect>
 
27
 
 
28
#include "randr.h"
 
29
#include "randrmode.h"
 
30
 
 
31
 
 
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
 
36
{
 
37
    Q_OBJECT
 
38
 
 
39
public:
 
40
    RandROutput(RandRScreen *parent, RROutput id);
 
41
    ~RandROutput();
 
42
 
 
43
    /** Returns the internal RANDR identifier for a particular output. */
 
44
    RROutput id() const;
 
45
 
 
46
    /** Return the screen that this output belongs to. */
 
47
    RandRScreen *screen() const;
 
48
 
 
49
    void loadSettings(bool notify = false);
 
50
 
 
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);
 
55
 
 
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;
 
61
 
 
62
    /** Return the icon name according to the device type. */
 
63
    QString icon() const;
 
64
 
 
65
    /** List possible CRT controllers for this output. */
 
66
    CrtcList possibleCrtcs() const;
 
67
 
 
68
    /** Returns the current CRTC for this output. */
 
69
    RandRCrtc *crtc() const;
 
70
 
 
71
    /** Returns a list of all RRModes supported by this output. */
 
72
    ModeList modes() const;
 
73
 
 
74
    /** Returns the current mode for this output. */
 
75
    RandRMode mode() const;
 
76
 
 
77
    /** Returns the preferred mode for this output. */
 
78
    RandRMode preferredMode(void) const;
 
79
 
 
80
    /** The list of supported sizes */
 
81
    SizeList sizes() const;
 
82
    QRect rect() const;
 
83
 
 
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;
 
87
 
 
88
    /** The current refresh rate. */
 
89
    float refreshRate() const;
 
90
 
 
91
    /** Return all possible rotations for all CRTCs this output can be connected
 
92
     * to. */
 
93
    int rotations() const;
 
94
 
 
95
    /** Returns the curent rotation of the CRTC this output is currently
 
96
     * connected to */
 
97
    int rotation() const;
 
98
 
 
99
    /** Determines whether this output is connected to a display device.
 
100
     * It is not necessarily active. */
 
101
    bool isConnected() const;
 
102
 
 
103
    /** Determines whether this output is currently driving a display
 
104
     * device. */
 
105
    bool isActive() const;
 
106
 
 
107
    bool applyProposed(int changes = 0xffffff);
 
108
    void proposeOriginal();
 
109
 
 
110
    // proposal functions
 
111
    void proposeRefreshRate(float rate);
 
112
    void proposeRect(const QRect &r);
 
113
    void proposeRotation(int rotation);
 
114
 
 
115
public slots:
 
116
    void slotDisable();
 
117
    void slotEnable();
 
118
 
 
119
private slots:
 
120
    void slotCrtcChanged(RRCrtc c, int changes);
 
121
 
 
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);
 
127
 
 
128
protected:
 
129
    /** Query Xrandr for information about this output, and set
 
130
     * up this instance accordingly. */
 
131
    bool queryOutputInfo(void);
 
132
 
 
133
    /** Find the first CRTC that is not controlling any
 
134
     * display devices. */
 
135
    RandRCrtc *findEmptyCrtc(void);
 
136
    bool tryCrtc(RandRCrtc *crtc, int changes);
 
137
 
 
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);
 
142
 
 
143
private:
 
144
    RROutput m_id;
 
145
    XRROutputInfo* m_info;
 
146
    QString m_name;
 
147
    QString m_alias;
 
148
 
 
149
    CrtcList m_possibleCrtcs;
 
150
 
 
151
    RandRScreen *m_screen;
 
152
    RandRCrtc *m_crtc;
 
153
 
 
154
    //proposed stuff (mostly to read from the configuration)
 
155
    QRect m_proposedRect;
 
156
    int   m_proposedRotation;
 
157
    float m_proposedRate;
 
158
 
 
159
    QRect m_originalRect;
 
160
    int   m_originalRotation;
 
161
    float m_originalRate;
 
162
 
 
163
    ModeList m_modes;
 
164
    RandRMode m_preferredMode;
 
165
 
 
166
    int m_rotations;
 
167
    bool m_connected;
 
168
};
 
169
#endif