[mutter/wip/carlosg/input-thread: 36/87] backends/native: Use viewport info to find out stage extents
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 36/87] backends/native: Use viewport info to find out stage extents
- Date: Fri, 27 Nov 2020 15:14:51 +0000 (UTC)
commit c362bc4b514940c5dcad846d504909df7ca9a170
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jul 31 19:11:32 2020 +0200
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>
src/backends/native/meta-input-device-native.c | 7 ++---
src/backends/native/meta-input-device-native.h | 2 +-
src/backends/native/meta-seat-native.c | 39 +++++++++++++-------------
3 files changed, 23 insertions(+), 25 deletions(-)
---
diff --git a/src/backends/native/meta-input-device-native.c b/src/backends/native/meta-input-device-native.c
index af209222d6..8d4b835dea 100644
--- a/src/backends/native/meta-input-device-native.c
+++ b/src/backends/native/meta-input-device-native.c
@@ -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;
diff --git a/src/backends/native/meta-input-device-native.h b/src/backends/native/meta-input-device-native.h
index 645d3ca749..da23b1778c 100644
--- a/src/backends/native/meta-input-device-native.h
+++ b/src/backends/native/meta-input-device-native.h
@@ -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);
diff --git a/src/backends/native/meta-seat-native.c b/src/backends/native/meta-seat-native.c
index 33412de5f2..cf6da1f37e 100644
--- a/src/backends/native/meta-seat-native.c
+++ b/src/backends/native/meta-seat-native.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]