swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.77k stars 1.11k forks source link

Strange trackpad behaviour after wakeup from suspend (not hibernate/shutdown) #7090

Open hw-lunemann opened 2 years ago

hw-lunemann commented 2 years ago

Auto start

exec lxqt-policykit-agent exec keepassxc

Variables

#

Logo key. Use Mod1 for Alt.

set $mod Mod4

Home row direction keys, like vim

set $left h set $down j set $up k set $right l

Your preferred terminal emulator

set $term foot

Your preferred application launcher

Note: pass the final command to swaymsg so that the resulting window can be opened

on the original workspace that the command was run on.

set $menu dmenu_path | dmenu | xargs swaymsg exec --

default_border normal

Output configuration

#

Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)

output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill #

Example configuration:

#

output HDMI-A-1 resolution 1920x1080 position 1920,0

#

You can get the names of your outputs by running: swaymsg -t get_outputs

Idle configuration

#

Example configuration:

#

exec swayidle -w \

timeout 300 'swaylock -f -c 000000' \

timeout 600 'swaymsg "output dpms off"' resume 'swaymsg "output dpms on"' \

before-sleep 'swaylock -f -c 000000'

#

This will lock your screen after 300 seconds of inactivity, then turn off

your displays after another 300 seconds, and turn your screens back on when

resumed. It will also lock your screen before your computer goes to sleep.

Input configuration

#

Example configuration:

#

input "2:14:SynPS/2_Synaptics_TouchPad" {

dwt enabled

tap enabled

natural_scroll enabled

middle_emulation enabled

}

#

You can get the names of your inputs by running: swaymsg -t get_inputs

Read man 5 sway-input for more information about this section.

input type:touchpad { dwt disabled tap enabled natural_scroll enabled }

Key bindings

#

Basics:

#

Start a terminal

bindsym $mod+Return exec $term

# Kill focused window
bindsym $mod+Shift+q kill

# Start your launcher
bindsym $mod+d exec $menu

# Drag floating windows by holding down $mod and left mouse button.
# Resize them with right mouse button + $mod.
# Despite the name, also works for non-floating windows.
# Change normal to inverse to use left mouse button for resizing and right
# mouse button for dragging.
floating_modifier $mod normal

# Reload the configuration file
bindsym $mod+Shift+c reload

# Exit sway (logs you out of your Wayland session)
bindsym $mod+Shift+e exec swaynag -t warning -m 'You pressed the exit shortcut. Do you really want to exit sway? This will end your Wayland session.' -b 'Yes, exit sway' 'swaymsg exit'

#

Moving around:

#

Move your focus around

bindsym $mod+$left focus left
bindsym $mod+$down focus down
bindsym $mod+$up focus up
bindsym $mod+$right focus right
# Or use $mod+[up|down|left|right]
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

# Move the focused window with the same, but add Shift
bindsym $mod+Shift+$left move left
bindsym $mod+Shift+$down move down
bindsym $mod+Shift+$up move up
bindsym $mod+Shift+$right move right
# Ditto, with arrow keys
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

bindsym $mod+Shift+a move parent
bindsym $mod+Shift+z move child

bindsym $mod+x mark

#

Workspaces:

#

Switch to workspace

bindsym $mod+1 workspace number 1
bindsym $mod+2 workspace number 2
bindsym $mod+3 workspace number 3
bindsym $mod+4 workspace number 4
bindsym $mod+5 workspace number 5
bindsym $mod+6 workspace number 6
bindsym $mod+7 workspace number 7
bindsym $mod+8 workspace number 8
bindsym $mod+9 workspace number 9
bindsym $mod+0 workspace number 10
# Move focused container to workspace
bindsym $mod+Shift+1 move container to workspace number 1
bindsym $mod+Shift+2 move container to workspace number 2
bindsym $mod+Shift+3 move container to workspace number 3
bindsym $mod+Shift+4 move container to workspace number 4
bindsym $mod+Shift+5 move container to workspace number 5
bindsym $mod+Shift+6 move container to workspace number 6
bindsym $mod+Shift+7 move container to workspace number 7
bindsym $mod+Shift+8 move container to workspace number 8
bindsym $mod+Shift+9 move container to workspace number 9
bindsym $mod+Shift+0 move container to workspace number 10
# Note: workspaces can have any name you want, not just numbers.
# We just use 1-10 as the default.

#

Layout stuff:

#

You can "split" the current object of your focus with

# $mod+b or $mod+v, for horizontal and vertical splits
# respectively.
bindsym $mod+b splith
bindsym $mod+v splitv

# Switch the current container between different layout styles
bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# Make the current focus fullscreen
bindsym $mod+f fullscreen

# Toggle the current focus between tiling and floating mode
bindsym $mod+Shift+space floating toggle

# Swap focus between the tiling area and the floating area
bindsym $mod+space focus mode_toggle

# Move focus to the parent container
bindsym $mod+a focus parent

# Move focus to the child container
bindsym $mod+z focus child

#

Scratchpad:

#

Sway has a "scratchpad", which is a bag of holding for windows.

# You can send windows there and get them back later.

# Move the currently focused window to the scratchpad
bindsym $mod+Shift+minus move scratchpad

# Show the next scratchpad window or hide the focused scratchpad window.
# If there are multiple scratchpad windows, this command cycles through them.
bindsym $mod+minus scratchpad show

#

Resizing containers:

# mode "resize" {

left will shrink the containers width

# right will grow the containers width
# up will shrink the containers height
# down will grow the containers height
bindsym $left resize shrink width 10px
bindsym $down resize grow height 10px
bindsym $up resize shrink height 10px
bindsym $right resize grow width 10px

# Ditto, with arrow keys
bindsym Left resize shrink width 10px
bindsym Down resize grow height 10px
bindsym Up resize shrink height 10px
bindsym Right resize grow width 10px

# Return to default mode
bindsym Return mode "default"
bindsym Escape mode "default"

} bindsym $mod+r mode "resize"

#

Fn keys:

bindsym XF86MonBrightnessDown exec licht intel_backlight -10 --stepping blend (0.75,1.8,2.2) bindsym XF86MonBrightnessUp exec licht intel_backlight +10 --stepping blend (0.75,1.8,2.2)

bindsym XF86AudioRaiseVolume exec pamixer -ui 2 bindsym XF86AudioLowerVolume exec pamixer -ud 2 bindsym XF86AudioMute exec pamixer --toggle-mute

#

Status Bar:

#

Read man 5 sway-bar for more information about this section.

bar { position top

# When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time.

status_command while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done

swaybar_command waybar

colors {
    statusline #ffffff
    background #323232
    inactive_workspace #32323200 #32323200 #5c5c5c
}

}

for_window [class="steam"] move workspace $(cat /tmp/steam)


- **Description:**
    - Close laptop lid / systemctl suspend
    - Open laptop lid / resume
    - About twice a week the following happens to me. Upon waking up the trackpad all actions will require one extra finger. Doing anything with a single finder does nothing anymore. Left click turns into a two finger tap, the cursor only moves if dragging with two fingers, right click becomes tapping with three fingers, middle mouse button becomes tapping with 4 fingers. After a few minutes the trackpad goes back to normal. 
    This does not happen with any non-wayland wm/de and I haven't tried another wlroots/non-wlroots compositor.
    My Laptop is a Xiaomi Notebook Pro 2018 with 

    I'm still trying to catch this happening in a debug log but if there's any more info I can supply in the meantime let me know.
zsolt-donca commented 2 years ago

I have the same issue using a Dell XPS 15. It's rarer for me, and for me the trackpad does not get back to normal. I will post a debug log here the next time I see it.

hw-lunemann commented 2 years ago

It can take a good while before it goes back to normal. Sometimes maybe 10-15 minutes. When it happens I usually don't bother restarting sway because I don't use the mouse a whole lot.

xsrvmy commented 2 years ago

Something else interesting to check: if you run sudo libinput debug-events before you suspend, you can see upon waking what libinput is receiving. I have had an issue before where sway got disconnected from libinput.

ackstorm23 commented 2 years ago

I have this problem too but it happens with my bluetooth mouse as well as trackpad.

ackstorm23 commented 2 years ago

I have this problem too but it happens with my bluetooth mouse as well as trackpad.

# sudo libinput debug-events
-event16  DEVICE_ADDED            Video Bus                         seat0 default group1  cap:k
-event0   DEVICE_ADDED            Lid Switch                        seat0 default group2  cap:S
-event1   DEVICE_ADDED            Intel Touch Host Controller       seat0 default group3  cap:t ntouches 1 calib
-event3   DEVICE_ADDED            gpio-keys                         seat0 default group4  cap:k
-event4   DEVICE_ADDED            gpio-keys                         seat0 default group4  cap:k
-event8   DEVICE_ADDED            Microsoft Surface 045E:09AE Keyboard seat0 default group5  cap:kp scroll-nat
-event9   DEVICE_ADDED            Microsoft Surface 045E:09B0 Keyboard seat0 default group6  cap:k
-event12  DEVICE_ADDED            Microsoft Surface 045E:09AF Mouse seat0 default group7  cap:p left scroll-nat scroll-button
-event13  DEVICE_ADDED            Microsoft Surface 045E:09AF Touchpad seat0 default group7  cap:pg  size 96x52mm tap(dl off) left scroll-nat scroll-2fg-edge click-buttonareas-clickfinger dwt-on dwtp-on
-event7   DEVICE_ADDED            Microsoft Surface KIP Tablet Mode Switch seat0 default group8  cap:S
-event5   DEVICE_ADDED            IPTS Touch                        seat0 default group9  cap:t  size 274x185mm ntouches 11 calib
-event6   DEVICE_ADDED            IPTS Stylus                       seat0 default group10 cap:T  size 274x185mm calib
-event31  DEVICE_ADDED            M720 Triathlon Keyboard           seat0 default group11 cap:k
-event256  DEVICE_ADDED            M720 Triathlon Mouse              seat0 default group11 cap:p left scroll-nat scroll-button
-event8   KEYBOARD_KEY            +0.000s       *** (-1) pressed

(suspend)

-event7   SWITCH_TOGGLE           +5.415s       switch tablet-mode state 1
 event7   SWITCH_TOGGLE           +5.526s       switch tablet-mode state 0
-event0   SWITCH_TOGGLE           +5.526s       switch lid state 1
-event31  DEVICE_REMOVED          M720 Triathlon Keyboard           seat0 default group11 cap:k
-event256  DEVICE_REMOVED          M720 Triathlon Mouse              seat0 default group11 cap:p
-event0   SWITCH_TOGGLE           +8.457s       switch lid state 0
-event9   KEYBOARD_KEY            +8.846s       *** (-1) pressed
 event9   KEYBOARD_KEY            +8.846s       KEY_LEFTMETA (125) pressed
 event9   KEYBOARD_KEY            +8.846s       KEY_F19 (189) pressed
 event9   KEYBOARD_KEY            +8.846s       *** (-1) released
 event9   KEYBOARD_KEY            +8.846s       KEY_LEFTMETA (125) released
 event9   KEYBOARD_KEY            +8.846s       KEY_F19 (189) released
-event8   KEYBOARD_KEY            +11.538s      *** (-1) pressed
 event8   KEYBOARD_KEY            +11.667s      *** (-1) pressed
 event8   KEYBOARD_KEY            +11.808s      *** (-1) released
 event8   KEYBOARD_KEY            +11.903s      *** (-1) pressed
 event8   KEYBOARD_KEY            +12.041s      *** (-1) released
 event8   KEYBOARD_KEY            +12.043s      *** (-1) released
 event8   KEYBOARD_KEY            +12.108s      *** (-1) pressed
 event8   KEYBOARD_KEY            +12.196s      *** (-1) released
 event8   KEYBOARD_KEY            +12.216s      *** (-1) pressed
 event8   KEYBOARD_KEY            +12.296s      *** (-1) pressed
ackstorm23 commented 2 years ago

I noticed that even if I quit sway, and load it back up, it remains like this. I had to reboot to get this to go away. Has anyone else experienced that or is that unique to me?

ackstorm23 commented 2 years ago

I noticed that even if I quit sway, and load it back up, it remains like this. I had to reboot to get this to go away. Has anyone else experienced that or is that unique to me?

I also tested it where I booted, did not start sway/wayland (no display manager), suspended, and came back. I then started sway, and sure enough I have to click twice on everything.

smlx commented 2 years ago

There'a a bug reported in libinput upstream that matches your description: https://gitlab.freedesktop.org/libinput/libinput/-/issues/712

The upstream bug describes the same problem happening in Gnome, so I guess it's unlikely to be a Sway bug?

ackstorm23 commented 2 years ago

There'a a bug reported in libinput upstream that matches your description: https://gitlab.freedesktop.org/libinput/libinput/-/issues/712

The upstream bug describes the same problem happening in Gnome, so I guess it's unlikely to be a Sway bug?

That bug seems to describe a problem with the touch part of the touch pad, but moving the mouse cursor works perfectly fine in my situation.

Mouse clicks are what are impacted for me. But I'll check it out.

sespiros commented 1 year ago

I also have the same issue and haven't been able to properly debug it yet. A workaround that I use is helps some times:

sudo modprobe -r psmouse
sudo modprobe psmouse

Source

treibholz commented 1 year ago

Same issue here, my workaround is a bit simpler:

then my touchpad works again.

treibholz commented 1 year ago

I just had the same behavior with gnome, maybe this is not related to sway at all...

cedricbu commented 1 year ago

Same behavior for me, on Fedora 38 + Sway : after resuming from suspect, touchpad requires 3 fingers for scroll (until I read this issue, I hadn't realized using 3 fingers instead of 2 would work). I'm dropping an additional piece of info that I haven't seen in the previous comments, maybe it might help someone?

Something that I realized is that the identifier of the touchpad changes when the weird behaviour happens:

When the touchpad requires 3 fingers, it is recognized as a SynPS/2 Synaptics TouchPad:

$ swaymsg -t get_inputs | jq '.[] | select(.type=="touchpad")' 
{
  "identifier": "2:7:SynPS/2_Synaptics_TouchPad",
  "name": "SynPS/2 Synaptics TouchPad",
  "vendor": 2,
  "product": 7,
  "type": "touchpad",
  "scroll_factor": 1.0,
  "libinput": {
    "send_events": "enabled",
    "tap": "disabled",
    "tap_button_map": "lrm",
    "tap_drag": "enabled",
    "tap_drag_lock": "disabled",
    "accel_speed": 0.0,
    "accel_profile": "adaptive",
    "natural_scroll": "disabled",
    "left_handed": "disabled",
    "click_method": "button_areas",
    "middle_emulation": "disabled",
    "scroll_method": "two_finger",
    "dwt": "enabled",
    "dwtp": "enabled"
  }
}

While when it works correctly (e.g.: after reboots, usually), it's being seen as a "Synaptics TM2749-001":

$ jq '.[] | select(.type=="touchpad")' < input-touchpad-working.json 
{
  "identifier": "1739:0:Synaptics_TM2749-001",
  "name": "Synaptics TM2749-001",
  "vendor": 1739,
  "product": 0,
  "type": "touchpad",
  "scroll_factor": 1.0,
  "libinput": {
    "send_events": "enabled",
    "tap": "disabled",
    "tap_button_map": "lrm",
    "tap_drag": "enabled",
    "tap_drag_lock": "disabled",
    "accel_speed": 0.0,
    "accel_profile": "adaptive",
    "natural_scroll": "disabled",
    "left_handed": "disabled",
    "click_method": "button_areas",
    "middle_emulation": "disabled",
    "scroll_method": "two_finger",
    "dwt": "enabled",
    "dwtp": "enabled"
  }
}

This seems to be consistent