diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c index a768b591d0..9777cfcf85 100644 --- a/gdk/gdkmonitor.c +++ b/gdk/gdkmonitor.c @@ -155,6 +155,7 @@ gdk_monitor_finalize (GObject *object) { GdkMonitor *monitor = GDK_MONITOR (object); + g_free (monitor->connector); g_free (monitor->manufacturer); g_free (monitor->model); @@ -354,6 +355,22 @@ gdk_monitor_get_height_mm (GdkMonitor *monitor) return monitor->height_mm; } +/*< private > + * gdk_monitor_get_connector: + * @monitor: a #GdkMonitor + * + * Gets the name of the monitor's connector, if available. + * + * Returns: (transfer none) (nullable): the name of the connector + */ +const char * +gdk_monitor_get_connector (GdkMonitor *monitor) +{ + g_return_val_if_fail (GDK_IS_MONITOR (monitor), NULL); + + return monitor->connector; +} + /** * gdk_monitor_get_manufacturer: * @monitor: a #GdkMonitor @@ -493,6 +510,16 @@ gdk_monitor_set_model (GdkMonitor *monitor, g_object_notify (G_OBJECT (monitor), "model"); } +void +gdk_monitor_set_connector (GdkMonitor *monitor, + const char *connector) +{ + g_free (monitor->connector); + monitor->connector = g_strdup (connector); + + /* g_object_notify (G_OBJECT (monitor), "connector"); */ +} + void gdk_monitor_set_position (GdkMonitor *monitor, int x, diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h index c76b59ce90..91219b2262 100644 --- a/gdk/gdkmonitorprivate.h +++ b/gdk/gdkmonitorprivate.h @@ -36,6 +36,7 @@ struct _GdkMonitor { GdkDisplay *display; char *manufacturer; char *model; + char *connector; GdkRectangle geometry; int width_mm; int height_mm; @@ -57,6 +58,9 @@ void gdk_monitor_set_manufacturer (GdkMonitor *monitor, const char *manufacturer); void gdk_monitor_set_model (GdkMonitor *monitor, const char *model); +void gdk_monitor_set_connector (GdkMonitor *monitor, + const char *connector); +const char * gdk_monitor_get_connector (GdkMonitor *monitor); void gdk_monitor_set_position (GdkMonitor *monitor, int x, int y); diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c index 4fa63f4b72..65c6ca0e52 100644 --- a/gdk/gdkscreen.c +++ b/gdk/gdkscreen.c @@ -21,8 +21,10 @@ #include "config.h" -#include "gdkinternals.h" #include "gdkscreenprivate.h" + +#include "gdkinternals.h" +#include "gdkmonitorprivate.h" #include "gdkrectangle.h" #include "gdkwindow.h" #include "gdkintl.h" @@ -821,7 +823,7 @@ gdk_screen_get_monitor_plug_name (GdkScreen *screen, g_return_val_if_fail (monitor != NULL, NULL); - return g_strdup (gdk_monitor_get_model (monitor)); + return g_strdup (gdk_monitor_get_connector (monitor)); } /** diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index 4668557cea..d57159b232 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -515,8 +515,11 @@ gdk_registry_handle_global (void *data, } else if (strcmp(interface, "zxdg_output_manager_v1") == 0) { + display_wayland->xdg_output_manager_version = MIN (version, 2); display_wayland->xdg_output_manager = - wl_registry_bind (registry, id, &zxdg_output_manager_v1_interface, 1); + wl_registry_bind (display_wayland->wl_registry, id, + &zxdg_output_manager_v1_interface, + display_wayland->xdg_output_manager_version); _gdk_wayland_screen_init_xdg_output (display_wayland->screen); _gdk_wayland_display_async_roundtrip (display_wayland); } diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index fb935a6dba..3b1ba200a3 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -121,6 +121,7 @@ struct _GdkWaylandDisplay int seat_version; int data_device_manager_version; int gtk_shell_version; + int xdg_output_manager_version; uint32_t server_decoration_mode; 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 diff --git a/gdk/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index f5faf8feac..7c503b36a8 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -524,6 +524,7 @@ init_randr15 (GdkScreen *screen, gboolean *changed) gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate); gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->window_scale); gdk_monitor_set_model (GDK_MONITOR (monitor), name); + gdk_monitor_set_connector (GDK_MONITOR (monitor), name); g_free (name); if (rr_monitors[i].primary)