Bug 356220 - Keyboard layout not being switched using a keyboard shortcut
Summary: Keyboard layout not being switched using a keyboard shortcut
Status: RESOLVED FIXED
Alias: None
Product: telepathy
Classification: Frameworks and Libraries
Component: text-ui (show other bugs)
Version: 15.08.2
Platform: Arch Linux Linux
: NOR normal
Target Milestone: Future
Assignee: Telepathy Bugs
URL:
Keywords:
: 333742 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-12-03 02:07 UTC by Ondřej Kučera
Modified: 2016-01-30 17:16 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ondřej Kučera 2015-12-03 02:07:52 UTC
I'm using two keyboard layouts (English and Czech) and a custom global shortcut (Meta+K) for switching. When I'm in the chat window, the Czech layout is activated (for example) and I press Meta+K, Plasma shows me an "OSD image" of keyboard being switched to English but that in fact doesn't happen.
When I use the icon in the system tray instead of the keyboard shortcut, everything works as expected.

Reproducible: Always

Steps to Reproduce:
1. Configure two keyboard layouts.
2. Open the chat window.
3. Press a keyboard shortcut for layout switching (Ctrl+Alt+K by default, IIRC).

Actual Results:  
The layout isn't switched.

Expected Results:  
The layout should be switched.
Comment 1 Martin Klapetek 2015-12-07 19:25:10 UTC
Thanks for the report

Is this happening only in ktp-text-ui? Or also in other applications?
Comment 2 Ondřej Kučera 2015-12-07 20:18:07 UTC
Only there. It works properly in all other applications that I use.
Comment 3 Martin Klapetek 2015-12-07 20:23:11 UTC
Ok, it's probably due to the layout-per-tab handling the text-ui uses.

I'll have a look.
Comment 4 Martin Klapetek 2015-12-07 20:30:27 UTC
Are you able to test patches btw?
Comment 5 Martin Klapetek 2015-12-07 20:32:36 UTC
Actually, what would be easier, please install bustle, run bustle, open some chat, switch the keyboard layout, stop bustle, save the log and attach it here. You can also email it directly if you're concerned about your data (it may contain your account and the chat contact).
Comment 6 Martin Klapetek 2015-12-07 21:29:05 UTC
Ok, after inspecting the bustle log and the code, I think I see the problem.

In app/chat-window.cpp, the restoreKeyboardLayout(..) is called on various occasions, this in turn calls the setLayout on the keyboard switching interface. I guess it's called with the old layout from somewhere.

I'll investigate more properly later tonight.

Oh and btw, for testing patches, you'd need to recompile only ktp-text-ui, should be really simple :)
Comment 7 Martin Klapetek 2015-12-09 03:47:37 UTC
Ok I understand now what's going on. It's...unexpected.

So. If you use "save layout per tab", the layout is set everytime
you switch to the window (make it an active window). Now when
you press the key combo to change layout, the OSD popups up
and that takes the focus away from ktp-text-ui, even if for a split
of a second. After that, the text-ui is switched back to, ie. made
an active window. At this point, text-ui is setting the "old" layout
back (because the updated layout didn't make it to it yet).

And that makes it look like it's blocking the change.
Comment 8 Martin Klapetek 2015-12-10 20:49:15 UTC
Some updates.

I made a patch yesterday [1] fixing this problem. I've added
Martin G to the review which prompted him to look for the
root cause of the bug (described in previous comment) and
it will likely get fixed elsewhere, but for the time being the
exact cause of the WindowDeactivate/WindowActivate events
is still unknown.

[1] - https://git.reviewboard.kde.org/r/126287/
Comment 9 Martin Klapetek 2015-12-10 20:54:45 UTC
*** Bug 333742 has been marked as a duplicate of this bug. ***
Comment 10 Ondřej Kučera 2016-01-30 17:16:38 UTC
It works properly now in 15.12.1.