Merge branch 'issue-1961' into 'gtk-3-24'

Report the monitor's connector name under Wayland

See merge request GNOME/gtk!951
This commit is contained in:
Matthias Clasen 2019-06-21 00:40:16 +00:00
commit 3090fe77d9
9 changed files with 71 additions and 3 deletions

View File

@ -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,

View File

@ -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);

View File

@ -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));
}
/**

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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;
};

View File

@ -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

View File

@ -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)