From a26c1a5f0d869c94f131e7155b88436a4d1c6152 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Fri, 11 Feb 2022 01:13:13 +0100 Subject: [PATCH 1/3] widget-factory: Make toggle fullscreen --- demos/widget-factory/widget-factory.c | 1 + 1 file changed, 1 insertion(+) diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c index db23a4884d..319ad760ac 100644 --- a/demos/widget-factory/widget-factory.c +++ b/demos/widget-factory/widget-factory.c @@ -2053,6 +2053,7 @@ activate (GApplication *app) { "win.open", { "o", NULL } }, { "win.record", { "r", NULL } }, { "win.lock", { "l", NULL } }, + { "win.fullscreen", { "F11", NULL } }, }; struct { const char *action_and_target; From 12908ab86391bb9e65774afd422104d9545c5f9d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 13 Feb 2022 18:04:18 +0100 Subject: [PATCH 2/3] docs: Add Since annotations to GDK_VERSION macros --- gdk/gdkversionmacros.h.in | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gdk/gdkversionmacros.h.in b/gdk/gdkversionmacros.h.in index 9c9ef8aa8a..2056956ac0 100644 --- a/gdk/gdkversionmacros.h.in +++ b/gdk/gdkversionmacros.h.in @@ -83,6 +83,8 @@ * * A macro that evaluates to the 4.2 version of GDK, in a format * that can be used by the C pre-processor. + * + * Since: 4.2 */ #define GDK_VERSION_4_2 (G_ENCODE_VERSION (4, 2)) @@ -91,6 +93,8 @@ * * A macro that evaluates to the 4.4 version of GDK, in a format * that can be used by the C pre-processor. + * + * Since: 4.4 */ #define GDK_VERSION_4_4 (G_ENCODE_VERSION (4, 4)) @@ -99,6 +103,8 @@ * * A macro that evaluates to the 4.6 version of GDK, in a format * that can be used by the C pre-processor. + * + * Since: 4.6 */ #define GDK_VERSION_4_6 (G_ENCODE_VERSION (4, 6)) From 481634930cb8d65d35068df0414783d2ccbccd45 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 16 Feb 2022 03:46:29 +0100 Subject: [PATCH 3/3] glcontext: Remove leftover function call That call should have been removed way back when. Add a testcase to make sure this keeps working. Fixes #4697 --- gdk/gdkglcontext.c | 6 +-- testsuite/gdk/glcontext.c | 82 +++++++++++++++++++++++++++++++++++++++ testsuite/gdk/meson.build | 1 + 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 testsuite/gdk/glcontext.c diff --git a/gdk/gdkglcontext.c b/gdk/gdkglcontext.c index d1bc7c57c2..373f2fefd5 100644 --- a/gdk/gdkglcontext.c +++ b/gdk/gdkglcontext.c @@ -279,11 +279,7 @@ gdk_gl_context_real_realize (GdkGLContext *context, G_GNUC_UNUSED gint64 start_time = GDK_PROFILER_CURRENT_TIME; if (share != NULL) - { - gdk_gl_context_get_required_version (share, &major, &minor); - gdk_gl_context_set_allowed_apis (context, - gdk_gl_context_get_allowed_apis (share)); - } + gdk_gl_context_get_required_version (share, &major, &minor); else gdk_gl_context_get_required_version (context, &major, &minor); diff --git a/testsuite/gdk/glcontext.c b/testsuite/gdk/glcontext.c new file mode 100644 index 0000000000..0bc9148064 --- /dev/null +++ b/testsuite/gdk/glcontext.c @@ -0,0 +1,82 @@ +#include + +#define ALL_APIS (GDK_GL_API_GL | GDK_GL_API_GLES) + +static GdkGLAPI +is_unique (GdkGLAPI api) +{ + return (api & (api - 1)) == 0; +} + +static void +test_allowed_backends (gconstpointer data) +{ + GdkGLAPI allowed = GPOINTER_TO_SIZE (data); + GdkGLAPI not_allowed = (~allowed) & ALL_APIS; + GdkGLAPI api, random_apis; + GdkDisplay *display = gdk_display_get_default (); + GdkGLContext *context; + GError *error = NULL; + + display = gdk_display_get_default (); + if (!gdk_display_prepare_gl (display, &error)) + { + g_test_message ("no GL support: %s", error->message); + g_test_skip ("no GL support"); + g_clear_error (&error); + return; + } + + context = gdk_display_create_gl_context (display, &error); + g_assert (context); + g_assert_no_error (error); + g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0); + g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, ALL_APIS); + + gdk_gl_context_set_allowed_apis (context, allowed); + g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, allowed); + g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0); + + if (!gdk_gl_context_realize (context, &error)) + { + g_assert_cmpint (gdk_gl_context_get_api (context), ==, 0); + + if (not_allowed && g_error_matches (error, GDK_GL_ERROR, GDK_GL_ERROR_NOT_AVAILABLE)) + { + g_clear_error (&error); + g_object_unref (context); + return; + } + g_assert_no_error (error); + } + + g_assert_no_error (error); + + g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, allowed); + + api = gdk_gl_context_get_api (context); + g_assert_cmpint (api, !=, 0); + g_assert_true (is_unique (api)); + g_assert_cmpint (api & allowed, ==, api); + g_assert_cmpint (api & not_allowed, ==, 0); + + random_apis = g_random_int_range (0, ALL_APIS + 1); + gdk_gl_context_set_allowed_apis (context, random_apis); + g_assert_cmpint (gdk_gl_context_get_allowed_apis (context), ==, random_apis); + g_assert_cmpint (gdk_gl_context_get_api (context), ==, api); + + g_object_unref (context); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv, NULL); + + g_test_add_data_func ("/allowed-apis/none", GSIZE_TO_POINTER (0), test_allowed_backends); + g_test_add_data_func ("/allowed-apis/gl", GSIZE_TO_POINTER (GDK_GL_API_GL), test_allowed_backends); + g_test_add_data_func ("/allowed-apis/gles", GSIZE_TO_POINTER (GDK_GL_API_GLES), test_allowed_backends); + g_test_add_data_func ("/allowed-apis/all", GSIZE_TO_POINTER (GDK_GL_API_GL | GDK_GL_API_GLES), test_allowed_backends); + + return g_test_run (); +} diff --git a/testsuite/gdk/meson.build b/testsuite/gdk/meson.build index e3b2e8869a..04c780f3f0 100644 --- a/testsuite/gdk/meson.build +++ b/testsuite/gdk/meson.build @@ -19,6 +19,7 @@ tests = [ { 'name': 'display' }, { 'name': 'displaymanager' }, { 'name': 'encoding' }, + { 'name': 'glcontext' }, { 'name': 'keysyms' }, { 'name': 'memorytexture' }, { 'name': 'pixbuf' },