mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
ClutterVirtualInputDevice: Add discrete scrolling
Add emitting of discrete scrolling events (such as mouse scroll wheel-like events). https://bugzilla.gnome.org/show_bug.cgi?id=784199
This commit is contained in:
parent
d3c559a917
commit
a10ad577a7
@ -115,6 +115,19 @@ clutter_virtual_input_device_notify_keyval (ClutterVirtualInputDevice *virtual_d
|
|||||||
klass->notify_keyval (virtual_device, time_us, keyval, key_state);
|
klass->notify_keyval (virtual_device, time_us, keyval, key_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
clutter_virtual_input_device_notify_discrete_scroll (ClutterVirtualInputDevice *virtual_device,
|
||||||
|
uint64_t time_us,
|
||||||
|
ClutterScrollDirection direction,
|
||||||
|
ClutterScrollSource scroll_source)
|
||||||
|
{
|
||||||
|
ClutterVirtualInputDeviceClass *klass =
|
||||||
|
CLUTTER_VIRTUAL_INPUT_DEVICE_GET_CLASS (virtual_device);
|
||||||
|
|
||||||
|
klass->notify_discrete_scroll (virtual_device, time_us,
|
||||||
|
direction, scroll_source);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clutter_virtual_input_device_get_manager:
|
* clutter_virtual_input_device_get_manager:
|
||||||
* @virtual_device: a virtual device
|
* @virtual_device: a virtual device
|
||||||
|
@ -76,6 +76,11 @@ struct _ClutterVirtualInputDeviceClass
|
|||||||
uint64_t time_us,
|
uint64_t time_us,
|
||||||
uint32_t keyval,
|
uint32_t keyval,
|
||||||
ClutterKeyState key_state);
|
ClutterKeyState key_state);
|
||||||
|
|
||||||
|
void (*notify_discrete_scroll) (ClutterVirtualInputDevice *virtual_device,
|
||||||
|
uint64_t time_us,
|
||||||
|
ClutterScrollDirection direction,
|
||||||
|
ClutterScrollSource scroll_source);
|
||||||
};
|
};
|
||||||
|
|
||||||
CLUTTER_AVAILABLE_IN_ALL
|
CLUTTER_AVAILABLE_IN_ALL
|
||||||
@ -108,6 +113,13 @@ void clutter_virtual_input_device_notify_keyval (ClutterVirtualInputDevice *virt
|
|||||||
uint32_t keyval,
|
uint32_t keyval,
|
||||||
ClutterKeyState key_state);
|
ClutterKeyState key_state);
|
||||||
|
|
||||||
|
CLUTTER_AVAILABLE_IN_ALL
|
||||||
|
void clutter_virtual_input_device_notify_discrete_scroll (ClutterVirtualInputDevice *virtual_device,
|
||||||
|
uint64_t time_us,
|
||||||
|
ClutterScrollDirection direction,
|
||||||
|
ClutterScrollSource scroll_source);
|
||||||
|
|
||||||
|
|
||||||
CLUTTER_AVAILABLE_IN_ALL
|
CLUTTER_AVAILABLE_IN_ALL
|
||||||
ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
|
ClutterDeviceManager * clutter_virtual_input_device_get_manager (ClutterVirtualInputDevice *virtual_device);
|
||||||
|
|
||||||
|
@ -397,6 +397,57 @@ clutter_virtual_input_device_evdev_notify_keyval (ClutterVirtualInputDevice *vir
|
|||||||
apply_level_modifiers (virtual_device, time_us, level, key_state);
|
apply_level_modifiers (virtual_device, time_us, level, key_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
direction_to_discrete (ClutterScrollDirection direction,
|
||||||
|
double *discrete_dx,
|
||||||
|
double *discrete_dy)
|
||||||
|
{
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case CLUTTER_SCROLL_UP:
|
||||||
|
*discrete_dx = 0.0;
|
||||||
|
*discrete_dy = -1.0;
|
||||||
|
break;
|
||||||
|
case CLUTTER_SCROLL_DOWN:
|
||||||
|
*discrete_dx = 0.0;
|
||||||
|
*discrete_dy = 1.0;
|
||||||
|
break;
|
||||||
|
case CLUTTER_SCROLL_LEFT:
|
||||||
|
*discrete_dx = -1.0;
|
||||||
|
*discrete_dy = 0.0;
|
||||||
|
break;
|
||||||
|
case CLUTTER_SCROLL_RIGHT:
|
||||||
|
*discrete_dx = 1.0;
|
||||||
|
*discrete_dy = 0.0;
|
||||||
|
break;
|
||||||
|
case CLUTTER_SCROLL_SMOOTH:
|
||||||
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
clutter_virtual_input_device_evdev_notify_discrete_scroll (ClutterVirtualInputDevice *virtual_device,
|
||||||
|
uint64_t time_us,
|
||||||
|
ClutterScrollDirection direction,
|
||||||
|
ClutterScrollSource scroll_source)
|
||||||
|
{
|
||||||
|
ClutterVirtualInputDeviceEvdev *virtual_evdev =
|
||||||
|
CLUTTER_VIRTUAL_INPUT_DEVICE_EVDEV (virtual_device);
|
||||||
|
double discrete_dx = 0.0, discrete_dy = 0.0;
|
||||||
|
|
||||||
|
if (time_us == CLUTTER_CURRENT_TIME)
|
||||||
|
time_us = g_get_monotonic_time ();
|
||||||
|
|
||||||
|
direction_to_discrete (direction, &discrete_dx, &discrete_dy);
|
||||||
|
|
||||||
|
clutter_seat_evdev_notify_discrete_scroll (virtual_evdev->seat,
|
||||||
|
virtual_evdev->device,
|
||||||
|
time_us,
|
||||||
|
discrete_dx, discrete_dy,
|
||||||
|
scroll_source);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
clutter_virtual_input_device_evdev_get_property (GObject *object,
|
clutter_virtual_input_device_evdev_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
@ -500,6 +551,7 @@ clutter_virtual_input_device_evdev_class_init (ClutterVirtualInputDeviceEvdevCla
|
|||||||
virtual_input_device_class->notify_button = clutter_virtual_input_device_evdev_notify_button;
|
virtual_input_device_class->notify_button = clutter_virtual_input_device_evdev_notify_button;
|
||||||
virtual_input_device_class->notify_key = clutter_virtual_input_device_evdev_notify_key;
|
virtual_input_device_class->notify_key = clutter_virtual_input_device_evdev_notify_key;
|
||||||
virtual_input_device_class->notify_keyval = clutter_virtual_input_device_evdev_notify_keyval;
|
virtual_input_device_class->notify_keyval = clutter_virtual_input_device_evdev_notify_keyval;
|
||||||
|
virtual_input_device_class->notify_discrete_scroll = clutter_virtual_input_device_evdev_notify_discrete_scroll;
|
||||||
|
|
||||||
obj_props[PROP_SEAT] = g_param_spec_pointer ("seat",
|
obj_props[PROP_SEAT] = g_param_spec_pointer ("seat",
|
||||||
P_("ClutterSeatEvdev"),
|
P_("ClutterSeatEvdev"),
|
||||||
|
Loading…
Reference in New Issue
Block a user