Skip to content

Work around an Ubuntu, Ibus or Qt issue regarding detecting the current keyboard layout.#14883

Merged
ronso0 merged 11 commits intomixxxdj:2.5from
daschuer:gh14838
Jun 11, 2025
Merged

Work around an Ubuntu, Ibus or Qt issue regarding detecting the current keyboard layout.#14883
ronso0 merged 11 commits intomixxxdj:2.5from
daschuer:gh14838

Conversation

@daschuer
Copy link
Copy Markdown
Member

@daschuer daschuer commented Jun 1, 2025

Since we can't wait for an upstream solution this is a workaround.
#14838 #14797

@daschuer daschuer changed the title Work around and Ubuntu, Ibus or Qt issue regarding detecting the current keyboard layout. Work around an Ubuntu, Ibus or Qt issue regarding detecting the current keyboard layout. Jun 1, 2025
@daschuer daschuer added this to the 2.5.2 milestone Jun 1, 2025
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 1, 2025

Looks like the Xfce pendant is
xfconf-query -c keyboard-layout -p /Default/XkbLayout
It will return a comma-separated list with the first item being the current layout.

I'll check if this works.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 1, 2025

Yep, this works for xfce
88fe19f

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 1, 2025

IIUC parsing the output of localectl status should also work.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 2, 2025

localectl status does not follow the gnome settings. Mixxx does.

$ localectl status
   System Locale: LANG=de_DE.UTF-8
       VC Keymap: n/a
      X11 Layout: de
       X11 Model: pc105
$ dconf read /org/gnome/desktop/input-sources/mru-sources 
[('xkb', 'us'), ('xkb', 'de')]

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 2, 2025

So GNOME settings override localectl which is still considered the default source, even on Wayland. Interesting..

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 2, 2025

Did you notice my Xfce fixup?

Yep, this works for xfce 88fe19f

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 2, 2025

Now :-)

Comment thread src/coreservices.cpp Outdated
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 2, 2025

and the 1st item reurned by xfconf-query -c keyboard-layout -p /Default/XkbLayout is the actual layout only if the layout is switched with xfce-keyboard-settings (default kbd settings page, preferred layout moved to top).

It's not when the layout switched with

  • xfce4-xkb-plugin (which is an optional tool IIUC)
  • custom hotkey
  • setxkbmap -layout [layout]

For my feeling, it's all pretty messed up in xfce, at least in 4.14

Since that woul donly affect users who a) switch layouts with b) the tools mentioned above, I'd say merge (with the dconf fixup) and wait for more reports.
Since Ubuntu Studio 24.04 now uses KDE Plasma, the number of users with Xfce is probably low.
Or we try xkblayout-state first (optional tool, recommended here), then use xfconf. But this is really too much of an edge case, so let's go.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 3, 2025

Now it shall cover the "only one" keyboard case. Of #14797 we have however no fr_CH keyboard yet.

The whole issue is a real mess. At one point we need to revive the keyboard controller idea, using the key codes, not what is printed when pressing the key.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 3, 2025

Haha, you wrote the commit message with en_US?

read kezboard lazout form /org/gnome/desktop/input-sources/sources if…

Please rewrite so it's easier to find 'keyboard' commits.

Will test again in my VM soonish.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 3, 2025

Done

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 5, 2025

I have tested xkblayout-state and it works like a charm. It seems to have really the truth. I can imagine to put the related x11 calls into Mixxx. Unfortunatly it requires to link agains -lX11 (Which we already do conditionally

find_package(X11)
) and it does not work with Wayland.

The solution here works for X11 and Wayland, is however somwhat fragile.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 5, 2025

Good news!
So, having xkblayout-state always available would be great. Can you add that to the ppa?

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 5, 2025

I prefere the idea to do the X11 API calls directly.
Likely easier to maintain.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 5, 2025

It seems to have really the truth. I can imagine to put the related x11 calls into Mixxx

Ah okay, sorry I overlooked / misunderstood that earlier (on mobile, in a hurry).
Yeah, sure, if you think that's feasible go ahead.

Btw I wonder why these issues are noticed just now, or is it that only recent Ubuntu(-ish) distros expose this issue?

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 5, 2025

That's an interesting question. I am sure it worked with older Ubuntu version and QT5, but I have no interest to track that down.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 6, 2025

Works now. First it ties to via X11 XWayland. That works even if Mixxx itself is running with Wayland. If XWayland is not installed it falls back to
dconf/Xfc and than ibus.
If there is still an issue user can use a custom keyboard.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 6, 2025

Great, thanks!
Idk when I have time for a proper test in the 24.04 VM, probably on sunday evening.

Copy link
Copy Markdown
Member

@ronso0 ronso0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing special. will try to review the Xkb function soon.

Comment thread src/coreservices.cpp Outdated
Comment thread src/coreservices.cpp Outdated
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 7, 2025

First it ties to via X11 XWayland. That works even if Mixxx itself is running with Wayland. If XWayland is not installed it falls back to dconf/Xfc and than ibus. If there is still an issue user can use a custom keyboard.

Can you add that as comments to inputLocale()? Some info is already there, but I think it would be good to document the issue and the entire approach.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 8, 2025

Comment added.

@daschuer
Copy link
Copy Markdown
Member Author

daschuer commented Jun 8, 2025

Can we now merge this? This should be really part of 2.5.2

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 8, 2025

If you're confident, go ahead.

Else, I'd like to do one more test, and take a look at the Xkb calls. Which I can do tomorrow night finally.

Comment thread src/coreservices.cpp
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 10, 2025

I can't test the 2.5 build in the 24.04 VM, so I created ronso0#94 against 2.6 to get a build.
Will report asap.

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 10, 2025

Works nicely in 24.04 👍

@daschuer
Copy link
Copy Markdown
Member Author

XCloseDisplay(pDisplay) is in place. Thank you for testing.

@daschuer
Copy link
Copy Markdown
Member Author

/softfix

I am curious to see if this now actualy did an autosquash

@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 10, 2025

It worked, but CI wasn't triggered.

@daschuer
Copy link
Copy Markdown
Member Author

Edited the initial description.
I need to have a look how we can trigger the CI automatically

@daschuer
Copy link
Copy Markdown
Member Author

All green finally.

@ronso0 ronso0 merged commit ffd1d82 into mixxxdj:2.5 Jun 11, 2025
3 checks passed
@ronso0
Copy link
Copy Markdown
Member

ronso0 commented Jun 11, 2025

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Current locale is not taken into account for setting the keyboard mapping (fr-CH), Mixxx assumes a US layout

2 participants