Changeset View
Changeset View
Standalone View
Standalone View
backends/xrandr/xrandroutput.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 124 | { | |||
---|---|---|---|---|---|
150 | } else if (conn == XCB_RANDR_CONNECTION_CONNECTED) { | 150 | } else if (conn == XCB_RANDR_CONNECTION_CONNECTED) { | ||
151 | // the output changed in some way, let's update the internal | 151 | // the output changed in some way, let's update the internal | ||
152 | // list of modes, as it may have changed | 152 | // list of modes, as it may have changed | ||
153 | XCB::OutputInfo outputInfo(m_id, XCB_TIME_CURRENT_TIME); | 153 | XCB::OutputInfo outputInfo(m_id, XCB_TIME_CURRENT_TIME); | ||
154 | if (outputInfo) { | 154 | if (outputInfo) { | ||
155 | updateModes(outputInfo); | 155 | updateModes(outputInfo); | ||
156 | } | 156 | } | ||
157 | 157 | | |||
158 | m_hotplugModeUpdate = XRandR::hasProperty(m_id, "hotplug_mode_update"); | ||||
158 | } | 159 | } | ||
159 | 160 | | |||
160 | // A monitor has been enabled or disabled | 161 | // A monitor has been enabled or disabled | ||
161 | // We don't use isEnabled(), because it checks for crtc && crtc->mode(), however | 162 | // We don't use isEnabled(), because it checks for crtc && crtc->mode(), however | ||
162 | // crtc->mode may already be unset due to xcb_randr_crtc_tChangeNotify coming before | 163 | // crtc->mode may already be unset due to xcb_randr_crtc_tChangeNotify coming before | ||
163 | // xcb_randr_output_tChangeNotify and reseting the CRTC mode | 164 | // xcb_randr_output_tChangeNotify and reseting the CRTC mode | ||
164 | 165 | | |||
165 | if ((m_crtc == nullptr) != (crtc == XCB_NONE)) { | 166 | if ((m_crtc == nullptr) != (crtc == XCB_NONE)) { | ||
166 | if (crtc == XCB_NONE && mode == XCB_NONE) { | 167 | if (crtc == XCB_NONE && mode == XCB_NONE) { | ||
167 | // Monitor has been disabled | 168 | // Monitor has been disabled | ||
168 | m_crtc->disconectOutput(m_id); | 169 | m_crtc->disconectOutput(m_id); | ||
169 | m_crtc = nullptr; | 170 | m_crtc = nullptr; | ||
170 | } else { | 171 | } else { | ||
171 | m_crtc = m_config->crtc(crtc); | 172 | m_crtc = m_config->crtc(crtc); | ||
172 | m_crtc->connectOutput(m_id); | 173 | m_crtc->connectOutput(m_id); | ||
173 | } | 174 | } | ||
174 | } | 175 | } | ||
175 | 176 | | |||
176 | // Primary has changed | 177 | // Primary has changed | ||
177 | m_primary = primary; | 178 | m_primary = primary; | ||
178 | } | 179 | } | ||
davidedmundson: This code path potentially updates this var twice.
Would it be better to do this inside the
}… | |||||
179 | 180 | | |||
180 | void XRandROutput::setIsPrimary(bool primary) | 181 | void XRandROutput::setIsPrimary(bool primary) | ||
181 | { | 182 | { | ||
182 | m_primary = primary; | 183 | m_primary = primary; | ||
183 | } | 184 | } | ||
184 | 185 | | |||
185 | 186 | | |||
186 | void XRandROutput::init() | 187 | void XRandROutput::init() | ||
Show All 16 Lines | 203 | for (int i = 0; i < outputInfo->num_clones; ++i) { | |||
203 | m_clones.append(clones[i]); | 204 | m_clones.append(clones[i]); | ||
204 | } | 205 | } | ||
205 | m_widthMm = outputInfo->mm_width; | 206 | m_widthMm = outputInfo->mm_width; | ||
206 | m_heightMm = outputInfo->mm_height; | 207 | m_heightMm = outputInfo->mm_height; | ||
207 | m_crtc = m_config->crtc(outputInfo->crtc); | 208 | m_crtc = m_config->crtc(outputInfo->crtc); | ||
208 | if (m_crtc) { | 209 | if (m_crtc) { | ||
209 | m_crtc->connectOutput(m_id); | 210 | m_crtc->connectOutput(m_id); | ||
210 | } | 211 | } | ||
212 | m_hotplugModeUpdate = XRandR::hasProperty(m_id, "hotplug_mode_update"); | ||||
why are we querying if the property exists rather than if the property is 1? davidedmundson: why are we querying if the property exists rather than if the property is 1? | |||||
Because it's poorly specified. In fact, it's always 0 as far as I can tell. apol: Because it's poorly specified. In fact, it's always 0 as far as I can tell. | |||||
211 | 213 | | |||
212 | updateModes(outputInfo); | 214 | updateModes(outputInfo); | ||
213 | } | 215 | } | ||
214 | 216 | | |||
215 | void XRandROutput::updateModes(const XCB::OutputInfo &outputInfo) | 217 | void XRandROutput::updateModes(const XCB::OutputInfo &outputInfo) | ||
216 | { | 218 | { | ||
217 | /* Init modes */ | 219 | /* Init modes */ | ||
218 | XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> screenResources(XRandR::screenResources()); | 220 | XCB::ScopedPointer<xcb_randr_get_screen_resources_reply_t> screenResources(XRandR::screenResources()); | ||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Line(s) | 298 | { | |||
299 | const bool signalsBlocked = kscreenOutput->signalsBlocked(); | 301 | const bool signalsBlocked = kscreenOutput->signalsBlocked(); | ||
300 | kscreenOutput->blockSignals(true); | 302 | kscreenOutput->blockSignals(true); | ||
301 | kscreenOutput->setId(m_id); | 303 | kscreenOutput->setId(m_id); | ||
302 | kscreenOutput->setType(m_type); | 304 | kscreenOutput->setType(m_type); | ||
303 | kscreenOutput->setSizeMm(QSize(m_widthMm, m_heightMm)); | 305 | kscreenOutput->setSizeMm(QSize(m_widthMm, m_heightMm)); | ||
304 | kscreenOutput->setName(m_name); | 306 | kscreenOutput->setName(m_name); | ||
305 | kscreenOutput->setIcon(m_icon); | 307 | kscreenOutput->setIcon(m_icon); | ||
306 | 308 | | |||
309 | //See https://bugzilla.redhat.com/show_bug.cgi?id=1290586 | ||||
310 | //QXL will be creating a new mode we need to jump to every time the display is resized | ||||
311 | kscreenOutput->setFollowPreferredMode(m_hotplugModeUpdate); | ||||
312 | | ||||
307 | kscreenOutput->setConnected(isConnected()); | 313 | kscreenOutput->setConnected(isConnected()); | ||
308 | if (isConnected()) { | 314 | if (isConnected()) { | ||
309 | KScreen::ModeList kscreenModes; | 315 | KScreen::ModeList kscreenModes; | ||
310 | for (auto iter = m_modes.constBegin(), end = m_modes.constEnd(); iter != end; ++iter) { | 316 | for (auto iter = m_modes.constBegin(), end = m_modes.constEnd(); iter != end; ++iter) { | ||
311 | XRandRMode *mode = iter.value(); | 317 | XRandRMode *mode = iter.value(); | ||
312 | kscreenModes.insert(QString::number(iter.key()), mode->toKScreenMode()); | 318 | kscreenModes.insert(QString::number(iter.key()), mode->toKScreenMode()); | ||
313 | } | 319 | } | ||
314 | kscreenOutput->setModes(kscreenModes); | 320 | kscreenOutput->setModes(kscreenModes); | ||
Show All 23 Lines |
This code path potentially updates this var twice.
Would it be better to do this inside the
} else if (conn == XCB_RANDR_CONNECTION_CONNECTED) {