Commit 67958ef6 authored by Joey Lee's avatar Joey Lee Committed by Federico Mena Quintero

RANDR - Add GConf options for a boot-time configuration

There are two boolean keys:
/apps/gnome_settings_daemon/xrandr/turn_on_external_monitors_at_startup
/apps/gnome_settings_daemon/xrandr/turn_on_laptop_monitor_at_startup

These can be tweaked by OEMs to select the default policy for
external monitors.
Signed-off-by: default avatarFederico Mena Quintero <federico@novell.com>
parent 56d3844b
......@@ -14,5 +14,31 @@
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/xrandr/turn_on_external_monitors_at_startup</key>
<applyto>/apps/gnome_settings_daemon/xrandr/turn_on_external_monitors_at_startup</applyto>
<owner>gnome</owner>
<type>bool</type>
<default>false</default>
<locale name="C">
<short>Turn on external monitor after system boot</short>
<long>Turn on external monitor after system boot if user plugin
external monitor when system boot.
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gnome_settings_daemon/xrandr/turn_on_laptop_monitor_at_startup</key>
<applyto>/apps/gnome_settings_daemon/xrandr/turn_on_laptop_monitor_at_startup</applyto>
<owner>gnome</owner>
<type>bool</type>
<default>true</default>
<locale name="C">
<short>Turn on laptop monitor after system boot</short>
<long>Turn on laptop monitor after system boot if user plugin
external monitor when system boot.
</long>
</locale>
</schema>
</schemalist>
</gconfschemafile>
......@@ -60,6 +60,8 @@
#define CONF_DIR "/apps/gnome_settings_daemon/xrandr"
#define CONF_KEY_SHOW_NOTIFICATION_ICON (CONF_DIR "/show_notification_icon")
#define CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP (CONF_DIR "/turn_on_external_monitors_at_startup")
#define CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP (CONF_DIR "/turn_on_laptop_monitor_at_startup")
#define VIDEO_KEYSYM "XF86Display"
#define ROTATE_KEYSYM "XF86RotateWindows"
......@@ -1961,13 +1963,15 @@ on_config_changed (GConfClient *client,
start_or_stop_icon (manager);
}
static void
static gboolean
apply_intended_configuration (GsdXrandrManager *manager, const char *intended_filename, guint32 timestamp)
{
GError *my_error;
gboolean result;
my_error = NULL;
if (!apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, &my_error)) {
result = apply_configuration_from_filename (manager, intended_filename, FALSE, timestamp, &my_error);
if (!result) {
if (my_error) {
if (!g_error_matches (my_error, G_FILE_ERROR, G_FILE_ERROR_NOENT))
error_message (manager, _("Could not apply the stored configuration for monitors"), my_error, NULL);
......@@ -1975,9 +1979,39 @@ apply_intended_configuration (GsdXrandrManager *manager, const char *intended_fi
g_error_free (my_error);
}
}
return result;
}
static void
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 =
gconf_client_get_bool (mgr->priv->client, CONF_KEY_TURN_ON_EXTERNAL_MONITORS_AT_STARTUP, NULL);
turn_on_laptop =
gconf_client_get_bool (mgr->priv->client, CONF_KEY_TURN_ON_LAPTOP_MONITOR_AT_STARTUP, NULL);
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);
}
}
static gboolean
apply_stored_configuration_at_startup (GsdXrandrManager *manager, guint32 timestamp)
{
GError *my_error;
......@@ -2021,7 +2055,7 @@ apply_stored_configuration_at_startup (GsdXrandrManager *manager, guint32 timest
* good. Apply the intended configuration instead.
*/
apply_intended_configuration (manager, intended_filename, timestamp);
success = apply_intended_configuration (manager, intended_filename, timestamp);
out:
......@@ -2030,6 +2064,8 @@ out:
g_free (backup_filename);
g_free (intended_filename);
return success;
}
gboolean
......@@ -2085,7 +2121,8 @@ gsd_xrandr_manager_start (GsdXrandrManager *manager,
}
show_timestamps_dialog (manager, "Startup");
apply_stored_configuration_at_startup (manager, GDK_CURRENT_TIME); /* we don't have a real timestamp at startup anyway */
if (!apply_stored_configuration_at_startup (manager, GDK_CURRENT_TIME)) /* we don't have a real timestamp at startup anyway */
apply_default_boot_configuration (manager, GDK_CURRENT_TIME);
gdk_window_add_filter (gdk_get_default_root_window(),
(GdkFilterFunc)event_filter,
......
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