mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 23:46:33 -05:00
backends/native: Use viewport info to find out stage extents
This information is equivalent to the stage extents, this just leaves meta_seat_native_get_stage() used for setting event->any.stage, which is a tiny lame excuse. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
parent
1377c2a97e
commit
c362bc4b51
@ -1425,17 +1425,16 @@ meta_input_device_native_get_libinput_device (ClutterInputDevice *device)
|
||||
|
||||
void
|
||||
meta_input_device_native_translate_coordinates (ClutterInputDevice *device,
|
||||
ClutterStage *stage,
|
||||
MetaViewportInfo *viewports,
|
||||
float *x,
|
||||
float *y)
|
||||
{
|
||||
MetaInputDeviceNative *device_evdev = META_INPUT_DEVICE_NATIVE (device);
|
||||
double min_x = 0, min_y = 0, max_x = 1, max_y = 1;
|
||||
double stage_width, stage_height;
|
||||
float stage_width, stage_height;
|
||||
double x_d, y_d;
|
||||
|
||||
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||
meta_viewport_info_get_extents (viewports, &stage_width, &stage_height);
|
||||
x_d = *x / stage_width;
|
||||
y_d = *y / stage_height;
|
||||
|
||||
|
@ -126,7 +126,7 @@ ClutterInputDeviceType meta_input_device_native_determine_type (struct libin
|
||||
|
||||
|
||||
void meta_input_device_native_translate_coordinates (ClutterInputDevice *device,
|
||||
ClutterStage *stage,
|
||||
MetaViewportInfo *viewports,
|
||||
float *x,
|
||||
float *y);
|
||||
|
||||
|
@ -391,7 +391,6 @@ new_absolute_motion_event (MetaSeatNative *seat,
|
||||
float y,
|
||||
double *axes)
|
||||
{
|
||||
ClutterStage *stage = meta_seat_native_get_stage (seat);
|
||||
ClutterEvent *event;
|
||||
|
||||
event = clutter_event_new (CLUTTER_MOTION);
|
||||
@ -411,9 +410,16 @@ new_absolute_motion_event (MetaSeatNative *seat,
|
||||
meta_xkb_translate_state (event, seat->xkb, seat->button_state);
|
||||
event->motion.x = x;
|
||||
event->motion.y = y;
|
||||
meta_input_device_native_translate_coordinates (input_device, stage,
|
||||
&event->motion.x,
|
||||
&event->motion.y);
|
||||
|
||||
/* This may happen early at startup */
|
||||
if (seat->viewports)
|
||||
{
|
||||
meta_input_device_native_translate_coordinates (input_device,
|
||||
seat->viewports,
|
||||
&event->motion.x,
|
||||
&event->motion.y);
|
||||
}
|
||||
|
||||
event->motion.axes = axes;
|
||||
clutter_event_set_device (event, seat->core_pointer);
|
||||
clutter_event_set_source_device (event, input_device);
|
||||
@ -798,7 +804,6 @@ meta_seat_native_notify_touch_event (MetaSeatNative *seat,
|
||||
double x,
|
||||
double y)
|
||||
{
|
||||
ClutterStage *stage = meta_seat_native_get_stage (seat);
|
||||
ClutterEvent *event = NULL;
|
||||
|
||||
event = clutter_event_new (evtype);
|
||||
@ -807,7 +812,8 @@ meta_seat_native_notify_touch_event (MetaSeatNative *seat,
|
||||
event->touch.time = us2ms (time_us);
|
||||
event->touch.x = x;
|
||||
event->touch.y = y;
|
||||
meta_input_device_native_translate_coordinates (input_device, stage,
|
||||
meta_input_device_native_translate_coordinates (input_device,
|
||||
seat->viewports,
|
||||
&event->touch.x,
|
||||
&event->touch.y);
|
||||
|
||||
@ -1813,7 +1819,6 @@ process_tablet_axis (MetaSeatNative *seat,
|
||||
struct libinput_event *event)
|
||||
{
|
||||
struct libinput_device *libinput_device = libinput_event_get_device (event);
|
||||
ClutterStage *stage = meta_seat_native_get_stage (seat);
|
||||
uint64_t time;
|
||||
double x, y, dx, dy, *axes;
|
||||
float stage_width, stage_height;
|
||||
@ -1830,8 +1835,7 @@ process_tablet_axis (MetaSeatNative *seat,
|
||||
if (!axes)
|
||||
return;
|
||||
|
||||
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||
meta_viewport_info_get_extents (seat->viewports, &stage_width, &stage_height);
|
||||
|
||||
time = libinput_event_tablet_tool_get_time_usec (tablet_event);
|
||||
|
||||
@ -1956,13 +1960,12 @@ process_device_event (MetaSeatNative *seat,
|
||||
uint64_t time_us;
|
||||
double x, y;
|
||||
float stage_width, stage_height;
|
||||
ClutterStage *stage = meta_seat_native_get_stage (seat);
|
||||
struct libinput_event_pointer *motion_event =
|
||||
libinput_event_get_pointer_event (event);
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
|
||||
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||
meta_viewport_info_get_extents (seat->viewports,
|
||||
&stage_width, &stage_height);
|
||||
|
||||
time_us = libinput_event_pointer_get_time_usec (motion_event);
|
||||
x = libinput_event_pointer_get_absolute_x_transformed (motion_event,
|
||||
@ -2057,7 +2060,6 @@ process_device_event (MetaSeatNative *seat,
|
||||
double x, y;
|
||||
float stage_width, stage_height;
|
||||
MetaSeatNative *seat;
|
||||
ClutterStage *stage;
|
||||
MetaTouchState *touch_state;
|
||||
struct libinput_event_touch *touch_event =
|
||||
libinput_event_get_touch_event (event);
|
||||
@ -2065,10 +2067,9 @@ process_device_event (MetaSeatNative *seat,
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
device_evdev = META_INPUT_DEVICE_NATIVE (device);
|
||||
seat = meta_input_device_native_get_seat (device_evdev);
|
||||
stage = meta_seat_native_get_stage (seat);
|
||||
|
||||
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||
meta_viewport_info_get_extents (seat->viewports,
|
||||
&stage_width, &stage_height);
|
||||
|
||||
seat_slot = libinput_event_touch_get_seat_slot (touch_event);
|
||||
time_us = libinput_event_touch_get_time_usec (touch_event);
|
||||
@ -2125,7 +2126,6 @@ process_device_event (MetaSeatNative *seat,
|
||||
double x, y;
|
||||
float stage_width, stage_height;
|
||||
MetaSeatNative *seat;
|
||||
ClutterStage *stage;
|
||||
MetaTouchState *touch_state;
|
||||
struct libinput_event_touch *touch_event =
|
||||
libinput_event_get_touch_event (event);
|
||||
@ -2133,10 +2133,9 @@ process_device_event (MetaSeatNative *seat,
|
||||
device = libinput_device_get_user_data (libinput_device);
|
||||
device_evdev = META_INPUT_DEVICE_NATIVE (device);
|
||||
seat = meta_input_device_native_get_seat (device_evdev);
|
||||
stage = meta_seat_native_get_stage (seat);
|
||||
|
||||
stage_width = clutter_actor_get_width (CLUTTER_ACTOR (stage));
|
||||
stage_height = clutter_actor_get_height (CLUTTER_ACTOR (stage));
|
||||
meta_viewport_info_get_extents (seat->viewports,
|
||||
&stage_width, &stage_height);
|
||||
|
||||
seat_slot = libinput_event_touch_get_seat_slot (touch_event);
|
||||
time_us = libinput_event_touch_get_time_usec (touch_event);
|
||||
|
Loading…
Reference in New Issue
Block a user