Tk Source Code

View Ticket
Login
Ticket UUID: 04e1735b8618653f88582101f7e5574ae6767f53
Title: Add support for Copy/Cut/Paste keys in X11
Type: Patch Version:
Submitter: anonymous Created on: 2025-09-17 09:00:13
Subsystem: 69. Events Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2025-09-24 12:23:50
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2025-09-24 12:23:50
Description:
These keys are present in some old unix keyboards, but more importantly, their keycodes can be mapped to physical keys in modern programmable keyboards.
Using them in Linux is a way to be able to have the same keys for copy/pasting in GUI apps and in terminal apps instead of switching between ctrl-c/ctrl-v and ctrl-shift-c/ctrl-shift-v.

The patches are very short so I am adding them here:

1. branch core-8-6-branch

Index: library/tk.tcl
==================================================================
--- library/tk.tcl
+++ library/tk.tcl
@@ -371,13 +371,13 @@
 # Define the set of common virtual events.
 #----------------------------------------------------------------------

 switch -exact -- [tk windowingsystem] {
     "x11" {
-       event add <<Cut>>               <Control-Key-x> <Key-F20> <Control-Lock-Key-X>
-       event add <<Copy>>              <Control-Key-c> <Key-F16> <Control-Lock-Key-C>
-       event add <<Paste>>             <Control-Key-v> <Key-F18> <Control-Lock-Key-V>
+       event add <<Cut>>               <Control-Key-x> <Key-F20> <Control-Lock-Key-X> <XF86Cut>
+       event add <<Copy>>              <Control-Key-c> <Key-F16> <Control-Lock-Key-C> <XF86Copy>
+       event add <<Paste>>             <Control-Key-v> <Key-F18> <Control-Lock-Key-V> <XF86Paste>
        event add <<PasteSelection>>    <ButtonRelease-2>
        event add <<Undo>>              <Control-Key-z> <Control-Lock-Key-Z>
        event add <<Redo>>              <Control-Key-Z> <Control-Lock-Key-z>
        event add <<ContextMenu>>       <Button-3>
        # On Darwin/Aqua, buttons from left to right are 1,3,2.  On Darwin/X11 with recent

2. branch core-9-0-branch

Index: library/tk.tcl
==================================================================
--- library/tk.tcl
+++ library/tk.tcl
@@ -374,13 +374,13 @@
 event add <<ContextMenu>>      <Button-3>
 event add <<PasteSelection>>   <ButtonRelease-2>

 switch -exact -- [tk windowingsystem] {
     "x11" {
-       event add <<Cut>>               <Control-x> <F20> <Control-Lock-X>
-       event add <<Copy>>              <Control-c> <F16> <Control-Lock-C>
-       event add <<Paste>>             <Control-v> <F18> <Control-Lock-V>
+       event add <<Cut>>               <Control-x> <F20> <Control-Lock-X> <XF86Cut>
+       event add <<Copy>>              <Control-c> <F16> <Control-Lock-C> <XF86Copy>
+       event add <<Paste>>             <Control-v> <F18> <Control-Lock-V> <XF86Paste>
        event add <<Undo>>              <Control-z> <Control-Lock-Z>
        event add <<Redo>>              <Control-Z> <Control-Lock-z>
        # On Darwin/Aqua, buttons from left to right are 1,3,2.  On Darwin/X11 with recent
        # XQuartz as the X server, they are 1,2,3; other X servers may differ.
User Comments: jan.nijtmans added on 2025-09-24 12:23:50:

Merged to all branches now


jan.nijtmans added on 2025-09-18 17:05:44:
Misled by: [https://github.com/telegramdesktop/tdesktop/issues/5835]

There is no XF86Undo/XF86Redo, it's just Undo/Redo

jan.nijtmans added on 2025-09-17 12:36:48:

If we do those 3, I think we should add the Undo and Redo variants as well


jan.nijtmans added on 2025-09-17 12:01:21:

Put into a [f8bf4f1a0ec636f8|branch] now

Thanks!