Commit graph

53 commits

Author SHA1 Message Date
Peter Hutterer
6a1bd5b0c9 meson.build: check gtk targets before building
We have two different dependencies on Wayland: GTK support and the
wayland-protocols we use directly. If we have GTK support but
wayland-protocols is not installed at meson configure time, our build
fails.

To avoid having multiple ifdefs in the code, let's define two new ones:
HAVE_GTK_WAYLAND and HAVE_GTK_X11, both set if GTK supports that
particular target (from pkgconfig) and we have the other support
libraries we need.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-06-11 10:54:15 +00:00
Peter Hutterer
395d12d634 util: auto-declare the element variable in ARRAY_FOR_EACH
All cases we have in our code base have an otherwise unused variable to
loop through the array. Let's auto-declare this as part of the loop.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2022-03-09 10:16:07 +10:00
Peter Hutterer
6bb02aaf30 High-resolution scroll wheel support
Starting with kernel v5.0 two new axes are available for high-resolution wheel
scrolling: REL_WHEEL_HI_RES and REL_HWHEEL_HI_RES. Both axes send data in
fractions of 120 where each multiple of 120 amounts to one logical scroll
event. Fractions of 120 indicate a wheel movement less than one detent.

This commit adds a new API for scroll events. Three new event types that encode
the axis source in the event type name and a new API to get a normalized-to-120
value that also used by Windows and the kernel (each multiple of 120 represents
a logical scroll click).

This addresses a main shortcoming with the existing API - it was unreliable to
calculate the click angle based on the axis value+discrete events and thus any
caller using the axis value alone would be left with some ambiguity. With the
v120 API it's now possible to (usually) calculate the click angle, but more
importantly it provides the simplest hw-independent way of scrolling by a
click or a fraction of a click.

A new event type is required, the only way to integrate the v120 value
otherwise was to start sending events with a discrete value of 0. This
would break existing xf86-input-libinput (divide by zero, fixed in 0.28.2) and
weston (general confusion). mutter, kwin are unaffected.

With the new API, the old POINTER_AXIS event are deprecated - callers should use
the new API where available and discard any POINTER_AXIS events.

Notable: REL_WHEEL/REL_HWHEEL are emulated by the kernel but there's no
guarantee that they'll come every accumulated 120 values, e.g. Logitech mice
often send events that don't add up to 120 per detent.

We use the kernel's wheel click emulation instead of doing our own.

libinput guarantees high-resolution events even on pre-5.0 kernels.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-31 08:45:01 +02:00
José Expósito
be7264f35b debug-gui: pointer locking on X11
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
José Expósito
a9b334ebb5 debug-gui: pointer locking on Wayland
Use the pointer constraints protocol to lock the pointer on Wayland.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
José Expósito
895e866da6 debug-gui: migrate to GTK4
Global:

- Stop passing commandline arguments to gtk_init:
  https://docs.gtk.org/gtk4/migrating-3to4.html#stop-passing-commandline-arguments-to-gtk_init

window_init function:

- gtk_window_new doesn't require a type anymore

- gtk_window_iconify has been renamed to gtk_window_minimize

- gtk_container_add has been removed in favor of container specific
  APIs. Use gtk_window_set_child in this case.

- gtk_widget_show_all has been removed, widgets are now visible by
  default:
  https://docs.gtk.org/gtk4/migrating-3to4.html#widgets-are-now-visible-by-default

- gtk_widget_set_events to NULL is no longer required, widgets must set
  their event handlers explicitly now:
  https://blog.gtk.org/2020/04/29/custom-widgets-in-gtk-4-input/

window_delete_event_cb function:

- Use the new close-request event:
  https://docs.gtk.org/gtk4/migrating-3to4.html#stop-using-gtkwidget-event-signals

map_event_cb function:

- gtk_widget_set_cursor_from_name instead of gdk_window_set_cursor

- Wait until the draw area is resized to use the whole window to start
  calculating sizes

window_place_ui_elements function:

- Use gtk_widget_get_width and gtk_widget_get_height instead of
  gtk_window_get_size

Drawing:

- Use gtk_drawing_area_set_draw_func instead of the GtkWidget::draw
  signal:
  https://docs.gtk.org/gtk4/migrating-3to4.html#adapt-to-drawing-model-changes

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
José Expósito
55889adeff tools/debug-gui: refactor UI element placement
Move the code used to pace the different UI elements to its own
function.

Refactor, no functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
José Expósito
791fbad5b9 tools/debug-gui: use GMainLoop instead of gtk_main
Migrate to GMainLoop because gtk_main is deprecated in GTK 4.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
José Expósito
f36ccc3c11 tools/debug-gui: move gtk_main_quit to a function
Wrap the calls to gtk_main_quit in its own function.

Refactor, no functional changes.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-08-03 16:52:39 +00:00
Peter Hutterer
234eeabe2f Replace fallthrough comments with __attribute__((fallthrough))
This has recently been endorsed by the linux kernel, it should be good
enough for us.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-07-22 23:14:43 +00:00
José Expósito
b6b15fa304 libinput: add hold gesture public API and tool support
Add hold gestures to the public API and the private functions to notify them.
Also add hold gestures to debug-events and debug-gui.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
2021-06-09 01:18:58 +00:00
weizhixiang
1339dbaf3d use more safety list_for_each_safe when remove element in traversing list
Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
2021-05-24 04:42:49 +00:00
weizhixiang
cce5921015 use ARRAY_FOR_EACH when traverse array
Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
2021-05-24 04:11:32 +00:00
Peter Hutterer
39b64107e9 tools/debug-gui: draw a sprite for the unaccelerated pointer as well
Add a second grey v-shaped (upside down triangle) pointer that moves around
with the unaccelerated deltas. This makes it easier to visualize how the
unaccelerated pointer moves around, the snake helps for some use-cases but not
all of them.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
1926a66fab tools/debug-gui: move the abs pointer position into a struct point
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
e99f59422c tools/debug-gui: move the pointer position into a struct point
No functional change

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
c71fa06607 tools/debug-gui: start the unaccelerated motion deltas in the screen center
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2021-03-11 10:40:00 +10:00
Peter Hutterer
4f282688ac tools: print the libinput_dispatch() counter for debugging messages
The messages with priority DEBUG refer to the various internal state machines
updating, so it's useful to know when they did so. Let's count up every time
we trigger libinput_dispatch() so we know how the messages group together.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-06 16:12:17 +10:00
Peter Hutterer
7244e36b50 tools: only call libinput_dispatch() once per poll
This is a closer approximation of all callers anyway, and it makes it easier
to debug which events are handled per libinput_dispatch() call.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-10-06 16:12:17 +10:00
Peter Hutterer
3403692ff0 tools: when running the test suite, start the debug-gui minimized
This allows us to run the option parsing test without getting interrupted by a
million debug-gui windows popping up for half a second.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-07-07 18:51:33 +10:00
Peter Hutterer
20cf83789d tools: constify the optarg handling of seats
This shuts up scan-build complaining about memory leaks in libinput
debug-events (needs the right combination of --device option and eventually
triggering usage()) and saves us a bunch of unnecessary allocations.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2020-02-24 01:53:21 +00:00
Peter Hutterer
2d1bcf982a pad: add LIBINPUT_EVENT_TABLET_PAD_KEY for pad keys
The Wacom Cintiq 24HD and later tablets send specific key events for
hardware/soft buttons. KEY_PROG1..KEY_PROG3 on earlier tablets,
KEY_CONTROLPANEL, KEY_ONSCREEN_DISPLAY, and KEY_BUTTONCONFIG on later tablets.
We ignore KEY_PROG1-3 because starting with kernel 5.4 older tablets will too
use the better-named #defines.

These differ from pad buttons as the key code in itself carries semantic
information, so we should pass them on as-is instead of mapping them to
meaningless 0-indexed buttons like we do on the other buttons.

So let's add a new event, LIBINPUT_EVENT_TABLET_PAD_KEY and the associated
functions to handle that case.

Pad keys have a fixed hw-defined semantic meaning and are thus not part of
a tablet mode group.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-04 15:38:39 +10:00
Peter Hutterer
490131ff61 tools: make debug-events accept multiple device nodes
For interaction between devices it's necessary to look at more than one device
at a time.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-26 00:34:08 +00:00
Peter Hutterer
12021c860e tools: debug-gui: show pressure/distance as vertical bar
Both of these are normalized so let's draw a bar that shows the values
accordingly. This makes it a lot easier to check whether pressure values go to
the maximum, etc.

A little extra square is shown whenever the tip is logically down.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-01 08:38:59 +10:00
Peter Hutterer
1e6802b91b Remove some usage of libinput-util.h
Positive side-effect - this exposed a bunch of missing #includes that got
pulled in by other headers before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-09-11 12:23:06 +10:00
Peter Hutterer
6a489b0636 tools: return 77 if gtk_init() fails in the debug-gui
And when that happens, skip the tests because what's happening here is that
you're running tests as root, but your X server doesn't allow root to connect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-26 21:09:22 +10:00
Peter Hutterer
8bfa1aa086 tools: handle pad strip/ring events in the debug-gui
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-13 11:02:42 +10:00
Peter Hutterer
e439d740f0 tools: display tablet and tablet pad buttons when pressed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-13 11:02:42 +10:00
Peter Hutterer
17d792445e tablet: add a the Totem tool type to the tablet interface
This is the public API only, not the internal bits, so nothing will work just
yet.

This interface addition is for the Dell Canvas Totem tool, so let's go with
the same name because options like "Rotary" are too ambiguous.

The totem is a knob that can be placed on the surface, it provides us with
location and rotation data. The touch major/minor fields are filled in by the
current totem, but they're always the same size.

The totem exports BTN_0 as well, so let's add that to the debug-events output.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-06-07 01:03:21 +00:00
Peter Hutterer
1150a8442f tools: display the discrete axis steps too
Draw a second smaller scroll bar that moves with every discrete step. For that
to work, we have to accumulate the value from the normal scroll events until
we get the first discrete one, then move up.

The value per discrete event changes depending on the click wheel angle, so we
can't just use discrete on its own if we want the two scroll bars aligned.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-04 15:47:27 +10:00
Peter Hutterer
d213804de8 tools: group the scroll bits into a struct
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-03-04 15:47:27 +10:00
Peter Hutterer
e0008d3dc2 tools: debug-gui: change the tablet color
Grey isn't pretty enough

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-14 13:08:51 +10:00
Peter Hutterer
f954cb29e4 tools: debug-gui: add a previously unbalanced cairo_restore()
And remove some of the unnecessary ones

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-14 13:02:13 +10:00
Peter Hutterer
c1ee05fb9a tools: debug-gui: move the pointer delta code to draw_pointer
Not sure why this was in draw_tablet(), probably copy/paste

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-14 13:02:13 +10:00
Peter Hutterer
e038a22360 tools: draw the tablet before the touch points
On the Dell Canvas Totem, the tool will cancel existing touch points and to
visually debug that, we need the touchpoints to be drawn over the tool.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-13 18:45:04 +10:00
Peter Hutterer
5b85cf06d8 tools: draw other buttons in the debug-gui
Buttons that aren't lmr are drawn in a separate button square now with the
name as it comes from the kernel. This only handles one button at a time, but
it'll do for debugging.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-13 07:26:54 +00:00
Peter Hutterer
335fe99a32 tools: debug-gui: move the lmr button handling into a substruct
No functional changes

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-13 07:26:54 +00:00
Peter Hutterer
790a301d13 tools: debug-gui: show cancelled touches as unfilled circles
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-02-13 07:26:54 +00:00
Peter Hutterer
96a0e8ed66 tools: don't apply config options on device removed
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-12-19 15:55:42 +10:00
Peter Hutterer
b033bc2677 tools: draw evdev events in the debug-gui
Listen to the pure evdev events from each device and print them. This makes it
slightly easier to associate certain jumps with the output, or otherwise see
that events are coming in even when libinput doesn't seem to process them
anymore.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 15:22:20 +10:00
Peter Hutterer
4e469291b1 tools: let debug-events take a device path
This is the most common use-case other than "all from udev", so let's just
parse a device path correctly without requiring --device.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
36af7d312b tools: make the tools exit with exit code 2 on usage issues
This makes it easier to test for usage issues

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
22890a4719 tools: handle sigint in debug-gui
Exit with success on SIGINT

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-11-07 05:03:52 +00:00
Peter Hutterer
e640bac867 tools: fix grab handling in libinput debug-gui
The libinput context's user_data was used for deciding whether to grab the
event device but also to hold the struct window data for the debug-gui. Worked
fine for the initial batch of devices, but any device coming in late would
just use the first field of the struct window to decide whether to grab or
not.

Fixes #122

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-27 17:04:51 +10:00
Peter Hutterer
f78d6669e5 tools: debug-*: show unaccelerated deltas for pointer events
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-08-08 10:07:43 +10:00
Peter Hutterer
0a13223c39 tools: fix grab argument passing for libinput debug-events
The &grab pointer we used to pass as userdata was the address of the function
argument which goes out of scope at the end of the function. This works fine
for devices immediately opened but when a device connects later, the address
may have been re-used since and it's content is undefined. If not NULL, we
end up grabbing the device.

Instead pass the grab option in which is guaranteed to live until the end of
main.

https://gitlab.freedesktop.org/libinput/libinput/issues/26

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-06-14 09:50:29 +10:00
Peter Hutterer
4c31a1a285 tools: debug-gui: add some extra targets for pointer acceleration testing
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-05-21 12:18:58 +10:00
Greg V
8adfac3975 Include stdarg.h where variadic functions are used
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-12-01 09:31:42 +10:00
Peter Hutterer
f7cfc2bbbb tools: restore option handling for the debug gui
window_init zeroes out the struct and loses any option parsing done before.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-09-05 10:41:27 +10:00
Peter Hutterer
d1b7b6267c tools: split the configuration option parsing out
We had one shared parsing function for all config options so tools parse
options that don't actually make sense (e.g. --quiet or --show-keycodes for
libinput-list-devices).

This patch splits the actual libinput device configuration out and reshuffles
everything to make use of that. One large patch, because splitting this up is
more confusing than dumping it all.

This means the actual option parsing is partially duplicated between debug-gui
and debug-events but hey, not everything in life is perfect.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2017-06-26 18:43:59 +10:00