summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiulio Camuffo <giuliocamuffo@gmail.com>2016-03-22 17:44:54 +0200
committerPekka Paalanen <pekka.paalanen@collabora.co.uk>2016-03-23 14:05:09 +0200
commit90a6fc659f8a842f2460be2742f4e1359848f615 (patch)
treead96b18dc293d963ceacc511fede2d1cd473a3a0
parentfcf4b6c0aef3d2e3afda5fa8a4d4127585f7231b (diff)
downloadweston-90a6fc659f8a842f2460be2742f4e1359848f615.tar.gz
weston-90a6fc659f8a842f2460be2742f4e1359848f615.tar.bz2
weston-90a6fc659f8a842f2460be2742f4e1359848f615.zip
input: use doubles in the interfaces to notify of input events
This patch is a further step in the wl_fixed_t internal sanitization. It changes the notify_* functions to take doubles instead of wl_fixed_t but does not change how these are stored in the various input structs yet, except for weston_pointer_axis_event. However this already allows to remove all wl_fixed_t usage in places like the libinput or the x11 backend. Reviewed-by: Daniel Stone <daniels@collabora.com> Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
-rw-r--r--desktop-shell/shell.c6
-rw-r--r--src/compositor-rdp.c12
-rw-r--r--src/compositor-wayland.c56
-rw-r--r--src/compositor-x11.c22
-rw-r--r--src/compositor.c12
-rw-r--r--src/compositor.h12
-rw-r--r--src/input.c19
-rw-r--r--src/libinput-device.c26
-rw-r--r--src/screen-share.c5
9 files changed, 89 insertions, 81 deletions
diff --git a/desktop-shell/shell.c b/desktop-shell/shell.c
index e1fefae1..24437d8d 100644
--- a/desktop-shell/shell.c
+++ b/desktop-shell/shell.c
@@ -4786,7 +4786,7 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time,
if (!shsurf)
return;
- shsurf->view->alpha -= wl_fixed_to_double(event->value) * step;
+ shsurf->view->alpha -= event->value * step;
if (shsurf->view->alpha > 1.0)
shsurf->view->alpha = 1.0;
@@ -4799,7 +4799,7 @@ surface_opacity_binding(struct weston_pointer *pointer, uint32_t time,
static void
do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
- wl_fixed_t value)
+ double value)
{
struct weston_compositor *compositor = seat->compositor;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
@@ -4823,7 +4823,7 @@ do_zoom(struct weston_seat *seat, uint32_t time, uint32_t key, uint32_t axis,
else if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
/* For every pixel zoom 20th of a step */
increment = output->zoom.increment *
- -wl_fixed_to_double(value) / 20.0;
+ -value / 20.0;
else
increment = 0;
diff --git a/src/compositor-rdp.c b/src/compositor-rdp.c
index e603b767..773b6b58 100644
--- a/src/compositor-rdp.c
+++ b/src/compositor-rdp.c
@@ -942,7 +942,6 @@ static BOOL xf_peer_post_connect(freerdp_peer *client)
static FREERDP_CB_RET_TYPE
xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
{
- wl_fixed_t wl_x, wl_y;
RdpPeerContext *peerContext = (RdpPeerContext *)input->context;
struct rdp_output *output;
uint32_t button = 0;
@@ -951,10 +950,8 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
if (flags & PTR_FLAGS_MOVE) {
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
- wl_x = wl_fixed_from_int((int)x);
- wl_y = wl_fixed_from_int((int)y);
notify_motion_absolute(&peerContext->item.seat, weston_compositor_get_time(),
- wl_x, wl_y);
+ x, y);
need_frame = true;
}
}
@@ -988,7 +985,7 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
value = -value;
weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
- weston_event.value = wl_fixed_from_double(DEFAULT_AXIS_STEP_DISTANCE * value);
+ weston_event.value = DEFAULT_AXIS_STEP_DISTANCE * value;
weston_event.discrete = (int)value;
weston_event.has_discrete = true;
@@ -1006,16 +1003,13 @@ xf_mouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
static FREERDP_CB_RET_TYPE
xf_extendedMouseEvent(rdpInput *input, UINT16 flags, UINT16 x, UINT16 y)
{
- wl_fixed_t wl_x, wl_y;
RdpPeerContext *peerContext = (RdpPeerContext *)input->context;
struct rdp_output *output;
output = peerContext->rdpBackend->output;
if (x < output->base.width && y < output->base.height) {
- wl_x = wl_fixed_from_int((int)x);
- wl_y = wl_fixed_from_int((int)y);
notify_motion_absolute(&peerContext->item.seat, weston_compositor_get_time(),
- wl_x, wl_y);
+ x, y);
}
FREERDP_CB_RETURN(TRUE);
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 8a1878ca..9d1a2518 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -1275,11 +1275,15 @@ input_set_cursor(struct wayland_input *input)
static void
input_handle_pointer_enter(void *data, struct wl_pointer *pointer,
uint32_t serial, struct wl_surface *surface,
- wl_fixed_t x, wl_fixed_t y)
+ wl_fixed_t fixed_x, wl_fixed_t fixed_y)
{
struct wayland_input *input = data;
int32_t fx, fy;
enum theme_location location;
+ double x, y;
+
+ x = wl_fixed_to_double(fixed_x);
+ y = wl_fixed_to_double(fixed_y);
/* XXX: If we get a modifier event immediately before the focus,
* we should try to keep the same serial. */
@@ -1288,11 +1292,10 @@ input_handle_pointer_enter(void *data, struct wl_pointer *pointer,
if (input->output->frame) {
location = frame_pointer_enter(input->output->frame, input,
- wl_fixed_to_int(x),
- wl_fixed_to_int(y));
+ x, y);
frame_interior(input->output->frame, &fx, &fy, NULL, NULL);
- x -= wl_fixed_from_int(fx);
- y -= wl_fixed_from_int(fy);
+ x -= fx;
+ y -= fy;
if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT)
weston_output_schedule_repaint(&input->output->base);
@@ -1337,23 +1340,26 @@ input_handle_pointer_leave(void *data, struct wl_pointer *pointer,
static void
input_handle_motion(void *data, struct wl_pointer *pointer,
- uint32_t time, wl_fixed_t x, wl_fixed_t y)
+ uint32_t time, wl_fixed_t fixed_x, wl_fixed_t fixed_y)
{
struct wayland_input *input = data;
int32_t fx, fy;
enum theme_location location;
bool want_frame = false;
+ double x, y;
if (!input->output)
return;
+ x = wl_fixed_to_double(fixed_x);
+ y = wl_fixed_to_double(fixed_y);
+
if (input->output->frame) {
location = frame_pointer_motion(input->output->frame, input,
- wl_fixed_to_int(x),
- wl_fixed_to_int(y));
+ x, y);
frame_interior(input->output->frame, &fx, &fy, NULL, NULL);
- x -= wl_fixed_from_int(fx);
- y -= wl_fixed_from_int(fy);
+ x -= fx;
+ y -= fy;
if (frame_status(input->output->frame) & FRAME_STATUS_REPAINT)
weston_output_schedule_repaint(&input->output->base);
@@ -1447,7 +1453,7 @@ input_handle_axis(void *data, struct wl_pointer *pointer,
struct weston_pointer_axis_event weston_event;
weston_event.axis = axis;
- weston_event.value = value;
+ weston_event.value = wl_fixed_to_double(value);
if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL &&
input->vert.has_discrete) {
@@ -1705,14 +1711,18 @@ static const struct wl_keyboard_listener keyboard_listener = {
static void
input_handle_touch_down(void *data, struct wl_touch *wl_touch,
uint32_t serial, uint32_t time,
- struct wl_surface *surface, int32_t id, wl_fixed_t x,
- wl_fixed_t y)
+ struct wl_surface *surface, int32_t id,
+ wl_fixed_t fixed_x, wl_fixed_t fixed_y)
{
struct wayland_input *input = data;
struct wayland_output *output;
enum theme_location location;
bool first_touch;
int32_t fx, fy;
+ double x, y;
+
+ x = wl_fixed_to_double(fixed_x);
+ y = wl_fixed_to_double(fixed_y);
first_touch = (input->touch_points == 0);
input->touch_points++;
@@ -1723,13 +1733,11 @@ input_handle_touch_down(void *data, struct wl_touch *wl_touch,
return;
if (output->frame) {
- location = frame_touch_down(output->frame, input, id,
- wl_fixed_to_int(x),
- wl_fixed_to_int(y));
+ location = frame_touch_down(output->frame, input, id, x, y);
frame_interior(output->frame, &fx, &fy, NULL, NULL);
- x -= wl_fixed_from_int(fx);
- y -= wl_fixed_from_int(fy);
+ x -= fx;
+ y -= fy;
if (frame_status(output->frame) & FRAME_STATUS_REPAINT)
weston_output_schedule_repaint(&output->base);
@@ -1792,20 +1800,24 @@ input_handle_touch_up(void *data, struct wl_touch *wl_touch,
static void
input_handle_touch_motion(void *data, struct wl_touch *wl_touch,
- uint32_t time, int32_t id, wl_fixed_t x,
- wl_fixed_t y)
+ uint32_t time, int32_t id,
+ wl_fixed_t fixed_x, wl_fixed_t fixed_y)
{
struct wayland_input *input = data;
struct wayland_output *output = input->touch_focus;
int32_t fx, fy;
+ double x, y;
+
+ x = wl_fixed_to_double(fixed_x);
+ y = wl_fixed_to_double(fixed_y);
if (!output || !input->touch_active)
return;
if (output->frame) {
frame_interior(output->frame, &fx, &fy, NULL, NULL);
- x -= wl_fixed_from_int(fx);
- y -= wl_fixed_from_int(fy);
+ x -= fx;
+ y -= fy;
}
weston_output_transform_coordinate(&output->base, x, y, &x, &y);
diff --git a/src/compositor-x11.c b/src/compositor-x11.c
index cca6ab73..f1cb71bd 100644
--- a/src/compositor-x11.c
+++ b/src/compositor-x11.c
@@ -58,7 +58,7 @@
#include "presentation-time-server-protocol.h"
#include "linux-dmabuf.h"
-#define DEFAULT_AXIS_STEP_DISTANCE wl_fixed_from_int(10)
+#define DEFAULT_AXIS_STEP_DISTANCE 10
static int option_width;
static int option_height;
@@ -85,8 +85,8 @@ struct x11_backend {
/* We could map multi-pointer X to multiple wayland seats, but
* for now we only support core X input. */
struct weston_seat core_seat;
- wl_fixed_t prev_x;
- wl_fixed_t prev_y;
+ double prev_x;
+ double prev_y;
struct {
xcb_atom_t wm_protocols;
@@ -1151,7 +1151,7 @@ x11_backend_deliver_motion_event(struct x11_backend *b,
xcb_generic_event_t *event)
{
struct x11_output *output;
- wl_fixed_t x, y;
+ double x, y;
struct weston_pointer_motion_event motion_event = { 0 };
xcb_motion_notify_event_t *motion_notify =
(xcb_motion_notify_event_t *) event;
@@ -1163,14 +1163,14 @@ x11_backend_deliver_motion_event(struct x11_backend *b,
return;
weston_output_transform_coordinate(&output->base,
- wl_fixed_from_int(motion_notify->event_x),
- wl_fixed_from_int(motion_notify->event_y),
+ motion_notify->event_x,
+ motion_notify->event_y,
&x, &y);
motion_event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_REL,
- .dx = wl_fixed_to_double(x - b->prev_x),
- .dy = wl_fixed_to_double(y - b->prev_y)
+ .dx = x - b->prev_x,
+ .dy = y - b->prev_y
};
notify_motion(&b->core_seat, weston_compositor_get_time(),
@@ -1186,7 +1186,7 @@ x11_backend_deliver_enter_event(struct x11_backend *b,
xcb_generic_event_t *event)
{
struct x11_output *output;
- wl_fixed_t x, y;
+ double x, y;
xcb_enter_notify_event_t *enter_notify =
(xcb_enter_notify_event_t *) event;
@@ -1199,8 +1199,8 @@ x11_backend_deliver_enter_event(struct x11_backend *b,
return;
weston_output_transform_coordinate(&output->base,
- wl_fixed_from_int(enter_notify->event_x),
- wl_fixed_from_int(enter_notify->event_y), &x, &y);
+ enter_notify->event_x,
+ enter_notify->event_y, &x, &y);
notify_pointer_focus(&b->core_seat, &output->base, x, y);
diff --git a/src/compositor.c b/src/compositor.c
index 3e3fc8ca..d8f3e344 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -4359,19 +4359,19 @@ weston_compositor_add_output(struct weston_compositor *compositor,
WL_EXPORT void
weston_output_transform_coordinate(struct weston_output *output,
- wl_fixed_t device_x, wl_fixed_t device_y,
- wl_fixed_t *x, wl_fixed_t *y)
+ double device_x, double device_y,
+ double *x, double *y)
{
struct weston_vector p = { {
- wl_fixed_to_double(device_x),
- wl_fixed_to_double(device_y),
+ device_x,
+ device_y,
0.0,
1.0 } };
weston_matrix_transform(&output->inverse_matrix, &p);
- *x = wl_fixed_from_double(p.f[0] / p.f[3]);
- *y = wl_fixed_from_double(p.f[1] / p.f[3]);
+ *x = p.f[0] / p.f[3];
+ *y = p.f[1] / p.f[3];
}
static void
diff --git a/src/compositor.h b/src/compositor.h
index 794a1b06..08b40593 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -253,7 +253,7 @@ struct weston_pointer_motion_event {
struct weston_pointer_axis_event {
uint32_t axis;
- wl_fixed_t value;
+ double value;
bool has_discrete;
int32_t discrete;
};
@@ -1155,7 +1155,7 @@ notify_motion(struct weston_seat *seat, uint32_t time,
struct weston_pointer_motion_event *event);
void
notify_motion_absolute(struct weston_seat *seat, uint32_t time,
- wl_fixed_t x, wl_fixed_t y);
+ double x, double y);
void
notify_button(struct weston_seat *seat, uint32_t time, int32_t button,
enum wl_pointer_button_state state);
@@ -1177,7 +1177,7 @@ notify_modifiers(struct weston_seat *seat, uint32_t serial);
void
notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
- wl_fixed_t x, wl_fixed_t y);
+ double x, double y);
void
notify_keyboard_focus_in(struct weston_seat *seat, struct wl_array *keys,
@@ -1187,7 +1187,7 @@ notify_keyboard_focus_out(struct weston_seat *seat);
void
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
- wl_fixed_t x, wl_fixed_t y, int touch_type);
+ double x, double y, int touch_type);
void
notify_touch_frame(struct weston_seat *seat);
@@ -1494,8 +1494,8 @@ void
weston_output_destroy(struct weston_output *output);
void
weston_output_transform_coordinate(struct weston_output *output,
- wl_fixed_t device_x, wl_fixed_t device_y,
- wl_fixed_t *x, wl_fixed_t *y);
+ double device_x, double device_y,
+ double *x, double *y);
void
weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec,
diff --git a/src/input.c b/src/input.c
index 5d13b087..c881792d 100644
--- a/src/input.c
+++ b/src/input.c
@@ -352,7 +352,8 @@ weston_pointer_send_axis(struct weston_pointer *pointer,
if (event->value)
wl_pointer_send_axis(resource, time,
- event->axis, event->value);
+ event->axis,
+ wl_fixed_from_double(event->value));
else if (wl_resource_get_version(resource) >=
WL_POINTER_AXIS_STOP_SINCE_VERSION)
wl_pointer_send_axis_stop(resource, time,
@@ -1275,7 +1276,7 @@ run_modifier_bindings(struct weston_seat *seat, uint32_t old, uint32_t new)
WL_EXPORT void
notify_motion_absolute(struct weston_seat *seat,
- uint32_t time, wl_fixed_t x, wl_fixed_t y)
+ uint32_t time, double x, double y)
{
struct weston_compositor *ec = seat->compositor;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
@@ -1285,8 +1286,8 @@ notify_motion_absolute(struct weston_seat *seat,
event = (struct weston_pointer_motion_event) {
.mask = WESTON_POINTER_MOTION_ABS,
- .x = wl_fixed_to_double(x),
- .y = wl_fixed_to_double(y),
+ .x = x,
+ .y = y,
};
pointer->grab->interface->motion(pointer->grab, time, &event);
@@ -1682,12 +1683,14 @@ notify_key(struct weston_seat *seat, uint32_t time, uint32_t key,
WL_EXPORT void
notify_pointer_focus(struct weston_seat *seat, struct weston_output *output,
- wl_fixed_t x, wl_fixed_t y)
+ double x, double y)
{
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (output) {
- weston_pointer_move_to(pointer, x, y);
+ weston_pointer_move_to(pointer,
+ wl_fixed_from_double(x),
+ wl_fixed_from_double(y));
} else {
/* FIXME: We should call weston_pointer_set_focus(seat,
* NULL) here, but somehow that breaks re-entry... */
@@ -1815,13 +1818,15 @@ weston_touch_set_focus(struct weston_touch *touch, struct weston_view *view)
*/
WL_EXPORT void
notify_touch(struct weston_seat *seat, uint32_t time, int touch_id,
- wl_fixed_t x, wl_fixed_t y, int touch_type)
+ double double_x, double double_y, int touch_type)
{
struct weston_compositor *ec = seat->compositor;
struct weston_touch *touch = weston_seat_get_touch(seat);
struct weston_touch_grab *grab = touch->grab;
struct weston_view *ev;
wl_fixed_t sx, sy;
+ wl_fixed_t x = wl_fixed_from_double(double_x);
+ wl_fixed_t y = wl_fixed_from_double(double_y);
/* Update grab's global coordinates. */
if (touch_id == touch->grab_touch_id && touch_type != WL_TOUCH_UP) {
diff --git a/src/libinput-device.c b/src/libinput-device.c
index f8b614a4..c5d3fd1f 100644
--- a/src/libinput-device.c
+++ b/src/libinput-device.c
@@ -109,7 +109,7 @@ handle_pointer_motion_absolute(
libinput_device_get_user_data(libinput_device);
struct weston_output *output = device->output;
uint32_t time;
- wl_fixed_t x, y;
+ double x, y;
uint32_t width, height;
if (!output)
@@ -119,12 +119,10 @@ handle_pointer_motion_absolute(
width = device->output->current_mode->width;
height = device->output->current_mode->height;
- x = wl_fixed_from_double(
- libinput_event_pointer_get_absolute_x_transformed(pointer_event,
- width));
- y = wl_fixed_from_double(
- libinput_event_pointer_get_absolute_y_transformed(pointer_event,
- height));
+ x = libinput_event_pointer_get_absolute_x_transformed(pointer_event,
+ width);
+ y = libinput_event_pointer_get_absolute_y_transformed(pointer_event,
+ height);
weston_output_transform_coordinate(device->output, x, y, &x, &y);
notify_motion_absolute(device->seat, time, x, y);
@@ -252,7 +250,7 @@ handle_pointer_axis(struct libinput_device *libinput_device,
vert = normalize_scroll(pointer_event, axis);
weston_event.axis = WL_POINTER_AXIS_VERTICAL_SCROLL;
- weston_event.value = wl_fixed_from_double(vert);
+ weston_event.value = vert;
weston_event.discrete = vert_discrete;
weston_event.has_discrete = (vert_discrete != 0);
@@ -267,7 +265,7 @@ handle_pointer_axis(struct libinput_device *libinput_device,
horiz = normalize_scroll(pointer_event, axis);
weston_event.axis = WL_POINTER_AXIS_HORIZONTAL_SCROLL;
- weston_event.value = wl_fixed_from_double(horiz);
+ weston_event.value = horiz;
weston_event.discrete = horiz_discrete;
weston_event.has_discrete = (horiz_discrete != 0);
@@ -286,8 +284,8 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
{
struct evdev_device *device =
libinput_device_get_user_data(libinput_device);
- wl_fixed_t x;
- wl_fixed_t y;
+ double x;
+ double y;
uint32_t width, height;
uint32_t time;
int32_t slot;
@@ -300,10 +298,8 @@ handle_touch_with_coords(struct libinput_device *libinput_device,
width = device->output->current_mode->width;
height = device->output->current_mode->height;
- x = wl_fixed_from_double(
- libinput_event_touch_get_x_transformed(touch_event, width));
- y = wl_fixed_from_double(
- libinput_event_touch_get_y_transformed(touch_event, height));
+ x = libinput_event_touch_get_x_transformed(touch_event, width);
+ y = libinput_event_touch_get_y_transformed(touch_event, height);
weston_output_transform_coordinate(device->output,
x, y, &x, &y);
diff --git a/src/screen-share.c b/src/screen-share.c
index 9b5154b7..196173e5 100644
--- a/src/screen-share.c
+++ b/src/screen-share.c
@@ -142,7 +142,8 @@ ss_seat_handle_motion(void *data, struct wl_pointer *pointer,
/* No transformation of input position is required here because we are
* always receiving the input in the same coordinates as the output. */
- notify_motion_absolute(&seat->base, time, x, y);
+ notify_motion_absolute(&seat->base, time,
+ wl_fixed_to_double(x), wl_fixed_to_double(y));
notify_pointer_frame(&seat->base);
}
@@ -165,7 +166,7 @@ ss_seat_handle_axis(void *data, struct wl_pointer *pointer,
struct weston_pointer_axis_event weston_event;
weston_event.axis = axis;
- weston_event.value = value;
+ weston_event.value = wl_fixed_to_double(value);
weston_event.has_discrete = false;
notify_axis(&seat->base, time, &weston_event);