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 694877 - Use localed to get XKB settings
Use localed to get XKB settings
Status: RESOLVED FIXED
Product: gnome-settings-daemon
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-settings-daemon-maint
gnome-settings-daemon-maint
Depends on:
Blocks:
 
 
Reported: 2013-02-28 15:57 UTC by Rui Matos
Modified: 2013-03-13 14:18 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
keyboard: Get layouts and variants from localed (7.33 KB, patch)
2013-02-28 15:57 UTC, Rui Matos
reviewed Details | Review
keyboard: Get XKB options from localed (2.38 KB, patch)
2013-02-28 15:57 UTC, Rui Matos
reviewed Details | Review
keyboard: Get layouts and variants from localed (7.71 KB, patch)
2013-03-12 17:12 UTC, Rui Matos
committed Details | Review
keyboard: Get XKB options from localed (2.67 KB, patch)
2013-03-12 17:12 UTC, Rui Matos
committed Details | Review

Description Rui Matos 2013-02-28 15:57:35 UTC
See patches.
Comment 1 Rui Matos 2013-02-28 15:57:37 UTC
Created attachment 237621 [details] [review]
keyboard: Get layouts and variants from localed

We get the current X server's XKB layouts and variants when populating
empty settings or running under GDM. This means that the g-s-d
instance running under GDM changes the X server's configuration and
thus, after a freshly created user account logs in, the new g-s-d
instance will no longer see the system's xorg.conf layouts and
variants but instead the ones that were last active in GDM due to the
way we configure XKB.

Using localed to get the system settings allows us to always get what
we actually want.
Comment 2 Rui Matos 2013-02-28 15:57:40 UTC
Created attachment 237622 [details] [review]
keyboard: Get XKB options from localed

Some users might have XKB options configured in their xorg.conf. In
case the current user's setting is empty or when running under GDM we
should honor the system options.
Comment 3 Christian Persch 2013-02-28 17:18:29 UTC
Review of attachment 237621 [details] [review]:

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +1307,3 @@
+        if (v) {
+                const gchar *s = g_variant_get_string (v, NULL);
+                if (s && *s)

The NULL check on |s| is unnecessary since g_variant_get_string *never* returns NULL.

@@ +1318,3 @@
+        if (v) {
+                const gchar *s = g_variant_get_string (v, NULL);
+                if (s && *s)

Same here.
Comment 4 Bastien Nocera 2013-03-01 11:52:39 UTC
Review of attachment 237621 [details] [review]:

Why not just avoid writing the configuration when running under GDM?
The XKB config comes from the X.org config file which are generated by localed. Furthermore, GDM's configuration should really be cleaned up for each session.
Comment 5 Bastien Nocera 2013-03-01 12:04:25 UTC
Review of attachment 237622 [details] [review]:

::: plugins/keyboard/gsd-keyboard-manager.c
@@ +1517,3 @@
+
+        options = g_settings_get_strv (settings, KEY_KEYBOARD_OPTIONS);
+        if (g_strv_length (options) < 1)

Seems that this makes it impossible to disable features that were enabled for GDM.
I would only inherit the server's/localed's x11options if we also inherited the layouts.
Comment 6 Rui Matos 2013-03-01 13:28:28 UTC
Ok, this is a bit nuanced - I got it wrong myself when I wrote this for 3.6!

I think you might be overlooking the fact that the gsettings store under GDM isn't the same as the one we then get for the user session. What does get propagated from the GDM session to the user session is the X property containing the XKB layouts/variants/options and that property is set by g-s-d when running under GDM and thus, in the user session, it will no longer be the original data that was there from the start, i.e. the xorg.conf data that the X server gets when it starts.

For example, suppose you have "us,fr,ru" as layouts in your xorg.conf. GDM's g-s-d will turn those into 3 input sources "us", "fr" and "ru". We need to do this so that the gnome-shell panel indicator actually shows up with 3 different entries.

Then it applies the first one "us" to the X server and thus the X property gets set to "us" only. Then the user's g-s-d could only create the "us" input source (for a fresh, settings-less user anyway).

Does that address both your comments?
Comment 7 Rui Matos 2013-03-12 17:12:36 UTC
Created attachment 238720 [details] [review]
keyboard: Get layouts and variants from localed

We used to get the current X server's XKB layouts and variants from
the X property when populating empty settings or running under
GDM. This means that the g-s-d instance running under GDM would then
change the X server's configuration (as a side-effect of applying the
input source) and thus, after a freshly created user account logged
in, the user session's g-s-d instance would no longer see the
system's xorg.conf layouts and variants but instead the ones that were
last active in GDM.

Using localed to get layouts and variants will allow us to always get
what we actually want i.e. the system settings.
--

Hopefully clarified the commit message.

I also squashed a fix I had locally to explicitly clear the
gsetting. Note that the previous code didn't need this since it always
started from an empty list but to make the code a bit more generic I'm
always starting from the current setting and just add stuff to it so
in the GDM path we need to explicitly clear it first.
Comment 8 Rui Matos 2013-03-12 17:12:49 UTC
Created attachment 238721 [details] [review]
keyboard: Get XKB options from localed

--
rebased
Comment 9 Bastien Nocera 2013-03-12 17:19:43 UTC
Review of attachment 238720 [details] [review]:

Looks good.
Comment 10 Bastien Nocera 2013-03-12 17:21:00 UTC
Review of attachment 238721 [details] [review]:

Looks good.
Comment 11 Rui Matos 2013-03-13 14:18:32 UTC
Attachment 238720 [details] pushed as 79b0f1b - keyboard: Get layouts and variants from localed
Attachment 238721 [details] pushed as 212fde3 - keyboard: Get XKB options from localed