[gnome-settings-daemon] xrandr: Simplify the default XRandR behaviour



commit 75e052127eeb022d83b7a744b110d8bde5b7280c
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Nov 5 15:32:46 2010 +0000

    xrandr: Simplify the default XRandR behaviour
    
    Instead of using 3 separate configuration items, only use one that
    will default to not touching the carefully crafted setup from Xorg.
    
    This makes it possible to default to using a "dock" setup (where the
    internal screen would be turned off if an external one is present),
    or defaulting to "clone".
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634092

 data/gnome-settings-daemon.convert                 |    3 -
 data/gsd-enums.h                                   |    7 +++
 ...ettings-daemon.plugins.xrandr.gschema.xml.in.in |   18 ++-----
 plugins/xrandr/Makefile.am                         |    1 +
 plugins/xrandr/gsd-xrandr-manager.c                |   52 +++++++++----------
 5 files changed, 37 insertions(+), 44 deletions(-)
---
diff --git a/data/gnome-settings-daemon.convert b/data/gnome-settings-daemon.convert
index 9469fdf..99ea6e6 100644
--- a/data/gnome-settings-daemon.convert
+++ b/data/gnome-settings-daemon.convert
@@ -93,9 +93,6 @@ priority = /apps/gnome_settings_daemon/plugins/sound/priority
 active = /apps/gnome_settings_daemon/plugins/xrandr/active
 default-configuration-file = /apps/gnome_settings_daemon/xrandr/default_configuration_file
 priority = /apps/gnome_settings_daemon/plugins/xrandr/priority
-turn-on-external-monitors = /apps/gnome_settings_daemon/xrandr/turn_on_external_monitors_at_startup
-turn-on-laptop-monitor = /apps/gnome_settings_daemon/xrandr/turn_on_laptop_monitor_at_startup
-use-xorg-monitor-settings = /apps/gnome_settings_daemon/xrandr/use_xorg_monitor_settings
 
 [org.gnome.settings-daemon.plugins.xrdb]
 active = /apps/gnome_settings_daemon/plugins/xrdb/active
diff --git a/data/gsd-enums.h b/data/gsd-enums.h
index d70a436..e955c30 100644
--- a/data/gsd-enums.h
+++ b/data/gsd-enums.h
@@ -75,4 +75,11 @@ typedef enum
   GSD_TOUCHPAD_HANDEDNESS_MOUSE
 } GsdTouchpadHandedness;
 
+typedef enum
+{
+  GSD_XRANDR_BOOT_BEHAVIOUR_DO_NOTHING,
+  GSD_XRANDR_BOOT_BEHAVIOUR_CLONE,
+  GSD_XRANDR_BOOT_BEHAVIOUR_DOCK
+} GsdXrandrBootBehaviour;
+
 #endif /* __gsd_enums_h__ */
diff --git a/data/org.gnome.settings-daemon.plugins.xrandr.gschema.xml.in.in b/data/org.gnome.settings-daemon.plugins.xrandr.gschema.xml.in.in
index 6188433..c03f294 100644
--- a/data/org.gnome.settings-daemon.plugins.xrandr.gschema.xml.in.in
+++ b/data/org.gnome.settings-daemon.plugins.xrandr.gschema.xml.in.in
@@ -15,20 +15,10 @@
       <_summary>Priority to use for this plugin</_summary>
       <_description>Priority to use for this plugin in gnome-settings-daemon startup queue</_description>
     </key>
-    <key name="turn-on-external-monitors" type="b">
-      <default>false</default>
-      <_summary>Turn on external monitor after system boot</_summary>
-      <_description>Turn on external monitor after system boot if user plugs in external monitor on system boot.</_description>
-    </key>
-    <key name="turn-on-laptop-monitor" type="b">
-      <default>true</default>
-      <_summary>Turn on laptop monitor after system boot</_summary>
-      <_description>Turn on laptop monitor after system boot if user plugs in external monitor on system boot.</_description>
-    </key>
-    <key name="use-xorg-monitor-settings" type="b">
-      <default>false</default>
-      <_summary>Do not touch monitor configuration</_summary>
-      <_description>Usually, gnome-settings-daemon configures internal and external monitors according to the turn_on_external_monitors_at_startup and turn_on_laptop_monitor_at_startup settings and determines an appropriate cloning/side-by-side mode. Setting this key to True disables this, and the monitor settings are not touched at all (unless there is an explicit user configuration).</_description>
+    <key name="default-monitors-setup" enum="org.gnome.settings-daemon.GsdXrandrBootBehaviour">
+      <default>'do-nothing'</default>
+      <_summary>Whether to turn off specific monitors after boot</_summary>
+      <_description>'clone' will display the same thing on all monitors, 'dock' will switch off the internal monitor, 'do-nothing' will use the default Xorg behaviour (extend the desktop in recent versions)</_description>
     </key>
   </schema>
 </schemalist>
diff --git a/plugins/xrandr/Makefile.am b/plugins/xrandr/Makefile.am
index c0c090c..d1acc22 100644
--- a/plugins/xrandr/Makefile.am
+++ b/plugins/xrandr/Makefile.am
@@ -48,6 +48,7 @@ libxrandr_la_SOURCES = 		\
 
 libxrandr_la_CPPFLAGS =						\
 	-I$(top_srcdir)/gnome-settings-daemon			\
+	-I$(top_srcdir)/data/					\
 	-DBINDIR=\"$(bindir)\"					\
 	-DGNOME_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\"	\
 	$(AM_CPPFLAGS)
diff --git a/plugins/xrandr/gsd-xrandr-manager.c b/plugins/xrandr/gsd-xrandr-manager.c
index e5a0404..81bbe75 100644
--- a/plugins/xrandr/gsd-xrandr-manager.c
+++ b/plugins/xrandr/gsd-xrandr-manager.c
@@ -50,16 +50,15 @@
 #include <libnotify/notify.h>
 #endif
 
+#include "gsd-enums.h"
 #include "gnome-settings-profile.h"
 #include "gsd-xrandr-manager.h"
 
 #define GSD_XRANDR_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_XRANDR_MANAGER, GsdXrandrManagerPrivate))
 
 #define CONF_DIR "org.gnome.settings-daemon.plugins.xrandr"
-#define CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP   "turn-on-external-monitors"
-#define CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP      "turn-on-laptop-monitor"
-#define CONF_KEY_DEFAULT_CONFIGURATION_FILE             "default-configuration-file"
-#define CONF_KEY_USE_XORG_MONITOR_SETTINGS              "use-xorg-monitor-settings"
+#define CONF_KEY_DEFAULT_MONITORS_SETUP   "default-monitors-setup"
+#define CONF_KEY_DEFAULT_CONFIGURATION_FILE   "default-configuration-file"
 
 #define VIDEO_KEYSYM    "XF86Display"
 #define ROTATE_KEYSYM   "XF86RotateWindows"
@@ -1083,7 +1082,6 @@ static void
 error_message (GsdXrandrManager *mgr, const char *primary_text, GError *error_to_display, const char *secondary_text)
 {
 #ifdef HAVE_LIBNOTIFY
-        GsdXrandrManagerPrivate *priv = mgr->priv;
         NotifyNotification *notification;
 
         g_assert (error_to_display == NULL || secondary_text == NULL);
@@ -1607,26 +1605,27 @@ apply_default_boot_configuration (GsdXrandrManager *mgr, guint32 timestamp)
         GsdXrandrManagerPrivate *priv = mgr->priv;
         GnomeRRScreen *screen = priv->rw_screen;
         GnomeRRConfig *config;
-        gboolean turn_on_external, turn_on_laptop;
-
-        turn_on_external =
-                g_settings_get_boolean (mgr->priv->settings, CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP);
-        turn_on_laptop =
-                g_settings_get_boolean (mgr->priv->settings, CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP);
-
-        if (turn_on_external && turn_on_laptop)
-                config = make_clone_setup (screen);
-        else if (!turn_on_external && turn_on_laptop)
-                config = make_laptop_setup (screen);
-        else if (turn_on_external && !turn_on_laptop)
-                config = make_other_setup (screen);
-        else
-                config = make_laptop_setup (screen);
-
-        if (config) {
-                apply_configuration_and_display_error (mgr, config, timestamp);
-                gnome_rr_config_free (config);
-        }
+        GsdXrandrBootBehaviour boot;
+
+        boot = g_settings_get_enum (priv->settings, CONF_KEY_DEFAULT_MONITORS_SETUP);
+
+        switch (boot) {
+	case GSD_XRANDR_BOOT_BEHAVIOUR_DO_NOTHING:
+		return;
+	case GSD_XRANDR_BOOT_BEHAVIOUR_CLONE:
+		config = make_clone_setup (screen);
+		break;
+	case GSD_XRANDR_BOOT_BEHAVIOUR_DOCK:
+		config = make_other_setup (screen);
+		break;
+	default:
+		g_assert_not_reached ();
+	}
+
+	if (config) {
+		apply_configuration_and_display_error (mgr, config, timestamp);
+		gnome_rr_config_free (config);
+	}
 }
 
 static gboolean
@@ -1733,8 +1732,7 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
         show_timestamps_dialog (manager, "Startup");
         if (!apply_stored_configuration_at_startup (manager, GDK_CURRENT_TIME)) /* we don't have a real timestamp at startup anyway */
                 if (!apply_default_configuration_from_file (manager, GDK_CURRENT_TIME))
-                        if (!g_settings_get_boolean (manager->priv->settings, CONF_KEY_USE_XORG_MONITOR_SETTINGS))
-                                apply_default_boot_configuration (manager, GDK_CURRENT_TIME);
+			apply_default_boot_configuration (manager, GDK_CURRENT_TIME);
 
         log_msg ("State of screen after initial configuration:\n");
         log_screen (manager->priv->rw_screen);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]