From d7854794cf092995950e9c3012ecf00564fb9b8c Mon Sep 17 00:00:00 2001 From: Jonathon Jongsma Date: Wed, 19 Nov 2014 10:56:27 -0600 Subject: [PATCH] monitor-manager: check framebuffer limits for all configs Refactor make_default_config() to always sanity-check the configuration to ensure that it fits within the framebuffer. Previously, this was only done for the default linear configuration. --- src/backends/meta-monitor-config.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/backends/meta-monitor-config.c b/src/backends/meta-monitor-config.c index 81f0a5e54..c249e5d85 100644 --- a/src/backends/meta-monitor-config.c +++ b/src/backends/meta-monitor-config.c @@ -1179,10 +1179,6 @@ make_linear_config (MetaMonitorConfig *self, config->outputs[i].rect.x = x; x += config->outputs[i].rect.width; } - - /* Disable outputs that would go beyond framebuffer limits */ - if (config->outputs[i].rect.x + config->outputs[i].rect.width > max_width) - config->outputs[i].enabled = FALSE; } } @@ -1263,6 +1259,7 @@ make_default_config (MetaMonitorConfig *self, gboolean use_stored_config) { MetaConfiguration *ret = NULL; + unsigned i; ret = config_new (); make_config_key (ret, outputs, n_outputs, -1); @@ -1272,21 +1269,29 @@ make_default_config (MetaMonitorConfig *self, nothing else to do */ if (n_outputs == 1) { - init_config_from_preferred_mode (&ret->outputs[0], &outputs[0]); ret->outputs[0].is_primary = TRUE; - return ret; + goto check_limits; } if (make_suggested_config (self, outputs, n_outputs, max_width, max_height, ret)) - return ret; + goto check_limits; if (use_stored_config && extend_stored_config (self, outputs, n_outputs, max_width, max_height, ret)) - return ret; + goto check_limits; make_linear_config (self, outputs, n_outputs, max_width, max_height, ret); +check_limits: + /* Disable outputs that would go beyond framebuffer limits */ + for (i = 0; i < n_outputs; i++) + { + if ((ret->outputs[i].rect.x + ret->outputs[i].rect.width > max_width) + || (ret->outputs[i].rect.y + ret->outputs[i].rect.height > max_height)) + ret->outputs[i].enabled = FALSE; + } + return ret; }