<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.kde.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugs.kde.org/"
          
          maintainer="sysadmin@kde.org"
>

    <bug>
          <bug_id>470113</bug_id>
          
          <creation_ts>2023-05-22 09:52:14 +0000</creation_ts>
          <short_desc>Main keyboard layout switching shortcuts fire on press instead of on release</short_desc>
          <delta_ts>2023-11-30 22:06:09 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Plasma</classification>
          <product>kwin</product>
          <component>input</component>
          <version>5.27.5</version>
          <rep_platform>Other</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>UPSTREAM</resolution>
          
          <see_also>https://bugs.kde.org/show_bug.cgi?id=464805</see_also>
    
    <see_also>https://bugs.kde.org/show_bug.cgi?id=470257</see_also>
    
    <see_also>https://bugs.kde.org/show_bug.cgi?id=470256</see_also>
          <bug_file_loc>https://github.com/xkbcommon/libxkbcommon/issues/92</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Oded Arbel">oded</reporter>
          <assigned_to name="KWin default assignee">kwin-bugs-null</assigned_to>
          <cc>beatloman91</cc>
    
    <cc>butirsky</cc>
    
    <cc>cravchik</cc>
          
          <cf_commitlink></cf_commitlink>
          <cf_versionfixedin></cf_versionfixedin>
          <cf_sentryurl></cf_sentryurl>
          <votes>0</votes>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2232391</commentid>
    <comment_count>0</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-22 09:52:14 +0000</bug_when>
    <thetext>SUMMARY
With multiple keyboard layouts configure, the shortcuts for switching layout trigger on press instead of on release, making them unusable as a prelude for other shortcuts - for example: CTRL+SHIFT is a common prefix for complex shortcuts (Kate, for example, has a ton of default CTRL+SHIFT shortcuts, but just consider &quot;Save As&quot;), but when setting Input Devices -&gt; Keyboard -&gt; Advances -&gt; switching to another layout -&gt; Ctrl+Shift, all these shortcuts become inaccessible.

The more common Alt+Shift (for people who grew up on multi-lingual MS-Windows) is less common in KDE software but still breaks a lot of useful functionality in other apps.

STEPS TO REPRODUCE
1. In System Settings -&gt; Input Devices -&gt; Keyboard -&gt; Layouts, set two or more layouts.
2. Click the &quot;Main shortcuts&quot; setting and choose, well, anything in the list that opens - but lets try &quot;Left Ctrl&quot; for the most damage.
3. Go to any app and try to save the document with CTRL + S.

OBSERVED RESULT
The layout switches.

EXPECTED RESULT
The expected action for the combined shortcut should trigger.

SOFTWARE/OS VERSIONS
Operating System: KDE neon Testing Edition
KDE Plasma Version: 5.27.5
KDE Frameworks Version: 5.107.0
Qt Version: 5.15.9
Kernel Version: 6.2.0-20-generic (64-bit)
Graphics Platform: offscreen
Processors: 8 × Intel® Core™ i7-7820HQ CPU @ 2.90GHz
Memory: 31.2 GiB of RAM
Graphics Processor: Mesa Intel® HD Graphics 630

ADDITIONAL INFORMATION
- See the 20 years old Xorg bug https://gitlab.freedesktop.org/xorg/xserver/-/issues/258 that describes the problem with the original XKB specification that is probably the cause of this kwin_wayland issue (and its 20 years worth of &quot;me too&quot;). Andrey Butirsky (@butirsky) had commented there about opening a ticket here, so - 2 years late - here we are.
- See bug #464805 and bug #420493 (X11-specific) for slightly different behaviors about &apos;fire on press&apos; that are also problematic and were (apparently) fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2232397</commentid>
    <comment_count>1</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-22 10:59:11 +0000</bug_when>
    <thetext>I corrected the summary to reflect what is the real problem on Plasma side. Please confirm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2232415</commentid>
    <comment_count>2</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-22 12:41:50 +0000</bug_when>
    <thetext>(In reply to Andrey from comment #1)
&gt; I corrected the summary to reflect what is the real problem on Plasma side.
&gt; Please confirm.

This is not about the kwin &quot;modifier only shortcut&quot; feature. This is about the implementation of the KXB-like &quot;shortcuts to switch layouts&quot; implementation, which I&apos;m not sure where exactly it is, but I&apos;m close to 100% sure it isn&apos;t using the &apos;[ModifierOnlyShortuts]&apos; configuration in kwin.

The current implementation definitely works with more than one modifier - I just chose the example of &quot;Left Ctrl&quot; as the &quot;worst possible but still possible&quot; example, but more common configurations are Ctrl+Shift and Alt+Shift. Also the actual problem isn&apos;t the &quot;only one&quot; behavior but the &quot;on press instead of on release&quot; behavior (which is also a problem with the &apos;[ModifierOnlyShortuts]&apos; configuration but as I mentioned above - likely a different similar problem).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2232419</commentid>
    <comment_count>3</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-22 12:59:12 +0000</bug_when>
    <thetext>(In reply to Oded Arbel from comment #2)
&gt; This is not about the kwin &quot;modifier only shortcut&quot; feature. This is about
&gt; the implementation of the KXB-like &quot;shortcuts to switch layouts&quot;
&gt; implementation, which I&apos;m not sure where exactly it is, but I&apos;m close to
&gt; 100% sure it isn&apos;t using the &apos;[ModifierOnlyShortuts]&apos; configuration in kwin.
There is no such implementation in KWin - there is XKB behavior support via libxkbcommon and native Plasma&apos;s global shortcuts implementation (accessible via Alternative shortcuts in Keyboard KCM), which can also include modifiers-only shortcuts.
That is why I think it&apos;s actually about &quot;modifier only shortcut&quot; feature. Please check all of that.

&gt; 
&gt; The current implementation definitely works with more than one modifier - I
&gt; just chose the example of &quot;Left Ctrl&quot; as the &quot;worst possible but still
&gt; possible&quot; example, but more common configurations are Ctrl+Shift and
&gt; Alt+Shift. Also the actual problem isn&apos;t the &quot;only one&quot; behavior but the &quot;on
&gt; press instead of on release&quot; behavior (which is also a problem with the
&gt; &apos;[ModifierOnlyShortuts]&apos; configuration but as I mentioned above - likely a
&gt; different similar problem).
I assumed ModifierOnlyShortuts trigger on release, if not - please file a separate report.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2232423</commentid>
    <comment_count>4</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-22 13:14:57 +0000</bug_when>
    <thetext>(In reply to Andrey from comment #3)
&gt; (In reply to Oded Arbel from comment #2)
&gt; &gt; This is about the implementation of the KXB-like &quot;shortcuts to switch layouts&quot; implementation
&gt; There is no such implementation in KWin - there is XKB behavior support via
&gt; libxkbcommon

Ok, so we&apos;re back to libxkbcommon&apos;s bug 92 - https://github.com/xkbcommon/libxkbcommon/issues/92 - which I see you picked up on 👍👍✌️

&gt; and native Plasma&apos;s global shortcuts implementation (accessible
&gt; via Alternative shortcuts in Keyboard KCM), which can also include
&gt; modifiers-only shortcuts.

It does not, and even it it did - it wouldn&apos;t work to solve the problem, both because of the &quot;only one modifier&quot; requirement, and because it uses logical keys and not hardware key codes, so it doesn&apos;t distinguish between left and right Ctrl, Alt vs AltGr, etc, which layout switching sometimes rely on (check, for example, &quot;left ctrl for first layout, right ctrl for second layout&quot;).

&gt; I assumed ModifierOnlyShortuts trigger on release, if not - please file a
&gt; separate report.

I will.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2232429</commentid>
    <comment_count>5</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-22 13:32:51 +0000</bug_when>
    <thetext>(In reply to Oded Arbel from comment #4)
&gt; (In reply to Andrey from comment #3)
&gt; &gt; and native Plasma&apos;s global shortcuts implementation (accessible
&gt; &gt; via Alternative shortcuts in Keyboard KCM), which can also include
&gt; &gt; modifiers-only shortcuts.
&gt; 
&gt; It does not, and even it it did - it wouldn&apos;t work to solve the problem,
&gt; both because of the &quot;only one modifier&quot; requirement, and because it uses
&gt; logical keys and not hardware key codes, so it doesn&apos;t distinguish between
&gt; left and right Ctrl, Alt vs AltGr, etc, which layout switching sometimes
&gt; rely on (check, for example, &quot;left ctrl for first layout, right ctrl for
&gt; second layout&quot;).
&gt; 
Please report it too

&gt; &gt; I assumed ModifierOnlyShortuts trigger on release, if not - please file a
&gt; &gt; separate report.
&gt; 
&gt; I will.
Please note bug 464805 wasn&apos;t confirmed on Wayland, so check it too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233095</commentid>
    <comment_count>6</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-25 14:07:01 +0000</bug_when>
    <thetext>I verified that #464805 is indeed still an issue on Wayland and created tickets #470256 and #470257</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233098</commentid>
    <comment_count>7</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-25 14:13:19 +0000</bug_when>
    <thetext>Can you check if bug 464805 is still there if you register she modifier-only shortcut through special config file?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233498</commentid>
    <comment_count>8</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-28 10:48:07 +0000</bug_when>
    <thetext>(In reply to Andrey from comment #7)
&gt; Can you check if bug 464805 is still there if you register she modifier-only
&gt; shortcut through special config file?

Setting up modifier-only shortcuts using kwinrc ([ModifierOnlyShortcuts] section), instead of using the System Settings shortcuts KCM, the modifier-only shortcut does trigger correctly on release.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233653</commentid>
    <comment_count>9</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-29 10:54:46 +0000</bug_when>
    <thetext>Nice, so temporary solution for you would be setting up the modifiers-only shortcut switching the layout through the config file.
I would be appreciate if you investigate it yourself fist, but if you need my assistant please ask.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233654</commentid>
    <comment_count>10</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-29 11:03:13 +0000</bug_when>
    <thetext>Hint: basically, you would have to configure sending appropriate DBus call switching the layout</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233662</commentid>
    <comment_count>11</comment_count>
    <who name="Oded Arbel">oded</who>
    <bug_when>2023-05-29 11:59:43 +0000</bug_when>
    <thetext>I can get it to work (for some values of &quot;work&quot;) by adding this to ~/.config/kwinrc:

[ModifierOnlyShortcuts]
Control=org.kde.keyboard,/Layouts,,switchToNextLayout

Then if I disable the kxbcommon group switch shortcut, I can still switch shortcuts by hitting CTRL and releasing (and it doesn&apos;t take effect if I use a CTRL prefix on a shortcut, like CTRL+S).

So.. well... I will try to live with this for a while - but it isn&apos;t a solution for people that still want to use &quot;MS-Windows-like&quot; shortcuts or have more complex setups. Some of that can be helped by implementing something like my suggestion in https://bugs.kde.org/show_bug.cgi?id=470256#c1, and obviously this needs to be figure out into the shortcut KCM (and not what it currently does, aka bug #464805) and the Keyboard KCM (bug #470257).

Ok, while writing this up I figured where the &quot;only CTRL on release&quot; layout switcher trips me up - I often hold CTRL while thinking about the next I do - for example, I expect to want to CTRL+Tab next, so I hold CTRL while finishing reading, at which point I might not want to CTRL+Tab and release CTRL causing a layout switch. Using another single modifier won&apos;t help (there aren&apos;t enough anyway: ALT triggers menus in various apps, SHIFT suffers from the same problem that I often just hold it down for a bit, and META is already used for Kickoff). I will try to get used to that, but multi-modifier-only shortcuts should definitely be a thing that Plasma supports, if we want to dump xkbcommon.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2233666</commentid>
    <comment_count>12</comment_count>
    <who name="Andrey">butirsky</who>
    <bug_when>2023-05-29 12:19:13 +0000</bug_when>
    <thetext>Still a progress) Thank you.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2270073</commentid>
    <comment_count>13</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2023-11-30 22:06:09 +0000</bug_when>
    <thetext>*** Bug 477508 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>