summaryrefslogtreecommitdiff
path: root/tinywl.c
diff options
context:
space:
mode:
authorSimon Ser <[email protected]>2019-12-28 13:18:38 +0100
committerDrew DeVault <[email protected]>2019-12-30 11:21:11 -0700
commit8067c84101d9966aac2fbf22a4a61fa35efd71de (patch)
tree228847c8d856ba4caf1924480d4a37b638396f75 /tinywl.c
parent5f589038c8fec55521fc6a09117e70345528157a (diff)
tinywl: enable and commit output when modesetting
While at it, choose the preferred mode instead of the last one.
Diffstat (limited to 'tinywl.c')
-rw-r--r--tinywl.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/tinywl.c b/tinywl.c
index 3ea7d07..e98aaf3 100644
--- a/tinywl.c
+++ b/tinywl.c
@@ -648,12 +648,15 @@ static void server_new_output(struct wl_listener *listener, void *data) {
/* Some backends don't have modes. DRM+KMS does, and we need to set a mode
* before we can use the output. The mode is a tuple of (width, height,
* refresh rate), and each monitor supports only a specific set of modes. We
- * just pick the first, a more sophisticated compositor would let the user
- * configure it or pick the mode the display advertises as preferred. */
+ * just pick the monitor's preferred mode, a more sophisticated compositor
+ * would let the user configure it. */
if (!wl_list_empty(&wlr_output->modes)) {
- struct wlr_output_mode *mode =
- wl_container_of(wlr_output->modes.prev, mode, link);
+ struct wlr_output_mode *mode = wlr_output_preferred_mode(wlr_output);
wlr_output_set_mode(wlr_output, mode);
+ wlr_output_enable(wlr_output, true);
+ if (!wlr_output_commit(wlr_output)) {
+ return;
+ }
}
/* Allocates and configures our state for this output */