From c766e31e8f680723837d6a500fdf6e82bc969a2b Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 7 Sep 2020 16:28:48 +0800 Subject: [PATCH 1/3] demos: Fix minesweeper demos on Windows Make sure the callback functions in the .ui files are exported, so that those functions can be recognized at runtime so that things run properly. --- demos/gtk-demo/listview_minesweeper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/gtk-demo/listview_minesweeper.c b/demos/gtk-demo/listview_minesweeper.c index 11ad0759be..f7f77d6231 100644 --- a/demos/gtk-demo/listview_minesweeper.c +++ b/demos/gtk-demo/listview_minesweeper.c @@ -429,7 +429,7 @@ sweeper_game_reveal_cell (SweeperGame *self, sweeper_game_check_finished (self); } -void +G_MODULE_EXPORT void minesweeper_cell_clicked_cb (GtkGridView *gridview, guint pos, SweeperGame *game) @@ -437,7 +437,7 @@ minesweeper_cell_clicked_cb (GtkGridView *gridview, sweeper_game_reveal_cell (game, pos); } -void +G_MODULE_EXPORT void minesweeper_new_game_cb (GtkButton *button, SweeperGame *game) { From 02aec7f5f40810401b7dc0ddb069585b7d707d9d Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 8 Sep 2020 16:09:46 +0800 Subject: [PATCH 2/3] gdkevents-win32.c: Clean up WM_ACTIVATE handling a bit We can group some things together, to make things a little bit more clear --- gdk/win32/gdkevents-win32.c | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index 244b0adde6..39546390a2 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3276,34 +3276,38 @@ gdk_event_translate (MSG *msg, break; } - if (LOWORD (msg->wParam) == WA_INACTIVE && msg->lParam != 0) + if (LOWORD (msg->wParam) == WA_INACTIVE) { - GdkSurface *other_surface = gdk_win32_handle_table_lookup ((HWND) msg->lParam); - if (other_surface != NULL && - (GDK_IS_POPUP (other_surface) || GDK_IS_DRAG_SURFACE (other_surface))) + if (msg->lParam != 0) { - /* We're being deactivated in favour of some popup or temp window. - * Since only toplevels can have visual focus, pretend that - * nothing happened. - */ - *ret_valp = 0; - return_val = TRUE; - break; + GdkSurface *other_surface = gdk_win32_handle_table_lookup ((HWND) msg->lParam); + if (other_surface != NULL && + (GDK_IS_POPUP (other_surface) || GDK_IS_DRAG_SURFACE (other_surface))) + { + /* We're being deactivated in favour of some popup or temp window. + * Since only toplevels can have visual focus, pretend that + * nothing happened. + */ + *ret_valp = 0; + return_val = TRUE; + break; + } } + + gdk_synthesize_surface_state (window, GDK_TOPLEVEL_STATE_FOCUSED, 0); + } + else + { + gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED); + + /* Bring any tablet contexts to the top of the overlap order when + * one of our windows is activated. + * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP + * instead + */ + _gdk_input_set_tablet_active (); } - if (LOWORD (msg->wParam) == WA_INACTIVE) - gdk_synthesize_surface_state (window, GDK_TOPLEVEL_STATE_FOCUSED, 0); - else - gdk_synthesize_surface_state (window, 0, GDK_TOPLEVEL_STATE_FOCUSED); - - /* Bring any tablet contexts to the top of the overlap order when - * one of our windows is activated. - * NOTE: It doesn't seem to work well if it is done in WM_ACTIVATEAPP - * instead - */ - if (LOWORD(msg->wParam) != WA_INACTIVE) - _gdk_input_set_tablet_active (); break; case WM_ACTIVATEAPP: From 52ba70d549fab82f6910be4e9f72b62567b06d32 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 15 Sep 2020 15:37:32 +0800 Subject: [PATCH 3/3] gdksurface-win32.c: Fix display of CSD windows Since the changes to GDK to use surface subtypes, CSD windows were broken because we did not set the window styles properly. Fix this by first acquiring whether decorations are used by the GtkWindow, and based on that result we set the decorations that we want to use accordingly and so apply them. Thanks to Matt Jakeman for investigating into the issue and providing pointers to a proposed fix. Fixes issue #3157, besides the part where window sizes are not correct since that is likely caused a separate issue. --- gdk/win32/gdksurface-win32.c | 20 +++++++++----------- gdk/win32/gdksurface-win32.h | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 05bd6a8974..69b71baf13 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -193,8 +193,6 @@ gdk_surface_win32_finalize (GObject *object) surface->hicon_small = NULL; } - g_free (surface->decorations); - if (surface->cache_surface) { cairo_surface_destroy (surface->cache_surface); @@ -1381,9 +1379,11 @@ get_effective_window_decorations (GdkSurface *window, *decoration = 0; if (!GDK_IS_TOPLEVEL (window)) - { - return FALSE; - } + return FALSE; + + /* we want to apply the "no decorations", if decorations are disabled */ + if (!GDK_WIN32_SURFACE (window)->decorate_all) + return TRUE; if ((impl->hint_flags & GDK_HINT_MIN_SIZE) && (impl->hint_flags & GDK_HINT_MAX_SIZE) && @@ -1779,8 +1779,7 @@ _gdk_win32_surface_lacks_wm_decorations (GdkSurface *window) * even though GdkWMDecoration docs indicate that 0 does NOT mean * "no decorations". */ - if (impl->decorations && - *impl->decorations == 0) + if (!impl->decorate_all) return TRUE; if (GDK_SURFACE_HWND (window) == 0) @@ -1880,6 +1879,7 @@ _gdk_win32_surface_update_style_bits (GdkSurface *window) if (get_effective_window_decorations (window, &decorations)) { all = (decorations & GDK_DECOR_ALL); + /* Keep this in sync with the test in _gdk_win32_surface_lacks_wm_decorations() */ update_single_bit (&new_style, all, decorations & GDK_DECOR_BORDER, WS_BORDER); update_single_bit (&new_style, all, decorations & GDK_DECOR_RESIZEH, WS_THICKFRAME); @@ -4829,6 +4829,7 @@ gdk_win32_toplevel_set_property (GObject *object, break; case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: + GDK_WIN32_SURFACE (surface)->decorate_all = g_value_get_boolean (value); _gdk_win32_surface_update_style_bits (surface); g_object_notify_by_pspec (G_OBJECT (surface), pspec); break; @@ -4882,10 +4883,7 @@ gdk_win32_toplevel_get_property (GObject *object, break; case LAST_PROP + GDK_TOPLEVEL_PROP_DECORATED: - { - GdkWMDecoration decorations = GDK_DECOR_ALL; - g_value_set_boolean (value, get_effective_window_decorations (surface, &decorations)); - } + g_value_set_boolean (value, GDK_WIN32_SURFACE (surface)->decorate_all); break; case LAST_PROP + GDK_TOPLEVEL_PROP_DELETABLE: diff --git a/gdk/win32/gdksurface-win32.h b/gdk/win32/gdksurface-win32.h index 603401f856..5f45eb7662 100644 --- a/gdk/win32/gdksurface-win32.h +++ b/gdk/win32/gdksurface-win32.h @@ -337,8 +337,8 @@ struct _GdkWin32Surface /* Also remember the same position, but in absolute form. */ GdkRectangle *snap_stash_int; - /* Decorations set by gdk_surface_set_decorations() or NULL if unset */ - GdkWMDecoration* decorations; + /* Enable all decorations? */ + gboolean decorate_all; /* No. of windows to force layered windows off */ guint suppress_layered;