SUMMARY Flatpak apps do not seem to remember their layout when using a per-application layout switch policy. STEPS TO REPRODUCE 1. Go to System Settings -> Input Devices -> Layouts. 2. If there are no additional layouts added, add some layout there so that there would be at least 2 layouts in the system. 3. Set the switching policy to "Application". 4. Install some flatpak GUI app (such as "Tauon Music Box") and launch it. 5. Switch the layout in the flatpak application. 6. Close the application, restart the computer, launch the app again. OBSERVED RESULT Has the default layout instead of the layout that was being used for it the last time. EXPECTED RESULT Should remember the layout that it last had in the same way as non-flatpak apps do. SOFTWARE/OS VERSIONS Operating System: Debian GNU/Linux KDE Plasma Version: 5.24.3 KDE Frameworks Version: 5.90.0 Qt Version: 5.15.2 Kernel Version: 5.16.0-5-amd64 (64-bit) Graphics Platform: X11 Processors: 16 × AMD Ryzen 7 2700 Eight-Core Processor Memory: 15.6 GiB of RAM Graphics Processor: AMD VEGA10
> System Settings -> Input Devices -> Layouts Can you attach a screenshots of the "Layouts" page? I don't have that on my system and I'm not familiar with what it is.
Created attachment 148107 [details] layout_config Attached a screenshot of my layout config.
Aha, *keyboard* layouts. That was the missing part. :)
I wouldn't say this is a bug in the portal, might be a feature entirely for xdg-desktop-portal, but I don't think there's much to do from the -kde side. In order to address it, it would be useful to understand why an application would want to switch keyboard layouts.
(In reply to Aleix Pol from comment #4) > I wouldn't say this is a bug in the portal, might be a feature entirely for > xdg-desktop-portal, but I don't think there's much to do from the -kde side. > > In order to address it, it would be useful to understand why an application > would want to switch keyboard layouts. It's not the application that switches layout, it's me switching it manually.
I probably am not understanding what the issue is then. Does this mean it happens on every app? > 5. Switch the layout in the flatpak application. What does this mean exactly? That you change the layout only for the app specifically?
Are you absolutely certain this works for non-flatpak apps? I can reproduce the problem but it affects all apps and indeed glancing at the code we don't understand why this would only affect flatpak apps.
(In reply to Aleix Pol from comment #6) > I probably am not understanding what the issue is then. > > Does this mean it happens on every app? > > > 5. Switch the layout in the flatpak application. > > What does this mean exactly? That you change the layout only for the app > specifically? The issue happens only in flatpak apps. What I mean by "switching layout for the app" is that I have the keyboard layout policy configured to be for each app (i.e. changing the layout in one app does not change the layout in other apps), and the way I change the keyboard layout for an app is either by pressing the assigned global keyboard shortcut, or by clicking on the language icon in the system tray. And yes, it does work correctly for non-flatpak apps, both QT and GTK.
Alright, we'll need a much more detailed guide to reproduce this. I've just - installed KDE neon user edition - set the switching policy to application - set up `us` and `at` layouts - opened kwrite - switched to `at` via the system tray icon - opened gwenview and saw it switch back to `us` - going back to kwrite automatically switched to `at` - closed both kwrite and gwenview - rebooted the system - opened kwrite and found it using `us` rather than the expected `at` layout For all intents and purposes this doesn't seem to be working regardless of sandboxing, and indeed the code supports this, flatpak or not makes no difference.
(In reply to Harald Sitter from comment #9) > Alright, we'll need a much more detailed guide to reproduce this. > > I've just > - installed KDE neon user edition > - set the switching policy to application > - set up `us` and `at` layouts > - opened kwrite > - switched to `at` via the system tray icon > - opened gwenview and saw it switch back to `us` > - going back to kwrite automatically switched to `at` > - closed both kwrite and gwenview > - rebooted the system > - opened kwrite and found it using `us` rather than the expected `at` layout > > For all intents and purposes this doesn't seem to be working regardless of > sandboxing, and indeed the code supports this, flatpak or not makes no > difference. In my setup (debian testing), at that last point, the app would open with the last layout it had before closing it. Not sure which other setting I might have that could change such behavior.
Please try to reproduce this in a clean environment. This will be impossible to debug if we can't reproduce it on a dev system.
(In reply to Harald Sitter from comment #11) > Please try to reproduce this in a clean environment. This will be impossible > to debug if we can't reproduce it on a dev system. Did some more testing and turns out the keyboard layout is actually not remembered for all native apps either - I tried kate and it always starts with the default layout for example, but it does work correctly (layout is remembered) for other apps, such as JuK.
I didn't try how it works on X11 but it also makes sense to check it for Wayland, maybe in separate report. IIRC the layout is only saved there for apps instantiating itself (e.g opening a new window in Konsole). So if Telegram is closed to tray, no layout restoration takes place on reopening. That might be more attractive point to apply the efforts.
Somehow, things are now working correctly in KDE 5.24.5 from debian sid. Layout is now remembered for flatpak-installed Tauon Music Box at least.
Created attachment 153884 [details] Presentation of bug 452445 This continues to happen for me for all applications under Wayland. I just tried it in a freshly installed KDE Neon VM (neon-user-20221117-0714.iso, KDE 5.26.3) and could reproduce it there as well. On my host machine (manjaro, KDE 5.26.3) I recorded a video to show the problem. As you can see, the system does not remember that I previously set the keyboard layout to US and starts with the default DE layout.
Andreas, that's because if an application closed it won't be treated as the same application when it run again. I don't know how to solve this. If you open a new window from existing application, the layout will be preserved there.
(In reply to Andrey from comment #16) > Andreas, that's because if an application closed it won't be treated as the > same application when it run again. > I don't know how to solve this. > > If you open a new window from existing application, the layout will be > preserved there. First of all, thank a lot for you blazingly fast response! For X11 it works as I would expect. I guess the X11 subsystem handled this then separately somehow? (I don't know much about the inner systems here) Maybe another point is interesting. In my attached video, if you look at the keyboard layout indicator when I open Konsole the second time and type the first 'z' (at around 00:11), the indicator jumps like it updates something, but stays at the default layout.
(In reply to Andrey from comment #16) > Andreas, that's because if an application closed it won't be treated as the > same application when it run again. > I don't know how to solve this. > > If you open a new window from existing application, the layout will be > preserved there. For the most part, applications do remember the layout after closing them and launching them again.
(In reply to David from comment #18) > (In reply to Andrey from comment #16) > > Andreas, that's because if an application closed it won't be treated as the > > same application when it run again. > > I don't know how to solve this. > > > > If you open a new window from existing application, the layout will be > > preserved there. > > For the most part, applications do remember the layout after closing them > and launching them again. I didn't find one yet where it works. Could you give me a specific example of an application where it works?
(In reply to Andreas Korb from comment #19) > (In reply to David from comment #18) > > (In reply to Andrey from comment #16) > > > Andreas, that's because if an application closed it won't be treated as the > > > same application when it run again. > > > I don't know how to solve this. > > > > > > If you open a new window from existing application, the layout will be > > > preserved there. > > > > For the most part, applications do remember the layout after closing them > > and launching them again. > > I didn't find one yet where it works. Could you give me a specific example > of an application where it works? Kate, notepadqq, gedit, JuK, among many others.
(In reply to David from comment #20) > (In reply to Andreas Korb from comment #19) > > (In reply to David from comment #18) > > > (In reply to Andrey from comment #16) > > > > Andreas, that's because if an application closed it won't be treated as the > > > > same application when it run again. > > > > I don't know how to solve this. > > > > > > > > If you open a new window from existing application, the layout will be > > > > preserved there. > > > > > > For the most part, applications do remember the layout after closing them > > > and launching them again. > > > > I didn't find one yet where it works. Could you give me a specific example > > of an application where it works? > > Kate, notepadqq, gedit, JuK, among many others. I just tried Kate and notepadqq on the latest KDE Neon and both don't remember the keyboard layout after restarting the application. Not sure what I'm doing wrong.
(In reply to Andreas Korb from comment #21) > (In reply to David from comment #20) > > (In reply to Andreas Korb from comment #19) > > > (In reply to David from comment #18) > > > > (In reply to Andrey from comment #16) > > > > > Andreas, that's because if an application closed it won't be treated as the > > > > > same application when it run again. > > > > > I don't know how to solve this. > > > > > > > > > > If you open a new window from existing application, the layout will be > > > > > preserved there. > > > > > > > > For the most part, applications do remember the layout after closing them > > > > and launching them again. > > > > > > I didn't find one yet where it works. Could you give me a specific example > > > of an application where it works? > > > > Kate, notepadqq, gedit, JuK, among many others. > > I just tried Kate and notepadqq on the latest KDE Neon and both don't > remember the keyboard layout after restarting the application. Not sure what > I'm doing wrong. Perhaps you haven't set the layout switching policy to "application"? (Settings -> Input devices -> Keyboard -> Layouts -> Switching policy).
Created attachment 153898 [details] Keyboard layout settings (In reply to David from comment #22) > (In reply to Andreas Korb from comment #21) > > Perhaps you haven't set the layout switching policy to "application"? > (Settings -> Input devices -> Keyboard -> Layouts -> Switching policy). I think I have (see attachment)
This appears to still be a issue in KDE 6, unfortunately. Is there any plan for this issue? Otherwise, I'm actually willing to implement this myself, as it is the only thing that hinders me of fully switching to Wayland. Then, I'd appreciate some pointers, e.g., why it worked under X11 but doesn't under Wayland as of now, and which code areas are relevant. Thanks!
Andreas, X11 and Wayland have completely different codepaths there: it's kded for X11 and kwin for Wayland. You have to dig into how layout saving works for apps in kwin. Ask if you need help, thanks.