3

I have the clipboard patch installed, and the following lines in my config.h

#define MODKEY Mod1Mask
#define TERMMOD (Mod1Mask|ShiftMask)

and

{ ShiftMask,            XK_Insert,      clippaste,      {.i =  0} },
{ TERMMOD,               XK_c,           clipcopy,       {.i =  0} },
{ TERMMOD,               XK_v,           clippaste,      {.i =  0} },
{ MODKEY,               XK_p,           selpaste,       {.i =  0} },

Interestingly Shift+Insert and mid-click on mouse let me paste from clipboard but the combination using TERMMOD and MODKEY from above don't. Other shortcuts using TERMMOD and MODKEY (e.g. zoom in/out, printscreen, scrolling) work. I tried to use other combinations like Ctrl+Shift+c/v but no joy. The same combination would work on xterm, urxvt and alacritty (I haven't exhaustively tested other emulators yet).

Can any one please shed some light?

tondor
  • 33
  • 2

1 Answers1

3

In the default keybindings in the st source, the binding uses XK_V (note capital).

    { TERMMOD,              XK_C,           clipcopy,       {.i =  0} },
    { TERMMOD,              XK_V,           clippaste,      {.i =  0} },
    { TERMMOD,              XK_Y,           selpaste,       {.i =  0} },

Try changing your lowercase XK_v back to that (while keeping your new value of TERMMOD).

Explanation

XK_v and XK_V are defined as 0x76 and 0x56 in the X11 include file keysymdef.h. They are considered different keypresses. You can test this with the xev tool:

Without Shift:

KeyRelease event, serial 47, synthetic NO, window 0x4c00001,
    root 0x4cf, subw 0x0, time 433723403, (134,121), root:(1235,171),
    state 0x0, keycode 55 (keysym 0x76, v), same_screen YES,
    XLookupString gives 1 bytes: (76) "v"
    XmbLookupString gives 1 bytes: (76) "v"
    XFilterEvent returns: False

With Shift held down, the same keycode results in a different keysym.

KeyPress event, serial 47, synthetic NO, window 0x4c00001,
    root 0x4cf, subw 0x0, time 433724571, (134,121), root:(1235,171),
    state 0x1, keycode 55 (keysym 0x56, V), same_screen YES,
    XLookupString gives 1 bytes: (56) "V"
    XmbLookupString gives 1 bytes: (56) "V"
    XFilterEvent returns: False

When you use XK_v in conjunction with TERMMOD, and TERMMOD contains ShiftMask, you are telling st you want to paste when a lowercase v is received while Shift is down. But when you're holding Shift, the X server sends an uppercase V key instead. That's not what st was looking for, so it does nothing.

JigglyNaga
  • 7,706
  • 1
  • 21
  • 47