From a723baec4b57532e1bcdb0f30930873f281cd644 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 May 2021 20:55:43 -0400 Subject: [PATCH 1/3] inspector: Show text direction This is not a property, so show it on the misc tab. --- gtk/inspector/misc-info.c | 36 ++++++++++++++++++++++++++++++++++-- gtk/inspector/misc-info.ui | 31 +++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c index 8d969d996f..df61d1ea00 100644 --- a/gtk/inspector/misc-info.c +++ b/gtk/inspector/misc-info.c @@ -47,6 +47,8 @@ struct _GtkInspectorMiscInfo GtkWidget *refcount; GtkWidget *state_row; GtkWidget *state; + GtkWidget *direction_row; + GtkWidget *direction; GtkWidget *buildable_id_row; GtkWidget *buildable_id; GtkWidget *mnemonic_label_row; @@ -296,6 +298,30 @@ update_frame_clock (GtkInspectorMiscInfo *sl) } } +static void +update_direction (GtkInspectorMiscInfo *sl) +{ + GtkWidget *widget = GTK_WIDGET (sl->object); + + switch (widget->priv->direction) + { + case GTK_TEXT_DIR_LTR: + gtk_label_set_label (GTK_LABEL (sl->direction), "Left-to-Right"); + break; + case GTK_TEXT_DIR_RTL: + gtk_label_set_label (GTK_LABEL (sl->direction), "Right-to-Left"); + break; + case GTK_TEXT_DIR_NONE: + if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR) + gtk_label_set_label (GTK_LABEL (sl->direction), "Left-to-Right (inherited)"); + else + gtk_label_set_label (GTK_LABEL (sl->direction), "Right-to-Left (inherited)"); + break; + default: + g_assert_not_reached (); + } +} + static gboolean update_info (gpointer data) { @@ -325,8 +351,10 @@ update_info (gpointer data) GtkWidget *child; GList *list, *l; - while ((child = gtk_widget_get_first_child (sl->mnemonic_label))) - gtk_box_remove (GTK_BOX (sl->mnemonic_label), child); + update_direction (sl); + + while ((child = gtk_widget_get_first_child (sl->mnemonic_label))) + gtk_box_remove (GTK_BOX (sl->mnemonic_label), child); list = gtk_widget_list_mnemonic_labels (GTK_WIDGET (sl->object)); for (l = list; l; l = l->next) @@ -418,6 +446,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl, { gtk_widget_show (sl->refcount_row); gtk_widget_show (sl->state_row); + gtk_widget_show (sl->direction_row); gtk_widget_show (sl->request_mode_row); gtk_widget_show (sl->allocated_size_row); gtk_widget_show (sl->baseline_row); @@ -437,6 +466,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl, else { gtk_widget_hide (sl->state_row); + gtk_widget_hide (sl->direction_row); gtk_widget_hide (sl->request_mode_row); gtk_widget_hide (sl->mnemonic_label_row); gtk_widget_hide (sl->allocated_size_row); @@ -534,6 +564,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass) gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, refcount); gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, state_row); gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, state); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, direction_row); + gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, direction); gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, buildable_id_row); gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, buildable_id); gtk_widget_class_bind_template_child (widget_class, GtkInspectorMiscInfo, mnemonic_label_row); diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui index ca7fbc9639..8313e5a6e3 100644 --- a/gtk/inspector/misc-info.ui +++ b/gtk/inspector/misc-info.ui @@ -136,6 +136,36 @@ + + + 0 + + + 10 + 10 + 10 + 10 + 40 + + + Direction + start + baseline + 0.0 + 1 + + + + + 1 + end + baseline + + + + + + 0 @@ -621,6 +651,7 @@ + From e2aa161590cd8a5dd326b5510a1669fc879b7fa5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 May 2021 21:24:50 -0400 Subject: [PATCH 2/3] inspector: Show EGL info for X11 as well --- gtk/inspector/general.c | 99 ++++++++++++++++++++++++++++++----------- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/gtk/inspector/general.c b/gtk/inspector/general.c index a668be18ce..e8c1b08eda 100644 --- a/gtk/inspector/general.c +++ b/gtk/inspector/general.c @@ -247,7 +247,7 @@ append_glx_extension_row (GtkInspectorGeneral *gen, } #endif -#ifdef GDK_WINDOWING_WAYLAND +#if defined(GDK_WINDOWING_WAYLAND) || defined (GDK_WINDOWING_X11) static void append_egl_extension_row (GtkInspectorGeneral *gen, EGLDisplay dpy, @@ -257,19 +257,37 @@ append_egl_extension_row (GtkInspectorGeneral *gen, } static EGLDisplay -wayland_get_display (struct wl_display *wl_display) +get_egl_display (GdkDisplay *display) { + void *native; + GLenum platform; EGLDisplay dpy = NULL; +#ifdef GDK_WINDOWING_WAYLAND + if (GDK_IS_WAYLAND_DISPLAY (display)) + { + native = gdk_wayland_display_get_wl_display (display); + platform = EGL_PLATFORM_WAYLAND_EXT; + } + else +#endif +#ifdef GDK_WINDOWING_X11 + if (GDK_IS_X11_DISPLAY (display)) + { + native = gdk_x11_display_get_xdisplay (display); + platform = EGL_PLATFORM_X11_EXT; + } + else +#endif + return NULL; + if (epoxy_has_egl_extension (NULL, "EGL_KHR_platform_base")) { PFNEGLGETPLATFORMDISPLAYPROC getPlatformDisplay = (void *) eglGetProcAddress ("eglGetPlatformDisplay"); if (getPlatformDisplay) - dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT, - wl_display, - NULL); + dpy = getPlatformDisplay (platform, native, NULL); if (dpy) return dpy; } @@ -280,14 +298,12 @@ wayland_get_display (struct wl_display *wl_display) (void *) eglGetProcAddress ("eglGetPlatformDisplayEXT"); if (getPlatformDisplay) - dpy = getPlatformDisplay (EGL_PLATFORM_WAYLAND_EXT, - wl_display, - NULL); + dpy = getPlatformDisplay (platform, native, NULL); if (dpy) return dpy; } - return eglGetDisplay ((EGLNativeDisplayType)wl_display); + return eglGetDisplay ((EGLNativeDisplayType)native); } #endif @@ -305,25 +321,54 @@ init_gl (GtkInspectorGeneral *gen) #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (gen->display)) { - Display *dpy = GDK_DISPLAY_XDISPLAY (gen->display); - int error_base, event_base; - char *version; - if (!glXQueryExtension (dpy, &error_base, &event_base)) - return; + if (gdk_display_get_debug_flags (gen->display) & GDK_DEBUG_GL_GLX) + { + Display *dpy = GDK_DISPLAY_XDISPLAY (gen->display); + int error_base, event_base; + char *version; - version = g_strconcat ("GLX ", glXGetClientString (dpy, GLX_VERSION), NULL); - gtk_label_set_text (GTK_LABEL (gen->gl_version), version); - g_free (version); - gtk_label_set_text (GTK_LABEL (gen->gl_vendor), glXGetClientString (dpy, GLX_VENDOR)); + if (!glXQueryExtension (dpy, &error_base, &event_base)) + return; - append_glx_extension_row (gen, dpy, "GLX_ARB_create_context_profile"); - append_glx_extension_row (gen, dpy, "GLX_SGI_swap_control"); - append_glx_extension_row (gen, dpy, "GLX_EXT_texture_from_pixmap"); - append_glx_extension_row (gen, dpy, "GLX_SGI_video_sync"); - append_glx_extension_row (gen, dpy, "GLX_EXT_buffer_age"); - append_glx_extension_row (gen, dpy, "GLX_OML_sync_control"); - append_glx_extension_row (gen, dpy, "GLX_ARB_multisample"); - append_glx_extension_row (gen, dpy, "GLX_EXT_visual_rating"); + version = g_strconcat ("GLX ", glXGetClientString (dpy, GLX_VERSION), NULL); + gtk_label_set_text (GTK_LABEL (gen->gl_version), version); + g_free (version); + gtk_label_set_text (GTK_LABEL (gen->gl_vendor), glXGetClientString (dpy, GLX_VENDOR)); + + append_glx_extension_row (gen, dpy, "GLX_ARB_create_context_profile"); + append_glx_extension_row (gen, dpy, "GLX_SGI_swap_control"); + append_glx_extension_row (gen, dpy, "GLX_EXT_texture_from_pixmap"); + append_glx_extension_row (gen, dpy, "GLX_SGI_video_sync"); + append_glx_extension_row (gen, dpy, "GLX_EXT_buffer_age"); + append_glx_extension_row (gen, dpy, "GLX_OML_sync_control"); + append_glx_extension_row (gen, dpy, "GLX_ARB_multisample"); + append_glx_extension_row (gen, dpy, "GLX_EXT_visual_rating"); + } + else + { + EGLDisplay dpy; + EGLint major, minor; + char *version; + + dpy = get_egl_display (gen->display); + + if (!eglInitialize (dpy, &major, &minor)) + { + gtk_label_set_text (GTK_LABEL (gen->gl_version), C_("GL version", "None")); + gtk_label_set_text (GTK_LABEL (gen->gl_vendor), C_("GL vendor", "None")); + return; + } + + version = g_strconcat ("EGL ", eglQueryString (dpy, EGL_VERSION), NULL); + gtk_label_set_text (GTK_LABEL (gen->gl_version), version); + g_free (version); + gtk_label_set_text (GTK_LABEL (gen->gl_vendor), eglQueryString (dpy, EGL_VENDOR)); + + append_egl_extension_row (gen, dpy, "EGL_KHR_create_context"); + append_egl_extension_row (gen, dpy, "EGL_EXT_buffer_age"); + append_egl_extension_row (gen, dpy, "EGL_EXT_swap_buffers_with_damage"); + append_egl_extension_row (gen, dpy, "EGL_KHR_surfaceless_context"); + } } else #endif @@ -334,7 +379,7 @@ init_gl (GtkInspectorGeneral *gen) EGLint major, minor; char *version; - dpy = wayland_get_display (gdk_wayland_display_get_wl_display (gen->display)); + dpy = get_egl_display (gen->display); if (!eglInitialize (dpy, &major, &minor)) { From ea162ed01612e42766717667f78f5a981a496c3c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 10 May 2021 21:25:08 -0400 Subject: [PATCH 3/3] inspector: Avoid a crash with GL variants When configuring the inspector display, preserve debug flags that affect which GL variant we pick. Otherwise, we may end up with a GLX context on the default display, and an EGL context on the inspector one. This hopelessly confuses libepoxy, and things don't go well when that happens. --- gtk/inspector/window.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c index 1b4560e08e..02b108d882 100644 --- a/gtk/inspector/window.c +++ b/gtk/inspector/window.c @@ -697,13 +697,16 @@ get_inspector_display (void) if (display) { const char *name; + GdkDebugFlags flags; name = g_getenv ("GTK_INSPECTOR_RENDERER"); g_object_set_data_full (G_OBJECT (display), "gsk-renderer", g_strdup (name), g_free); - gdk_display_set_debug_flags (display, 0); + flags = gdk_display_get_debug_flags (gdk_display_get_default ()); + + gdk_display_set_debug_flags (display, flags & (GDK_DEBUG_GL_GLES | GDK_DEBUG_GL_GLX)); gtk_set_display_debug_flags (display, 0); }