diff options
author | infirit <[email protected]> | 2014-11-07 23:30:28 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-11-28 08:44:02 +0100 |
commit | b48e20dde74897461bd0914bfb8cef9a9eaa296e (patch) | |
tree | 640b10d779ed31ae521a64b13ae6e12732dac756 /libmate-desktop/mate-rr-config.c | |
parent | f2219d2afd13fd8dcfe6a35353828f4f143e8b48 (diff) | |
download | mate-desktop-b48e20dde74897461bd0914bfb8cef9a9eaa296e.tar.bz2 mate-desktop-b48e20dde74897461bd0914bfb8cef9a9eaa296e.tar.xz |
rr: add api for ensuring a primary display is set in config
Based on gnome-desktop commit: f632805c549053a548877785e3e624b1fe687f23
From: William Jon McCann <[email protected]>
Diffstat (limited to 'libmate-desktop/mate-rr-config.c')
-rw-r--r-- | libmate-desktop/mate-rr-config.c | 64 |
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); |