Merge branch 'inspector-layouts' into 'master'

Various small inspector improvements

See merge request GNOME/gtk!3500
This commit is contained in:
Matthias Clasen
2021-05-03 01:40:46 +00:00
6 changed files with 123 additions and 29 deletions

View File

@@ -86,6 +86,14 @@
*/
#define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2))
/**
* GDK_VERSION_4_4:
*
* A macro that evaluates to the 4.4 version of GDK, in a format
* that can be used by the C pre-processor.
*/
#define GDK_VERSION_4_4 (G_ENCODE_VERSION (4, 4))
/* evaluates to the current stable version; for development cycles,
* this means the next stable target, with a hard backstop to the
@@ -198,4 +206,19 @@
# define GDK_DEPRECATED_IN_4_2_FOR(f) _GDK_EXTERN
#endif
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_4_4
# define GDK_AVAILABLE_IN_4_4 GDK_UNAVAILABLE(4, 4)
#else
# define GDK_AVAILABLE_IN_4_4 _GDK_EXTERN
#endif
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_4_4
# define GDK_DEPRECATED_IN_4_4 GDK_DEPRECATED
# define GDK_DEPRECATED_IN_4_4_FOR(f) GDK_DEPRECATED_FOR(f)
#else
# define GDK_DEPRECATED_IN_4_4 _GDK_EXTERN
# define GDK_DEPRECATED_IN_4_4_FOR(f) _GDK_EXTERN
#endif
#endif /* __GDK_VERSION_MACROS_H__ */

View File

@@ -1037,6 +1037,23 @@ gdk_wayland_device_get_wl_keyboard (GdkDevice *device)
return seat->wl_keyboard;
}
/**
* gdk_wayland_device_get_xkb_keymap:
* @device: (type GdkWaylandDevice): a `GdkDevice`
*
* Returns the `xkb_keymap` of a `GdkDevice`.
*
* Returns: (transfer none): a `struct xkb_keymap`
*
* Since: 4.4
*/
struct xkb_keymap *
gdk_wayland_device_get_xkb_keymap (GdkDevice *device)
{
GdkWaylandSeat *seat = GDK_WAYLAND_SEAT (gdk_device_get_seat (device));
return _gdk_wayland_keymap_get_xkb_keymap (seat->keymap);
}
GdkKeymap *
_gdk_wayland_device_get_keymap (GdkDevice *device)
{

View File

@@ -52,6 +52,8 @@ GDK_AVAILABLE_IN_ALL
struct wl_pointer *gdk_wayland_device_get_wl_pointer (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
struct wl_keyboard *gdk_wayland_device_get_wl_keyboard (GdkDevice *device);
GDK_AVAILABLE_IN_4_4
struct xkb_keymap *gdk_wayland_device_get_xkb_keymap (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
const char *gdk_wayland_device_get_node_path (GdkDevice *device);

View File

@@ -51,6 +51,7 @@
#ifdef GDK_WINDOWING_WAYLAND
#include "wayland/gdkwayland.h"
#include <epoxy/egl.h>
#include <xkbcommon/xkbcommon.h>
#endif
#ifdef GDK_WINDOWING_BROADWAY
@@ -568,26 +569,23 @@ populate_display (GdkDisplay *display, GtkInspectorGeneral *gen)
gdk_display_is_composited (display));
}
static GtkWidget *
populate_monitor (gpointer item,
gpointer gen)
static void
add_monitor (GtkInspectorGeneral *gen,
GdkMonitor *monitor,
guint i)
{
GtkListBox *list;
GdkMonitor *monitor = item;
char *name;
char *value;
GdkRectangle rect;
int scale;
char *name;
char *scale_str = NULL;
const char *manufacturer;
const char *model;
list = GTK_LIST_BOX (gtk_list_box_new ());
gtk_widget_add_css_class (GTK_WIDGET (list), "rich-list");
gtk_list_box_set_selection_mode (list, GTK_SELECTION_NONE);
list = GTK_LIST_BOX (gen->monitor_box);
/* XXX: add monitor # here when porting to listview */
name = g_strdup_printf ("Monitor %d", 1);
name = g_strdup_printf ("Monitor %u", i);
manufacturer = gdk_monitor_get_manufacturer (monitor);
model = gdk_monitor_get_model (monitor);
value = g_strdup_printf ("%s%s%s",
@@ -595,13 +593,15 @@ populate_monitor (gpointer item,
manufacturer || model ? " " : "",
model ? model : "");
add_label_row (gen, list, name, value, 0);
g_free (name);
g_free (value);
g_free (name);
add_label_row (gen, list, "Connector", gdk_monitor_get_connector (monitor), 10);
gdk_monitor_get_geometry (monitor, &rect);
scale = gdk_monitor_get_scale_factor (monitor);
if (scale != 1)
scale_str = g_strdup_printf (" @ %d", scale);
scale_str = g_strdup_printf ("@%d", scale);
value = g_strdup_printf ("%d×%d%s at %d, %d",
rect.width, rect.height,
@@ -611,25 +611,46 @@ populate_monitor (gpointer item,
g_free (value);
g_free (scale_str);
value = g_strdup_printf ("%d×%d mm²",
value = g_strdup_printf ("%d×%dmm²",
gdk_monitor_get_width_mm (monitor),
gdk_monitor_get_height_mm (monitor));
add_label_row (gen, list, "Size", value, 10);
g_free (value);
if (gdk_monitor_get_refresh_rate (monitor) != 0)
value = g_strdup_printf ("%.2f Hz",
0.001 * gdk_monitor_get_refresh_rate (monitor));
else
value = g_strdup ("unknown");
add_label_row (gen, list, "Refresh rate", value, 10);
g_free (value);
{
value = g_strdup_printf ("%.2fHz",
0.001 * gdk_monitor_get_refresh_rate (monitor));
add_label_row (gen, list, "Refresh rate", value, 10);
g_free (value);
}
value = g_strdup (translate_subpixel_layout (gdk_monitor_get_subpixel_layout (monitor)));
add_label_row (gen, list, "Subpixel layout", value, 10);
g_free (value);
if (gdk_monitor_get_subpixel_layout (monitor) != GDK_SUBPIXEL_LAYOUT_UNKNOWN)
{
add_label_row (gen, list, "Subpixel layout",
translate_subpixel_layout (gdk_monitor_get_subpixel_layout (monitor)),
10);
}
}
return GTK_WIDGET (list);
static void
populate_monitors (GdkDisplay *display,
GtkInspectorGeneral *gen)
{
GtkWidget *child;
GListModel *list;
while ((child = gtk_widget_get_first_child (gen->monitor_box)))
gtk_list_box_remove (GTK_LIST_BOX (gen->monitor_box), child);
list = gdk_display_get_monitors (gen->display);
for (guint i = 0; i < g_list_model_get_n_items (list); i++)
{
GdkMonitor *monitor = g_list_model_get_item (list, i);
add_monitor (gen, monitor, i);
g_object_unref (monitor);
}
}
static void
@@ -640,16 +661,25 @@ populate_display_notify_cb (GdkDisplay *display,
populate_display (display, gen);
}
static void
monitors_changed_cb (GListModel *monitors,
guint position,
guint removed,
guint added,
GtkInspectorGeneral *gen)
{
populate_monitors (gen->display, gen);
}
static void
init_display (GtkInspectorGeneral *gen)
{
g_signal_connect (gen->display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
gtk_list_box_bind_model (GTK_LIST_BOX (gen->monitor_box),
gdk_display_get_monitors (gen->display),
populate_monitor,
gen, NULL);
g_signal_connect (gdk_display_get_monitors (gen->display), "items-changed",
G_CALLBACK (monitors_changed_cb), gen);
populate_display (gen->display, gen);
populate_monitors (gen->display, gen);
}
static void
@@ -754,6 +784,26 @@ add_device (GtkInspectorGeneral *gen,
g_free (text);
}
#ifdef GDK_WINDOWING_WAYLAND
if (GDK_IS_WAYLAND_DEVICE (device) &&
gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
{
struct xkb_keymap *keymap = gdk_wayland_device_get_xkb_keymap (device);
GString *s;
s = g_string_new ("");
for (int i = 0; i < xkb_keymap_num_layouts (keymap); i++)
{
if (s->len > 0)
g_string_append (s, ", ");
g_string_append (s, xkb_keymap_layout_get_name (keymap, i));
}
add_label_row (gen, GTK_LIST_BOX (gen->device_box), "Layouts", s->str, 20);
g_string_free (s, TRUE);
}
#endif
g_type_class_unref (class);
}
@@ -953,6 +1003,8 @@ gtk_inspector_general_dispose (GObject *object)
g_signal_handlers_disconnect_by_func (gen->display, G_CALLBACK (seat_added), gen);
g_signal_handlers_disconnect_by_func (gen->display, G_CALLBACK (seat_removed), gen);
g_signal_handlers_disconnect_by_func (gen->display, G_CALLBACK (populate_display_notify_cb), gen);
g_signal_handlers_disconnect_by_func (gdk_display_get_monitors (gen->display), G_CALLBACK (monitors_changed_cb), gen);
list = gdk_display_list_seats (gen->display);
for (l = list; l; l = l->next)

View File

@@ -1,5 +1,5 @@
project('gtk', 'c',
version: '4.2.0',
version: '4.3.0',
default_options: [
'buildtype=debugoptimized',
'warning_level=1',

View File

@@ -1 +1 @@
invalid5.ui:3:1 Required GTK version 5.10, current version is 4.2
invalid5.ui:3:1 Required GTK version 5.10, current version is 4.3