aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Rouven Czerwinski <rouven@czerwinskis.de>2019-08-07 08:13:15 +0200
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-08-07 16:25:37 +0900
commit724926ea6ae119956dc7b1e39c2e30c1e3657676 (patch)
tree24982083647dccc23d9b14c255607b1f133fa7db
parentsway.5: explain how to enable pango markup in font (diff)
downloadsway-724926ea6ae119956dc7b1e39c2e30c1e3657676.tar.gz
sway-724926ea6ae119956dc7b1e39c2e30c1e3657676.tar.zst
sway-724926ea6ae119956dc7b1e39c2e30c1e3657676.zip
Revert "Add support for wlr_output's atomic API"
This reverts commit 6e0565e9de4247bbf0ca662565c58e0a54258d6e. This is required for the revert on swaywm/wlroots#1781
-rw-r--r--sway/config/output.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index a96007fb..9da009bb 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -201,13 +201,12 @@ struct output_config *store_output_config(struct output_config *oc) {
201 return oc; 201 return oc;
202} 202}
203 203
204static void set_mode(struct wlr_output *output, int width, int height, 204static bool set_mode(struct wlr_output *output, int width, int height,
205 float refresh_rate) { 205 float refresh_rate) {
206 int mhz = (int)(refresh_rate * 1000); 206 int mhz = (int)(refresh_rate * 1000);
207 if (wl_list_empty(&output->modes)) { 207 if (wl_list_empty(&output->modes)) {
208 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name); 208 sway_log(SWAY_DEBUG, "Assigning custom mode to %s", output->name);
209 wlr_output_set_custom_mode(output, width, height, mhz); 209 return wlr_output_set_custom_mode(output, width, height, mhz);
210 return;
211 } 210 }
212 211
213 struct wlr_output_mode *mode, *best = NULL; 212 struct wlr_output_mode *mode, *best = NULL;
@@ -227,7 +226,7 @@ static void set_mode(struct wlr_output *output, int width, int height,
227 } else { 226 } else {
228 sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name); 227 sway_log(SWAY_DEBUG, "Assigning configured mode to %s", output->name);
229 } 228 }
230 wlr_output_set_mode(output, best); 229 return wlr_output_set_mode(output, best);
231} 230}
232 231
233bool apply_output_config(struct output_config *oc, struct sway_output *output) { 232bool apply_output_config(struct output_config *oc, struct sway_output *output) {
@@ -244,12 +243,11 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
244 wlr_output_layout_remove(root->output_layout, wlr_output); 243 wlr_output_layout_remove(root->output_layout, wlr_output);
245 } 244 }
246 wlr_output_enable(wlr_output, false); 245 wlr_output_enable(wlr_output, false);
247 return wlr_output_commit(wlr_output); 246 return true;
248 } else if (!output->enabled) { 247 } else if (!output->enabled) {
249 // Output is not enabled. Enable it, output_enable will call us again. 248 // Output is not enabled. Enable it, output_enable will call us again.
250 if (!oc || oc->dpms_state != DPMS_OFF) { 249 if (!oc || oc->dpms_state != DPMS_OFF) {
251 wlr_output_enable(wlr_output, true); 250 wlr_output_enable(wlr_output, true);
252 wlr_output_commit(wlr_output);
253 } 251 }
254 output_enable(output, oc); 252 output_enable(output, oc);
255 return true; 253 return true;
@@ -260,14 +258,26 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
260 wlr_output_enable(wlr_output, true); 258 wlr_output_enable(wlr_output, true);
261 } 259 }
262 260
263 struct wlr_output_mode *preferred_mode = 261 bool modeset_success;
264 wlr_output_preferred_mode(wlr_output);
265 if (oc && oc->width > 0 && oc->height > 0) { 262 if (oc && oc->width > 0 && oc->height > 0) {
266 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width, 263 sway_log(SWAY_DEBUG, "Set %s mode to %dx%d (%f GHz)", oc->name, oc->width,
267 oc->height, oc->refresh_rate); 264 oc->height, oc->refresh_rate);
268 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate); 265 modeset_success =
269 } else if (preferred_mode != NULL) { 266 set_mode(wlr_output, oc->width, oc->height, oc->refresh_rate);
270 wlr_output_set_mode(wlr_output, preferred_mode); 267 } else if (!wl_list_empty(&wlr_output->modes)) {
268 struct wlr_output_mode *mode =
269 wl_container_of(wlr_output->modes.prev, mode, link);
270 modeset_success = wlr_output_set_mode(wlr_output, mode);
271 } else {
272 // Output doesn't support modes
273 modeset_success = true;
274 }
275 if (!modeset_success) {
276 // Failed to modeset, maybe the output is missing a CRTC. Leave the
277 // output disabled for now and try again when the output gets the mode
278 // we asked for.
279 sway_log(SWAY_ERROR, "Failed to modeset output %s", wlr_output->name);
280 return false;
271 } 281 }
272 282
273 if (oc && oc->scale > 0) { 283 if (oc && oc->scale > 0) {
@@ -287,14 +297,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
287 wlr_output_set_transform(wlr_output, oc->transform); 297 wlr_output_set_transform(wlr_output, oc->transform);
288 } 298 }
289 299
290 if (!wlr_output_commit(wlr_output)) {
291 // Failed to modeset, maybe the output is missing a CRTC. Leave the
292 // output disabled for now and try again when the output gets the mode
293 // we asked for.
294 sway_log(SWAY_ERROR, "Failed to modeset output %s", wlr_output->name);
295 return false;
296 }
297
298 // Find position for it 300 // Find position for it
299 if (oc && (oc->x != -1 || oc->y != -1)) { 301 if (oc && (oc->x != -1 || oc->y != -1)) {
300 sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y); 302 sway_log(SWAY_DEBUG, "Set %s position to %d, %d", oc->name, oc->x, oc->y);
@@ -314,7 +316,6 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
314 if (oc && oc->dpms_state == DPMS_OFF) { 316 if (oc && oc->dpms_state == DPMS_OFF) {
315 sway_log(SWAY_DEBUG, "Turning off screen"); 317 sway_log(SWAY_DEBUG, "Turning off screen");
316 wlr_output_enable(wlr_output, false); 318 wlr_output_enable(wlr_output, false);
317 wlr_output_commit(wlr_output);
318 } 319 }
319 320
320 return true; 321 return true;
@@ -323,12 +324,12 @@ bool apply_output_config(struct output_config *oc, struct sway_output *output) {
323static void default_output_config(struct output_config *oc, 324static void default_output_config(struct output_config *oc,
324 struct wlr_output *wlr_output) { 325 struct wlr_output *wlr_output) {
325 oc->enabled = 1; 326 oc->enabled = 1;
326 struct wlr_output_mode *preferred_mode = 327 if (!wl_list_empty(&wlr_output->modes)) {
327 wlr_output_preferred_mode(wlr_output); 328 struct wlr_output_mode *mode =
328 if (preferred_mode != NULL) { 329 wl_container_of(wlr_output->modes.prev, mode, link);
329 oc->width = preferred_mode->width; 330 oc->width = mode->width;
330 oc->height = preferred_mode->height; 331 oc->height = mode->height;
331 oc->refresh_rate = preferred_mode->refresh; 332 oc->refresh_rate = mode->refresh;
332 } 333 }
333 oc->x = oc->y = -1; 334 oc->x = oc->y = -1;
334 oc->scale = 1; 335 oc->scale = 1;