macos: Only allow keyboard focus on toplevel windows

This avoids the focus to move to a popup or popover window.
The red/yellow/green buttons remain colored.
This commit is contained in:
Arjan Molenaar 2024-08-26 13:06:12 +02:00
parent 3372b1a84b
commit aca11d6879
2 changed files with 3 additions and 3 deletions

View File

@ -250,8 +250,7 @@ typedef NSString *CALayerContentsGravity;
-(BOOL)canBecomeKeyWindow -(BOOL)canBecomeKeyWindow
{ {
return GDK_IS_TOPLEVEL (gdk_surface) || return GDK_IS_TOPLEVEL (gdk_surface);
(GDK_IS_POPUP (gdk_surface) && GDK_SURFACE (gdk_surface)->input_region != NULL);
} }
-(void)showAndMakeKey:(BOOL)makeKey -(void)showAndMakeKey:(BOOL)makeKey

View File

@ -273,7 +273,8 @@ quartz_set_client_surface (GtkIMContext *context,
if (widget != NULL) if (widget != NULL)
{ {
GtkNative *native = gtk_widget_get_native (widget); GtkRoot *root = gtk_widget_get_root (widget);
GtkNative *native = gtk_widget_get_native (GTK_WIDGET (root));
if (native != NULL) if (native != NULL)
qc->client_surface = gtk_native_get_surface (native); qc->client_surface = gtk_native_get_surface (native);