kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.12k stars 972 forks source link

Selecting text fails to fill PRIMARY selection on X11 if cursor wanders off the left edge of the screen #6104

Closed morgan-greywolf closed 1 year ago

morgan-greywolf commented 1 year ago

Describe the bug I use kitty in a maximized window, without window decorations (hide_window_decorations yes) and with no window padding on GNOME running on Xorg. I have three monitors, one to the left of the one I use kitty on, and one to the right. Since grabbing the left edge of the text is often tricky when selecting, I usually grab text from the right and drag left and up. Unfortunately, if the cursor wanders off to the screen on the left slightly (even just by a pixel), the text will be highlighted, but the PRIMARY selection buffer will not be replaced. This behavior does not occur with other terminal emulators, only kitty.

To Reproduce Steps to reproduce the behavior:

  1. Configure a display to the left of your primary display.
  2. Start kitty on your primary display,
  3. Drag text starting at the bottom right and move to the upper left, but drag the cursor slighty off onto the display to the left.
  4. ZZZ
  5. See error

Screenshots If applicable, add screenshots to help explain your problem.

Environment details

Press Ctrl+Shift+F6 (cmd+option+comma on macOS) in kitty, to copy debug output about kitty and its
configuration to the clipboard and paste it here. kitty 0.27.1 () created by Kovid Goyal
Linux lugh 6.2.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 03 Mar 2023 15:58:31 +0000 x86_64
Arch Linux 6.2.2-arch1-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/bash
Loaded config files:
  /home/rshinn/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control    socket-only
background_opacity      0.8
editor                  /usr/bin/vim
enable_audio_bell       False
focus_follows_mouse     True
font_family             SauceCodeProNerdFontComplete-Regular
font_features:
{'SauceCodeProNerdFontComplete-Regular': ('+calt',)}
hide_window_decorations 1
tab_bar_style           powerline
term                    xterm-256color
Added shortcuts:
        ctrl+, →  edit_config_file
        ctrl+. →  layout_action bias 50 66 75
        ctrl+down →  resize_window shorter 3
        ctrl+f3 →  detach_window
        ctrl+home →  resize_window reset
        ctrl+left →  resize_window narrower
        ctrl+right →  resize_window wider
        ctrl+shift+/ →  launch  --location=hsplit --allow-remote-control kitty +kitten search.py @active-kitty-window-id
        ctrl+shift+f3 →  detach_tab
        ctrl+shift+f4 →  detach_tab ask
        ctrl+shift+y →  change_window_tab
        ctrl+up →  resize_window taller
Changed shortcuts:
        kitty_mod+e →  new_tab mc -b
        kitty_mod+z →  toggle_layout stack
Colors:
        active_tab_background   #e6db74   
        inactive_tab_background #293739   
        inactive_tab_foreground #ffffff   
        tab_bar_background      #232526   
        tab_bar_margin_color    #232526   

Important environment variables seen by the kitty process:
kitty 0.27.1 () created by Kovid Goyal
Linux lugh 6.2.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 03 Mar 2023 15:58:31 +0000 x86_64
Arch Linux 6.2.2-arch1-1 (/dev/tty)

DISTRIB_ID="Arch"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="Arch Linux"
Running under: X11
Frozen: False
Paths:
  kitty: /usr/bin/kitty
  base dir: /usr/lib/kitty
  extensions dir: /usr/lib/kitty/kitty
  system shell: /bin/bash
Loaded config files:
  /home/rshinn/.config/kitty/kitty.conf

Config options different from defaults:
allow_remote_control    socket-only
background_opacity      0.8
editor                  /usr/bin/vim
enable_audio_bell       False
focus_follows_mouse     True
font_family             SauceCodeProNerdFontComplete-Regular
font_features:
{'SauceCodeProNerdFontComplete-Regular': ('+calt',)}
hide_window_decorations 1
tab_bar_style           powerline
term                    xterm-256color
Added shortcuts:
        ctrl+, →  edit_config_file
        ctrl+. →  layout_action bias 50 66 75
        ctrl+down →  resize_window shorter 3
        ctrl+f3 →  detach_window
        ctrl+home →  resize_window reset
        ctrl+left →  resize_window narrower
        ctrl+right →  resize_window wider
        ctrl+shift+/ →  launch  --location=hsplit --allow-remote-control kitty +kitten search.py @active-kitty-window-id
        ctrl+shift+f3 →  detach_tab
        ctrl+shift+f4 →  detach_tab ask
        ctrl+shift+y →  change_window_tab
        ctrl+up →  resize_window taller
Changed shortcuts:
        kitty_mod+e →  new_tab mc -b
        kitty_mod+z →  toggle_layout stack
Colors:
        active_tab_background   #e6db74   
        inactive_tab_background #293739   
        inactive_tab_foreground #ffffff   
        tab_bar_background      #232526   
        tab_bar_margin_color    #232526   

Important environment variables seen by the kitty process:

        PATH                                /opt/google-cloud-sdk/bin:/opt/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/var/lib/snapd/snap/bin:/usr/local/sbin:/opt/android-sdk/emulator:/opt/cuda/bin:/opt/cuda/ns>
        LANG                                en_US.UTF-8
        SHELL                               /bin/bash
        DISPLAY                             :0
        USER                                rshinn
        XDG_DATA_DIRS                       /home/rshinn/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop
        XDG_RUNTIME_DIR                     /var/run/user/1000
        XDG_CACHE_HOME                      /home/rshinn/.cache
        XDG_CONFIG_HOME                     /home/rshinn/.config
        XDG_CURRENT_DESKTOP                 GNOME
        XDG_DATA_HOME                       /home/rshinn/.local/share
        XDG_MENU_PREFIX                     gnome-
        XDG_SESSION_CLASS                   user
        XDG_SESSION_DESKTOP                 gnome-xorg
        XDG_SESSION_TYPE                    x11
        XDG_STATE_HOME                      /home/rshinn/.local/state

Additional context Problem actually also occurs with kitty --config NONE.

morgan-greywolf commented 1 year ago

Also, I get this in kitty's stdout/stderr:

[068 16:41:08.056095] [glfw error 65545]: X11: Failed to convert selection to data from clipboard
[068 16:41:08.935913] [glfw error 65545]: X11: Failed to convert selection to data from clipboard
[068 16:41:11.471838] [glfw error 65545]: X11: Failed to convert selection to data from clipboard
kovidgoyal commented 1 year ago

I dont have a dual monitor system to test with, so I cannot reproduce. I would guess it's caused by your system sending focus change events when the cursor leaves the monitor. You can confirm this by running kitty with --debug-input when you dont move the cursor off the monitor, you will see the mouse release event reported as being handled as drag end, and that wont happen if the cursor leaves the screen. I dont know why your system is doing that, but I doubt its normal behavior. You can probably work around it by commenting out the line that sets active_drag_in_window = 0 in window_focus_callback() in glfw.c

If you have some kind of setting in your window manager to automatically change focus when the mouse leaves a monitor turn it off.