From fddd5f33ab10ded7978128734d214653c12f48ca Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 19 Oct 2024 17:51:49 +0200 Subject: [PATCH 01/34] win32: Avoid g_warning() when layout doesn't exist If the registry key doesn't exist, it doesn't warrant a warning. We hit that case in CI and it aborts every test during startup. --- gdk/win32/gdkkeys-win32.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gdk/win32/gdkkeys-win32.c b/gdk/win32/gdkkeys-win32.c index 8243daa5a6..912747191d 100644 --- a/gdk/win32/gdkkeys-win32.c +++ b/gdk/win32/gdkkeys-win32.c @@ -254,11 +254,15 @@ _get_keyboard_layout_file (const char *layout_name) status = RegOpenKeyExA (HKEY_LOCAL_MACHINE, (LPCSTR) kbdKeyPath, 0, KEY_QUERY_VALUE, &hkey); - if (status != ERROR_SUCCESS) + if (status == ERROR_FILE_NOT_FOUND) + { + return NULL; + } + else if (status != ERROR_SUCCESS) { g_warning("Could not open registry key '%s'. Error code: %d", kbdKeyPath, (int)status); - goto fail1; + return NULL; } /* Get sizes */ @@ -268,14 +272,14 @@ _get_keyboard_layout_file (const char *layout_name) { g_warning("Could not query registry key '%s\\Layout File'. Error code: %d", kbdKeyPath, (int)status); - goto fail2; + goto fail_close_key; } dir_len = GetSystemDirectoryA (0, 0); /* includes \0 */ if (dir_len == 0) { g_warning("GetSystemDirectoryA failed. Error: %d", (int)GetLastError()); - goto fail2; + goto fail_close_key; } /* Allocate buffer */ @@ -284,7 +288,7 @@ _get_keyboard_layout_file (const char *layout_name) /* Append system directory. The -1 is because dir_len includes \0 */ if (GetSystemDirectoryA (&result[0], dir_len) != dir_len - 1) - goto fail3; + goto fail_free_result; /* Append directory separator */ result[dir_len - 1] = '\\'; @@ -293,20 +297,17 @@ _get_keyboard_layout_file (const char *layout_name) status = RegQueryValueExA (hkey, "Layout File", 0, &var_type, (LPBYTE) &result[dir_len], &file_name_len); if (status != ERROR_SUCCESS) - { - goto fail3; - } + goto fail_free_result; result[dir_len + file_name_len] = '\0'; RegCloseKey (hkey); return result; -fail3: +fail_free_result: g_free (result); -fail2: +fail_close_key: RegCloseKey (hkey); -fail1: return NULL; } From 5e9e8a6f5df841f849aaf6031f98651b6dcf20b5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 19 Oct 2024 03:47:33 +0200 Subject: [PATCH 02/34] testsuite: Canonicalize filenames It looks weird on Windows if half the paths use \ and the other half use / --- testsuite/gsk/compare-render.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/gsk/compare-render.c b/testsuite/gsk/compare-render.c index 3ab9cc0ebe..b933ab544d 100644 --- a/testsuite/gsk/compare-render.c +++ b/testsuite/gsk/compare-render.c @@ -831,7 +831,7 @@ main (int argc, char **argv) if (argc <= 2) test->png_file = file_replace_extension (test->node_file, ".node", ".png"); else - test->png_file = g_strdup (argv[2]); + test->png_file = g_canonicalize_filename (argv[2], NULL); g_test_add_vtable (test->node_file, 0, From 35c0068345a6281755eea92f178941737a554fef Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 19 Oct 2024 03:38:00 +0200 Subject: [PATCH 03/34] rendernodeparser: Implement font loading on Windows --- gsk/gskrendernodeparser.c | 102 ++++++++++++++++++++------------------ meson.build | 3 ++ 2 files changed, 58 insertions(+), 47 deletions(-) diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index 268fdb933e..ea3541fffa 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -55,6 +55,9 @@ #ifdef HAVE_PANGOFT #include #endif +#ifdef HAVE_PANGOWIN32 +#include +#endif #include @@ -1135,7 +1138,6 @@ create_ascii_glyphs (PangoFont *font) } #ifdef HAVE_PANGOFT - static void delete_file (gpointer data) { @@ -1144,25 +1146,31 @@ delete_file (gpointer data) g_remove (path); g_free (path); } +#endif static void ensure_fontmap (Context *context) { - FcConfig *config; - GPtrArray *files; - if (context->fontmap) return; context->fontmap = pango_cairo_font_map_new (); - config = FcConfigCreate (); - pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config); - FcConfigDestroy (config); +#ifdef HAVE_PANGOFT + if (PANGO_IS_FC_FONT_MAP (context->fontmap)) + { + FcConfig *config; + GPtrArray *files; - files = g_ptr_array_new_with_free_func (delete_file); + config = FcConfigCreate (); + pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (context->fontmap), config); + FcConfigDestroy (config); - g_object_set_data_full (G_OBJECT (context->fontmap), "font-files", files, (GDestroyNotify) g_ptr_array_unref); + files = g_ptr_array_new_with_free_func (delete_file); + + g_object_set_data_full (G_OBJECT (context->fontmap), "font-files", files, (GDestroyNotify) g_ptr_array_unref); + } +#endif } static gboolean @@ -1170,37 +1178,53 @@ add_font_from_file (Context *context, const char *path, GError **error) { - FcConfig *config; - GPtrArray *files; - ensure_fontmap (context); - if (!PANGO_IS_FC_FONT_MAP (context->fontmap)) +#ifdef HAVE_PANGOFT + if (PANGO_IS_FC_FONT_MAP (context->fontmap)) { + FcConfig *config; + GPtrArray *files; + + config = pango_fc_font_map_get_config (PANGO_FC_FONT_MAP (context->fontmap)); + + if (!FcConfigAppFontAddFile (config, (FcChar8 *) path)) + { + g_set_error (error, + GTK_CSS_PARSER_ERROR, + GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE, + "Failed to load font"); + return FALSE; + } + + files = (GPtrArray *) g_object_get_data (G_OBJECT (context->fontmap), "font-files"); + g_ptr_array_add (files, g_strdup (path)); + + pango_fc_font_map_config_changed (PANGO_FC_FONT_MAP (context->fontmap)); + + return TRUE; + } + else +#endif +#ifdef HAVE_PANGOWIN32 + if (g_type_is_a (G_OBJECT_TYPE (context->fontmap), g_type_from_name ("PangoWin32FontMap"))) + { + gboolean result; + + result = pango_win32_font_map_add_font_file (context->fontmap, path, error); + g_remove (path); + return result; + } + else +#endif + { + g_remove (path); g_set_error (error, GTK_CSS_PARSER_ERROR, GTK_CSS_PARSER_ERROR_FAILED, "Custom fonts are not implemented for %s", G_OBJECT_TYPE_NAME (context->fontmap)); return FALSE; } - - config = pango_fc_font_map_get_config (PANGO_FC_FONT_MAP (context->fontmap)); - - if (!FcConfigAppFontAddFile (config, (FcChar8 *) path)) - { - g_set_error (error, - GTK_CSS_PARSER_ERROR, - GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE, - "Failed to load font"); - return FALSE; - } - - files = (GPtrArray *) g_object_get_data (G_OBJECT (context->fontmap), "font-files"); - g_ptr_array_add (files, g_strdup (path)); - - pango_fc_font_map_config_changed (PANGO_FC_FONT_MAP (context->fontmap)); - - return TRUE; } static gboolean @@ -1236,22 +1260,6 @@ add_font_from_bytes (Context *context, return result; } -#else /* !HAVE_PANGOFT */ - -static gboolean -add_font_from_bytes (Context *context, - GBytes *bytes, - GError **error) -{ - g_set_error (error, - GTK_CSS_PARSER_ERROR, - GTK_CSS_PARSER_ERROR_FAILED, - "Not implemented"); - return FALSE; -} - -#endif - static gboolean parse_font (GtkCssParser *parser, Context *context, diff --git a/meson.build b/meson.build index cc7bb83718..5804bbfa52 100644 --- a/meson.build +++ b/meson.build @@ -501,6 +501,9 @@ if have_egl endif cdata.set('HAVE_HARFBUZZ', harfbuzz_dep.found()) cdata.set('HAVE_PANGOFT', pangoft_dep.found()) +if win32_enabled + cdata.set('HAVE_PANGOWIN32', pangowin32_dep.found()) +endif wayland_pkgs = [] if wayland_enabled From f907d8a17a5f3a1d6747148772df0456e11b5363 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sat, 19 Oct 2024 02:33:07 +0200 Subject: [PATCH 04/34] win32: Don't crash when threads start too slow Passing on-stack items to a thread in a function that exits right after spawning the threads is a bad idea: By the time the thread starts up and reads the values, the stack might be in use for other stuff. So instead of putting the items on the stack, just read them out of the clipdrop struct. --- gdk/win32/gdkclipdrop-win32.c | 44 ++++++++++++++--------------------- gdk/win32/gdkclipdrop-win32.h | 9 ------- gdk/win32/gdkdrag-win32.c | 6 ++--- 3 files changed, 19 insertions(+), 40 deletions(-) diff --git a/gdk/win32/gdkclipdrop-win32.c b/gdk/win32/gdkclipdrop-win32.c index 3e082b1dec..c927607d54 100644 --- a/gdk/win32/gdkclipdrop-win32.c +++ b/gdk/win32/gdkclipdrop-win32.c @@ -1454,22 +1454,22 @@ failed: static gpointer _gdk_win32_clipboard_thread_main (gpointer data) { + GdkWin32Clipdrop *self = data; MSG msg; - clipdrop_thread_items *items = (clipdrop_thread_items*) data; - GAsyncQueue *queue = items->queue; - GAsyncQueue *render_queue = (GAsyncQueue *) g_async_queue_pop (queue); + GAsyncQueue *queue = self->clipboard_open_thread_queue; + GAsyncQueue *render_queue = self->clipboard_render_queue; + + g_assert (self->clipboard_thread_items == NULL); - g_assert (items->clipdrop->clipboard_thread_items == NULL); + self->clipboard_thread_items = g_new0 (GdkWin32ClipboardThread, 1); + CLIPDROP_CB_THREAD_MEMBER (self, input_queue) = queue; + CLIPDROP_CB_THREAD_MEMBER (self, render_queue) = render_queue; + CLIPDROP_CB_THREAD_MEMBER (self, clipboard_opened_for) = INVALID_HANDLE_VALUE; - items->clipdrop->clipboard_thread_items = g_new0 (GdkWin32ClipboardThread, 1); - CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, input_queue) = queue; - CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, render_queue) = render_queue; - CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_opened_for) = INVALID_HANDLE_VALUE; - - if (!register_clipboard_notification (items->clipdrop)) + if (!register_clipboard_notification (self)) { g_async_queue_unref (queue); - g_clear_pointer (&items->clipdrop->clipboard_thread_items, g_free); + g_clear_pointer (&self->clipboard_thread_items, g_free); return NULL; } @@ -1481,10 +1481,9 @@ _gdk_win32_clipboard_thread_main (gpointer data) } /* Just in case, as this should only happen when we shut down */ - DestroyWindow (CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_hwnd)); - CloseHandle (CLIPDROP_CB_THREAD_MEMBER (items->clipdrop, clipboard_hwnd)); - g_async_queue_unref (queue); - g_clear_pointer (&items->clipdrop->clipboard_thread_items, g_free); + DestroyWindow (CLIPDROP_CB_THREAD_MEMBER (self, clipboard_hwnd)); + CloseHandle (CLIPDROP_CB_THREAD_MEMBER (self, clipboard_hwnd)); + g_clear_pointer (&self->clipboard_thread_items, g_free); return NULL; } @@ -1521,8 +1520,7 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop) GArray *comp; GdkWin32ContentFormatPair fmt; HMODULE user32; - clipdrop_thread_items cb_items, dnd_items; - + win32_clipdrop->thread_wakeup_message = RegisterWindowMessage (L"GDK_WORKER_THREAD_WEAKEUP"); user32 = LoadLibrary (L"user32.dll"); @@ -1810,22 +1808,14 @@ gdk_win32_clipdrop_init (GdkWin32Clipdrop *win32_clipdrop) win32_clipdrop->clipboard_open_thread_queue = g_async_queue_new (); win32_clipdrop->clipboard_render_queue = g_async_queue_new (); - /* Out of sheer laziness, we just push the extra queue through the - * main queue, instead of allocating a struct with two queue - * pointers and then passing *that* to the thread. - */ - g_async_queue_push (win32_clipdrop->clipboard_open_thread_queue, g_async_queue_ref (win32_clipdrop->clipboard_render_queue)); - cb_items.clipdrop = dnd_items.clipdrop = win32_clipdrop; - cb_items.queue = g_async_queue_ref (win32_clipdrop->clipboard_open_thread_queue); win32_clipdrop->clipboard_open_thread = g_thread_new ("GDK Win32 Clipboard Thread", _gdk_win32_clipboard_thread_main, - &cb_items); + win32_clipdrop); win32_clipdrop->dnd_queue = g_async_queue_new (); - dnd_items.queue = g_async_queue_ref (win32_clipdrop->dnd_queue); win32_clipdrop->dnd_thread = g_thread_new ("GDK Win32 DnD Thread", _gdk_win32_dnd_thread_main, - &dnd_items); + win32_clipdrop); win32_clipdrop->dnd_thread_id = GPOINTER_TO_UINT (g_async_queue_pop (win32_clipdrop->dnd_queue)); } diff --git a/gdk/win32/gdkclipdrop-win32.h b/gdk/win32/gdkclipdrop-win32.h index c48d9a17f2..4b0893c37a 100644 --- a/gdk/win32/gdkclipdrop-win32.h +++ b/gdk/win32/gdkclipdrop-win32.h @@ -113,15 +113,6 @@ typedef enum _GdkWin32CFIndex GdkWin32CFIndex; typedef struct _GdkWin32Clipdrop GdkWin32Clipdrop; typedef struct _GdkWin32ClipdropClass GdkWin32ClipdropClass; -/* this is shared with gdkdrag-win32.c as well */ -struct _clipdrop_thread_items -{ - GdkWin32Clipdrop *clipdrop; - GAsyncQueue *queue; -}; - -typedef struct _clipdrop_thread_items clipdrop_thread_items; - typedef BOOL (WINAPI * GetUpdatedClipboardFormatsFunc)( _Out_ PUINT lpuiFormats, _In_ UINT cFormats, diff --git a/gdk/win32/gdkdrag-win32.c b/gdk/win32/gdkdrag-win32.c index 0b1799507d..87fc0ae1c8 100644 --- a/gdk/win32/gdkdrag-win32.c +++ b/gdk/win32/gdkdrag-win32.c @@ -637,10 +637,8 @@ do_drag_drop (GdkWin32DnDThreadDoDragDrop *ddd) gpointer _gdk_win32_dnd_thread_main (gpointer data) { - - clipdrop_thread_items *clipdrop_items = (clipdrop_thread_items *) data; - GAsyncQueue *queue = clipdrop_items->queue; - GdkWin32Clipdrop *clipdrop = clipdrop_items->clipdrop; + GdkWin32Clipdrop *clipdrop = data; + GAsyncQueue *queue = clipdrop->dnd_queue; GdkWin32DnDThreadQueueItem *item; MSG msg; HRESULT hr; From 3a7f242e0811648f5749c26f20b6ce7c421e36d3 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 02:11:25 +0200 Subject: [PATCH 05/34] testsuite: MIME types aren't CONTENT types Somebody came up with the great idea of content types, which are just like mime types, only that they aren't on Windows. So if we want a working testsuite that actually works on Windows, we cannot mix them up. --- testsuite/gtk/filefilter.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/testsuite/gtk/filefilter.c b/testsuite/gtk/filefilter.c index 524efa5fce..b01a2ca077 100644 --- a/testsuite/gtk/filefilter.c +++ b/testsuite/gtk/filefilter.c @@ -90,7 +90,7 @@ static void test_mime_type (void) { GtkFileFilter *filter; - char *attrs; + char *attrs, *content_type; GFileInfo *info; filter = gtk_file_filter_new (); @@ -100,15 +100,21 @@ test_mime_type (void) info = g_file_info_new (); g_file_info_set_display_name (info, "abracadabra"); - g_file_info_set_content_type (info, "text/plain"); + content_type = g_content_type_from_mime_type ("text/plain"); + g_file_info_set_content_type (info, content_type); + g_free (content_type); g_assert_false (gtk_filter_match (GTK_FILTER (filter), info)); g_file_info_set_display_name (info, "dro.png"); - g_file_info_set_content_type (info, "image/png"); + content_type = g_content_type_from_mime_type ("image/png"); + g_file_info_set_content_type (info, content_type); + g_free (content_type); g_assert_true (gtk_filter_match (GTK_FILTER (filter), info)); g_file_info_set_display_name (info, "dro.PNG"); - g_file_info_set_content_type (info, "image/png"); + content_type = g_content_type_from_mime_type ("image/png"); + g_file_info_set_content_type (info, content_type); + g_free (content_type); g_assert_true (gtk_filter_match (GTK_FILTER (filter), info)); g_object_unref (info); @@ -138,7 +144,11 @@ test_buildable (void) filter = GTK_FILE_FILTER (gtk_builder_get_object (builder, "filter")); v1 = gtk_file_filter_to_gvariant (filter); - v2 = g_variant_parse (NULL, "('Audio Files', [(1, 'audio/*')])", NULL, NULL, NULL); + s1 = g_content_type_from_mime_type ("audio/*"); + s2 = g_strdup_printf ("('Audio Files', [(1, '%s')])", s1); + v2 = g_variant_parse (NULL, s2, NULL, NULL, NULL); + g_free (s2); + g_free (s1); s1 = g_variant_print (v1, FALSE); s2 = g_variant_print (v2, FALSE); @@ -176,7 +186,11 @@ test_builder (void) filter = GTK_FILE_FILTER (gtk_builder_get_object (builder, "filter")); v1 = gtk_file_filter_to_gvariant (filter); - v2 = g_variant_parse (NULL, "('Audio Files', [(0, '*.x'), (0, '*.y'), (1, 'audio/*'), (0, '*.[bB][lL][aA][hH]')])", NULL, NULL, NULL); + s1 = g_content_type_from_mime_type ("audio/*"); + s2 = g_strdup_printf ("('Audio Files', [(0, '*.x'), (0, '*.y'), (1, '%s'), (0, '*.[bB][lL][aA][hH]')])", s1); + v2 = g_variant_parse (NULL, s2, NULL, NULL, NULL); + g_free (s2); + g_free (s1); s1 = g_variant_print (v1, FALSE); s2 = g_variant_print (v2, FALSE); From 6ef3fc2dbb5ad854608cdd024aca8627d6b149ed Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 02:17:16 +0200 Subject: [PATCH 06/34] testsuite: Hey, everyone has an NGL renderer, right? No. This fix is not that much better, but I'm too tired to fix stuff like this properly. And the Cairo renderer did at least work everywhere during 4.x --- testsuite/gsk/normalize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/gsk/normalize.c b/testsuite/gsk/normalize.c index c7c66175a5..5ca51f32e3 100644 --- a/testsuite/gsk/normalize.c +++ b/testsuite/gsk/normalize.c @@ -6,7 +6,7 @@ static void test_normalize (GskRenderNode *node1, GskRenderNode *node2) { - GskRenderer *renderer = gsk_ngl_renderer_new (); + GskRenderer *renderer = gsk_cairo_renderer_new (); graphene_rect_t bounds1, bounds2; GdkTexture *texture1, *texture2, *diff; GError *error = NULL; From 5d01fe96c6994ab229eb1beaf909604b8d89ad56 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 04:48:30 +0200 Subject: [PATCH 07/34] testsuite: Create timezone without guessing names Guessing names is not portable, in particular not to Windows. See also commit 4881ef2. --- testsuite/gtk/calendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/gtk/calendar.c b/testsuite/gtk/calendar.c index 86c1ad6be5..56dcd2af82 100644 --- a/testsuite/gtk/calendar.c +++ b/testsuite/gtk/calendar.c @@ -28,7 +28,7 @@ test_calendar_select_day (void) cal = gtk_calendar_new (); - tz = g_time_zone_new_identifier ("Europe/Brussels"); + tz = g_time_zone_new_offset (2 * 60 * 60); g_assert_nonnull (tz); dt = g_date_time_new (tz, 1970, 3, 1, 0, 0, 0); g_assert_nonnull (dt); From a891c9079830f0a0309feb40f31af1f7bab73ec6 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 04:58:54 +0200 Subject: [PATCH 08/34] win32: Use right name for GIO_USE_VOLUME_MONITOR in CI --- testsuite/meson.build | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/testsuite/meson.build b/testsuite/meson.build index e4033e7c10..8fb7a99362 100644 --- a/testsuite/meson.build +++ b/testsuite/meson.build @@ -9,7 +9,6 @@ if catch.found() endif common_env = [ - 'GIO_USE_VOLUME_MONITOR=unix', 'GIO_USE_VFS=local', 'GSETTINGS_BACKEND=memory', 'GTK_CSD=1', @@ -20,6 +19,13 @@ common_env = [ ] exclude_unstable = ['flaky', 'failing'] +if os_win32 + common_env += [ 'GIO_USE_VOLUME_MONITOR=win32' ] +else + common_env += [ 'GIO_USE_VOLUME_MONITOR=unix' ] +endif + + setups = [ { 'backend': 'x11', 'if': x11_enabled, }, { 'backend': 'wayland', 'if': wayland_enabled, 'is_default': true, }, From 3694aed0222f2c45eade5c1062c9f04f56d73077 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 05:38:53 +0200 Subject: [PATCH 09/34] build: Use sources argument Being more explicit is better. --- gtk/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/meson.build b/gtk/meson.build index 5d2f2859fe..a662d53f7e 100644 --- a/gtk/meson.build +++ b/gtk/meson.build @@ -882,7 +882,7 @@ gtk_use_wayland_or_x11_c_sources = files([ ]) gtk_dbus_src = gnome.gdbus_codegen('gtkdbusgenerated', - 'gtkdbusinterfaces.xml', + sources:'gtkdbusinterfaces.xml', interface_prefix: 'org.Gtk.', namespace: '_Gtk', ) From 01c754f93b12cabb46760151d4d3eac17e2a3775 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 07:00:42 +0200 Subject: [PATCH 10/34] testsuite: Windows separators are different On top of that we defined a preprocessor constant to 2 different values, but instead of checking the value, we only checked if it was defined. Now we only define it in one place. --- testsuite/gtk/fnmatch.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/testsuite/gtk/fnmatch.c b/testsuite/gtk/fnmatch.c index 25bbc7b0e6..f5738a2372 100644 --- a/testsuite/gtk/fnmatch.c +++ b/testsuite/gtk/fnmatch.c @@ -1,9 +1,7 @@ #include #include "gtk/gtkprivate.h" -#if defined(G_OS_WIN32) || defined(G_WITH_CYGWIN) -#define DO_ESCAPE 0 -#else +#if !defined(G_OS_WIN32) && !defined(G_WITH_CYGWIN) #define DO_ESCAPE 1 #endif @@ -25,17 +23,17 @@ static TestCase tests[] = { { "?", "a", TRUE, FALSE, TRUE }, { "?", ".", TRUE, FALSE, FALSE }, { "a?", "a.", TRUE, FALSE, TRUE }, - { "a/?", "a/b", TRUE, FALSE, TRUE }, - { "a/?", "a/.", TRUE, FALSE, FALSE }, - { "?", "/", TRUE, FALSE, FALSE }, + { "a" G_DIR_SEPARATOR_S "?", "a" G_DIR_SEPARATOR_S "b", TRUE, FALSE, TRUE }, + { "a" G_DIR_SEPARATOR_S "?", "a" G_DIR_SEPARATOR_S ".", TRUE, FALSE, FALSE }, + { "?", "" G_DIR_SEPARATOR_S "", TRUE, FALSE, FALSE }, /* Test what * matches */ { "*", "a", TRUE, FALSE, TRUE }, { "*", ".", TRUE, FALSE, FALSE }, { "a*", "a.", TRUE, FALSE, TRUE }, - { "a/*", "a/b", TRUE, FALSE, TRUE }, - { "a/*", "a/.", TRUE, FALSE, FALSE }, - { "*", "/", TRUE, FALSE, FALSE }, + { "a" G_DIR_SEPARATOR_S "*", "a" G_DIR_SEPARATOR_S "b", TRUE, FALSE, TRUE }, + { "a" G_DIR_SEPARATOR_S "*", "a" G_DIR_SEPARATOR_S ".", TRUE, FALSE, FALSE }, + { "*", "" G_DIR_SEPARATOR_S "", TRUE, FALSE, FALSE }, /* Range tests */ { "[ab]", "a", TRUE, FALSE, TRUE }, @@ -61,9 +59,9 @@ static TestCase tests[] = { /* Ranges and special no-wildcard matches */ { "[.]", ".", TRUE, FALSE, FALSE }, { "a[.]", "a.", TRUE, FALSE, TRUE }, - { "a/[.]", "a/.", TRUE, FALSE, FALSE }, - { "[/]", "/", TRUE, FALSE, FALSE }, - { "[^/]", "a", TRUE, FALSE, TRUE }, + { "a" G_DIR_SEPARATOR_S "[.]", "a" G_DIR_SEPARATOR_S ".", TRUE, FALSE, FALSE }, + { "[" G_DIR_SEPARATOR_S "]", "" G_DIR_SEPARATOR_S "", TRUE, FALSE, FALSE }, + { "[^" G_DIR_SEPARATOR_S "]", "a", TRUE, FALSE, TRUE }, /* Basic tests of * (and combinations of * and ?) */ { "a*b", "ab", TRUE, FALSE, TRUE }, @@ -81,8 +79,8 @@ static TestCase tests[] = { { "a*[cd]", "axc", TRUE, FALSE, TRUE }, { "a*[cd]", "axx", TRUE, FALSE, FALSE }, - { "a/[.]", "a/.", TRUE, FALSE, FALSE }, - { "a*[.]", "a/.", TRUE, FALSE, FALSE }, + { "a" G_DIR_SEPARATOR_S "[.]", "a" G_DIR_SEPARATOR_S ".", TRUE, FALSE, FALSE }, + { "a*[.]", "a" G_DIR_SEPARATOR_S ".", TRUE, FALSE, FALSE }, /* Test of UTF-8 */ From fdb4469234967229f598dfd8bb16b07da18b11f1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Sun, 20 Oct 2024 15:33:29 +0200 Subject: [PATCH 11/34] testsuite: Don't use random numbers in test output glibc prints the value as 0.096203, msvcrt prints 0.0962031. And I don't think any spec defines which way things need to be rounded. --- testsuite/css/parser/color-mix.css | 4 ++-- testsuite/css/parser/color-mix.ref.css | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/testsuite/css/parser/color-mix.css b/testsuite/css/parser/color-mix.css index 79dba1ddbd..29b17651a6 100644 --- a/testsuite/css/parser/color-mix.css +++ b/testsuite/css/parser/color-mix.css @@ -51,11 +51,11 @@ m { } n { - color: color-mix(in oklch shorter hue, red, blue); + color: color-mix(in oklch shorter hue, oklch(1 0 0), oklch(0 1 0)); } o { - color: color-mix(in oklab, red, blue); + color: color-mix(in oklab, oklab(1 0 0), oklab(0 1 0)); } p { diff --git a/testsuite/css/parser/color-mix.ref.css b/testsuite/css/parser/color-mix.ref.css index d17ff80b87..dd93325d46 100644 --- a/testsuite/css/parser/color-mix.ref.css +++ b/testsuite/css/parser/color-mix.ref.css @@ -51,11 +51,11 @@ m { } n { - color: oklch(0.539985 0.285449 326.643); + color: oklch(0.5 0.5 0); } o { - color: oklab(0.539985 0.096203 -0.0928409); + color: oklab(0.5 0.5 0); } v { From b5f9d989558e0e71032d88960fd1d6333b446820 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 05:25:25 +0200 Subject: [PATCH 12/34] build: Fix MSVC warning INPUT is a name for a Windows type, see https://learn.microsoft.com/en-us/windows/win32/api/winuser/ns-winuser-input --- gtk/gtkspinbutton.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index bdc936c510..6c279fcecc 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -264,7 +264,7 @@ enum { /* Signals */ enum { - INPUT, + INPUT_, OUTPUT, VALUE_CHANGED, ACTIVATE, @@ -499,7 +499,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) * Returns: %TRUE for a successful conversion, %FALSE if the input * was not handled, and %GTK_INPUT_ERROR if the conversion failed. */ - spinbutton_signals[INPUT] = + spinbutton_signals[INPUT_] = g_signal_new (I_("input"), G_TYPE_FROM_CLASS (gobject_class), G_SIGNAL_RUN_LAST, @@ -508,7 +508,7 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) _gtk_marshal_INT__POINTER, G_TYPE_INT, 1, G_TYPE_POINTER); - g_signal_set_va_marshaller (spinbutton_signals[INPUT], + g_signal_set_va_marshaller (spinbutton_signals[INPUT_], G_TYPE_FROM_CLASS (gobject_class), _gtk_marshal_INT__POINTERv); @@ -2541,7 +2541,7 @@ gtk_spin_button_update (GtkSpinButton *spin_button) g_return_if_fail (GTK_IS_SPIN_BUTTON (spin_button)); return_val = FALSE; - g_signal_emit (spin_button, spinbutton_signals[INPUT], 0, &val, &return_val); + g_signal_emit (spin_button, spinbutton_signals[INPUT_], 0, &val, &return_val); if (return_val == FALSE) { return_val = gtk_spin_button_default_input (spin_button, &val); From 591bc5edc02bf5f5559e716b30b885d2265ac7b0 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 05:59:53 +0200 Subject: [PATCH 13/34] build: Work around duplicated define of APIENTRY epoxy defines it if windows.h hasn't been included. So include windows.h before epoxy. See also https://github.com/anholt/libepoxy/issues/299 --- gdk/gdkmemoryformatprivate.h | 5 +++++ gdk/win32/gdkglcontext-win32.h | 4 ++++ gsk/gl/gskgltypesprivate.h | 8 ++++++-- testsuite/gdk/gltexture.c | 4 ++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/gdk/gdkmemoryformatprivate.h b/gdk/gdkmemoryformatprivate.h index 994e8e845c..6fbd3363cc 100644 --- a/gdk/gdkmemoryformatprivate.h +++ b/gdk/gdkmemoryformatprivate.h @@ -22,6 +22,11 @@ #include "gdkenums.h" #include "gdktypes.h" +/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */ +#ifdef GDK_WINDOWING_WIN32 +#include +#endif + #include #ifdef GDK_RENDERING_VULKAN diff --git a/gdk/win32/gdkglcontext-win32.h b/gdk/win32/gdkglcontext-win32.h index c3c8c1a8d5..0f4c7c2535 100644 --- a/gdk/win32/gdkglcontext-win32.h +++ b/gdk/win32/gdkglcontext-win32.h @@ -21,6 +21,10 @@ #pragma once #ifndef DONT_INCLUDE_LIBEPOXY +#ifdef GDK_WINDOWING_WIN32 +/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */ +#include +#endif #include #include diff --git a/gsk/gl/gskgltypesprivate.h b/gsk/gl/gskgltypesprivate.h index c16c22c5a0..301a232bf1 100644 --- a/gsk/gl/gskgltypesprivate.h +++ b/gsk/gl/gskgltypesprivate.h @@ -20,10 +20,14 @@ #pragma once -#include -#include #include #include +#ifdef GDK_WINDOWING_WIN32 +/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */ +#include +#endif +#include +#include G_BEGIN_DECLS diff --git a/testsuite/gdk/gltexture.c b/testsuite/gdk/gltexture.c index b186b674ad..860b2c5a3b 100644 --- a/testsuite/gdk/gltexture.c +++ b/testsuite/gdk/gltexture.c @@ -1,4 +1,8 @@ #include +#ifdef GDK_WINDOWING_WIN32 +/* epoxy needs this, see https://github.com/anholt/libepoxy/issues/299 */ +#include +#endif #include #include "gdk/gdktextureprivate.h" #include "gdk/gdkglcontextprivate.h" From 66e059ae52e0afa4873b9fc5eaf621966fb87db6 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:01:48 +0200 Subject: [PATCH 14/34] build: Fix MSVC warning about function prototypes We're using custom sorters and those want int as the return value, not GtkOrdering. --- demos/gtk-demo/font_features.c | 2 +- gtk/gtkfilechooserwidget.c | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/demos/gtk-demo/font_features.c b/demos/gtk-demo/font_features.c index 3b6606b0c8..66155f70e1 100644 --- a/demos/gtk-demo/font_features.c +++ b/demos/gtk-demo/font_features.c @@ -811,7 +811,7 @@ tag_pair_equal (gconstpointer a, gconstpointer b) } -static GtkOrdering +static int script_sort (const void *item1, const void *item2, void *data) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 9337afbea2..e10bebda21 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -6959,7 +6959,7 @@ match_func (gpointer item, gpointer user_data) return g_file_info_get_attribute_boolean (G_FILE_INFO (item), "filechooser::visible"); } -static GtkOrdering +static int directory_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) @@ -6980,13 +6980,13 @@ directory_sort_func (gconstpointer a, return GTK_ORDERING_EQUAL; } -static GtkOrdering +static int name_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) { char *key_a, *key_b; - GtkOrdering result; + int result; /* FIXME: use sortkeys for these */ key_a = g_utf8_collate_key_for_filename (g_file_info_get_display_name ((GFileInfo *)a), -1); @@ -7026,7 +7026,7 @@ location_sort_func (gconstpointer a, return result; } -static GtkOrdering +static int size_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) @@ -7044,14 +7044,14 @@ size_sort_func (gconstpointer a, return GTK_ORDERING_EQUAL; } -static GtkOrdering +static int type_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) { GtkFileChooserWidget *impl = user_data; char *key_a, *key_b; - GtkOrdering result; + int result; /* FIXME: use sortkeys for these */ key_a = get_type_information (impl, (GFileInfo *)a); @@ -7065,7 +7065,7 @@ type_sort_func (gconstpointer a, return result; } -static GtkOrdering +static int time_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) @@ -7094,12 +7094,12 @@ time_sort_func (gconstpointer a, return GTK_ORDERING_EQUAL; } -static GtkOrdering +static int recent_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) { - GtkOrdering result; + int result; result = time_sort_func (a, b, user_data); @@ -7116,12 +7116,12 @@ recent_sort_func (gconstpointer a, return result; } -static GtkOrdering +static int search_sort_func (gconstpointer a, gconstpointer b, gpointer user_data) { - GtkOrdering result; + int result; result = location_sort_func (a, b, user_data); From 2646785e4ca040f1f942c56f817f87009b6e79a5 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:03:13 +0200 Subject: [PATCH 15/34] build: Fix MSVC warning about non-matching types --- gdk/win32/gdkevents-win32.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 62c090d328..2a114dc4dc 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -1780,19 +1780,19 @@ gdk_event_translate (MSG *msg, { /* XXX Handle WM_QUIT here ? */ if (msg->message == WM_QUIT) - { - GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam)); - exit (msg->wParam); - } + { + GDK_NOTE (EVENTS, g_print (" %d", (int) msg->wParam)); + exit (msg->wParam); + } else if (msg->message == WM_CREATE) - { - surface = (UNALIGNED GdkSurface*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams); - GDK_SURFACE_HWND (surface) = msg->hwnd; - } + { + surface = (GdkSurface*) (((LPCREATESTRUCTW) msg->lParam)->lpCreateParams); + GDK_SURFACE_HWND (surface) = msg->hwnd; + } else - { - GDK_NOTE (EVENTS, g_print (" (no GdkSurface)")); - } + { + GDK_NOTE (EVENTS, g_print (" (no GdkSurface)")); + } return FALSE; } @@ -2302,8 +2302,8 @@ gdk_event_translate (MSG *msg, * */ if (win32_display->tablet_input_api == GDK_WIN32_TABLET_INPUT_API_WINPOINTER && - ( (msg->time - win32_display->device_manager->last_digitizer_time) < 200 || - -(msg->time - win32_display->device_manager->last_digitizer_time) < 200 )) + ((msg->time - win32_display->device_manager->last_digitizer_time) < 200 || + (win32_display->device_manager->last_digitizer_time - msg->time) < 200 )) break; win32_display->device_manager->pen_touch_input = FALSE; From be08be2fa97d225caf514a797dc3b667a35399f2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:03:50 +0200 Subject: [PATCH 16/34] renderer: Remove unneeded headers --- gsk/gskrenderer.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/gsk/gskrenderer.c b/gsk/gskrenderer.c index 45cac210f5..814bd4ed57 100644 --- a/gsk/gskrenderer.c +++ b/gsk/gskrenderer.c @@ -53,25 +53,12 @@ #include #include "gdk/gdkdebugprivate.h" -#ifdef GDK_WINDOWING_X11 -#include -#endif #ifdef GDK_WINDOWING_WAYLAND #include #endif #ifdef GDK_WINDOWING_BROADWAY #include "broadway/gskbroadwayrenderer.h" #endif -#ifdef GDK_WINDOWING_MACOS -#include -#endif -#ifdef GDK_WINDOWING_WIN32 -#include - -/* Remove these lines when OpenGL/ES 2.0 shader is ready */ -#include "win32/gdkprivate-win32.h" -#include "win32/gdkdisplay-win32.h" -#endif typedef struct { From 67a34ac1d28c63dde43fbb233035ac4208cc8abe Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:04:15 +0200 Subject: [PATCH 17/34] build: Fix MSVC warning about type mismatch G_STRUCT_OFFSET() returns a long. long is a 32bit type on 64bit Windows. Casting int to pointer of different size causes a warning. --- gsk/gl/gskglcommandqueue.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gsk/gl/gskglcommandqueue.c b/gsk/gl/gskglcommandqueue.c index 4421cf02a0..ae4ee16686 100644 --- a/gsk/gl/gskglcommandqueue.c +++ b/gsk/gl/gskglcommandqueue.c @@ -1087,25 +1087,25 @@ gsk_gl_command_queue_execute (GskGLCommandQueue *self, glEnableVertexAttribArray (0); glVertexAttribPointer (0, 2, GL_FLOAT, GL_FALSE, sizeof (GskGLDrawVertex), - (void *) G_STRUCT_OFFSET (GskGLDrawVertex, position)); + GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, position))); /* 1 = texture coord location */ glEnableVertexAttribArray (1); glVertexAttribPointer (1, 2, GL_FLOAT, GL_FALSE, sizeof (GskGLDrawVertex), - (void *) G_STRUCT_OFFSET (GskGLDrawVertex, uv)); + GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, uv))); /* 2 = color location */ glEnableVertexAttribArray (2); glVertexAttribPointer (2, 4, GL_HALF_FLOAT, GL_FALSE, sizeof (GskGLDrawVertex), - (void *) G_STRUCT_OFFSET (GskGLDrawVertex, color)); + GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, color))); /* 3 = color2 location */ glEnableVertexAttribArray (3); glVertexAttribPointer (3, 4, GL_HALF_FLOAT, GL_FALSE, sizeof (GskGLDrawVertex), - (void *) G_STRUCT_OFFSET (GskGLDrawVertex, color2)); + GSIZE_TO_POINTER ((gsize) G_STRUCT_OFFSET (GskGLDrawVertex, color2))); /* Setup initial scissor clip */ if (scissor != NULL && cairo_region_num_rectangles (scissor) > 0) From 19e1eee05ac89a9a546bf044e519f1e06f7221c4 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:05:47 +0200 Subject: [PATCH 18/34] treeview: Fix MSVC warning This code was unnecessary. --- gtk/gtktextbtree.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/gtk/gtktextbtree.c b/gtk/gtktextbtree.c index ceb8c715a9..d3d9f0c074 100644 --- a/gtk/gtktextbtree.c +++ b/gtk/gtktextbtree.c @@ -1606,9 +1606,6 @@ _gtk_text_btree_remove_view (GtkTextBTree *tree, gtk_text_btree_node_remove_view (view, tree->root_node, view_id); - view->layout = (gpointer) 0xdeadbeef; - view->view_id = (gpointer) 0xdeadbeef; - g_free (view); } From 9e38c628f2e9edbd1ce29f25748f8c1350db0d12 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:06:14 +0200 Subject: [PATCH 19/34] roundedbox: Fix shadowed name of Windows API Arc() is a GDI function that draws an arc: https://learn.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-arc --- gtk/gtkroundedbox.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/gtk/gtkroundedbox.c b/gtk/gtkroundedbox.c index 44f8f8312c..fa8a52f8e9 100644 --- a/gtk/gtkroundedbox.c +++ b/gtk/gtkroundedbox.c @@ -31,7 +31,7 @@ typedef struct { double angle1; double angle2; gboolean negative; -} Arc; +} ArcPath; static inline guint mem_hash (gconstpointer v, int len) @@ -49,14 +49,14 @@ mem_hash (gconstpointer v, int len) } static guint -arc_path_hash (Arc *arc) +arc_path_hash (ArcPath *arc) { - return mem_hash ((gconstpointer)arc, sizeof (Arc)); + return mem_hash ((gconstpointer)arc, sizeof (ArcPath)); } static gboolean -arc_path_equal (Arc *arc1, - Arc *arc2) +arc_path_equal (ArcPath *arc1, + ArcPath *arc2) { return arc1->angle1 == arc2->angle1 && arc1->angle2 == arc2->angle2 && @@ -80,10 +80,10 @@ static void append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative) { static GHashTable *arc_path_cache; - Arc key; + ArcPath key; cairo_path_t *arc; - memset (&key, 0, sizeof (Arc)); + memset (&key, 0, sizeof (ArcPath)); key.angle1 = angle1; key.angle2 = angle2; key.negative = negative; From 225acbb12b748183e895d07d7ea6d70053592e83 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:07:46 +0200 Subject: [PATCH 20/34] build: Fix MSVC warning about casting enums and uints might have a different size, so pointers to enums and poiters to uints don't match. --- gtk/gtkapplicationaccels.c | 6 ++++-- gtk/gtkbuilderparser.c | 4 +++- gtk/gtkmountoperation.c | 6 +++--- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/gtk/gtkapplicationaccels.c b/gtk/gtkapplicationaccels.c index 8ac33f8526..4b4f3d5fe8 100644 --- a/gtk/gtkapplicationaccels.c +++ b/gtk/gtkapplicationaccels.c @@ -119,7 +119,8 @@ gtk_application_accels_set_accels_for_action (GtkApplicationAccels *accels, for (i = 0; accelerators[i]; i++) { GtkShortcutTrigger *new_trigger; - guint key, modifier; + guint key; + GdkModifierType modifier; if (!gtk_accelerator_parse (accelerators[i], &key, &modifier)) { @@ -267,7 +268,8 @@ gtk_application_accels_get_actions_for_accel (GtkApplicationAccels *accels, const char *accel) { GPtrArray *result; - guint key, modifiers; + guint key; + GdkModifierType modifiers; guint i; if (!gtk_accelerator_parse (accel, &key, &modifiers)) diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c index fb093b7b48..a216895c70 100644 --- a/gtk/gtkbuilderparser.c +++ b/gtk/gtkbuilderparser.c @@ -913,11 +913,13 @@ parse_property (ParserData *data, if (bind_flags_str) { - if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &bind_flags, error)) + guint flags; + if (!_gtk_builder_flags_from_string (G_TYPE_BINDING_FLAGS, bind_flags_str, &flags, error)) { _gtk_builder_prefix_error (data->builder, &data->ctx, error); return; } + bind_flags = flags; } gtk_buildable_parse_context_get_position (&data->ctx, &line, &col); diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index 58efb7ebe4..4429467860 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -828,7 +828,7 @@ call_password_proxy_cb (GObject *source, { _GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source); GMountOperation *op = user_data; - GMountOperationResult result; + guint result; GVariant *result_details; GVariantIter iter; const char *key; @@ -983,7 +983,7 @@ call_question_proxy_cb (GObject *source, { _GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source); GMountOperation *op = user_data; - GMountOperationResult result; + guint result; GVariant *result_details; GVariantIter iter; const char *key; @@ -1566,7 +1566,7 @@ call_processes_proxy_cb (GObject *source, { _GtkMountOperationHandler *proxy = _GTK_MOUNT_OPERATION_HANDLER (source); GMountOperation *op = user_data; - GMountOperationResult result; + guint result; GVariant *result_details; GVariantIter iter; const char *key; From 5637b3ba20ec3d4c33e096d126babbad942ece2e Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:09:43 +0200 Subject: [PATCH 21/34] gpu: Avoid duplicated name with Windows API CacheData is an enum value, see https://learn.microsoft.com/en-us/windows/win32/api/winnt/ne-winnt-processor_cache_type --- gsk/gpu/gskgpucache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gsk/gpu/gskgpucache.c b/gsk/gpu/gskgpucache.c index ab0ec4a9d6..7af5f5884e 100644 --- a/gsk/gpu/gskgpucache.c +++ b/gsk/gpu/gskgpucache.c @@ -846,7 +846,7 @@ typedef struct { guint n_items; guint n_stale; -} CacheData; +} GskGpuCacheData; static void print_cache_stats (GskGpuCache *self) @@ -860,10 +860,10 @@ print_cache_stats (GskGpuCache *self) for (cached = self->first_cached; cached != NULL; cached = cached->next) { - CacheData *cache_data = g_hash_table_lookup (classes, cached->class); + GskGpuCacheData *cache_data = g_hash_table_lookup (classes, cached->class); if (cache_data == NULL) { - cache_data = g_new0 (CacheData, 1); + cache_data = g_new0 (GskGpuCacheData, 1); g_hash_table_insert (classes, (gpointer) cached->class, cache_data); } cache_data->n_items++; @@ -892,7 +892,7 @@ print_cache_stats (GskGpuCache *self) while (g_hash_table_iter_next (&iter, &key, &value)) { const GskGpuCachedClass *class = key; - const CacheData *cache_data = value; + const GskGpuCacheData *cache_data = value; g_string_append_printf (message, "\n %s:%*s%5u (%u stale)", class->name, 12 - MIN (12, (int) strlen (class->name)), "", cache_data->n_items, cache_data->n_stale); From 4fcdcc2e50a69f92388af41b1069d2b7b7eceb51 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:43:09 +0200 Subject: [PATCH 22/34] textview: Don't overflow Both numbers are unsigned, so the result is always unsigned. (Which also means ABS() doing a < 0 check doesn't work.) And that in particular means that end - begin overflows to a very large number when begin > end. --- gtk/gtktexthistory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtktexthistory.c b/gtk/gtktexthistory.c index 732973b99d..53cab1cbb6 100644 --- a/gtk/gtktexthistory.c +++ b/gtk/gtktexthistory.c @@ -1194,7 +1194,7 @@ gtk_text_history_text_deleted (GtkTextHistory *self, action->u.delete.end = end; action->u.delete.selection.insert = self->selection.insert; action->u.delete.selection.bound = self->selection.bound; - istring_set (&action->u.delete.istr, text, len, ABS (end - begin)); + istring_set (&action->u.delete.istr, text, len, MAX (end, begin) - MIN (end, begin)); gtk_text_history_push (self, action); } From faae6f4c19a7dd072d0ae7bdcc639592dd860b55 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:49:38 +0200 Subject: [PATCH 23/34] tests: Fix file to be Unicode --- tests/testcalendar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testcalendar.c b/tests/testcalendar.c index b4edcac895..3ae4b48f40 100644 --- a/tests/testcalendar.c +++ b/tests/testcalendar.c @@ -1,6 +1,6 @@ /* example-start calendar calendar.c */ /* - * Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund + * Copyright (C) 1998 Cesar Miquel, Shawn T. Amundson, Mattias Grönlund * Copyright (C) 2000 Tony Gale * * This library is free software; you can redistribute it and/or modify From 516506e1ad56b37c976d6e1055235c1bff689b6d Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:55:48 +0200 Subject: [PATCH 24/34] inspector: Rename enum SEVERITY_ERROR is part of Windows COM error handling, see https://learn.microsoft.com/en-us/windows/win32/com/structure-of-com-error-codes --- gtk/inspector/a11yoverlay.c | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/gtk/inspector/a11yoverlay.c b/gtk/inspector/a11yoverlay.c index b22137181e..db493bd208 100644 --- a/gtk/inspector/a11yoverlay.c +++ b/gtk/inspector/a11yoverlay.c @@ -48,9 +48,9 @@ G_DEFINE_TYPE (GtkA11yOverlay, gtk_a11y_overlay, GTK_TYPE_INSPECTOR_OVERLAY) typedef enum { - SEVERITY_GOOD, - SEVERITY_RECOMMENDATION, - SEVERITY_ERROR + FIX_SEVERITY_GOOD, + FIX_SEVERITY_RECOMMENDATION, + FIX_SEVERITY_ERROR } FixSeverity; typedef enum @@ -132,7 +132,7 @@ check_accessibility_errors (GtkATContext *context, if (gtk_accessible_role_is_abstract (role)) { *hint = g_strdup_printf ("%s is an abstract role", role_name); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } /* Check for name and description */ @@ -142,12 +142,12 @@ check_accessibility_errors (GtkATContext *context, switch (gtk_accessible_role_get_naming (role)) { case GTK_ACCESSIBLE_NAME_ALLOWED: - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; case GTK_ACCESSIBLE_NAME_REQUIRED: if (label_set) { - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } else { @@ -160,18 +160,18 @@ check_accessibility_errors (GtkATContext *context, g_free (name); *hint = g_strdup_printf ("%s must have text content or label", role_name); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } else { - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } } else { *hint = g_strdup_printf ("%s must have label", role_name); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } } break; @@ -181,37 +181,37 @@ check_accessibility_errors (GtkATContext *context, { *hint = g_strdup_printf ("%s can't have label", role_name); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } else { - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } break; case GTK_ACCESSIBLE_NAME_RECOMMENDED: if (label_set) { - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } else { *hint = g_strdup_printf ("label recommended for %s", role_name); - return SEVERITY_RECOMMENDATION; + return FIX_SEVERITY_RECOMMENDATION; } break; case GTK_ACCESSIBLE_NAME_NOT_RECOMMENDED: if (!label_set) { - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } else { *hint = g_strdup_printf ("label not recommended for %s", role_name); - return SEVERITY_RECOMMENDATION; + return FIX_SEVERITY_RECOMMENDATION; } break; @@ -234,7 +234,7 @@ check_accessibility_errors (GtkATContext *context, if (!gtk_at_context_has_accessible_state (context, required_attributes[i].id)) { *hint = g_strdup_printf ("%s must have state %s", role_name, g_enum_get_value (states, required_attributes[i].id)->value_nick); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } break; @@ -242,7 +242,7 @@ check_accessibility_errors (GtkATContext *context, if (!gtk_at_context_has_accessible_property (context, required_attributes[i].id)) { *hint = g_strdup_printf ("%s must have property %s", role_name, g_enum_get_value (properties, required_attributes[i].id)->value_nick); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } break; @@ -250,7 +250,7 @@ check_accessibility_errors (GtkATContext *context, if (!gtk_at_context_has_accessible_relation (context, required_attributes[i].id)) { *hint = g_strdup_printf ("%s must have relation %s", role_name, g_enum_get_value (relations, required_attributes[i].id)->value_nick); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } break; @@ -304,10 +304,10 @@ check_accessibility_errors (GtkATContext *context, g_string_free (s, TRUE); - return SEVERITY_ERROR; + return FIX_SEVERITY_ERROR; } - return SEVERITY_GOOD; + return FIX_SEVERITY_GOOD; } static FixSeverity @@ -342,7 +342,7 @@ recurse_child_widgets (GtkA11yOverlay *self, severity = check_widget_accessibility_errors (widget, self->context, &hint); - if (severity != SEVERITY_GOOD) + if (severity != FIX_SEVERITY_GOOD) { int width, height; GdkRGBA color; @@ -350,7 +350,7 @@ recurse_child_widgets (GtkA11yOverlay *self, width = gtk_widget_get_width (widget); height = gtk_widget_get_height (widget); - if (severity == SEVERITY_ERROR) + if (severity == FIX_SEVERITY_ERROR) color = self->error_color; else color = self->recommend_color; From 5a6ea4ac864aad25d447a5011d40cbad149a6725 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:57:45 +0200 Subject: [PATCH 25/34] timsort: add ELEM_REV() for reverse-element lookup. Because our indices are always unsigned, we need to take special care to not trigger compiler warnings when doing negative array indexing. And yes, for now "0 - x" is good enough. --- gtk/timsort/gtktimsort-impl.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/gtk/timsort/gtktimsort-impl.c b/gtk/timsort/gtktimsort-impl.c index 3e60706b21..9ec8482924 100644 --- a/gtk/timsort/gtktimsort-impl.c +++ b/gtk/timsort/gtktimsort-impl.c @@ -25,6 +25,7 @@ #define INCPTR(x) ((gpointer) ((char *) (x) + WIDTH)) #define DECPTR(x) ((gpointer) ((char *) (x) - WIDTH)) #define ELEM(a, i) ((char *) (a) + (i) * WIDTH) +#define ELEM_REV(a, i) ELEM(a, 0 - (i)) #define LEN(n) ((n) * WIDTH) #define CONCAT(x, y) gtk_tim_sort_ ## x ## _ ## y @@ -296,7 +297,7 @@ gtk_tim_sort(gallop_left) (GtkTimSort *self, const gsize max_ofs = hint + 1; gsize tmp; while (ofs < max_ofs - && gtk_tim_sort_compare (self, key, ELEM (hintp, -ofs)) <= 0) + && gtk_tim_sort_compare (self, key, ELEM_REV (hintp, ofs)) <= 0) { last_ofs = ofs; ofs = (ofs << 1) + 1; /* no need to check for overflow */ @@ -363,7 +364,7 @@ gtk_tim_sort(gallop_right) (GtkTimSort *self, gsize max_ofs = hint + 1; gsize tmp; while (ofs < max_ofs - && gtk_tim_sort_compare (self, key, ELEM (hintp, -ofs)) < 0) + && gtk_tim_sort_compare (self, key, ELEM_REV (hintp, ofs)) < 0) { last_ofs = ofs; ofs = (ofs << 1) + 1; /* no need to check for overflow */ @@ -622,13 +623,13 @@ gtk_tim_sort(merge_hi) (GtkTimSort *self, cursor1 = DECPTR (cursor1); if (--len1 == 0) { - memcpy (ELEM (dest, -(len2 - 1)), tmp, LEN (len2)); /* POP: can't overlap */ + memcpy (ELEM_REV (dest, (len2 - 1)), tmp, LEN (len2)); /* POP: can't overlap */ return; } if (len2 == 1) { - dest = ELEM (dest, -len1); - cursor1 = ELEM (cursor1, -len1); + dest = ELEM_REV (dest, len1); + cursor1 = ELEM_REV (cursor1, len1); memmove (ELEM (dest, 1), ELEM (cursor1, 1), LEN (len1)); /* POP: overlaps */ /* a[dest] = tmp[cursor2]; */ ASSIGN (dest, cursor2); @@ -684,8 +685,8 @@ gtk_tim_sort(merge_hi) (GtkTimSort *self, count1 = len1 - gtk_tim_sort(gallop_right) (self, cursor2, base1, len1, len1 - 1); if (count1 != 0) { - dest = ELEM (dest, -count1); - cursor1 = ELEM (cursor1, -count1); + dest = ELEM_REV (dest, count1); + cursor1 = ELEM_REV (cursor1, count1); len1 -= count1; memmove (INCPTR (dest), INCPTR (cursor1), LEN (count1)); /* POP: might overlap */ @@ -701,8 +702,8 @@ gtk_tim_sort(merge_hi) (GtkTimSort *self, count2 = len2 - gtk_tim_sort(gallop_left) (self, cursor1, tmp, len2, len2 - 1); if (count2 != 0) { - dest = ELEM (dest, -count2); - cursor2 = ELEM (cursor2, -count2); + dest = ELEM_REV (dest, count2); + cursor2 = ELEM_REV (cursor2, count2); len2 -= count2; memcpy (INCPTR (dest), INCPTR (cursor2), LEN (count2)); /* POP: can't overlap */ if (len2 <= 1) /* len2 == 1 || len2 == 0 */ @@ -725,8 +726,8 @@ outer: if (len2 == 1) { g_assert (len1 > 0); - dest = ELEM (dest, -len1); - cursor1 = ELEM (cursor1, -len1); + dest = ELEM_REV (dest, len1); + cursor1 = ELEM_REV (cursor1, len1); memmove (INCPTR (dest), INCPTR (cursor1), LEN (len1)); /* POP: might overlap */ /* a[dest] = tmp[cursor2]; // Move first elt of run2 to front of merge */ ASSIGN (dest, cursor2); @@ -740,7 +741,7 @@ outer: { g_assert (len1 == 0); g_assert (len2 > 0); - memcpy (ELEM (dest, -(len2 - 1)), tmp, LEN (len2)); /* POP: can't overlap */ + memcpy (ELEM_REV (dest, (len2 - 1)), tmp, LEN (len2)); /* POP: can't overlap */ } } @@ -802,7 +803,7 @@ gtk_tim_sort(merge_at) (GtkTimSort *self, gtk_tim_sort(merge_lo) (self, base1, self->max_merge_size, base2, len2); gtk_tim_sort_set_change (out_change, base1, self->max_merge_size + len2); self->run[i].len -= self->max_merge_size; - self->run[i + 1].base = ELEM (self->run[i + 1].base, - self->max_merge_size); + self->run[i + 1].base = ELEM_REV (self->run[i + 1].base, self->max_merge_size); self->run[i + 1].len += self->max_merge_size; g_assert (ELEM (self->run[i].base, self->run[i].len) == self->run[i + 1].base); return; From 4f3ebb9e9ff25fcc3e02b3994bc22672c379b369 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 06:59:41 +0200 Subject: [PATCH 26/34] shortcutssection: Fix MSVC warning ... and simplify what's actually going on. ABS (n_rows - n) < ABS ((n_rows - height) - (n + height)) Those values are all unsigned, so this is equivalent to n_rows - n < (n_rows - height) - (n + height) The math on the right is confusing but can be rearranged: n_rows - n < n_rows - n - 2 * height With x = n_rows - n, this simplifies to: x < x - 2 * height Which is only true if it underflows, ie if x < 2 * height Resubstituting the old values gives: n_rows - n < 2 * height Which is the value I used. --- gtk/gtkshortcutssection.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkshortcutssection.c b/gtk/gtkshortcutssection.c index df7ebf89d3..58a76032ca 100644 --- a/gtk/gtkshortcutssection.c +++ b/gtk/gtkshortcutssection.c @@ -714,7 +714,7 @@ gtk_shortcuts_section_reflow_groups (GtkShortcutsSection *self) if (n_rows - height == 0) break; - if (ABS (n_rows - n) < ABS ((n_rows - height) - (n + height))) + if (n_rows - n < 2 * height) break; n_rows -= height; From ea3aad28487c4168c4e14759d00fca40e5364f89 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:15:05 +0200 Subject: [PATCH 27/34] inspector: Don't shadow connect(2) --- gtk/inspector/actions.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk/inspector/actions.c b/gtk/inspector/actions.c index 3f2a2183a2..6823b59597 100644 --- a/gtk/inspector/actions.c +++ b/gtk/inspector/actions.c @@ -463,7 +463,7 @@ gtk_inspector_actions_observer_iface_init (GtkActionObserverInterface *iface) } static void -connect (GtkInspectorActions *sl) +gtk_inspector_actions_connect (GtkInspectorActions *sl) { if (G_IS_ACTION_GROUP (sl->object)) { @@ -494,7 +494,7 @@ connect (GtkInspectorActions *sl) } static void -disconnect (GtkInspectorActions *sl) +gtk_inspector_actions_disconnect (GtkInspectorActions *sl) { if (G_IS_ACTION_GROUP (sl->object)) { @@ -533,7 +533,7 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl, gtk_stack_page_set_visible (page, FALSE); if (sl->object) - disconnect (sl); + gtk_inspector_actions_disconnect (sl); g_set_object (&sl->object, object); @@ -542,7 +542,7 @@ gtk_inspector_actions_set_object (GtkInspectorActions *sl, gtk_stack_page_set_visible (page, loaded); if (sl->object) - connect (sl); + gtk_inspector_actions_connect (sl); } static void @@ -623,7 +623,7 @@ dispose (GObject *object) GtkInspectorActions *sl = GTK_INSPECTOR_ACTIONS (object); if (sl->object) - disconnect (sl); + gtk_inspector_actions_disconnect (sl); g_clear_object (&sl->sorted); g_clear_object (&sl->actions); From 9a59fce10615feac55fba85ad0b04dff1ed5c844 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:15:25 +0200 Subject: [PATCH 28/34] treerbtree: Fix MSVC compiler warnings the simplest way It's deprecated code after all. --- gtk/deprecated/gtktreerbtree.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/gtk/deprecated/gtktreerbtree.c b/gtk/deprecated/gtktreerbtree.c index 06062ed159..9cfbdd8561 100644 --- a/gtk/deprecated/gtktreerbtree.c +++ b/gtk/deprecated/gtktreerbtree.c @@ -75,16 +75,6 @@ gtk_tree_rbnode_new (GtkTreeRBTree *tree, static void gtk_tree_rbnode_free (GtkTreeRBNode *node) { - if (GTK_DEBUG_CHECK (TREE)) - { - node->left = (gpointer) 0xdeadbeef; - node->right = (gpointer) 0xdeadbeef; - node->parent = (gpointer) 0xdeadbeef; - node->total_count = 56789; - node->offset = 56789; - node->count = 56789; - node->flags = 0; - } g_slice_free (GtkTreeRBNode, node); } @@ -1178,7 +1168,7 @@ gtk_tree_rbtree_remove_node (GtkTreeRBTree *tree, /* We need to clean up the validity of the tree. */ - gtk_rbnode_adjust (tree, y, -1, -y_total_count, -y_height); + gtk_rbnode_adjust (tree, y, -1, -(int) y_total_count, -y_height); if (GTK_TREE_RBNODE_GET_COLOR (y) == GTK_TREE_RBNODE_BLACK) gtk_tree_rbtree_remove_node_fixup (tree, x, y->parent); From a74457697e46498f9980bafe50ac4711bbb85636 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:21:03 +0200 Subject: [PATCH 29/34] build: Fix MSVC warning due to Pango bug Pango unconditionally defines STRICT, which we use, see https://learn.microsoft.com/en-us/windows/win32/winprog/enabling-strict And that causes a duplicate definition, so we undefined it before including the offending Pango header. See also https://gitlab.gnome.org/GNOME/pango/-/merge_requests/749 --- gdk/win32/gdkwin32misc.c | 1 + gsk/gskrendernodeparser.c | 1 + gtk/gtkimcontextime.c | 1 + 3 files changed, 3 insertions(+) diff --git a/gdk/win32/gdkwin32misc.c b/gdk/win32/gdkwin32misc.c index c8ede75061..4b7d087813 100644 --- a/gdk/win32/gdkwin32misc.c +++ b/gdk/win32/gdkwin32misc.c @@ -27,6 +27,7 @@ #include "gdkprivate-win32.h" #include "gdkdisplay-win32.h" +#undef STRICT #include struct _GdkWin32ALPNSink diff --git a/gsk/gskrendernodeparser.c b/gsk/gskrendernodeparser.c index ea3541fffa..12d7fcfcd0 100644 --- a/gsk/gskrendernodeparser.c +++ b/gsk/gskrendernodeparser.c @@ -56,6 +56,7 @@ #include #endif #ifdef HAVE_PANGOWIN32 +#undef STRICT #include #endif diff --git a/gtk/gtkimcontextime.c b/gtk/gtkimcontextime.c index 50eea0fe7e..9004948e4f 100644 --- a/gtk/gtkimcontextime.c +++ b/gtk/gtkimcontextime.c @@ -40,6 +40,7 @@ #include "gtk/deprecated/gtkstylecontextprivate.h" #include "gtkwidgetprivate.h" +#undef STRICT #include /* Determines what happens when focus is lost while preedit is in process. */ From a68f1d61552548195c70e4d9068bcf2462dc8daa Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:22:48 +0200 Subject: [PATCH 30/34] testsuite: Fix MSVC warnings ints/longs have a different size to pointers on Windows 64bit. And casts from int to pointer of diferent size cause a warning. --- testsuite/gtk/object.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/testsuite/gtk/object.c b/testsuite/gtk/object.c index 96e9daa9cf..1dd841af0c 100644 --- a/testsuite/gtk/object.c +++ b/testsuite/gtk/object.c @@ -40,7 +40,7 @@ __dvalue == 0.5 ? "medium" : \ __dvalue > 0 && __dvalue < 1 ? "fractional" : \ "random") -#define MATCH_ANY_VALUE ((void*) 0xf1874c23) +#define MATCH_ANY_VALUE ((void*) (gsize) 0xf1874c23) /* --- ignored property names --- */ typedef struct { @@ -54,19 +54,19 @@ list_ignore_properties (gboolean buglist) /* currently untestable properties */ static const IgnoreProperty ignore_properties[] = { { "GtkWidget", "parent", NULL, }, /* needs working parent widget */ - { "GtkWidget", "has-default", (void*) TRUE, }, /* conflicts with toplevel-less widgets */ - { "GtkWidget", "display", (void*) MATCH_ANY_VALUE }, + { "GtkWidget", "has-default", (void*) (gsize) TRUE, }, /* conflicts with toplevel-less widgets */ + { "GtkWidget", "display", (void*) (gsize) MATCH_ANY_VALUE }, { "GtkCellView", "background", (void*) "", }, /* "" is not a valid background color */ { "GtkFileChooserWidget", "select-multiple", (void*) 0x1 }, /* property conflicts */ - { "GtkFileChooserDialog", "select-multiple", (void*) MATCH_ANY_VALUE }, /* property disabled */ - { "GtkTextView", "overwrite", (void*) MATCH_ANY_VALUE }, /* needs text buffer */ - { "GtkTreeView", "expander-column", (void*) MATCH_ANY_VALUE }, /* assertion list != NULL */ - { "GtkWindow", "display", (void*) MATCH_ANY_VALUE }, + { "GtkFileChooserDialog", "select-multiple", (void*) (gsize) MATCH_ANY_VALUE }, /* property disabled */ + { "GtkTextView", "overwrite", (void*) (gsize) MATCH_ANY_VALUE }, /* needs text buffer */ + { "GtkTreeView", "expander-column", (void*) (gsize) MATCH_ANY_VALUE }, /* assertion list != NULL */ + { "GtkWindow", "display", (void*) (gsize) MATCH_ANY_VALUE }, { NULL, NULL, NULL } }; /* properties suspected to be Gdk/Gtk+ bugs */ static const IgnoreProperty bug_properties[] = { - { "GtkComboBox", "active", (void*) MATCH_ANY_VALUE }, /* FIXME: triggers NULL model bug */ + { "GtkComboBox", "active", (void*) (gsize) MATCH_ANY_VALUE }, /* FIXME: triggers NULL model bug */ { NULL, NULL, NULL } }; if (buglist) From 7aa8afa9d7ccce21bbead9e558c68d2a5aa2c4f3 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:24:24 +0200 Subject: [PATCH 31/34] build: Disable MSVC warnings Those 2 warnings happen with legitimate usage, so we don't want to see them. In particular not when using "-Werror" (or the MSVC equivalent "/WX") --- meson.build | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/meson.build b/meson.build index 5804bbfa52..8dc5d9628b 100644 --- a/meson.build +++ b/meson.build @@ -267,6 +267,14 @@ if cc.get_id() == 'msvc' '-D_USE_MATH_DEFINES', required_debug_cflags ] + # Extra warning flags and those that should be disabled because they are too common or + # break features. + test_cflags += [ + '/wd4068', # unknown pragma, triggers for all gcc/clang pragmas + '/wd4116', # breaks G_ALIGNOF() + '/wd4090', # VC2017 is way too aggressive with this + ] + msvc_supported_cflags = cc.get_supported_arguments(test_cflags) if debug required_cflags += required_debug_cflags @@ -339,6 +347,7 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang' 'write-strings', ] + if get_option('buildtype').startswith('debug') foreach warning: extra_warnings test_cflags += '-Werror=@0@'.format(warning) @@ -503,6 +512,7 @@ cdata.set('HAVE_HARFBUZZ', harfbuzz_dep.found()) cdata.set('HAVE_PANGOFT', pangoft_dep.found()) if win32_enabled cdata.set('HAVE_PANGOWIN32', pangowin32_dep.found()) + cdata.set('CONST_VTABLE', 1) endif wayland_pkgs = [] From 07a5f75fe4b25b855cf8f5150875d07853bcdf29 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 09:09:37 +0200 Subject: [PATCH 32/34] gpu: Make definition match declaration --- gsk/gpu/gskgpuuploadop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gsk/gpu/gskgpuuploadop.c b/gsk/gpu/gskgpuuploadop.c index df2ea0a3a6..030fb5f174 100644 --- a/gsk/gpu/gskgpuuploadop.c +++ b/gsk/gpu/gskgpuuploadop.c @@ -665,7 +665,7 @@ void gsk_gpu_upload_glyph_op (GskGpuFrame *frame, GskGpuImage *image, PangoFont *font, - const PangoGlyph glyph, + PangoGlyph glyph, const cairo_rectangle_int_t *area, const graphene_point_t *origin) { From e6cfc5e3cd1056a4f58fa93b7a2c932ac7a20709 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 18:03:59 +0200 Subject: [PATCH 33/34] CI: Add pcre2 to disabled werrors --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0bfbd713fe..8b4e3f09b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ stages: # Common variables variables: - COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false" + COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpcre2:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false" BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true" FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true -Dintrospection=enabled" MESON_TEST_TIMEOUT_MULTIPLIER: 3 From 62b1ef9f72d39d2e5e7e4e96f66792d64f174940 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Mon, 21 Oct 2024 07:32:42 +0200 Subject: [PATCH 34/34] CI: Enable -Werror in MSVC build --- .gitlab-ci.yml | 2 +- .gitlab-ci/test-msvc.bat | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8b4e3f09b2..f25044c116 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -274,7 +274,7 @@ vs2017-x64: - win32-ps needs: [] script: - - .gitlab-ci/test-msvc.bat + - .gitlab-ci/test-msvc.bat ${COMMON_MESON_FLAGS} artifacts: when: always paths: diff --git a/.gitlab-ci/test-msvc.bat b/.gitlab-ci/test-msvc.bat index 4d54a0881a..f8c20a254f 100644 --- a/.gitlab-ci/test-msvc.bat +++ b/.gitlab-ci/test-msvc.bat @@ -4,9 +4,8 @@ call "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64 @echo on -:: FIXME: make warnings fatal pip3 install --upgrade --user meson~=1.2 || goto :error -meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled _build || goto :error +meson setup -Dbackend_max_links=1 -Ddebug=false -Dmedia-gstreamer=disabled -Dvulkan=disabled %~1 _build || goto :error ninja -C _build || goto :error goto :EOF