From 9297439de4b5223aaa195a4431c1f1f0b00bf409 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Sat, 6 Apr 2024 10:44:02 +0200 Subject: [PATCH 1/3] GdkWin32: Remove some work arounds that are not needed anymore 2cc650ce was added to work around some of the regressions introduced by 79557271, but that commit was finally reverted in 43476c09. We can now revert 2cc650ce as well. Fixes https://gitlab.gnome.org/GNOME/gtk/-/issues/6614 --- gdk/win32/gdkevents-win32.c | 1 - gdk/win32/gdksurface-win32.c | 5 +---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index c5599f33d7..c46c1f06ad 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3081,7 +3081,6 @@ gdk_event_translate (MSG *msg, GetForegroundWindow () == GDK_SURFACE_HWND (window)) { SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner)); - SetCapture (GDK_SURFACE_HWND (impl->transient_owner)); } } diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 13bd0db1aa..1c8c4cee0b 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -4804,10 +4804,7 @@ gdk_win32_toplevel_set_property (GObject *object, GDK_SURFACE (surface)->modal_hint = g_value_get_boolean (value); if (GDK_SURFACE (surface)->modal_hint) - { - SetCapture (GDK_SURFACE_HWND (surface)); - _gdk_push_modal_window (surface); - } + _gdk_push_modal_window (surface); g_object_notify_by_pspec (G_OBJECT (surface), pspec); break; From 8a1bee1d79a9cfe43ffaebaa7815c832f96bf699 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Sat, 6 Apr 2024 10:51:53 +0200 Subject: [PATCH 2/3] GdkWin32: Don't explicitly set the transient owner as active ...when a transient child is hidden. The system does that automatically --- gdk/win32/gdkevents-win32.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/gdk/win32/gdkevents-win32.c b/gdk/win32/gdkevents-win32.c index c46c1f06ad..6465f8765f 100644 --- a/gdk/win32/gdkevents-win32.c +++ b/gdk/win32/gdkevents-win32.c @@ -3071,19 +3071,6 @@ gdk_event_translate (MSG *msg, } } - if ((windowpos->flags & SWP_HIDEWINDOW) && - !GDK_SURFACE_DESTROYED (window)) - { - /* Make transient parent the foreground window when window unmaps */ - impl = GDK_WIN32_SURFACE (window); - - if (impl->transient_owner && - GetForegroundWindow () == GDK_SURFACE_HWND (window)) - { - SetForegroundWindow (GDK_SURFACE_HWND (impl->transient_owner)); - } - } - if (!(windowpos->flags & SWP_NOCLIENTSIZE)) { if (window->resize_count > 1) From 3c94e91e5e8823ba6bb2abf3c3c0745b03112486 Mon Sep 17 00:00:00 2001 From: Luca Bacci Date: Sat, 6 Apr 2024 10:53:46 +0200 Subject: [PATCH 3/3] GdkWin32: Do not clear surface contents when restoring from minimize The code does not work anyway since we dropped WS_EX_LAYERED windows. --- gdk/win32/gdksurface-win32.c | 71 +----------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/gdk/win32/gdksurface-win32.c b/gdk/win32/gdksurface-win32.c index 1c8c4cee0b..0a4ea0abc9 100644 --- a/gdk/win32/gdksurface-win32.c +++ b/gdk/win32/gdksurface-win32.c @@ -4200,82 +4200,13 @@ BOOL WINAPI GtkShowWindow (GdkSurface *window, int cmd_show) { - cairo_t *cr; - cairo_surface_t *surface; - RECT window_rect; - HDC hdc; - POINT window_position; - SIZE window_size; - POINT source_point; - BLENDFUNCTION blender; - - HWND hwnd = GDK_SURFACE_HWND (window); GdkWin32Surface *impl = GDK_WIN32_SURFACE (window); - switch (cmd_show) - { - case SW_FORCEMINIMIZE: - case SW_HIDE: - case SW_MINIMIZE: - break; - case SW_MAXIMIZE: - case SW_RESTORE: - case SW_SHOW: - case SW_SHOWDEFAULT: - case SW_SHOWMINIMIZED: - case SW_SHOWMINNOACTIVE: - case SW_SHOWNA: - case SW_SHOWNOACTIVATE: - case SW_SHOWNORMAL: - if (IsWindowVisible (hwnd)) - break; - - /* Window was hidden, will be shown. Erase it, GDK will repaint soon, - * but not soon enough, so it's possible to see old content before - * the next redraw, unless we erase the window first. - */ - GetWindowRect (hwnd, &window_rect); - source_point.x = source_point.y = 0; - - window_position.x = window_rect.left; - window_position.y = window_rect.top; - window_size.cx = window_rect.right - window_rect.left; - window_size.cy = window_rect.bottom - window_rect.top; - - blender.BlendOp = AC_SRC_OVER; - blender.BlendFlags = 0; - blender.AlphaFormat = AC_SRC_ALPHA; - blender.SourceConstantAlpha = 255; - - /* Create a surface of appropriate size and clear it */ - surface = cairo_win32_surface_create_with_dib (CAIRO_FORMAT_ARGB32, - window_size.cx, - window_size.cy); - cairo_surface_set_device_scale (surface, impl->surface_scale, impl->surface_scale); - cr = cairo_create (surface); - cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); - cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0); - cairo_paint (cr); - cairo_destroy (cr); - cairo_surface_flush (surface); - hdc = cairo_win32_surface_get_dc (surface); - - /* No API_CALL() wrapper, don't check for errors */ - UpdateLayeredWindow (hwnd, NULL, - &window_position, &window_size, - hdc, &source_point, - 0, &blender, ULW_ALPHA); - - cairo_surface_destroy (surface); - - break; - } - /* Ensure that maximized window size is corrected later on */ if (cmd_show == SW_MAXIMIZE) impl->maximizing = TRUE; - return ShowWindow (hwnd, cmd_show); + return ShowWindow (GDK_SURFACE_HWND (window), cmd_show); } static void