[mutter] device-pool: Only fetch major/minor for taken devices



commit 3d882b6410c760baa625e6e516e2b4bdc96fec5b
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Tue Apr 6 17:06:38 2021 +0200

    device-pool: Only fetch major/minor for taken devices
    
    It's only when we take/release from/to logind we need these two
    integers, so only retrieve them when that's done. Making this change
    makes it possible to open devices that don't have these parameters.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>

 src/backends/native/meta-device-pool.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/native/meta-device-pool.c b/src/backends/native/meta-device-pool.c
index baca12c5fe..69e3e8d2f0 100644
--- a/src/backends/native/meta-device-pool.c
+++ b/src/backends/native/meta-device-pool.c
@@ -211,7 +211,7 @@ meta_device_pool_open (MetaDevicePool       *pool,
 {
   g_autoptr (GMutexLocker) locker = NULL;
   MetaDeviceFile *file;
-  int major, minor;
+  int major = -1, minor = -1;
   int fd;
 
   locker = g_mutex_locker_new (&pool->mutex);
@@ -224,15 +224,6 @@ meta_device_pool_open (MetaDevicePool       *pool,
       return file;
     }
 
-  if (!get_device_info_from_path (path, &major, &minor))
-    {
-      g_set_error (error,
-                   G_IO_ERROR,
-                   G_IO_ERROR_NOT_FOUND,
-                   "Could not get device info for path %s: %m", path);
-      return NULL;
-    }
-
   if (flags & META_DEVICE_FILE_FLAG_TAKE_CONTROL)
     {
       if (!pool->session_proxy)
@@ -242,6 +233,15 @@ meta_device_pool_open (MetaDevicePool       *pool,
           return NULL;
         }
 
+      if (!get_device_info_from_path (path, &major, &minor))
+        {
+          g_set_error (error,
+                       G_IO_ERROR,
+                       G_IO_ERROR_NOT_FOUND,
+                       "Could not get device info for path %s: %m", path);
+          return NULL;
+        }
+
       if (!take_device (pool->session_proxy, major, minor, &fd, NULL, error))
         return NULL;
     }


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