[gtk/issue-1961: 3/3] Relay the xdg_output.name to GdkMonitor



commit 9222173d23eea2db0e5dd839f4a2f995cbfcf067
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Thu Jun 20 15:55:58 2019 +0100

    Relay the xdg_output.name to GdkMonitor
    
    The xdg_output interface has a `name` property that reflects the output
    name coming from the compositor.
    
    This is the closest thing we can get to a connector name.
    
    Fixes: #1961

 gdk/wayland/gdkmonitor-wayland.c |  2 ++
 gdk/wayland/gdkmonitor-wayland.h |  1 +
 gdk/wayland/gdkscreen-wayland.c  | 15 +++++++++++++++
 3 files changed, 18 insertions(+)
---
diff --git a/gdk/wayland/gdkmonitor-wayland.c b/gdk/wayland/gdkmonitor-wayland.c
index 59ab74e4fa..68591df55b 100644
--- a/gdk/wayland/gdkmonitor-wayland.c
+++ b/gdk/wayland/gdkmonitor-wayland.c
@@ -35,6 +35,8 @@ gdk_wayland_monitor_finalize (GObject *object)
 {
   GdkWaylandMonitor *monitor = (GdkWaylandMonitor *)object;
 
+  g_free (monitor->name);
+
   wl_output_destroy (monitor->output);
 
   G_OBJECT_CLASS (gdk_wayland_monitor_parent_class)->finalize (object);
diff --git a/gdk/wayland/gdkmonitor-wayland.h b/gdk/wayland/gdkmonitor-wayland.h
index 593ab1d85c..69592bd28a 100644
--- a/gdk/wayland/gdkmonitor-wayland.h
+++ b/gdk/wayland/gdkmonitor-wayland.h
@@ -37,6 +37,7 @@ struct _GdkWaylandMonitor {
   int32_t y;
   int32_t width;
   int32_t height;
+  char *name;
   gboolean wl_output_done;
   gboolean xdg_output_done;
 };
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index 5e156072f2..e45909ab7a 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -1458,6 +1458,7 @@ apply_monitor_change (GdkWaylandMonitor *monitor)
 
   gdk_monitor_set_position (GDK_MONITOR (monitor), monitor->x, monitor->y);
   gdk_monitor_set_size (GDK_MONITOR (monitor), monitor->width, monitor->height);
+  gdk_monitor_set_connector (GDK_MONITOR (monitor), monitor->name);
   monitor->wl_output_done = FALSE;
   monitor->xdg_output_done = FALSE;
 
@@ -1509,10 +1510,24 @@ xdg_output_handle_done (void                  *data,
     apply_monitor_change (monitor);
 }
 
+static void
+xdg_output_handle_name (void                  *data,
+                        struct zxdg_output_v1 *xdg_output,
+                        const char *          *name)
+{
+  GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
+
+  GDK_NOTE (MISC,
+            g_message ("handle name xdg-output %d", monitor->id));
+
+  monitor->name = g_strdup (name);
+}
+
 static const struct zxdg_output_v1_listener xdg_output_listener = {
     xdg_output_handle_logical_position,
     xdg_output_handle_logical_size,
     xdg_output_handle_done,
+    xdg_output_handle_name,
 };
 
 static void


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