[mutter] monitor-config: Prevent a crash applying config for a closed lid
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] monitor-config: Prevent a crash applying config for a closed lid
- Date: Fri, 31 Oct 2014 16:51:16 +0000 (UTC)
commit 3b1271d9be8a5603f3d52cc5b5f31958623f391c
Author: Rui Matos <tiagomatos gmail com>
Date: Fri Oct 31 15:02:05 2014 +0100
monitor-config: Prevent a crash applying config for a closed lid
When a laptop's lid is closed we try to build and apply a temporary
configuration that disables the laptop's display if we have other
outputs.
This isn't enough though, we must also check if at least one of these
other outputs is enabled otherwise we'll try to resize the screen to
0x0 which (rightfully) hits an assertion.
https://bugzilla.gnome.org/show_bug.cgi?id=739450
src/backends/meta-monitor-config.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
---
diff --git a/src/backends/meta-monitor-config.c b/src/backends/meta-monitor-config.c
index a421761..98ae220 100644
--- a/src/backends/meta-monitor-config.c
+++ b/src/backends/meta-monitor-config.c
@@ -914,6 +914,19 @@ laptop_display_is_on (MetaConfiguration *config)
return FALSE;
}
+static gboolean
+multiple_outputs_are_enabled (MetaConfiguration *config)
+{
+ unsigned int i, enabled;
+
+ enabled = 0;
+ for (i = 0; i < config->n_outputs; i++)
+ if (config->outputs[i].enabled)
+ enabled++;
+
+ return enabled > 1;
+}
+
static MetaConfiguration *
make_laptop_lid_config (MetaConfiguration *reference)
{
@@ -923,7 +936,7 @@ make_laptop_lid_config (MetaConfiguration *reference)
int x_after, y_after;
int x_offset, y_offset;
- g_assert (reference->n_outputs > 1);
+ g_assert (multiple_outputs_are_enabled (reference));
new = config_new ();
new->n_outputs = reference->n_outputs;
@@ -986,7 +999,7 @@ apply_configuration_with_lid (MetaMonitorConfig *self,
MetaMonitorManager *manager)
{
if (self->lid_is_closed &&
- config->n_outputs > 1 &&
+ multiple_outputs_are_enabled (config) &&
laptop_display_is_on (config))
{
MetaConfiguration *laptop_lid_config = make_laptop_lid_config (config);
@@ -1353,7 +1366,7 @@ turn_off_laptop_display (MetaMonitorConfig *self,
{
MetaConfiguration *new;
- if (self->current->n_outputs == 1)
+ if (!multiple_outputs_are_enabled (self->current))
return;
new = make_laptop_lid_config (self->current);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]