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

Stylus input doesn't rotate. #1990

Closed
dashavoo opened this issue Jul 17, 2024 · 11 comments · Fixed by #2060
Closed

Stylus input doesn't rotate. #1990

dashavoo opened this issue Jul 17, 2024 · 11 comments · Fixed by #2060

Comments

@dashavoo
Copy link

  • Version: labwc 0.7.3
  • Distro: Arch

I am using a laptop with a touchscreen and stylus and using rot8 to rotate the screen based on orientation.
This works well under Xorg and Sway, but under labwc the rotation is only applying to the finger input, not the stylus input.

These are the lines from my rc.xml

<touch deviceName="Wacom HID 5284 Finger" mapToOutput="eDP-1" />
<touch deviceName="Wacom HID 5284 Pen" mapToOutput="eDP-1" />

The same works under Sway when I run these commands:

swaymsg "input 1386:21124:Wacom_HID_5284_Pen map_to_output eDP-1"
swaymsg "input 1386:21124:Wacom_HID_5284_Finger map_to_output eDP-1"
@johanmalm
Copy link
Collaborator

@jp7677 - may we lean on your knowledge here?

@dashavoo
Copy link
Author

Sorry, I should have added more detail in the original post. It didn't occur to me there might be a --debug option until now 🤦‍♂️ . I've attached the full output of labwc --debug: labwc-debug.log.

I think particularly relevant is:

00:00:00.177 [DEBUG] [backend/libinput/events.c:70] Adding Wacom HID 5284 Pen [1386:21124]
00:00:00.177 [DEBUG] [../labwc-0.7.3/src/input/tablet.c:528] setting up tablet
00:00:00.177 [INFO] [../labwc-0.7.3/src/input/tablet.c:547] tablet dimensions: 286.08mm x 178.80mm
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:372] map tablet to output (null)

For some reason the output isn't being mapped to the output, despite the option shown in my original post.
The Finger input, on the other hand, is mapped as expected:

00:00:00.177 [DEBUG] [backend/libinput/events.c:70] Adding Wacom HID 5284 Finger [1386:21124]
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:137] tap unavailable
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:147] tap-and-drag not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:156] drag lock not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:165] natural scroll not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:174] left-handed mode not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:182] pointer acceleration unavailable
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:197] middle emulation not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:206] dwt not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:216] click method not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:236] send events mode not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:245] calibration matrix not configured
00:00:00.177 [INFO] [../labwc-0.7.3/src/config/touch.c:24] find touch configuration for Wacom HID 5284 Finger

00:00:00.177 [INFO] [../labwc-0.7.3/src/config/touch.c:28] found touch configuration for Wacom HID 5284 Finger

00:00:00.177 [INFO] [../labwc-0.7.3/src/seat.c:348] map touch to output eDP-1

There seems to be a lot more going on for the "Finger" input than the "Pen" input, but I am not sure any of it is relevant apart from the last line about mapping to output.

@jp7677
Copy link
Contributor

jp7677 commented Jul 19, 2024 via email

@dashavoo
Copy link
Author

The same behaviour (stylus input doesn't follow screen orientation) but in the logs it does say it is being mapped to that screen now.
labwc-debug-with-tablet-maptooutput.log

@dashavoo
Copy link
Author

Is there any more information I can provide to help debug this?

@dashavoo
Copy link
Author

dashavoo commented Jul 25, 2024

I have noticed that the cursor is correctly rotated, despite the actual stylus movements not being rotated.

I've been trying to work this out without success, but I've wondered whether the rotation here should be coming from a non-static source? I haven't yet worked out what that source might be.

Hopefully this is helpful to solve the problem or at least to tell me if I'm barking up the wrong tree!

Just to confirm also, the issue still exists on 0.7.3 and latest HEAD.

@johanmalm
Copy link
Collaborator

Are you okay to wait until @jp7677 has time to respond? They are the most knowledgeable on this.
Things sometimes slow down a bit in the summer so hope that is okay

@dashavoo
Copy link
Author

Of course. Sorry, I didn't mean to seem impatient. I know people have other things to do.

@jp7677
Copy link
Contributor

jp7677 commented Aug 6, 2024

Sorry for the late response, I was indeed away for a while.

I'm seeing the same behavior on my machine using wlr-randr --output DP-1 --transform 90/wlr-randr --output DP-1 --transform normal with mapping the tablet to "DP-1". Manually setting the tablet rotation mitigates this, but I understand that this is not practical for your setup.

That said, I don't see (yet, not yet looked that closely) what we are doing differently for output mapping comparing to sway and where auto rotation should comes from in sway. Does your sway logs say anything interesting with regard to output mapping or even rotation?

@jp7677
Copy link
Contributor

jp7677 commented Aug 7, 2024

@dashavoo Do you have a chance to try this hack applied on labwc master? I just wanna make sure that I'm on the right track for your setup.

Edit: Removed wrong approach.

wlroots already does coordinate transformation when a tablet is mapped to an output (https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/types/wlr_cursor.c#L903), so I'm not yet sure why this isn't sufficient. I'll look into the math later, but it's a start.

@jp7677
Copy link
Contributor

jp7677 commented Aug 8, 2024

Oh, i think i know what is going on. We (labwc) are subscribed directly to the tablet events (https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/include/wlr/types/wlr_tablet_tool.h#L70), but the tablet events also exists on wlr_cursor (there is also https://gitlab.freedesktop.org/wlroots/wlroots/-/blob/master/include/wlr/types/wlr_cursor.h#L72). Only the latter emits transformed coordinates.

So something like this is probably the correct fix:

diff --git a/include/input/tablet.h b/include/input/tablet.h
index 93fdda5a..0ca11fae 100644
--- a/include/input/tablet.h
    b/include/input/tablet.h
@@ -23,10  23,10 @@ struct drawing_tablet {
        double slider;
        double wheel_delta;
        struct {
-               struct wl_listener proximity;
-               struct wl_listener axis;
-               struct wl_listener tip;
-               struct wl_listener button;
                struct wl_listener tablet_tool_proximity;
                struct wl_listener tablet_tool_axis;
                struct wl_listener tablet_tool_tip;
                struct wl_listener tablet_tool_button;
                struct wl_listener destroy;
        } handlers;
        struct wl_list link; /* seat.tablets */
diff --git a/src/input/tablet.c b/src/input/tablet.c
index 743fa72e..c207b83f 100644
--- a/src/input/tablet.c
    b/src/input/tablet.c
@@ -236,7  236,7 @@ notify_motion(struct drawing_tablet *tablet, struct drawing_tablet_tool *tool,
 }
 
 static void
-handle_proximity(struct wl_listener *listener, void *data)
 handle_tablet_tool_proximity(struct wl_listener *listener, void *data)
 {
        struct wlr_tablet_tool_proximity_event *ev = data;
        struct drawing_tablet *tablet = ev->tablet->data;
@@ -286,7  286,7 @@ handle_proximity(struct wl_listener *listener, void *data)
 static bool is_down_mouse_emulation = false;
 
 static void
-handle_axis(struct wl_listener *listener, void *data)
 handle_tablet_tool_axis(struct wl_listener *listener, void *data)
 {
        struct wlr_tablet_tool_axis_event *ev = data;
        struct drawing_tablet *tablet = ev->tablet->data;
@@ -460,7  460,7 @@ seat_pointer_end_grab(struct drawing_tablet_tool *tool,
 }
 
 static void
-handle_tip(struct wl_listener *listener, void *data)
 handle_tablet_tool_tip(struct wl_listener *listener, void *data)
 {
        struct wlr_tablet_tool_tip_event *ev = data;
        struct drawing_tablet *tablet = ev->tablet->data;
@@ -535,7  535,7 @@ handle_tip(struct wl_listener *listener, void *data)
 }
 
 static void
-handle_button(struct wl_listener *listener, void *data)
 handle_tablet_tool_button(struct wl_listener *listener, void *data)
 {
        struct wlr_tablet_tool_button_event *ev = data;
        struct drawing_tablet *tablet = ev->tablet->data;
@@ -604,10  604,10 @@ handle_destroy(struct wl_listener *listener, void *data)
        wl_list_remove(&tablet->link);
        tablet_pad_attach_tablet(tablet->seat);
 
-       wl_list_remove(&tablet->handlers.tip.link);
-       wl_list_remove(&tablet->handlers.button.link);
-       wl_list_remove(&tablet->handlers.proximity.link);
-       wl_list_remove(&tablet->handlers.axis.link);
        wl_list_remove(&tablet->handlers.tablet_tool_tip.link);
        wl_list_remove(&tablet->handlers.tablet_tool_button.link);
        wl_list_remove(&tablet->handlers.tablet_tool_proximity.link);
        wl_list_remove(&tablet->handlers.tablet_tool_axis.link);
        wl_list_remove(&tablet->handlers.destroy.link);
        free(tablet);
 }
@@ -636,10  636,10 @@ tablet_init(struct seat *seat, struct wlr_input_device *wlr_device)
        tablet->wheel_delta = 0.0;
        wlr_log(WLR_INFO, "tablet dimensions: %.2fmm x %.2fmm",
                tablet->tablet->width_mm, tablet->tablet->height_mm);
-       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, axis);
-       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, proximity);
-       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, tip);
-       CONNECT_SIGNAL(tablet->tablet, &tablet->handlers, button);
        CONNECT_SIGNAL(tablet->seat->cursor, &tablet->handlers, tablet_tool_axis);
        CONNECT_SIGNAL(tablet->seat->cursor, &tablet->handlers, tablet_tool_proximity);
        CONNECT_SIGNAL(tablet->seat->cursor, &tablet->handlers, tablet_tool_tip);
        CONNECT_SIGNAL(tablet->seat->cursor, &tablet->handlers, tablet_tool_button);
        CONNECT_SIGNAL(wlr_device, &tablet->handlers, destroy);
 
        wl_list_insert(&seat->tablets, &tablet->link);

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

Successfully merging a pull request may close this issue.

3 participants