From 8407a6268b69ebf127240f5ad4372cabedb6891a Mon Sep 17 00:00:00 2001 From: John Ralls Date: Sun, 28 Dec 2014 14:54:14 -0800 Subject: [PATCH] Bug 707945 - GTK2/Quartz: 'typeahead find' in GtkTreeView no longer accepts text input Get win from the event rather than from the IMContextQuartz's client window, because it's the event window that will eventually be called on to insert the text. --- modules/input/imquartz.c | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/modules/input/imquartz.c b/modules/input/imquartz.c index 67c7d6c..b72d05f 100644 --- a/modules/input/imquartz.c +++ b/modules/input/imquartz.c @@ -194,15 +194,6 @@ quartz_filter_keypress (GtkIMContext *context, if (!qc->client_window) return FALSE; - nsview = gdk_quartz_window_get_nsview (qc->client_window); - if (GDK_IS_WINDOW (nsview)) - /* it gets GDK_WINDOW in some cases */ - return gtk_im_context_filter_keypress (qc->slave, event); - else - win = (GdkWindow *)[ (GdkQuartzView *)nsview gdkWindow]; - GTK_NOTE (MISC, g_print ("client_window: %p, win: %p, nsview: %p\n", - qc->client_window, win, nsview)); - NSEvent *nsevent = gdk_quartz_event_get_nsevent ((GdkEvent *)event); if (!nsevent) @@ -214,6 +205,22 @@ quartz_filter_keypress (GtkIMContext *context, return gtk_im_context_filter_keypress (qc->slave, event); } + nsview = gdk_quartz_window_get_nsview (qc->client_window); + if (GDK_IS_WINDOW (nsview)) + /* it gets GDK_WINDOW in some cases */ + return gtk_im_context_filter_keypress (qc->slave, event); + else + /* It's the window in the event, not the window that Gtk thinks + * has focus, that NSTextInputClient calls to insert the text, so + * we need to pass the right window to output_result in order to + * get it back. + */ + win = (GdkWindow *)[(GdkQuartzView *)[[nsevent window] contentView] gdkWindow]; + + GTK_NOTE (MISC, g_print ("client_window: %p, win: %p, nsview: %p\n", + qc->client_window, win, nsview)); + + if (event->type == GDK_KEY_RELEASE) return FALSE; @@ -226,6 +233,7 @@ quartz_filter_keypress (GtkIMContext *context, g_object_set_data (G_OBJECT (win), TIC_IN_KEY_DOWN, GUINT_TO_POINTER (TRUE)); [nsview keyDown: nsevent]; + } /* JIS_Eisu || JIS_Kana */ if (event->hardware_keycode == 102 || event->hardware_keycode == 104) -- 1.8.3.rc0