[gnome-desktop] rr: add api for ensuring a primary display is set in config
- From: William Jon McCann <mccann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-desktop] rr: add api for ensuring a primary display is set in config
- Date: Tue, 23 Nov 2010 02:50:25 +0000 (UTC)
commit f632805c549053a548877785e3e624b1fe687f23
Author: William Jon McCann <jmccann redhat com>
Date: Mon Nov 22 21:39:30 2010 -0500
rr: add api for ensuring a primary display is set in config
https://bugzilla.gnome.org/show_bug.cgi?id=635455
libgnome-desktop/gnome-rr-config.c | 64 ++++++++++++++++++++++++++++++++++++
libgnome-desktop/gnome-rr-config.h | 1 +
2 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index daf626d..f5fe251 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -1059,6 +1059,69 @@ gnome_rr_config_sanitize (GnomeRRConfig *config)
}
}
+static gboolean
+output_info_is_laptop (GnomeOutputInfo *info)
+{
+ if (info->name
+ && (strstr (info->name, "lvds") || /* Most drivers use an "LVDS" prefix... */
+ strstr (info->name, "LVDS") ||
+ strstr (info->name, "Lvds") ||
+ strstr (info->name, "LCD"))) /* ... but fglrx uses "LCD" in some versions. Shoot me now, kthxbye. */
+ return TRUE;
+
+ return FALSE;
+}
+
+gboolean
+gnome_rr_config_ensure_primary (GnomeRRConfig *configuration)
+{
+ int i;
+ GnomeOutputInfo *laptop;
+ GnomeOutputInfo *top_left;
+ gboolean found;
+
+ laptop = NULL;
+ top_left = NULL;
+ found = FALSE;
+
+ for (i = 0; configuration->outputs[i] != NULL; ++i) {
+ GnomeOutputInfo *info = configuration->outputs[i];
+
+ if (! info->on)
+ continue;
+
+ /* ensure only one */
+ if (info->primary) {
+ if (found) {
+ info->primary = FALSE;
+ } else {
+ found = TRUE;
+ }
+ }
+
+ if (top_left == NULL
+ || (info->x < top_left->x
+ && info->y < top_left->y)) {
+ top_left = info;
+ }
+ if (laptop == NULL
+ && output_info_is_laptop (info)) {
+ /* shame we can't find the connector type
+ as with gnome_rr_output_is_laptop */
+ laptop = info;
+ }
+ }
+
+ if (! found) {
+ if (laptop != NULL) {
+ laptop->primary = TRUE;
+ } else {
+ top_left->primary = TRUE;
+ }
+ }
+
+ return !found;
+}
gboolean
gnome_rr_config_save (GnomeRRConfig *configuration, GError **error)
@@ -1349,6 +1412,7 @@ gnome_rr_config_apply_from_filename_with_time (GnomeRRScreen *screen, const char
{
gboolean result;
+ gnome_rr_config_ensure_primary (stored);
result = gnome_rr_config_apply_with_time (stored, screen, timestamp, error);
gnome_rr_config_free (stored);
diff --git a/libgnome-desktop/gnome-rr-config.h b/libgnome-desktop/gnome-rr-config.h
index 6c3aa22..f230337 100644
--- a/libgnome-desktop/gnome-rr-config.h
+++ b/libgnome-desktop/gnome-rr-config.h
@@ -88,6 +88,7 @@ gboolean gnome_rr_config_equal (GnomeRRConfig *config1,
gboolean gnome_rr_config_save (GnomeRRConfig *configuration,
GError **error);
void gnome_rr_config_sanitize (GnomeRRConfig *configuration);
+gboolean gnome_rr_config_ensure_primary (GnomeRRConfig *configuration);
#ifndef GNOME_DISABLE_DEPRECATED
gboolean gnome_rr_config_apply (GnomeRRConfig *configuration,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]