diff options
author | Vsevolod Kukol <sevoku@microsoft.com> | 2021-03-08 19:23:36 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-08 19:23:36 +0300 |
commit | de4f209c5c6f9034a3c9691f8271d9db159441e3 (patch) | |
tree | d6216174a7e163fff8027dcc2fe3fd6463f70558 | |
parent | a98a02bc82384c27e7b2f138e660de52c75a6e16 (diff) |
[Gtk] Fix a crash when tooltip query runs right after a native window has been released (#168)
-rw-r--r-- | packages/gtk+.py | 3 | ||||
-rw-r--r-- | packages/patches/gtk/gdk-quartz-Remove-titlebar-handling-from-find_child.patch | 94 |
2 files changed, 96 insertions, 1 deletions
diff --git a/packages/gtk+.py b/packages/gtk+.py index 23b7820..cec45bd 100644 --- a/packages/gtk+.py +++ b/packages/gtk+.py @@ -234,7 +234,8 @@ class GtkPackage (GitHubPackage): 'patches/gtk/Fix-1080409-StackOverflow-exception-opening-Gtk-host.patch', # https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1092021/ - 'patches/gtk/0078-Optimize-querying-symbolic-hotkeys.patch' + 'patches/gtk/0078-Optimize-querying-symbolic-hotkeys.patch', + 'patches/gtk/gdk-quartz-Remove-titlebar-handling-from-find_child.patch' ]) def prep(self): diff --git a/packages/patches/gtk/gdk-quartz-Remove-titlebar-handling-from-find_child.patch b/packages/patches/gtk/gdk-quartz-Remove-titlebar-handling-from-find_child.patch new file mode 100644 index 0000000..06b941f --- /dev/null +++ b/packages/patches/gtk/gdk-quartz-Remove-titlebar-handling-from-find_child.patch @@ -0,0 +1,94 @@ +From dc7a4906b15e3896bdac641730ac8e85dd90be24 Mon Sep 17 00:00:00 2001 +From: Vsevolod Kukol <sevo@xamarin.com> +Date: Sun, 7 Mar 2021 21:07:30 +0100 +Subject: [PATCH] gdk: quartz: Remove titlebar handling from + find_child_window_helper + +Being run on Idle to handle tooltips this can crash if the +NSWindow has been released in between. +With https://github.com/GNOME/gtk/commit/f91b42983937c94a2875af3498fa2ea6078ec58d +this should not be necessary anymore and can be removed. +--- + gdk/quartz/gdkevents-quartz.c | 23 +++++++++++++++++++++++ + gdk/quartz/gdkwindow-quartz.c | 31 ------------------------------- + 2 files changed, 23 insertions(+), 31 deletions(-) + +diff --git a/gdk/quartz/gdkevents-quartz.c b/gdk/quartz/gdkevents-quartz.c +index 24d5094a4e..4e75aaf102 100644 +--- a/gdk/quartz/gdkevents-quartz.c ++++ b/gdk/quartz/gdkevents-quartz.c +@@ -567,6 +567,29 @@ get_toplevel_from_ns_event (NSEvent *nsevent, + * here, not very nice. + */ + _gdk_quartz_events_break_all_grabs (get_time_from_ns_event (nsevent)); ++ ++ /* Check if the event occurred on the titlebar. If it did, ++ * explicitly return NULL to prevent going through the ++ * fallback path, which could match the window that is ++ * directly under the titlebar. ++ */ ++ if (view_point.y < 0 && ++ view_point.x >= view_frame.origin.x && ++ view_point.x < view_frame.origin.x + view_frame.size.width) ++ { ++ NSView *superview = [view superview]; ++ if (superview) ++ { ++ NSRect superview_frame = [superview frame]; ++ int titlebar_height = superview_frame.size.height - ++ view_frame.size.height; ++ ++ if (titlebar_height > 0 && view_point.y >= -titlebar_height) ++ { ++ return NULL; ++ } ++ } ++ } + } + else + { +diff --git a/gdk/quartz/gdkwindow-quartz.c b/gdk/quartz/gdkwindow-quartz.c +index cd5cc26415..12ebc9cc26 100644 +--- a/gdk/quartz/gdkwindow-quartz.c ++++ b/gdk/quartz/gdkwindow-quartz.c +@@ -757,37 +757,6 @@ find_child_window_helper (GdkWindow *window, + temp_x = x_offset + child_private->x; + temp_y = y_offset + child_private->y; + +- /* Special-case the root window. We have to include the title +- * bar in the checks, otherwise the window below the title bar +- * will be found i.e. events punch through. (If we can find a +- * better way to deal with the events in gdkevents-quartz, this +- * might not be needed.) +- */ +- if (window == _gdk_root) +- { +- NSRect frame = NSMakeRect (0, 0, 100, 100); +- NSRect content; +- NSUInteger mask; +- int titlebar_height; +- +- mask = [child_impl->toplevel styleMask]; +- +- /* Get the title bar height. */ +- content = [NSWindow contentRectForFrameRect:frame +- styleMask:mask]; +- titlebar_height = frame.size.height - content.size.height; +- +- if (titlebar_height > 0 && +- x >= temp_x && y >= temp_y - titlebar_height && +- x < temp_x + child_private->width && y < temp_y) +- { +- /* The root means "unknown" i.e. a window not managed by +- * GDK. +- */ +- return (GdkWindow *)_gdk_root; +- } +- } +- + if (x >= temp_x && y >= temp_y && + x < temp_x + child_private->width && y < temp_y + child_private->height) + { +-- +2.21.1 (Apple Git-122.3) + |