Changeset View
Changeset View
Standalone View
Standalone View
backends/xrandr/xrandrcrtc.cpp
Show All 12 Lines | |||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | | ||||
22 | #include "xrandrcrtc.h" | 21 | #include "xrandrcrtc.h" | ||
23 | #include "xrandrconfig.h" | 22 | | ||
24 | #include "xrandr.h" | 23 | #include "xrandr.h" | ||
24 | #include "xrandrconfig.h" | ||||
25 | 25 | | |||
26 | #include "../xcbwrapper.h" | 26 | #include "../xcbwrapper.h" | ||
27 | 27 | | |||
28 | XRandRCrtc::XRandRCrtc(xcb_randr_crtc_t crtc, XRandRConfig *config) | 28 | XRandRCrtc::XRandRCrtc(xcb_randr_crtc_t crtc, XRandRConfig *config) | ||
29 | : QObject(config) | 29 | : QObject(config) | ||
30 | , m_crtc(crtc) | 30 | , m_crtc(crtc) | ||
31 | , m_mode(0) | 31 | , m_mode(0) | ||
32 | , m_rotation(XCB_RANDR_ROTATION_ROTATE_0) | 32 | , m_rotation(XCB_RANDR_ROTATION_ROTATE_0) | ||
Show All 30 Lines | |||||
63 | { | 63 | { | ||
64 | return m_outputs; | 64 | return m_outputs; | ||
65 | } | 65 | } | ||
66 | 66 | | |||
67 | bool XRandRCrtc::connectOutput(xcb_randr_output_t output) | 67 | bool XRandRCrtc::connectOutput(xcb_randr_output_t output) | ||
68 | { | 68 | { | ||
69 | update(); | 69 | update(); | ||
70 | qCDebug(KSCREEN_XRANDR) << "Connected output" << output << "to CRTC" << m_crtc; | 70 | qCDebug(KSCREEN_XRANDR) << "Connected output" << output << "to CRTC" << m_crtc; | ||
71 | | ||||
71 | if (!m_possibleOutputs.contains(output)) { | 72 | if (!m_possibleOutputs.contains(output)) { | ||
72 | qCDebug(KSCREEN_XRANDR) << "Output" << output << "is not an allowed output for CRTC" << m_crtc; | 73 | qCDebug(KSCREEN_XRANDR) << "Output" << output | ||
74 | << "is not an allowed output for CRTC" << m_crtc; | ||||
73 | return false; | 75 | return false; | ||
74 | } | 76 | } | ||
75 | 77 | | |||
76 | if (!m_outputs.contains(output)) { | 78 | if (!m_outputs.contains(output)) { | ||
77 | m_outputs.append(output); | 79 | m_outputs.append(output); | ||
78 | } | 80 | } | ||
79 | return true; | 81 | return true; | ||
80 | } | 82 | } | ||
81 | 83 | | |||
82 | void XRandRCrtc::disconectOutput(xcb_randr_output_t output) | 84 | void XRandRCrtc::disconectOutput(xcb_randr_output_t output) | ||
83 | { | 85 | { | ||
84 | update(); | 86 | update(); | ||
85 | qCDebug(KSCREEN_XRANDR) << "Disconnected output" << output << "from CRTC" << m_crtc; | 87 | qCDebug(KSCREEN_XRANDR) << "Disconnected output" << output << "from CRTC" << m_crtc; | ||
88 | | ||||
86 | const int index = m_outputs.indexOf(output); | 89 | const int index = m_outputs.indexOf(output); | ||
87 | if (index > -1) { | 90 | if (index > -1) { | ||
88 | m_outputs.remove(index); | 91 | m_outputs.remove(index); | ||
89 | } | 92 | } | ||
90 | } | 93 | } | ||
91 | 94 | | |||
92 | bool XRandRCrtc::isFree() const | 95 | bool XRandRCrtc::isFree() const | ||
93 | { | 96 | { | ||
94 | return m_outputs.isEmpty(); | 97 | return m_outputs.isEmpty(); | ||
95 | } | 98 | } | ||
96 | 99 | | |||
97 | void XRandRCrtc::update() | 100 | void XRandRCrtc::update() | ||
98 | { | 101 | { | ||
99 | XCB::CRTCInfo crtcInfo(m_crtc, XCB_TIME_CURRENT_TIME); | 102 | XCB::CRTCInfo crtcInfo(m_crtc, XCB_TIME_CURRENT_TIME); | ||
100 | m_mode = crtcInfo->mode; | 103 | m_mode = crtcInfo->mode; | ||
101 | m_rotation = (xcb_randr_rotation_t) crtcInfo->rotation; | 104 | | ||
102 | m_geometry = QRect(crtcInfo->x, crtcInfo->y, crtcInfo->width, crtcInfo->height); | 105 | m_geometry = QRect(crtcInfo->x, crtcInfo->y, crtcInfo->width, crtcInfo->height); | ||
106 | m_rotation = (xcb_randr_rotation_t) crtcInfo->rotation; | ||||
107 | | ||||
103 | m_possibleOutputs.clear(); | 108 | m_possibleOutputs.clear(); | ||
104 | m_possibleOutputs.reserve(crtcInfo->num_possible_outputs); | 109 | m_possibleOutputs.reserve(crtcInfo->num_possible_outputs); | ||
110 | | ||||
105 | xcb_randr_output_t *possible = xcb_randr_get_crtc_info_possible(crtcInfo); | 111 | xcb_randr_output_t *possible = xcb_randr_get_crtc_info_possible(crtcInfo); | ||
106 | for (int i = 0; i < crtcInfo->num_possible_outputs; ++i) { | 112 | for (int i = 0; i < crtcInfo->num_possible_outputs; ++i) { | ||
107 | m_possibleOutputs.append(possible[i]); | 113 | m_possibleOutputs.append(possible[i]); | ||
108 | } | 114 | } | ||
109 | 115 | | |||
110 | m_outputs.clear(); | 116 | m_outputs.clear(); | ||
111 | xcb_randr_output_t *outputs = xcb_randr_get_crtc_info_outputs(crtcInfo); | 117 | xcb_randr_output_t *outputs = xcb_randr_get_crtc_info_outputs(crtcInfo); | ||
112 | for (int i = 0; i < crtcInfo->num_outputs; ++i) { | 118 | for (int i = 0; i < crtcInfo->num_outputs; ++i) { | ||
113 | m_outputs.append(outputs[i]); | 119 | m_outputs.append(outputs[i]); | ||
114 | } | 120 | } | ||
115 | } | 121 | } | ||
116 | 122 | | |||
117 | void XRandRCrtc::update(xcb_randr_mode_t mode, xcb_randr_rotation_t rotation, const QRect &geom) | 123 | void XRandRCrtc::update(xcb_randr_mode_t mode, xcb_randr_rotation_t rotation, const QRect &geom) | ||
118 | { | 124 | { | ||
119 | m_mode = mode; | 125 | m_mode = mode; | ||
120 | m_rotation = rotation; | | |||
121 | m_geometry = geom; | 126 | m_geometry = geom; | ||
127 | m_rotation = rotation; | ||||
122 | } | 128 | } | ||
123 | 129 | |