<?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>459384</bug_id>
          
          <creation_ts>2022-09-19 11:05:23 +0000</creation_ts>
          <short_desc>Fire shortcuts on key release, not press</short_desc>
          <delta_ts>2022-09-22 19:50:51 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>3</classification_id>
          <classification>Frameworks and Libraries</classification>
          <product>frameworks-kglobalaccel</product>
          <component>general</component>
          <version>5.97.0</version>
          <rep_platform>Manjaro</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>420493</dup_id>
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>NOR</priority>
          <bug_severity>wishlist</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter>owl-from-hogvarts</reporter>
          <assigned_to name="kdelibs bugs">kdelibs-bugs-null</assigned_to>
          <cc>nate</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>2154189</commentid>
    <comment_count>0</comment_count>
    <who name="">owl-from-hogvarts</who>
    <bug_when>2022-09-19 11:05:23 +0000</bug_when>
    <thetext>SUMMARY
***
NOTE: If you are reporting a crash, please try to attach a backtrace with debug symbols.
See https://community.kde.org/Guidelines_and_HOWTOs/Debugging/How_to_create_useful_crash_reports
***
Global shortcuts should be fired on key release and not press.


OBSERVED RESULT
Shortcuts are fired on key press.
Therefore the shortest shortcut is fired instead of a desired one. So we can&apos;t have overlapping shortcuts, i.e. which starts with same, multiple modifiers keys (ctrl + shift + ... will not work if we have ctrl + shift assigned to layout switch).

DESIRED BEHAVIOR
Shortcuts are fired on key release, so the desired shortcut is fired instead of shortest.

POSSIBLE IMPLEMENTATION
P_BUFFER - buffer of pressed keys
S_BUFFER - buffer of suspended keys
1. Accumulate pressed keys in P_BUFFER
1.1 on keypress event add pressed key to P_BUFFER (works same for all buttons, so we would be able to start shortcut from any shortcut&apos;s keys)
2. on keyrelease event of any key contained in P_BUFFER, fire shortcut with all keys currently in P_BUFFER, including one that was released just before (that is because we won&apos;t delete it from P_BUFFER just after the key was released, but will wait for shortcut to fire and only then remove)

Note: other (still pressed) keys are moved to suspending buffer S_BUFFER. That means that when other keys will be released they won&apos;t cause any undesired shortcuts. BUT when any new key is pressed, already pressed keys (i.e. contained in S_BUFFER) will be moved back to P_BUFFER. Key will be REMOVED (and not moved) from suspending buffer ONLY when released 




SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.25.5
(available in About System)
Operating System: Manjaro Linux
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.97.0
Qt Version: 5.15.5
Kernel Version: 5.19.7-1-MANJARO (64-bit)
Graphics Platform: Wayland

ADDITIONAL INFORMATION</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154345</commentid>
    <comment_count>1</comment_count>
    <who name="">owl-from-hogvarts</who>
    <bug_when>2022-09-19 19:36:19 +0000</bug_when>
    <thetext>EXAMPLE
Lets imagine that we have next shortcuts defined:
ctrl + shift - switch keyboard layout
ctrl + shift + t - open new terminal instance
ctrl + shift + d - show desktop

And user acts like this:
&quot;wants to show desktop and open terminal&quot;
1. press &quot;shift&quot;
2. press &quot;ctrl&quot;
3. press &quot;d&quot; and release it (ctrl + shift are still pressed)
4. press &quot;t&quot; and release ctrl, shift, t in order

5. press ctrl, shift to switch keyboard layout
6. releases shift

What happens according to the algorithm:
1. shift is added to P_BUFFER
2. ctrl is added to P_BUFFER
3. d is added to P_BUFFER
4. release event for &quot;d&quot; received
5. shortcut &quot;show desktop&quot; is fired
6. content of P_BUFFER is moved to S_BUFFER (i.e. ctrl, shift, d)
7. system detects that &quot;d&quot; is no longer pressed and removes it from S_BUFFER (so the content of S_BUFFER becomes &quot;ctrl, shift&quot;)
8. press event for &quot;t&quot; received
9. ctrl, shift are moved back to P_BUFFER
10. &quot;t&quot; is added to P_BUFFER
11. &quot;ctrl&quot; release event received 
12. open new terminal instance shortcut fired
13. content of P_BUFFER is moved to S_BUFFER (i.e. ctrl, shift, t)
14. system detects that &quot;ctrl&quot; is no longer pressed and removes it from S_BUFFER (so the content of S_BUFFER becomes &quot;shift, t&quot;)
15. receives release events for &quot;shift, t&quot;
16. removes &quot;shift, t&quot; from S_BUFFER so it becomes empty

17. receives press events for &quot;ctrl&quot; and &quot;shift&quot;
18. adds them to the P_BUFFER
19. receives release event for &quot;shift&quot;
20. fire &quot;switch keyboard layout&quot; shortcut</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2154846</commentid>
    <comment_count>2</comment_count>
    <who name="">owl-from-hogvarts</who>
    <bug_when>2022-09-21 05:57:13 +0000</bug_when>
    <thetext>Excuse me, but may be the severeness is &quot;major&quot; since this thing affects all shortcuts (including of foreign applications, such as VS code, chrome). So current shortcut behavior heavily breaks my UX, because shortcuts, which includes ctrl + shift + ... are not working!</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2155409</commentid>
    <comment_count>3</comment_count>
    <who name="Nate Graham">nate</who>
    <bug_when>2022-09-22 19:50:51 +0000</bug_when>
    <thetext>

*** This bug has been marked as a duplicate of bug 420493 ***</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>