[mutter] device-file: Add tags



commit 5502f956f5ff41232636a970028cbe7e3a7aaee7
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Sun Apr 11 02:18:57 2021 +0200

    device-file: Add tags
    
    Tags are meant to make it possible for a device file opener to tag a
    file if it has affected the state the file descriptor is in; e.g. if it
    has enabled a DRM capability.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1828>

 src/backends/native/meta-device-pool.c | 17 +++++++++++++++++
 src/backends/native/meta-device-pool.h | 13 +++++++++++++
 2 files changed, 30 insertions(+)
---
diff --git a/src/backends/native/meta-device-pool.c b/src/backends/native/meta-device-pool.c
index ba1cdbaaad..f15ad90a36 100644
--- a/src/backends/native/meta-device-pool.c
+++ b/src/backends/native/meta-device-pool.c
@@ -43,6 +43,7 @@ struct _MetaDeviceFile
   int minor;
   int fd;
   MetaDeviceFileFlags flags;
+  uint32_t tags[META_DEVICE_FILE_N_TAGS];
 };
 
 struct _MetaDevicePool
@@ -107,6 +108,22 @@ meta_device_file_get_path (MetaDeviceFile *device_file)
   return device_file->path;
 }
 
+void
+meta_device_file_tag (MetaDeviceFile     *device_file,
+                      MetaDeviceFileTags  tag,
+                      uint32_t            value)
+{
+  device_file->tags[tag] |= value;
+}
+
+uint32_t
+meta_device_file_has_tag (MetaDeviceFile     *device_file,
+                          MetaDeviceFileTags  tag,
+                          uint32_t            value)
+{
+  return (device_file->tags[tag] & value) == value;
+}
+
 static MetaDeviceFile *
 meta_device_file_acquire_locked (MetaDeviceFile *file)
 {
diff --git a/src/backends/native/meta-device-pool.h b/src/backends/native/meta-device-pool.h
index f37fc7302c..083bc7b53e 100644
--- a/src/backends/native/meta-device-pool.h
+++ b/src/backends/native/meta-device-pool.h
@@ -30,6 +30,11 @@ typedef enum _MetaDeviceFileFlags
   META_DEVICE_FILE_FLAG_READ_ONLY = 1 << 1,
 } MetaDeviceFileFlags;
 
+typedef enum _MetaDeviceFileTags
+{
+  META_DEVICE_FILE_N_TAGS,
+} MetaDeviceFileTags;
+
 typedef struct _MetaDeviceFile MetaDeviceFile;
 typedef struct _MetaDevicePool MetaDevicePool;
 
@@ -37,6 +42,14 @@ int meta_device_file_get_fd (MetaDeviceFile *device_file);
 
 const char * meta_device_file_get_path (MetaDeviceFile *device_file);
 
+void meta_device_file_tag (MetaDeviceFile     *device_file,
+                           MetaDeviceFileTags  tag,
+                           uint32_t            value);
+
+uint32_t meta_device_file_has_tag (MetaDeviceFile     *device_file,
+                                   MetaDeviceFileTags  tag,
+                                   uint32_t            value);
+
 MetaDeviceFile * meta_device_file_acquire (MetaDeviceFile *file);
 
 void meta_device_file_release (MetaDeviceFile *device_file);


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