mirror of
https://review.haiku-os.org/haiku
synced 2024-11-23 07:18:40 +01:00
PadBlocker: Avoid blocking non-trackpad devices
Exposes a new field on mouse events named "device" that specifices what type of device the event originates from. This is then used in PadBlocker to ignore events that don't originate from trackpads. This field should also be exposed to the public API in case any program in userspace want to use it, as it may be useful for other purposes. Fixes #19238 and #17821 Change-Id: Ic0f8c088cf5d2b0414a8e69498b48f2a3e370d73 Reviewed-on: https://review.haiku-os.org/c/haiku/+/8557 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk> Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
parent
fd7bde29e9
commit
b08fdcde6f
@ -25,6 +25,14 @@ enum input_device_type {
|
||||
};
|
||||
|
||||
|
||||
enum input_pointing_device_subtype {
|
||||
B_UNKNOWN_DEVICE_SUBTYPE = 0,
|
||||
B_MOUSE_DEVICE_SUBTYPE = 1,
|
||||
B_TOUCHPAD_DEVICE_SUBTYPE = 2,
|
||||
B_TABLET_DEVICE_SUBTYPE = 3
|
||||
};
|
||||
|
||||
|
||||
enum input_device_notification {
|
||||
B_INPUT_DEVICE_ADDED = 0x0001,
|
||||
B_INPUT_DEVICE_STARTED = 0x0002,
|
||||
|
@ -277,6 +277,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg)
|
||||
}
|
||||
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE);
|
||||
message->AddInt32("buttons", movements.buttons);
|
||||
message->AddFloat("x", movements.xpos);
|
||||
message->AddFloat("y", movements.ypos);
|
||||
@ -287,6 +288,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg)
|
||||
message = new BMessage(B_MOUSE_MOVED);
|
||||
if (message) {
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE);
|
||||
message->AddInt32("buttons", movements.buttons);
|
||||
message->AddFloat("x", movements.xpos);
|
||||
message->AddFloat("y", movements.ypos);
|
||||
@ -307,6 +309,7 @@ EasyPenInputDevice::DeviceWatcher(void *arg)
|
||||
message = new BMessage(B_MOUSE_WHEEL_CHANGED);
|
||||
if (message) {
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_TABLET_DEVICE_SUBTYPE);
|
||||
message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta);
|
||||
message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta);
|
||||
|
||||
|
@ -517,7 +517,11 @@ MouseDevice::_ControlThread()
|
||||
&& message->AddFloat("be:wheel_delta_x",
|
||||
movements.wheel_xdelta) == B_OK
|
||||
&& message->AddFloat("be:wheel_delta_y",
|
||||
movements.wheel_ydelta) == B_OK)
|
||||
movements.wheel_ydelta) == B_OK
|
||||
&& message->AddInt32("be:device_subtype",
|
||||
fIsTouchpad
|
||||
? B_TOUCHPAD_DEVICE_SUBTYPE
|
||||
: B_MOUSE_DEVICE_SUBTYPE) == B_OK)
|
||||
fTarget.EnqueueMessage(message);
|
||||
else
|
||||
delete message;
|
||||
@ -637,7 +641,9 @@ MouseDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons,
|
||||
if (message->AddInt64("when", when) < B_OK
|
||||
|| message->AddInt32("buttons", buttons) < B_OK
|
||||
|| message->AddInt32("x", deltaX) < B_OK
|
||||
|| message->AddInt32("y", deltaY) < B_OK) {
|
||||
|| message->AddInt32("y", deltaY) < B_OK
|
||||
|| message->AddInt32("be:device_subtype",
|
||||
fIsTouchpad ? B_TOUCHPAD_DEVICE_SUBTYPE : B_MOUSE_DEVICE_SUBTYPE) < B_OK) {
|
||||
delete message;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -276,6 +276,7 @@ MouseInputDevice::DeviceWatcher(void* arg)
|
||||
message = new BMessage(B_MOUSE_UP);
|
||||
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE);
|
||||
message->AddInt32("buttons", movements.buttons);
|
||||
|
||||
if ((buttons & movements.buttons) > 0) {
|
||||
@ -333,6 +334,7 @@ MouseInputDevice::DeviceWatcher(void* arg)
|
||||
message = new BMessage(B_MOUSE_MOVED);
|
||||
if (message) {
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE);
|
||||
message->AddInt32("buttons", movements.buttons);
|
||||
message->AddInt32("x", xdelta);
|
||||
message->AddInt32("y", ydelta);
|
||||
@ -345,6 +347,7 @@ MouseInputDevice::DeviceWatcher(void* arg)
|
||||
message = new BMessage(B_MOUSE_WHEEL_CHANGED);
|
||||
if (message) {
|
||||
message->AddInt64("when", movements.timestamp);
|
||||
message->AddInt32("be:device_subtype", B_MOUSE_DEVICE_SUBTYPE);
|
||||
message->AddFloat("be:wheel_delta_x", movements.wheel_xdelta);
|
||||
message->AddFloat("be:wheel_delta_y", movements.wheel_ydelta);
|
||||
|
||||
|
@ -381,7 +381,9 @@ TabletDevice::_ControlThread()
|
||||
&& message->AddFloat("be:wheel_delta_x",
|
||||
movements.wheel_xdelta) == B_OK
|
||||
&& message->AddFloat("be:wheel_delta_y",
|
||||
movements.wheel_ydelta) == B_OK)
|
||||
movements.wheel_ydelta) == B_OK
|
||||
&& message->AddInt32("be:device_subtype",
|
||||
B_TABLET_DEVICE_SUBTYPE) == B_OK)
|
||||
fTarget.EnqueueMessage(message);
|
||||
else
|
||||
delete message;
|
||||
@ -433,7 +435,9 @@ TabletDevice::_BuildMouseMessage(uint32 what, uint64 when, uint32 buttons,
|
||||
if (message->AddInt64("when", when) < B_OK
|
||||
|| message->AddInt32("buttons", buttons) < B_OK
|
||||
|| message->AddFloat("x", xPosition) < B_OK
|
||||
|| message->AddFloat("y", yPosition) < B_OK) {
|
||||
|| message->AddFloat("y", yPosition) < B_OK
|
||||
|| message->AddInt32("be:device_subtype",
|
||||
B_TABLET_DEVICE_SUBTYPE) < B_OK) {
|
||||
delete message;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <OS.h>
|
||||
#include <StorageKit.h>
|
||||
|
||||
#include <add-ons/input_server/InputServerDevice.h>
|
||||
#include <add-ons/input_server/InputServerFilter.h>
|
||||
|
||||
#if DEBUG
|
||||
@ -162,10 +163,16 @@ filter_result PadBlocker::Filter(BMessage *message, BList *outList)
|
||||
|
||||
case B_MOUSE_DOWN:
|
||||
{
|
||||
int32 device;
|
||||
// do nothing if disabled
|
||||
if (_threshold == 0)
|
||||
break;
|
||||
|
||||
// only block touchpad devices
|
||||
if (message->FindInt32("be:device_subtype", &device) != B_OK
|
||||
|| device != B_TOUCHPAD_DEVICE_SUBTYPE)
|
||||
break;
|
||||
|
||||
bigtime_t now = system_time();
|
||||
// if less than the threshold has passed, tell input server
|
||||
// to ignore this message
|
||||
|
@ -1681,13 +1681,24 @@ InputServer::_SanitizeEvents(EventList& events)
|
||||
for (int32 index = 0; BMessage* event = (BMessage*)events.ItemAt(index);
|
||||
index++) {
|
||||
switch (event->what) {
|
||||
case B_MOUSE_WHEEL_CHANGED:
|
||||
{
|
||||
int32 device;
|
||||
if (event->FindInt32("be:device_subtype", &device) != B_OK)
|
||||
event->AddInt32("be:device_subtype", B_UNKNOWN_DEVICE_SUBTYPE);
|
||||
|
||||
break;
|
||||
}
|
||||
case B_MOUSE_MOVED:
|
||||
case B_MOUSE_DOWN:
|
||||
{
|
||||
int32 buttons;
|
||||
int32 buttons, device;
|
||||
if (event->FindInt32("buttons", &buttons) != B_OK)
|
||||
event->AddInt32("buttons", 0);
|
||||
|
||||
if (event->FindInt32("be:device_subtype", &device) != B_OK)
|
||||
event->AddInt32("be:device_subtype", B_UNKNOWN_DEVICE_SUBTYPE);
|
||||
|
||||
// supposed to fall through
|
||||
}
|
||||
case B_MOUSE_UP:
|
||||
|
Loading…
Reference in New Issue
Block a user