util: Add INPUT debug topic

Allow debugging input issues more easily by adding an INPUT debug topic.
Currently there are only debug messages for the native backend.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/1065
This commit is contained in:
Jonas Dreßler 2020-02-18 14:56:25 +01:00 committed by Jonas Ådahl
parent 41992757e0
commit efe1bc2e59
4 changed files with 73 additions and 12 deletions

View File

@ -275,7 +275,12 @@ update_button_count (MetaSeatNative *seat,
{
/* Handle cases where we newer saw the initial pressed event. */
if (seat->button_count[button] == 0)
return 0;
{
meta_topic (META_DEBUG_INPUT,
"Counting release of key 0x%x and count is already 0\n",
button);
return 0;
}
return --seat->button_count[button];
}
@ -297,10 +302,14 @@ meta_seat_native_notify_key (MetaSeatNative *seat,
{
/* Drop any repeated button press (for example from virtual devices. */
int count = update_button_count (seat, key, state);
if (state && count > 1)
return;
if (!state && count != 0)
return;
if ((state && count > 1) ||
(!state && count != 0))
{
meta_topic (META_DEBUG_INPUT,
"Dropping repeated %s of key 0x%x, count %d, state %d\n",
state ? "press" : "release", key, count, state);
return;
}
}
/* We can drop the event on the floor if no stage has been
@ -514,10 +523,14 @@ meta_seat_native_notify_button (MetaSeatNative *seat,
/* Drop any repeated button press (for example from virtual devices. */
button_count = update_button_count (seat, button, state);
if (state && button_count > 1)
return;
if (!state && button_count != 0)
return;
if ((state && button_count > 1) ||
(!state && button_count != 0))
{
meta_topic (META_DEBUG_INPUT,
"Dropping repeated %s of button 0x%x, count %d\n",
state ? "press" : "release", button, button_count);
return;
}
/* We can drop the event on the floor if no stage has been
* associated with the device yet. */
@ -1840,7 +1853,14 @@ process_device_event (MetaSeatNative *seat,
seat_key_count != 1) ||
(key_state == LIBINPUT_KEY_STATE_RELEASED &&
seat_key_count != 0))
break;
{
meta_topic (META_DEBUG_INPUT,
"Dropping key-%s of key 0x%x because seat-wide "
"key count is %d\n",
key_state == LIBINPUT_KEY_STATE_PRESSED ? "press" : "release",
key, seat_key_count);
break;
}
meta_seat_native_notify_key (seat_from_device (device),
device,
@ -1927,7 +1947,14 @@ process_device_event (MetaSeatNative *seat,
seat_button_count != 1) ||
(button_state == LIBINPUT_BUTTON_STATE_RELEASED &&
seat_button_count != 0))
break;
{
meta_topic (META_DEBUG_INPUT,
"Dropping button-%s of button 0x%x because seat-wide "
"button count is %d\n",
button_state == LIBINPUT_BUTTON_STATE_PRESSED ? "press" : "release",
button, seat_button_count);
break;
}
meta_seat_native_notify_button (seat_from_device (device), device,
time_us, button, button_state);

View File

@ -27,6 +27,7 @@
#include "backends/native/meta-seat-native.h"
#include "backends/native/meta-virtual-input-device-native.h"
#include "clutter/clutter-mutter.h"
#include "meta/util.h"
enum
{
@ -116,6 +117,10 @@ release_pressed_buttons (ClutterVirtualInputDevice *virtual_device)
time_us = g_get_monotonic_time ();
meta_topic (META_DEBUG_INPUT,
"Releasing pressed buttons while destroying virtual input device "
"(device %p)\n", virtual_device);
for (code = 0; code < G_N_ELEMENTS (virtual_evdev->button_count); code++)
{
if (virtual_evdev->button_count[code] == 0)
@ -231,6 +236,11 @@ meta_virtual_input_device_native_notify_button (ClutterVirtualInputDevice *virtu
return;
}
meta_topic (META_DEBUG_INPUT,
"Emitting virtual button-%s of button 0x%x (device %p)\n",
button_state == CLUTTER_BUTTON_STATE_PRESSED ? "press" : "release",
evdev_button, virtual_device);
meta_seat_native_notify_button (virtual_evdev->seat,
virtual_evdev->device,
time_us,
@ -266,6 +276,11 @@ meta_virtual_input_device_native_notify_key (ClutterVirtualInputDevice *virtual_
return;
}
meta_topic (META_DEBUG_INPUT,
"Emitting virtual key-%s of key 0x%x (device %p)\n",
key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release",
key, virtual_device);
meta_seat_native_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
@ -355,6 +370,12 @@ apply_level_modifiers (ClutterVirtualInputDevice *virtual_device,
clutter_input_device_keycode_to_evdev (virtual_evdev->device,
keycode, &evcode);
meta_topic (META_DEBUG_INPUT,
"Emitting virtual key-%s of modifier key 0x%x (device %p)\n",
key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release",
evcode, virtual_device);
meta_seat_native_notify_key (virtual_evdev->seat,
virtual_evdev->device,
time_us,
@ -402,6 +423,12 @@ meta_virtual_input_device_native_notify_keyval (ClutterVirtualInputDevice *virtu
return;
}
meta_topic (META_DEBUG_INPUT,
"Emitting virtual key-%s of key 0x%x with modifier level %d, "
"press count %d (device %p)\n",
key_state == CLUTTER_KEY_STATE_PRESSED ? "press" : "release",
evcode, level, key_count, virtual_device);
if (key_state)
apply_level_modifiers (virtual_device, time_us, level, key_state);
@ -637,6 +664,10 @@ meta_virtual_input_device_native_constructed (GObject *object)
device_type = clutter_virtual_input_device_get_device_type (virtual_device);
meta_topic (META_DEBUG_INPUT,
"Creating new virtual input device of type %d (%p)\n",
device_type, virtual_device);
virtual_evdev->device =
meta_input_device_native_new_virtual (virtual_evdev->seat,
device_type,

View File

@ -335,6 +335,8 @@ topic_name (MetaDebugTopic topic)
return "EDGE_RESISTANCE";
case META_DEBUG_DBUS:
return "DBUS";
case META_DEBUG_INPUT:
return "INPUT";
case META_DEBUG_VERBOSE:
return "VERBOSE";
}

View File

@ -111,7 +111,8 @@ typedef enum
META_DEBUG_SHAPES = 1 << 19,
META_DEBUG_COMPOSITOR = 1 << 20,
META_DEBUG_EDGE_RESISTANCE = 1 << 21,
META_DEBUG_DBUS = 1 << 22
META_DEBUG_DBUS = 1 << 22,
META_DEBUG_INPUT = 1 << 23
} MetaDebugTopic;
META_EXPORT