summaryrefslogtreecommitdiff
path: root/libmate-desktop/mate-rr-config.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmate-desktop/mate-rr-config.c')
-rw-r--r--libmate-desktop/mate-rr-config.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/libmate-desktop/mate-rr-config.c b/libmate-desktop/mate-rr-config.c
index 27ecd1a..c9cd85c 100644
--- a/libmate-desktop/mate-rr-config.c
+++ b/libmate-desktop/mate-rr-config.c
@@ -1068,6 +1068,69 @@ mate_rr_config_sanitize (MateRRConfig *config)
}
}
+static gboolean
+output_info_is_laptop (MateOutputInfo *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
+mate_rr_config_ensure_primary (MateRRConfig *configuration)
+{
+ int i;
+ MateOutputInfo *laptop;
+ MateOutputInfo *top_left;
+ gboolean found;
+
+ laptop = NULL;
+ top_left = NULL;
+ found = FALSE;
+
+ for (i = 0; configuration->outputs[i] != NULL; ++i) {
+ MateOutputInfo *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
mate_rr_config_save (MateRRConfig *configuration, GError **error)
@@ -1359,6 +1422,7 @@ mate_rr_config_apply_from_filename_with_time (MateRRScreen *screen, const char *
{
gboolean result;
+ mate_rr_config_ensure_primary (stored);
result = mate_rr_config_apply_with_time (stored, screen, timestamp, error);
mate_rr_config_free (stored);