diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index 3de29617c3..7cb4a8aab9 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -1128,6 +1128,7 @@ gdk_monitor_get_width_mm gdk_monitor_get_height_mm gdk_monitor_get_manufacturer gdk_monitor_get_model +gdk_monitor_get_connector gdk_monitor_get_scale_factor gdk_monitor_get_refresh_rate GdkSubpixelLayout diff --git a/gdk/gdkmonitor.c b/gdk/gdkmonitor.c index 18730d3df2..2d27c29972 100644 --- a/gdk/gdkmonitor.c +++ b/gdk/gdkmonitor.c @@ -49,6 +49,7 @@ enum { PROP_DISPLAY, PROP_MANUFACTURER, PROP_MODEL, + PROP_CONNECTOR, PROP_SCALE_FACTOR, PROP_GEOMETRY, PROP_WORKAREA, @@ -100,6 +101,10 @@ gdk_monitor_get_property (GObject *object, g_value_set_string (value, monitor->model); break; + case PROP_CONNECTOR: + g_value_set_string (value, monitor->connector); + break; + case PROP_SCALE_FACTOR: g_value_set_int (value, monitor->scale_factor); break; @@ -165,6 +170,7 @@ gdk_monitor_finalize (GObject *object) { GdkMonitor *monitor = GDK_MONITOR (object); + g_free (monitor->connector); g_free (monitor->manufacturer); g_free (monitor->model); @@ -198,6 +204,12 @@ gdk_monitor_class_init (GdkMonitorClass *class) "The model name", NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + props[PROP_CONNECTOR] = + g_param_spec_string ("connector", + "Connector", + "The connector name", + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); props[PROP_SCALE_FACTOR] = g_param_spec_int ("scale-factor", "Scale factor", @@ -369,6 +381,22 @@ gdk_monitor_get_height_mm (GdkMonitor *monitor) return monitor->height_mm; } +/** + * 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 @@ -504,6 +532,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/gdkmonitor.h b/gdk/gdkmonitor.h index 79fd434660..b711195e31 100644 --- a/gdk/gdkmonitor.h +++ b/gdk/gdkmonitor.h @@ -80,6 +80,8 @@ const char * gdk_monitor_get_manufacturer (GdkMonitor *monitor); GDK_AVAILABLE_IN_ALL const char * gdk_monitor_get_model (GdkMonitor *monitor); GDK_AVAILABLE_IN_ALL +const char * gdk_monitor_get_connector (GdkMonitor *monitor); +GDK_AVAILABLE_IN_ALL int gdk_monitor_get_scale_factor (GdkMonitor *monitor); GDK_AVAILABLE_IN_ALL int gdk_monitor_get_refresh_rate (GdkMonitor *monitor); diff --git a/gdk/gdkmonitorprivate.h b/gdk/gdkmonitorprivate.h index a2c7b5c86b..f7331376e7 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; @@ -58,6 +59,8 @@ 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); void gdk_monitor_set_position (GdkMonitor *monitor, int x, int y); diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c index eb46fa42af..c02f7c66eb 100644 --- a/gdk/wayland/gdkdisplay-wayland.c +++ b/gdk/wayland/gdkdisplay-wayland.c @@ -531,8 +531,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_display_init_xdg_output (display_wayland); _gdk_wayland_display_async_roundtrip (display_wayland); } @@ -2222,6 +2225,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; @@ -2272,10 +2276,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/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h index 6c5265f6a4..11768033d2 100644 --- a/gdk/wayland/gdkdisplay-wayland.h +++ b/gdk/wayland/gdkdisplay-wayland.h @@ -137,6 +137,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 189be0514a..7f73dd66a6 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/x11/gdkscreen-x11.c b/gdk/x11/gdkscreen-x11.c index 294e1c4338..cda654f04e 100644 --- a/gdk/x11/gdkscreen-x11.c +++ b/gdk/x11/gdkscreen-x11.c @@ -432,6 +432,7 @@ init_randr15 (GdkX11Screen *x11_screen, gboolean *changed) gdk_monitor_set_refresh_rate (GDK_MONITOR (monitor), refresh_rate); gdk_monitor_set_scale_factor (GDK_MONITOR (monitor), x11_screen->surface_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)