Commit 32a00a06 authored by Thomas Wood's avatar Thomas Wood

display: prevent the built-in display being turned on if the lid is closed

https://bugzilla.gnome.org/show_bug.cgi?id=704487
parent 48789d61
...@@ -122,7 +122,8 @@ PKG_CHECK_MODULES(DATETIME_PANEL, $COMMON_MODULES ...@@ -122,7 +122,8 @@ PKG_CHECK_MODULES(DATETIME_PANEL, $COMMON_MODULES
gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION gnome-desktop-3.0 >= $GNOME_DESKTOP_REQUIRED_VERSION
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION
gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION) gdk-pixbuf-2.0 >= $GDKPIXBUF_REQUIRED_VERSION)
PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES gnome-desktop-3.0 >= 3.1.0) PKG_CHECK_MODULES(DISPLAY_PANEL, $COMMON_MODULES gnome-desktop-3.0 >= 3.1.0
upower-glib >= 0.9.1)
PKG_CHECK_MODULES(INFO_PANEL, $COMMON_MODULES libgtop-2.0 gl PKG_CHECK_MODULES(INFO_PANEL, $COMMON_MODULES libgtop-2.0 gl
polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION) polkit-gobject-1 >= $POLKIT_REQUIRED_VERSION)
PKG_CHECK_MODULES(KEYBOARD_PANEL, $COMMON_MODULES PKG_CHECK_MODULES(KEYBOARD_PANEL, $COMMON_MODULES
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <gdesktop-enums.h> #include <gdesktop-enums.h>
#include "cc-rr-labeler.h" #include "cc-rr-labeler.h"
#include <libupower-glib/upower.h>
CC_PANEL_REGISTER (CcDisplayPanel, cc_display_panel) CC_PANEL_REGISTER (CcDisplayPanel, cc_display_panel)
...@@ -97,6 +98,9 @@ struct _CcDisplayPanelPrivate ...@@ -97,6 +98,9 @@ struct _CcDisplayPanelPrivate
/* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */ /* These are used while we are waiting for the ApplyConfiguration method to be executed over D-bus */
GDBusProxy *proxy; GDBusProxy *proxy;
UpClient *up_client;
gboolean lid_is_closed;
}; };
typedef struct typedef struct
...@@ -151,6 +155,10 @@ cc_display_panel_set_property (GObject *object, ...@@ -151,6 +155,10 @@ cc_display_panel_set_property (GObject *object,
static void static void
cc_display_panel_dispose (GObject *object) cc_display_panel_dispose (GObject *object)
{ {
CcDisplayPanelPrivate *priv = CC_DISPLAY_PANEL (object)->priv;
g_clear_object (&priv->up_client);
G_OBJECT_CLASS (cc_display_panel_parent_class)->dispose (object); G_OBJECT_CLASS (cc_display_panel_parent_class)->dispose (object);
} }
...@@ -693,7 +701,20 @@ rebuild_on_off_radios (CcDisplayPanel *self) ...@@ -693,7 +701,20 @@ rebuild_on_off_radios (CcDisplayPanel *self)
if (!gnome_rr_config_get_clone (self->priv->current_configuration) && self->priv->current_output) if (!gnome_rr_config_get_clone (self->priv->current_configuration) && self->priv->current_output)
{ {
if (count_active_outputs (self) > 1 || !gnome_rr_output_info_is_active (self->priv->current_output)) gboolean display_closed = FALSE;
if (self->priv->lid_is_closed)
{
GnomeRROutput *output;
output = gnome_rr_screen_get_output_by_name (self->priv->screen,
gnome_rr_output_info_get_name (self->priv->current_output));
display_closed = gnome_rr_output_is_builtin_display (output);
}
if ((count_active_outputs (self) > 1 || !gnome_rr_output_info_is_active (self->priv->current_output))
&& !display_closed)
sensitive = TRUE; sensitive = TRUE;
else else
sensitive = FALSE; sensitive = FALSE;
...@@ -2599,6 +2620,23 @@ cc_display_panel_init (CcDisplayPanel *self) ...@@ -2599,6 +2620,23 @@ cc_display_panel_init (CcDisplayPanel *self)
g_resources_register (cc_display_get_resource ()); g_resources_register (cc_display_get_resource ());
} }
static void
cc_display_panel_up_client_changed (UpClient *client,
CcDisplayPanel *self)
{
CcDisplayPanelPrivate *priv = self->priv;
gboolean lid_is_closed;
lid_is_closed = up_client_get_lid_is_closed (client);
if (lid_is_closed != priv->lid_is_closed)
{
priv->lid_is_closed = lid_is_closed;
rebuild_on_off_radios (self);
}
}
static GObject * static GObject *
cc_display_panel_constructor (GType gtype, cc_display_panel_constructor (GType gtype,
guint n_properties, guint n_properties,
...@@ -2703,5 +2741,21 @@ cc_display_panel_constructor (GType gtype, ...@@ -2703,5 +2741,21 @@ cc_display_panel_constructor (GType gtype,
gtk_widget_show (self->priv->panel); gtk_widget_show (self->priv->panel);
gtk_container_add (GTK_CONTAINER (self), self->priv->panel); gtk_container_add (GTK_CONTAINER (self), self->priv->panel);
self->priv->up_client = up_client_new ();
if (up_client_get_lid_is_present (self->priv->up_client))
{
/* Connect to the "changed" signal to track changes to "lid-is-closed"
* property. Connecting to "notify::lid-is-closed" would be preferable,
* but currently doesn't work as expected:
* https://bugs.freedesktop.org/show_bug.cgi?id=43001
*/
g_signal_connect (self->priv->up_client, "changed",
G_CALLBACK (cc_display_panel_up_client_changed), self);
cc_display_panel_up_client_changed (self->priv->up_client, self);
}
else
g_clear_object (&self->priv->up_client);
return obj; return obj;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment