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



commit 407ec0d3fe1e5d4c9d8a86b9fe7a2c952f9ee747
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/gdkdisplay-wayland.c |  2 +-
 gdk/wayland/gdkmonitor-wayland.c |  2 ++
 gdk/wayland/gdkmonitor-wayland.h |  1 +
 gdk/wayland/gdkscreen-wayland.c  | 27 +++++++++++++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)
---
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 4668557cea..91c9bfdd8e 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -516,7 +516,7 @@ gdk_registry_handle_global (void               *data,
   else if (strcmp(interface, "zxdg_output_manager_v1") == 0)
     {
       display_wayland->xdg_output_manager =
-            wl_registry_bind (registry, id, &zxdg_output_manager_v1_interface, 1);
+            wl_registry_bind (registry, id, &zxdg_output_manager_v1_interface, 2);
       _gdk_wayland_screen_init_xdg_output (display_wayland->screen);
       _gdk_wayland_display_async_roundtrip (display_wayland);
     }
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..1a7f8210e9 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,36 @@ 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 void
+xdg_output_handle_description (void                  *data,
+                               struct zxdg_output_v1 *xdg_output,
+                               const char            *description)
+{
+  GdkWaylandMonitor *monitor = (GdkWaylandMonitor *) data;
+
+  GDK_NOTE (MISC,
+            g_message ("handle description xdg-output %d", monitor->id));
+}
+
 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,
+    xdg_output_handle_description,
 };
 
 static void


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