[gnome-desktop] gnome-rr: Unify laptop identification by name



commit d9f5e5f58e86798c48995e1abc36e7c43174d132
Author: Bastien Nocera <hadess hadess net>
Date:   Tue May 29 14:26:30 2012 +0100

    gnome-rr: Unify laptop identification by name

 libgnome-desktop/gnome-rr-config.c  |   15 +--------------
 libgnome-desktop/gnome-rr-private.h |    2 ++
 libgnome-desktop/gnome-rr.c         |   30 ++++++++++++++++++++----------
 3 files changed, 23 insertions(+), 24 deletions(-)
---
diff --git a/libgnome-desktop/gnome-rr-config.c b/libgnome-desktop/gnome-rr-config.c
index 1f83141..708e6d0 100644
--- a/libgnome-desktop/gnome-rr-config.c
+++ b/libgnome-desktop/gnome-rr-config.c
@@ -1166,19 +1166,6 @@ gnome_rr_config_sanitize (GnomeRRConfig *config)
     }
 }
 
-static gboolean
-output_info_is_laptop (GnomeRROutputInfo *info)
-{
-        if (info->priv->name
-            && (strstr (info->priv->name, "lvds") ||  /* Most drivers use an "LVDS" prefix... */
-                strstr (info->priv->name, "LVDS") ||
-                strstr (info->priv->name, "Lvds") ||
-                strstr (info->priv->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)
 {
@@ -1218,7 +1205,7 @@ gnome_rr_config_ensure_primary (GnomeRRConfig *configuration)
                         top_left = info;
                 }
                 if (laptop == NULL
-                    && output_info_is_laptop (info)) {
+                    && _gnome_rr_output_name_is_laptop (info->priv->name)) {
                         /* shame we can't find the connector type
                            as with gnome_rr_output_is_laptop */
                         laptop = info;
diff --git a/libgnome-desktop/gnome-rr-private.h b/libgnome-desktop/gnome-rr-private.h
index f996ad9..136f1de 100644
--- a/libgnome-desktop/gnome-rr-private.h
+++ b/libgnome-desktop/gnome-rr-private.h
@@ -74,4 +74,6 @@ struct GnomeRRConfigPrivate
   GnomeRROutputInfo **outputs;
 };
 
+gboolean _gnome_rr_output_name_is_laptop (const char *name);
+
 #endif
diff --git a/libgnome-desktop/gnome-rr.c b/libgnome-desktop/gnome-rr.c
index 24daa89..daffedf 100644
--- a/libgnome-desktop/gnome-rr.c
+++ b/libgnome-desktop/gnome-rr.c
@@ -1882,6 +1882,24 @@ gnome_rr_output_get_connector_type (GnomeRROutput *output)
 }
 
 gboolean
+_gnome_rr_output_name_is_laptop (const char *name)
+{
+    if (!name)
+        return FALSE;
+
+    if (strstr (name, "lvds") ||  /* Most drivers use an "LVDS" prefix... */
+	strstr (name, "LVDS") ||
+	strstr (name, "Lvds") ||
+	strstr (name, "LCD")  ||  /* ... but fglrx uses "LCD" in some versions.  Shoot me now, kthxbye. */
+	strstr (name, "eDP")  ||  /* eDP is for internal laptop panel connections */
+	strstr (name, "DFP")  ||  /* DFP is also an internal laptop display */
+	strstr (name, "default")) /* Finally, NVidia and all others that don't bother to do RANDR properly */
+        return TRUE;
+
+    return FALSE;
+}
+
+gboolean
 gnome_rr_output_is_laptop (GnomeRROutput *output)
 {
     g_return_val_if_fail (output != NULL, FALSE);
@@ -1896,16 +1914,8 @@ gnome_rr_output_is_laptop (GnomeRROutput *output)
     /* Older versions of RANDR - this is a best guess, as @#$% RANDR doesn't have standard output names,
      * so drivers can use whatever they like.
      */
-
-    if (output->name
-	&& (strstr (output->name, "lvds") ||  /* Most drivers use an "LVDS" prefix... */
-	    strstr (output->name, "LVDS") ||
-	    strstr (output->name, "Lvds") ||
-	    strstr (output->name, "LCD")  ||  /* ... but fglrx uses "LCD" in some versions.  Shoot me now, kthxbye. */
-	    strstr (output->name, "eDP")  ||  /* eDP is for internal laptop panel connections */
-	    strstr (output->name, "DFP")  ||  /* DFP is also an internal laptop display */
-	    strstr (output->name, "default"))) /* Finally, NVidia and all others that don't bother to do RANDR properly */
-	return TRUE;
+    if (_gnome_rr_output_name_is_laptop (output->name))
+        return TRUE;
 
     return FALSE;
 }



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