Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tablet pen map_to_output not applied correctly at startup #5231

Closed
Xyene opened this issue Apr 18, 2020 · 0 comments · Fixed by #5243
Closed

Tablet pen map_to_output not applied correctly at startup #5231

Xyene opened this issue Apr 18, 2020 · 0 comments · Fixed by #5243

Comments

@Xyene
Copy link
Member

Xyene commented Apr 18, 2020

I'm running sway master, and have two displays, arranged in the below configuration:

image

(One is 2560x1440, the other 1600x900.)

My sway config contains directives for mapping my pen to DP-1.

input 9580:110:HUION_420_Pen {
  map_to_output DP-1
  map_from_region 0.22x0.22 0.78x0.78
  left_handed enabled
}

However, on startup, my pen is not confined, and actually appears at the bottom-right corner of HDMI-A-2. Moving it over to DP-1 myself doesn't make it confined. Triggering a reload after startup via swaymsg reload correctly confines the pen, though.

Edit: this appears to me to be a race of sorts. My logs contain:

00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=3 [0:0]                                      
00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=7 [0:0]                                      
00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=8 [0:0]                                      
00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=9 [0:0]                                      
00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=10 [0:0]                                     
00:00:00.439 [backend/libinput/events.c:94] Added HDA ATI HDMI HDMI/DP,pcm=11 [0:0]                                     
00:00:00.439 [backend/libinput/events.c:94] Added HUION 420 Pen [9580:110]                                              
00:00:00.439 [sway/input/input-manager.c:231] adding device: '9580:110:HUION_420_Pen'                                   
00:00:00.439 [sway/input/libinput.c:191] config_libinput_pointer('9580:110:HUION_420_Pen' on  '9580:110:HUION_420_Pen') 
00:00:00.439 [sway/input/libinput.c:106] left_handed_set(1)                                                             
00:00:00.439 [sway/input/seat.c:824] adding device 9580:110:HUION_420_Pen to seat seat0                                 
00:00:00.439 [sway/input/seat.c:630] Applying input config to 9580:110:HUION_420_Pen                                    
00:00:00.439 [sway/input/seat.c:644] Mapping input device 9580:110:HUION_420_Pen to output DP-1                         
00:00:00.439 [backend/libinput/events.c:94] Added HUION 420 Pad [9580:110]                                              
...
00:00:00.456 [backend/libinput/backend.c:101] libinput successfully initialized                                         
00:00:00.456 [backend/drm/drm.c:1320] Scanning DRM connectors                                                           
00:00:00.457 [backend/drm/drm.c:1383] Found connector 'DP-1'                                                            
00:00:00.457 [backend/drm/drm.c:1419] 'DP-1' connected                                                                  
00:00:00.457 [backend/drm/drm.c:1421] Current CRTC: 47                                                                  
00:00:00.457 [backend/drm/drm.c:1426] Physical size: 600x340                                                            
00:00:00.457 [backend/drm/drm.c:1443] Detected modes:                                                                   
00:00:00.457 [backend/drm/drm.c:1468]   2560x1440@59951 (preferred)                                                     
00:00:00.457 [backend/drm/drm.c:1468]   2560x1440@61029

So, it would seem that if the display isn't initialized before the output map is set, it won't take effect. Seemingly supporting this hypothesis, unplugging and replugging the tablet (rather than swaymsg reload) also works.

The code responsible is:

sway/sway/input/seat.c

Lines 653 to 658 in 58eb0c4

struct sway_output *output = output_by_name_or_id(mapped_to_output);
if (!output) {
return;
}
wlr_cursor_map_input_to_output(seat->cursor->cursor,
sway_device->input_device->wlr_device, output->wlr_output);

(output is NULL at that point in time, and the map is never set.)

Xyene added a commit to Xyene/sway that referenced this issue Apr 20, 2020
Some input rules, like `map_to_output`, are dependent on the presence of
a specific screen being present. This currently does not work for
hotplugged outputs, or outputs that are processed after the input device
is initially probed.

This commit fixes both cases, by reconfiguring inputs on each output
addition.

Fixes swaywm#5231.
Xyene added a commit to Xyene/sway that referenced this issue Apr 20, 2020
Some input rules, like `map_to_output`, are dependent on a specific
screen being present. This currently does not work for hotplugged
outputs, or outputs that are processed after the input device is
initially probed.

This commit fixes both cases, by reconfiguring inputs on each output
addition.

Fixes swaywm#5231.
emersion pushed a commit that referenced this issue Apr 24, 2020
Some input rules, like `map_to_output`, are dependent on a specific
screen being present. This currently does not work for hotplugged
outputs, or outputs that are processed after the input device is
initially probed.

This commit fixes both cases, by reconfiguring inputs on each output
addition.

Fixes #5231.
Xyene added a commit to Xyene/sway that referenced this issue Apr 25, 2020
Xyene added a commit to Xyene/sway that referenced this issue Apr 25, 2020
Previously in 3de1a39, it "worked by accident" in my testing since the
display being used in `map_to_output` was initialized first (the map
would not be applied because the display hadn't actually come online
yet), and was followed by a second display (at which point the map would
get applied for the first display).

Refs swaywm#5231
emersion pushed a commit that referenced this issue Apr 26, 2020
Previously in 3de1a39, it "worked by accident" in my testing since the
display being used in `map_to_output` was initialized first (the map
would not be applied because the display hadn't actually come online
yet), and was followed by a second display (at which point the map would
get applied for the first display).

Refs #5231
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant