After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 658325 - gnome-shell ViewSelector does not accept to commit the strings from input method
gnome-shell ViewSelector does not accept to commit the strings from input method
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: st
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
: 669080 676949 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2011-09-06 07:17 UTC by Takao Fujiwara
Modified: 2012-11-25 16:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for st-im-text.c (3.07 KB, patch)
2011-09-06 07:19 UTC, Takao Fujiwara
needs-work Details | Review
Patch for st-im-text.c (6.52 KB, patch)
2011-10-06 09:38 UTC, Takao Fujiwara
none Details | Review
st-im-text: install additional "activate" key bindings for search providers (6.87 KB, patch)
2012-08-30 07:53 UTC, Daiki Ueno
none Details | Review
Use connect_after() for entries' key-press-event signals (6.01 KB, patch)
2012-08-31 03:02 UTC, Rui Matos
none Details | Review
st-im-text: Replace key-* handler with captured-event (3.75 KB, patch)
2012-09-12 15:59 UTC, Florian Müllner
accepted-commit_now Details | Review
st-im-text: Replace key-* handler with captured-event (3.90 KB, patch)
2012-09-12 16:48 UTC, Florian Müllner
committed Details | Review

Description Takao Fujiwara 2011-09-06 07:17:20 UTC
When input method is open on gnome-shell ViewSelector text entry and try to type some chars and Enter key with input method, ViewSelector always starts to search the string but the Enter key is expected to commit the string to the text entry.

My idea is to add a wrapper for gtk_im_context_filter_keypress() in StIMText to fix this problem so that js codes can check input method.
Comment 1 Takao Fujiwara 2011-09-06 07:19:17 UTC
Created attachment 195755 [details] [review]
Patch for st-im-text.c

I attached the patch.
Comment 2 Owen Taylor 2011-09-12 16:28:14 UTC
Review of attachment 195755 [details] [review]:

I'd like to see an 'activate' signal added to StEntry signal that is internally hooked up to do the right thing rather than this.
Comment 3 Takao Fujiwara 2011-10-06 09:38:02 UTC
Created attachment 198417 [details] [review]
Patch for st-im-text.c

Revised the patch.

(In reply to comment #2)
> Review of attachment 195755 [details] [review]:
> 
> I'd like to see an 'activate' signal added to StEntry signal that is internally
> hooked up to do the right thing rather than this.

OK, I added 'activate' signal but didn't use clutter_binding_pool_install_action() in StEntry against ClutterText because the previous change seems to check Control + Enter key:
http://git.gnome.org/browse/gnome-shell/commit/?id=203dedfb3ab216ee4bcd5d3a7e158cc9506410ca

I think StEntry needs st_im_text_filter_keypress() because StIMText.priv->im_context and StIMText.priv->need_im_reset are private members in StIMText.
Maybe we would need the similar API in GtkEntry in GTK3.
Comment 4 Takao Fujiwara 2011-11-29 04:29:21 UTC
What about the patch?
Comment 5 Weng Xuetian 2012-05-16 07:14:19 UTC
I don't think this is the right way to patch, since it's more like hack and only take "Enter" into account, actually this should be take as the exact same issue as this: https://bugzilla.gnome.org/show_bug.cgi?id=90082 (Though with clutter there seems need to be something different.)
Comment 6 Milan Bouchet-Valat 2012-05-16 09:27:22 UTC
*** Bug 669080 has been marked as a duplicate of this bug. ***
Comment 7 André Klapper 2012-05-28 08:51:20 UTC
*** Bug 676949 has been marked as a duplicate of this bug. ***
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-06-01 11:31:38 UTC
Given that native IBus integration is happening, I don't think we want this anymore.
Comment 9 Bastien Nocera 2012-06-01 11:53:33 UTC
Still needed.
Comment 10 André Klapper 2012-08-13 13:30:46 UTC
So could a gnome-shell maintainer review the patch here?
Comment 11 Daiki Ueno 2012-08-30 07:42:53 UTC
Review of attachment 198417 [details] [review]:

I'm not a gnome-shell maintainer but fwiw.

This patch no longer applies cleanly to the latest git master.
I personally think it has unnecessary complicated code and should be rewritten.

::: js/ui/viewSelector.js
@@ +148,1 @@
                 return true;

"activate" signal does not have return value.

::: src/st/st-entry.c
@@ +84,3 @@
   PRIMARY_ICON_CLICKED,
   SECONDARY_ICON_CLICKED,
+  ACTIVATE,

Why do you want to extend StEntry instead of StIMText?  StEntry's "text" property is visible from JS and you can directly connect to the "activate" signal of that.

@@ +466,3 @@
+  /* We do not use clutter_binding_pool_find but check keyval directly
+   * because the receivers might want to connect 'activate' signal
+   * with/without any modifiers. */

Why not install custom binding pool and chain up to "key-press-event" handler of ClutterText?  That will help a little not to scatter IM handling code in various places.

::: src/st/st-im-text.c
@@ +447,2 @@
 /**
+ * st_im_text_filter_keypress:

I don't think this is necessary atm, as long as only Control modifier is needed.
Comment 12 Daiki Ueno 2012-08-30 07:53:52 UTC
Created attachment 222913 [details] [review]
st-im-text: install additional "activate" key bindings for search providers

Use "activate" signal instead of "key-press-event" to activate search.
Since some search providers require Control modifier to change
the behavior, install custom keybindings for "activate" in StIMText.
Comment 13 Rui Matos 2012-08-31 03:01:40 UTC
Review of attachment 222913 [details] [review]:

I don't like it much that this adds even more special cases.
Comment 14 Rui Matos 2012-08-31 03:02:38 UTC
Created attachment 223015 [details] [review]
Use connect_after() for entries' key-press-event signals

This way we don't unnecessarily override default behavior. In
particular input methods' key processing now has a chance to deal with
important keys for its operation like Return/Enter, Up, Down or Tab.

Unmodified Return/Enter needs to be treated differently though since
ClutterText processes those by default and thus they are not available
on connect_after(). But it emits the 'activate' signal which we can
use instead.

--

What about this instead?
Comment 15 Takao Fujiwara 2012-08-31 03:58:20 UTC
We expect input method gets the key events at first. Currently ibus also uses key snooper.
I'd think it would be great if the application handler could use connect_after() and input method would use connect() instead.
Comment 16 Daiki Ueno 2012-08-31 05:43:12 UTC
(In reply to comment #14)
> Unmodified Return/Enter needs to be treated differently though since
> ClutterText processes those by default and thus they are not available
> on connect_after(). But it emits the 'activate' signal which we can
> use instead.

The patch, if it works, looks ok to me as a short-term workaround, but it looks a bit unfortunate that the actual handler code copied among "key-press-event" and "activate" handlers.  I'd suggest to add a comment explaining why, to avoid any confusion in the future.

(In reply to comment #13)
> Review of attachment 222913 [details] [review]:
> 
> I don't like it much that this adds even more special cases.

If you mean the code manually installing the keybindings in st-im-text.c by "special cases", I could think of moving it to CSS (like GTK3), that would be a long-term solution though.
Comment 17 Rui Matos 2012-08-31 14:45:41 UTC
(In reply to comment #16)
> (In reply to comment #14)
> > Unmodified Return/Enter needs to be treated differently though since
> > ClutterText processes those by default and thus they are not available
> > on connect_after(). But it emits the 'activate' signal which we can
> > use instead.
> 
> The patch, if it works, looks ok to me as a short-term workaround, but it looks
> a bit unfortunate that the actual handler code copied among "key-press-event"
> and "activate" handlers.  I'd suggest to add a comment explaining why, to avoid
> any confusion in the future.

It is unfortunate but since ClutterText already does its own processing of unmodified Return/Enter we can't do much better. Well, and this is only an issue because for these specific entries we want to handle Ctrl+Return differently so I don't thing having specific code for a specific different case is that wrong.

> (In reply to comment #13)
> > Review of attachment 222913 [details] [review] [details]:
> > 
> > I don't like it much that this adds even more special cases.
> 
> If you mean the code manually installing the keybindings in st-im-text.c by
> "special cases",

I mean that adding more keybindings because *some* users of StIMText want to use Ctrl+Return differently doesn't look right. Next we'll have to add Shift+Return etc. And what about Up, Down, Tab, etc.?

> I could think of moving it to CSS (like GTK3), that would be a
> long-term solution though.

I don't understand this part.
Comment 18 Florian Müllner 2012-09-12 15:59:48 UTC
Created attachment 224129 [details] [review]
st-im-text: Replace key-* handler with captured-event

When using an input method like IBus, the IM is expected to process
key events before anything else. Currently this doesn't always work
as expected, as the event filtering is done in the default handlers
of the key-press and key-release events, e.g. only after other
handlers have been run.
To allow the IM to filter events earlier, move the code to a
captured-event handler instead.
Comment 19 Florian Müllner 2012-09-12 16:10:42 UTC
We clearly haven't had enough attempts to fix this issue, so here's a fourth one :-)

I have looked at the connect_after() approach, but I don't really like it either:
 - the (moderate) code duplication makes the code harder to read:

   entry.connect('key-press-event', function() {
       if (key == RETURN) {
           if (mods & CONTROL_MASK)
               doSomething(true);
          else
              doSomething(false);
       }
   });

  is easier to read IMHO than

  entry.connect('activate', function() {
      doSomething(false);  
  });
  entry.connect('key-press-event', function() {
    if (key == RETURN && mods & CONTROL_MASK)
        doSomething(true); 
 });

 - it assumes that search providers may want to treat ctrl-enter differently,
   but not activation with any other modifier (which nothing in core does, but
   extensions may as the current code allows it)

 - probably the most important one:
   having to use connect_after() instead of connect() for entries is not exactly obvious, which
   means that we will keep sneaking broken entries in :-)
   also entries in extensions are almost guaranteed to be broken (unless the extension author
  happens to use IM)
Comment 20 Rui Matos 2012-09-12 16:42:16 UTC
Review of attachment 224129 [details] [review]:

This is a better approach indeed. Ok to push with the fixes below

::: src/st/st-im-text.c
@@ +357,3 @@
 static gboolean
+st_im_text_captured_event (ClutterActor    *actor,
+                           ClutterKeyEvent *event)

This should be ClutterEvent *
Comment 21 Florian Müllner 2012-09-12 16:48:06 UTC
Created attachment 224132 [details] [review]
st-im-text: Replace key-* handler with captured-event

(Fix a compiler warning - sorry, I thought I had -Werror in my CFLAGS ...)
Comment 22 Rui Matos 2012-09-12 16:49:34 UTC
Review of attachment 224132 [details] [review]:

yup
Comment 23 Florian Müllner 2012-09-12 16:51:22 UTC
Attachment 224132 [details] pushed as 49df72c - st-im-text: Replace key-* handler with captured-event