[gtk/inspector-display: 3/6] inspector: Make general respect inspected display
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/inspector-display: 3/6] inspector: Make general respect inspected display
- Date: Sat, 7 Dec 2019 23:09:24 +0000 (UTC)
commit 4eeed47c7b38f37d20600ab76c66213e11924746
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Dec 7 12:30:15 2019 -0500
inspector: Make general respect inspected display
gtk/inspector/general.c | 78 ++++++++++++++++++++++++-------------------------
gtk/inspector/general.h | 2 ++
gtk/inspector/window.c | 3 ++
gtk/inspector/window.h | 1 +
gtk/inspector/window.ui | 2 +-
5 files changed, 45 insertions(+), 41 deletions(-)
---
diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c
index 977671b749..4f575de4a9 100644
--- a/gtk/inspector/general.c
+++ b/gtk/inspector/general.c
@@ -19,6 +19,7 @@
#include <glib/gi18n-lib.h>
#include "general.h"
+#include "window.h"
#include "gtkdebug.h"
#include "gtklabel.h"
@@ -89,6 +90,8 @@ struct _GtkInspectorGeneralPrivate
GtkWidget *display_composited;
GtkSizeGroup *labels;
GtkAdjustment *focus_adjustment;
+
+ GdkDisplay *display;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorGeneral, gtk_inspector_general, GTK_TYPE_WIDGET)
@@ -97,41 +100,38 @@ static void
init_version (GtkInspectorGeneral *gen)
{
const char *backend;
- GdkDisplay *display;
GdkSurface *surface;
GskRenderer *gsk_renderer;
const char *renderer;
- display = gdk_display_get_default ();
-
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (display))
+ if (GDK_IS_X11_DISPLAY (gen->priv->display))
backend = "X11";
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (display))
+ if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
backend = "Wayland";
else
#endif
#ifdef GDK_WINDOWING_BROADWAY
- if (GDK_IS_BROADWAY_DISPLAY (display))
+ if (GDK_IS_BROADWAY_DISPLAY (gen->priv->display))
backend = "Broadway";
else
#endif
#ifdef GDK_WINDOWING_WIN32
- if (GDK_IS_WIN32_DISPLAY (display))
+ if (GDK_IS_WIN32_DISPLAY (gen->priv->display))
backend = "Windows";
else
#endif
#ifdef GDK_WINDOWING_QUARTZ
- if (GDK_IS_QUARTZ_DISPLAY (display))
+ if (GDK_IS_QUARTZ_DISPLAY (gen->priv->display))
backend = "Quartz";
else
#endif
backend = "Unknown";
- surface = gdk_surface_new_toplevel (display, 10, 10);
+ surface = gdk_surface_new_toplevel (gen->priv->display, 10, 10);
gsk_renderer = gsk_renderer_new_for_surface (surface);
if (strcmp (G_OBJECT_TYPE_NAME (gsk_renderer), "GskVulkanRenderer") == 0)
renderer = "Vulkan";
@@ -289,10 +289,9 @@ static void
init_gl (GtkInspectorGeneral *gen)
{
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_X11_DISPLAY (gen->priv->display))
{
- GdkDisplay *display = gdk_display_get_default ();
- Display *dpy = GDK_DISPLAY_XDISPLAY (display);
+ Display *dpy = GDK_DISPLAY_XDISPLAY (gen->priv->display);
int error_base, event_base;
gchar *version;
if (!glXQueryExtension (dpy, &error_base, &event_base))
@@ -315,14 +314,13 @@ init_gl (GtkInspectorGeneral *gen)
else
#endif
#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
{
- GdkDisplay *display = gdk_display_get_default ();
EGLDisplay dpy;
EGLint major, minor;
gchar *version;
- dpy = wayland_get_display (gdk_wayland_display_get_wl_display (display));
+ dpy = wayland_get_display (gdk_wayland_display_get_wl_display (gen->priv->display));
if (!eglInitialize (dpy, &major, &minor))
return;
@@ -389,9 +387,8 @@ init_vulkan (GtkInspectorGeneral *gen)
#ifdef GDK_RENDERING_VULKAN
GdkSurface *surface;
GdkVulkanContext *context;
- GdkDisplay *display = gdk_display_get_default ();
- surface = gdk_surface_new_toplevel (display, 10, 10);
+ surface = gdk_surface_new_toplevel (gen->priv->display, 10, 10);
context = gdk_surface_create_vulkan_context (surface, NULL);
gdk_surface_destroy (surface);
@@ -426,11 +423,11 @@ init_vulkan (GtkInspectorGeneral *gen)
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), VK_KHR_SURFACE_EXTENSION_NAME, TRUE, 0);
#ifdef GDK_WINDOWING_X11
- if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_X11_DISPLAY (gen->priv->display))
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), "VK_KHR_xlib_surface", TRUE, 0);
#endif
#ifdef GDK_WINDOWING_WAYLAND
- if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ()))
+ if (GDK_IS_WAYLAND_DISPLAY (gen->priv->display))
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), "VK_KHR_wayland_surface", TRUE, 0);
#endif
add_check_row (gen, GTK_LIST_BOX (gen->priv->vulkan_box), VK_EXT_DEBUG_REPORT_EXTENSION_NAME,
@@ -615,15 +612,11 @@ populate_display_monitor_cb (GdkDisplay *display,
static void
init_display (GtkInspectorGeneral *gen)
{
- GdkDisplay *display;
-
- display = gdk_display_get_default ();
-
- g_signal_connect (display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
- g_signal_connect (display, "monitor-added", G_CALLBACK (populate_display_monitor_cb), gen);
- g_signal_connect (display, "monitor-removed", G_CALLBACK (populate_display_monitor_cb), gen);
+ g_signal_connect (gen->priv->display, "notify", G_CALLBACK (populate_display_notify_cb), gen);
+ g_signal_connect (gen->priv->display, "monitor-added", G_CALLBACK (populate_display_monitor_cb), gen);
+ g_signal_connect (gen->priv->display, "monitor-removed", G_CALLBACK (populate_display_monitor_cb), gen);
- populate_display (display, gen);
+ populate_display (gen->priv->display, gen);
}
static void
@@ -779,7 +772,6 @@ add_seat (GtkInspectorGeneral *gen,
static void
populate_seats (GtkInspectorGeneral *gen)
{
- GdkDisplay *display = gdk_display_get_default ();
GList *list, *l;
int i;
@@ -788,7 +780,7 @@ populate_seats (GtkInspectorGeneral *gen)
gtk_widget_destroy (GTK_WIDGET (l->data));
g_list_free (list);
- list = gdk_display_list_seats (display);
+ list = gdk_display_list_seats (gen->priv->display);
for (l = list, i = 0; l; l = l->next, i++)
add_seat (gen, GDK_SEAT (l->data), i);
@@ -799,10 +791,8 @@ populate_seats (GtkInspectorGeneral *gen)
static void
init_device (GtkInspectorGeneral *gen)
{
- GdkDisplay *display = gdk_display_get_default ();
-
- g_signal_connect_swapped (display, "seat-added", G_CALLBACK (populate_seats), gen);
- g_signal_connect_swapped (display, "seat-removed", G_CALLBACK (populate_seats), gen);
+ g_signal_connect_swapped (gen->priv->display, "seat-added", G_CALLBACK (populate_seats), gen);
+ g_signal_connect_swapped (gen->priv->display, "seat-removed", G_CALLBACK (populate_seats), gen);
populate_seats (gen);
}
@@ -812,13 +802,6 @@ gtk_inspector_general_init (GtkInspectorGeneral *gen)
{
gen->priv = gtk_inspector_general_get_instance_private (gen);
gtk_widget_init_template (GTK_WIDGET (gen));
- init_version (gen);
- init_env (gen);
- init_display (gen);
- init_pango (gen);
- init_gl (gen);
- init_vulkan (gen);
- init_device (gen);
}
static gboolean
@@ -967,4 +950,19 @@ gtk_inspector_general_class_init (GtkInspectorGeneralClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorGeneral, device_box);
}
+void
+gtk_inspector_general_set_display (GtkInspectorGeneral *gen,
+ GdkDisplay *display)
+{
+ gen->priv->display = display;
+
+ init_version (gen);
+ init_env (gen);
+ init_display (gen);
+ init_pango (gen);
+ init_gl (gen);
+ init_vulkan (gen);
+ init_device (gen);
+}
+
// vim: set et sw=2 ts=2:
diff --git a/gtk/inspector/general.h b/gtk/inspector/general.h
index 9e3ce85785..3cf2bbb4c2 100644
--- a/gtk/inspector/general.h
+++ b/gtk/inspector/general.h
@@ -45,6 +45,8 @@ typedef struct _GtkInspectorGeneralClass
G_BEGIN_DECLS
GType gtk_inspector_general_get_type (void);
+void gtk_inspector_general_set_display (GtkInspectorGeneral *general,
+ GdkDisplay *display);
G_END_DECLS
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 7686323aed..3b173f73c5 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -42,6 +42,7 @@
#include "magnifier.h"
#include "recorder.h"
#include "visual.h"
+#include "general.h"
#include "gdk-private.h"
#include "gskrendererprivate.h"
@@ -270,6 +271,7 @@ gtk_inspector_window_constructed (GObject *object)
gtk_inspector_object_tree_set_display (GTK_INSPECTOR_OBJECT_TREE (iw->object_tree), iw->inspected_display);
gtk_inspector_css_editor_set_display (GTK_INSPECTOR_CSS_EDITOR (iw->css_editor), iw->inspected_display);
gtk_inspector_visual_set_display (GTK_INSPECTOR_VISUAL (iw->visual), iw->inspected_display);
+ gtk_inspector_general_set_display (GTK_INSPECTOR_GENERAL (iw->general), iw->inspected_display);
}
static void
@@ -421,6 +423,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, sidebar_revealer);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, css_editor);
gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, visual);
+ gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, general);
gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index d5f611582c..90e455fb4d 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -73,6 +73,7 @@ typedef struct
GtkWidget *sidebar_revealer;
GtkWidget *css_editor;
GtkWidget *visual;
+ GtkWidget *general;
GtkWidget *selected_widget;
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 1b689371b1..32ef89dccc 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -464,7 +464,7 @@
<property name="name">general</property>
<property name="title" translatable="yes">Information</property>
<property name="child">
- <object class="GtkInspectorGeneral"/>
+ <object class="GtkInspectorGeneral" id="general"/>
</property>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]