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 695428 - Execute the second ibus input method engine.
Execute the second ibus input method engine.
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
3.10
Depends on:
Blocks:
 
 
Reported: 2013-03-08 09:12 UTC by Takao Fujiwara
Modified: 2014-11-12 20:11 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for gsd-keyboard-manager.c (3.97 KB, patch)
2013-03-08 09:16 UTC, Takao Fujiwara
needs-work Details | Review
Patch for gsd-keyboard-manager.c (4.65 KB, patch)
2013-03-11 03:11 UTC, Takao Fujiwara
none Details | Review
Patch for gsd-keyboard-manager.c (4.76 KB, patch)
2013-09-24 03:32 UTC, Takao Fujiwara
none Details | Review
Patch for ibusManager.js (2.10 KB, patch)
2014-10-31 05:46 UTC, Takao Fujiwara
needs-work Details | Review
Patch for ibusManager.js (4.41 KB, patch)
2014-11-06 08:36 UTC, Takao Fujiwara
none Details | Review
Patch for ibusManager.js (4.40 KB, patch)
2014-11-06 08:39 UTC, Takao Fujiwara
none Details | Review
Patch for ibusManager.js (4.41 KB, patch)
2014-11-07 03:36 UTC, Takao Fujiwara
needs-work Details | Review
Patch for ibusManager.js (4.55 KB, patch)
2014-11-10 10:10 UTC, Takao Fujiwara
none Details | Review
Patch for ibusManager.js (4.55 KB, patch)
2014-11-10 10:39 UTC, Takao Fujiwara
committed Details | Review

Description Takao Fujiwara 2013-03-08 09:12:47 UTC
Normally users switches an xkb engine and an input method engine.
But currently the first engine only is running. It's also good to run
the second engine at first for the typing performance.

Recently ibus was updated to fix it:
https://github.com/ibus/ibus/commit/cff35929a9330081db25a86a8258489a27d4bdd5

I think the similar fix can be applied in gnome-settings-daemon.
Comment 1 Takao Fujiwara 2013-03-08 09:16:22 UTC
Created attachment 238366 [details] [review]
Patch for gsd-keyboard-manager.c

The patch can launch the second input method too.
Comment 2 Rui Matos 2013-03-08 13:25:17 UTC
Review of attachment 238366 [details] [review]:

Thanks, this looks useful but I think it needs some further work.

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +216,3 @@
 }
 
+#ifdef HAVE_IBUS

This section of code is already inside a #ifdef HAVE_IBUS

@@ +218,3 @@
+#ifdef HAVE_IBUS
+static void
+fetch_ibus_preload_engines_result (GObject            *object,

There's nothing useful here so we can just pass NULL for the async callback below and then this isn't needed.

@@ +262,3 @@
+                                     n_sources - 1);
+                goto exit;
+        }

None of this initial part is needed as it's already checked by apply_input_sources_settings().

@@ +267,3 @@
+                if (next == current) {
+                        continue;
+                }

The rest of the code avoids braces for single line if statements.

@@ +293,3 @@
+        g_free (names[0]);
+        g_free (names[1]);
+        g_free (names);

Use g_strfreev()

@@ +349,2 @@
         apply_input_sources_settings (priv->input_sources_settings, NULL, 0, manager);
+#ifdef HAVE_IBUS

Not needed here.

@@ +349,3 @@
         apply_input_sources_settings (priv->input_sources_settings, NULL, 0, manager);
+#ifdef HAVE_IBUS
+        preload_ibus_engine (manager);

So, here's a more general comment on this. I think we should use g_timeout_add_seconds(), say with 30 seconds or something, so that we don't create needless I/O during login and slow everything down even further.
Comment 3 Takao Fujiwara 2013-03-11 03:11:46 UTC
Created attachment 238553 [details] [review]
Patch for gsd-keyboard-manager.c

OK, revised the patch.
Comment 4 Takao Fujiwara 2013-04-17 02:41:36 UTC
ibus 1.5.2 is released.
Comment 5 Takao Fujiwara 2013-08-28 04:32:58 UTC
Could you review the patch?
Comment 6 Takao Fujiwara 2013-09-24 03:32:25 UTC
Created attachment 255603 [details] [review]
Patch for gsd-keyboard-manager.c

Updated the patch for the latest HEAD.
Comment 7 Takao Fujiwara 2014-10-31 05:45:22 UTC
The code is moved to gnome-shell.
Comment 8 Takao Fujiwara 2014-10-31 05:46:56 UTC
Created attachment 289711 [details] [review]
Patch for ibusManager.js

Revised the patch.
Comment 9 Rui Matos 2014-11-04 15:30:08 UTC
Review of attachment 289711 [details] [review]:

This doesn't preload just second but all configured engines right? Please fix the commit subject and message accordingly.

::: js/misc/ibusManager.js
@@ +178,3 @@
     },
+
+    preloadEngines: function(ids, callback) {

The callback isn't being used right? We can add it later if we find that we need it.

@@ +179,3 @@
+
+    preloadEngines: function(ids, callback) {
+        if (!this._ibus.preload_engines_async)

All public methods in this class need to check that we have the IBus import loaded and that we have successfully connected to the daemon so

if (!IBus || !this._ready)
    return;

@@ +183,3 @@
+
+        this._ibus.preload_engines_async(ids, this._MAX_INPUT_SOURCE_ACTIVATION_TIME,
+                                         null, callback);

If we don't need the callback we don't need the dbus timeout either.

::: js/ui/status/keyboard.js
@@ +390,3 @@
+                break;
+            }
+        }

this._ibusManager.preloadEngines(Object.keys(this._ibusSources));
Comment 10 Rui Matos 2014-11-04 15:31:30 UTC
(In reply to comment #2)
> So, here's a more general comment on this. I think we should use
> g_timeout_add_seconds(), say with 30 seconds or something, so that we don't
> create needless I/O during login and slow everything down even further.

Oh, and this still applies.
Comment 11 Takao Fujiwara 2014-11-06 08:36:37 UTC
Created attachment 290080 [details] [review]
Patch for ibusManager.js

Updated the patch.
I added a version check function because I think IBus.Bus.preload_engines_async is not accessible in GJS without the instance.
Comment 12 Takao Fujiwara 2014-11-06 08:39:27 UTC
Created attachment 290081 [details] [review]
Patch for ibusManager.js

Fixed a typo.
Comment 13 Takao Fujiwara 2014-11-07 03:36:19 UTC
Created attachment 290132 [details] [review]
Patch for ibusManager.js

s/_MAX_PRELOAD_DELAY_TIME/_PRELOAD_ENGINES_DELAY_TIME/
Comment 14 Bastien Nocera 2014-11-07 15:42:43 UTC
"keyboard" is the component for the on-screen keyboard. Reassigning to "general" until it's triaged.
Comment 15 Rui Matos 2014-11-07 16:21:10 UTC
Review of attachment 290132 [details] [review]:

Almost there.

s/Execute/Preload/ and s/run/preload/ would be more accurate. Also, no period at the end of the subject

::: js/misc/ibusManager.js
@@ +10,3 @@
     var IBus = imports.gi.IBus;
+    if (checkVersion(1, 5, 2) < 0)
+        throw "IBus requires 1.5.2 or later";

This is a "private" function so prefix it with underscore, i.e. _checkIBusVersion()

Also, passing the minimum version like this doesn't seem very useful. I'd just write this as:

_checkIBusVersion();

then see below

@@ +21,3 @@
+function checkVersion(major, minor, micro) {
+    if (IBus.MAJOR_VERSION == major && IBus.MINOR_VERSION == minor &&
+        IBus.MICRO_VERSION == micro)

This check is pointless, the one below is enough.

@@ +27,3 @@
+        (IBus.MAJOR_VERSION == major && IBus.MINOR_VERSION > minor) ||
+        (IBus.MAJOR_VERSION == major && IBus.MINOR_VERSION == minor &&
+         IBus.MICRO_VERSION > micro))

Removing the check above means this has to be MICRO_VERSION >= micro

@@ +30,3 @@
+        return 1;
+
+    return -1;

I'd throw right here. Also, please put the minimum required version in variables and then use that to format the error message like

throw "Found IBus version %d.%d.%d but required is %d.%d.%d".format(IBus.MAJOR_VERSION, ..., ..., requiredMajor, ... , ...);

@@ +196,3 @@
     },
+
+    preloadEngines: function(ids) {

This will be called unconditionally from outside so we need to check

if (!IBus || !this._ibus) return;

@@ +203,3 @@
+
+        this._preloadEnginesId =
+            Mainloop.timeout_add(this._PRELOAD_ENGINES_DELAY_TIME,

Since this is a relatively long time that doesn't need millisecond precision, it should use timeout_add_seconds()

::: js/ui/status/keyboard.js
@@ +386,3 @@
+        // when users switch the input sources.
+        let ibusSources = Object.keys(this._ibusSources);
+        if (ibusSources.length > 0)

The IBus code seems to handle empty lists just fine so this check seems pointless. No big deal though
Comment 16 Takao Fujiwara 2014-11-10 10:10:32 UTC
Created attachment 290324 [details] [review]
Patch for ibusManager.js

Revised the patch.
Comment 17 Takao Fujiwara 2014-11-10 10:39:35 UTC
Created attachment 290326 [details] [review]
Patch for ibusManager.js

s/.$// in the commit subject.
Comment 18 Rui Matos 2014-11-12 20:10:09 UTC
Review of attachment 290326 [details] [review]:

Looks fine, thanks for the patch.

In fact, it seems I was wrong about ibus handling empty lists fine so I'm going to amend the patch before pushing. It seems the server side ibus code does handle it but the client library has this check https://github.com/ibus/ibus/blob/master/src/ibusbus.c#L2092 .