From 2ee0a782bdd85f32a8eb4d8224bf5f6dff6a4803 Mon Sep 17 00:00:00 2001 From: Junghoon Date: Mon, 2 Nov 2015 16:06:40 +0900 Subject: [PATCH] pepper: change input event sending APIs - APIs for pointer, keyboard, touch - add view parameter to send input event Change-Id: Ibb512319c85f67eb253d685ecbd65a386434c858 --- src/lib/desktop-shell/shell-surface.c | 18 +++++++++-------- src/lib/desktop-shell/shell.c | 33 +++++++++++++++++-------------- src/lib/pepper/keyboard.c | 33 +++++++++++++++---------------- src/lib/pepper/pepper.h | 35 ++++++++++++++++++++------------- src/lib/pepper/pointer.c | 37 +++++++++++++++++++---------------- src/lib/pepper/touch.c | 23 +++++++++++----------- 6 files changed, 97 insertions(+), 82 deletions(-) diff --git a/src/lib/desktop-shell/shell-surface.c b/src/lib/desktop-shell/shell-surface.c index 781fc9f..ed50630 100644 --- a/src/lib/desktop-shell/shell-surface.c +++ b/src/lib/desktop-shell/shell-surface.c @@ -828,11 +828,12 @@ shell_surface_map_toplevel(shell_surface_t *shsurf) keyboard = pepper_seat_get_keyboard(shseat->seat); if (keyboard) { - if (pepper_keyboard_get_focus(keyboard) != shsurf->view) + pepper_view_t *focus = pepper_keyboard_get_focus(keyboard); + if ( focus != shsurf->view) { - pepper_keyboard_send_leave(keyboard); + pepper_keyboard_send_leave(keyboard, focus); pepper_keyboard_set_focus(keyboard, shsurf->view); - pepper_keyboard_send_enter(keyboard); + pepper_keyboard_send_enter(keyboard, shsurf->view); } } } @@ -849,15 +850,16 @@ pointer_popup_grab_motion(pepper_pointer_t *pointer, void *data, double vx, vy; pepper_compositor_t *compositor = pepper_pointer_get_compositor(pointer); pepper_view_t *view = pepper_compositor_pick_view(compositor, x, y, &vx, &vy); + pepper_view_t *focus = pepper_pointer_get_focus(pointer); - if (pepper_pointer_get_focus(pointer) != view) + if (focus != view) { - pepper_pointer_send_leave(pointer); + pepper_pointer_send_leave(pointer, focus); pepper_pointer_set_focus(pointer, view); - pepper_pointer_send_enter(pointer, vx, vy); + pepper_pointer_send_enter(pointer, view, vx, vy); } - pepper_pointer_send_motion(pointer, time, vx, vy); + pepper_pointer_send_motion(pointer, view, time, vx, vy); } static struct wl_client * @@ -892,7 +894,7 @@ pointer_popup_grab_button(pepper_pointer_t *pointer, void *data, if (client == shsurf->client) { - pepper_pointer_send_button(pointer, time, button, state); + pepper_pointer_send_button(pointer, focus, time, button, state); } else if (shsurf->popup.button_up) { diff --git a/src/lib/desktop-shell/shell.c b/src/lib/desktop-shell/shell.c index 2e5cd09..a776256 100644 --- a/src/lib/desktop-shell/shell.c +++ b/src/lib/desktop-shell/shell.c @@ -103,15 +103,16 @@ default_pointer_grab_motion(pepper_pointer_t *pointer, void *data, uint32_t time double vx, vy; pepper_compositor_t *compositor = pepper_pointer_get_compositor(pointer); pepper_view_t *view = pepper_compositor_pick_view(compositor, x, y, &vx, &vy); + pepper_view_t *focus = pepper_pointer_get_focus(pointer); - if (pepper_pointer_get_focus(pointer) != view) + if (focus != view) { - pepper_pointer_send_leave(pointer); + pepper_pointer_send_leave(pointer, focus); pepper_pointer_set_focus(pointer, view); - pepper_pointer_send_enter(pointer, vx, vy); + pepper_pointer_send_enter(pointer, view, vx, vy); } - pepper_pointer_send_motion(pointer, time, vx, vy); + pepper_pointer_send_motion(pointer, view, time, vx, vy); } static void @@ -120,30 +121,31 @@ default_pointer_grab_button(pepper_pointer_t *pointer, void *data, { pepper_seat_t *seat = pepper_pointer_get_seat(pointer); pepper_keyboard_t *keyboard = pepper_seat_get_keyboard(seat); + pepper_view_t *pointer_focus = pepper_pointer_get_focus(pointer); if (keyboard && state == PEPPER_BUTTON_STATE_PRESSED) { - pepper_view_t *focus = pepper_pointer_get_focus(pointer); + pepper_view_t *keyboard_focus = pepper_keyboard_get_focus(keyboard); - if (pepper_keyboard_get_focus(keyboard) != focus) + if (keyboard_focus != pointer_focus) { - pepper_keyboard_send_leave(keyboard); - pepper_keyboard_set_focus(keyboard, focus); - pepper_keyboard_send_enter(keyboard); + pepper_keyboard_send_leave(keyboard, keyboard_focus); + pepper_keyboard_set_focus(keyboard, pointer_focus); + pepper_keyboard_send_enter(keyboard, pointer_focus); } - if (focus) - pepper_view_stack_top(focus, PEPPER_FALSE); + if (pointer_focus) + pepper_view_stack_top(pointer_focus, PEPPER_FALSE); } - pepper_pointer_send_button(pointer, time, button, state); + pepper_pointer_send_button(pointer, pointer_focus, time, button, state); } static void default_pointer_grab_axis(pepper_pointer_t *pointer, void *data, uint32_t time, uint32_t axis, double value) { - pepper_pointer_send_axis(pointer, time, axis, value); + pepper_pointer_send_axis(pointer, pepper_pointer_get_focus(pointer), time, axis, value); } static void @@ -179,14 +181,15 @@ static void default_keyboard_grab_key(pepper_keyboard_t *keyboard, void *data, uint32_t time, uint32_t key, uint32_t state) { - pepper_keyboard_send_key(keyboard, time, key, state); + pepper_keyboard_send_key(keyboard, pepper_keyboard_get_focus(keyboard), time, key, state); } static void default_keyboard_grab_modifiers(pepper_keyboard_t *keyboard, void *data, uint32_t mods_depressed, uint32_t mods_latched, uint32_t mods_locked, uint32_t group) { - pepper_keyboard_send_modifiers(keyboard, mods_depressed, mods_latched, mods_locked, group); + pepper_keyboard_send_modifiers(keyboard, pepper_keyboard_get_focus(keyboard), + mods_depressed, mods_latched, mods_locked, group); } static void diff --git a/src/lib/pepper/keyboard.c b/src/lib/pepper/keyboard.c index dff13d3..492ec5b 100644 --- a/src/lib/pepper/keyboard.c +++ b/src/lib/pepper/keyboard.c @@ -349,59 +349,57 @@ pepper_keyboard_get_focus(pepper_keyboard_t *keyboard) } PEPPER_API void -pepper_keyboard_send_leave(pepper_keyboard_t *keyboard) +pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *view) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!keyboard->focus || !keyboard->focus->surface || !keyboard->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(keyboard->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(keyboard->seat->compositor->display); wl_resource_for_each(resource, &keyboard->resource_list) { if (wl_resource_get_client(resource) == client) - wl_keyboard_send_leave(resource, serial, keyboard->focus->surface->resource); + wl_keyboard_send_leave(resource, serial, view->surface->resource); } } PEPPER_API void -pepper_keyboard_send_enter(pepper_keyboard_t *keyboard) +pepper_keyboard_send_enter(pepper_keyboard_t *keyboard, pepper_view_t *view) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!keyboard->focus || !keyboard->focus->surface || !keyboard->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(keyboard->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(keyboard->seat->compositor->display); wl_resource_for_each(resource, &keyboard->resource_list) { if (wl_resource_get_client(resource) == client) - { - wl_keyboard_send_enter(resource, serial, - keyboard->focus->surface->resource, &keyboard->keys); - } + wl_keyboard_send_enter(resource, serial, view->surface->resource, &keyboard->keys); } } PEPPER_API void -pepper_keyboard_send_key(pepper_keyboard_t *keyboard, uint32_t time, uint32_t key, uint32_t state) +pepper_keyboard_send_key(pepper_keyboard_t *keyboard, pepper_view_t *view, + uint32_t time, uint32_t key, uint32_t state) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!keyboard->focus || !keyboard->focus->surface || !keyboard->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(keyboard->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(keyboard->seat->compositor->display); wl_resource_for_each(resource, &keyboard->resource_list) @@ -412,17 +410,18 @@ pepper_keyboard_send_key(pepper_keyboard_t *keyboard, uint32_t time, uint32_t ke } PEPPER_API void -pepper_keyboard_send_modifiers(pepper_keyboard_t *keyboard, uint32_t depressed, uint32_t latched, +pepper_keyboard_send_modifiers(pepper_keyboard_t *keyboard, pepper_view_t *view, + uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!keyboard->focus || !keyboard->focus->surface || !keyboard->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(keyboard->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(keyboard->seat->compositor->display); wl_resource_for_each(resource, &keyboard->resource_list) diff --git a/src/lib/pepper/pepper.h b/src/lib/pepper/pepper.h index 90c2d09..05e0ac0 100644 --- a/src/lib/pepper/pepper.h +++ b/src/lib/pepper/pepper.h @@ -898,19 +898,22 @@ PEPPER_API pepper_view_t * pepper_pointer_get_focus(pepper_pointer_t *pointer); PEPPER_API void -pepper_pointer_send_leave(pepper_pointer_t *pointer); +pepper_pointer_send_leave(pepper_pointer_t *pointer, pepper_view_t *view); PEPPER_API void -pepper_pointer_send_enter(pepper_pointer_t *pointer, double x, double y); +pepper_pointer_send_enter(pepper_pointer_t *pointer, pepper_view_t *view, double x, double y); PEPPER_API void -pepper_pointer_send_motion(pepper_pointer_t *pointer, uint32_t time, double x, double y); +pepper_pointer_send_motion(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, double x, double y); PEPPER_API void -pepper_pointer_send_button(pepper_pointer_t *pointer, uint32_t time, uint32_t button, uint32_t state); +pepper_pointer_send_button(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, uint32_t button, uint32_t state); PEPPER_API void -pepper_pointer_send_axis(pepper_pointer_t *pointer, uint32_t time, uint32_t axis, double value); +pepper_pointer_send_axis(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, uint32_t axis, double value); PEPPER_API void pepper_pointer_set_grab(pepper_pointer_t *pointer, const pepper_pointer_grab_t *grab, void *data); @@ -947,16 +950,18 @@ PEPPER_API pepper_view_t * pepper_keyboard_get_focus(pepper_keyboard_t *keyboard); PEPPER_API void -pepper_keyboard_send_leave(pepper_keyboard_t *keyboard); +pepper_keyboard_send_leave(pepper_keyboard_t *keyboard, pepper_view_t *view); PEPPER_API void -pepper_keyboard_send_enter(pepper_keyboard_t *keyboard); +pepper_keyboard_send_enter(pepper_keyboard_t *keyboard, pepper_view_t *view); PEPPER_API void -pepper_keyboard_send_key(pepper_keyboard_t *keyboard, uint32_t time, uint32_t key, uint32_t state); +pepper_keyboard_send_key(pepper_keyboard_t *keyboard, pepper_view_t *view, + uint32_t time, uint32_t key, uint32_t state); PEPPER_API void -pepper_keyboard_send_modifiers(pepper_keyboard_t *keyboard, uint32_t depressed, uint32_t latched, +pepper_keyboard_send_modifiers(pepper_keyboard_t *keyboard, pepper_view_t *view, + uint32_t depressed, uint32_t latched, uint32_t locked, uint32_t group); PEPPER_API void @@ -1008,19 +1013,21 @@ PEPPER_API void pepper_touch_point_get_position(pepper_touch_t *touch, uint32_t id, double *x, double *y); PEPPER_API void -pepper_touch_send_down(pepper_touch_t *touch, uint32_t time, uint32_t id, double x, double y); +pepper_touch_send_down(pepper_touch_t *touch, pepper_view_t *view, + uint32_t time, uint32_t id, double x, double y); PEPPER_API void -pepper_touch_send_up(pepper_touch_t *touch, uint32_t time, uint32_t id); +pepper_touch_send_up(pepper_touch_t *touch, pepper_view_t *view, uint32_t time, uint32_t id); PEPPER_API void -pepper_touch_send_motion(pepper_touch_t *touch, uint32_t time, uint32_t id, double x, double y); +pepper_touch_send_motion(pepper_touch_t *touch, pepper_view_t *view, + uint32_t time, uint32_t id, double x, double y); PEPPER_API void -pepper_touch_send_frame(pepper_touch_t *touch); +pepper_touch_send_frame(pepper_touch_t *touch, pepper_view_t *view); PEPPER_API void -pepper_touch_send_cancel(pepper_touch_t *touch); +pepper_touch_send_cancel(pepper_touch_t *touch, pepper_view_t *view); PEPPER_API void pepper_touch_set_grab(pepper_touch_t *touch, const pepper_touch_grab_t *grab, void *data); diff --git a/src/lib/pepper/pointer.c b/src/lib/pepper/pointer.c index 1e9a7b6..2f68217 100644 --- a/src/lib/pepper/pointer.c +++ b/src/lib/pepper/pointer.c @@ -323,27 +323,27 @@ pepper_pointer_get_focus(pepper_pointer_t *pointer) } PEPPER_API void -pepper_pointer_send_leave(pepper_pointer_t *pointer) +pepper_pointer_send_leave(pepper_pointer_t *pointer, pepper_view_t *view) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!pointer->focus || !pointer->focus->surface || !pointer->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(pointer->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(pointer->seat->compositor->display); wl_resource_for_each(resource, &pointer->resource_list) { if (wl_resource_get_client(resource) == client) - wl_pointer_send_leave(resource, serial, pointer->focus->surface->resource); + wl_pointer_send_leave(resource, serial, view->surface->resource); } } PEPPER_API void -pepper_pointer_send_enter(pepper_pointer_t *pointer, double x, double y) +pepper_pointer_send_enter(pepper_pointer_t *pointer, pepper_view_t *view, double x, double y) { struct wl_resource *resource; wl_fixed_t fx = wl_fixed_from_double(x); @@ -351,31 +351,32 @@ pepper_pointer_send_enter(pepper_pointer_t *pointer, double x, double y) struct wl_client *client; uint32_t serial; - if (!pointer->focus || !pointer->focus->surface || !pointer->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(pointer->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(pointer->seat->compositor->display); wl_resource_for_each(resource, &pointer->resource_list) { if (wl_resource_get_client(resource) == client) - wl_pointer_send_enter(resource, serial, pointer->focus->surface->resource, fx, fy); + wl_pointer_send_enter(resource, serial, view->surface->resource, fx, fy); } } PEPPER_API void -pepper_pointer_send_motion(pepper_pointer_t *pointer, uint32_t time, double x, double y) +pepper_pointer_send_motion(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, double x, double y) { struct wl_resource *resource; wl_fixed_t fx = wl_fixed_from_double(x); wl_fixed_t fy = wl_fixed_from_double(y); struct wl_client *client; - if (!pointer->focus || !pointer->focus->surface || !pointer->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(pointer->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); wl_resource_for_each(resource, &pointer->resource_list) { @@ -385,16 +386,17 @@ pepper_pointer_send_motion(pepper_pointer_t *pointer, uint32_t time, double x, d } PEPPER_API void -pepper_pointer_send_button(pepper_pointer_t *pointer, uint32_t time, uint32_t button, uint32_t state) +pepper_pointer_send_button(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, uint32_t button, uint32_t state) { struct wl_resource *resource; struct wl_client *client; uint32_t serial; - if (!pointer->focus || !pointer->focus->surface || !pointer->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(pointer->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); serial = wl_display_next_serial(pointer->seat->compositor->display); wl_resource_for_each(resource, &pointer->resource_list) @@ -405,16 +407,17 @@ pepper_pointer_send_button(pepper_pointer_t *pointer, uint32_t time, uint32_t bu } PEPPER_API void -pepper_pointer_send_axis(pepper_pointer_t *pointer, uint32_t time, uint32_t axis, double value) +pepper_pointer_send_axis(pepper_pointer_t *pointer, pepper_view_t *view, + uint32_t time, uint32_t axis, double value) { struct wl_resource *resource; wl_fixed_t v = wl_fixed_from_double(value); struct wl_client *client; - if (!pointer->focus || !pointer->focus->surface || !pointer->focus->surface->resource) + if (!view || !view->surface || !view->surface->resource) return; - client = wl_resource_get_client(pointer->focus->surface->resource); + client = wl_resource_get_client(view->surface->resource); wl_resource_for_each(resource, &pointer->resource_list) { diff --git a/src/lib/pepper/touch.c b/src/lib/pepper/touch.c index 9816e8d..a720feb 100644 --- a/src/lib/pepper/touch.c +++ b/src/lib/pepper/touch.c @@ -252,19 +252,20 @@ pepper_touch_point_get_position(pepper_touch_t *touch, uint32_t id, double *x, d } PEPPER_API void -pepper_touch_send_down(pepper_touch_t *touch, uint32_t time, uint32_t id, double x, double y) +pepper_touch_send_down(pepper_touch_t *touch, pepper_view_t *view, + uint32_t time, uint32_t id, double x, double y) { struct wl_resource *resource; wl_fixed_t fx = wl_fixed_from_double(x); wl_fixed_t fy = wl_fixed_from_double(y); pepper_touch_point_t *point = get_touch_point(touch, id); - if (!point || !point->focus || !point->focus->surface || !point->focus->surface->resource) + if (!point || !view || !view->surface || !view->surface->resource) return; wl_resource_for_each(resource, &touch->resource_list) { - struct wl_resource *surface_resource = point->focus->surface->resource; + struct wl_resource *surface_resource = view->surface->resource; if (wl_resource_get_client(resource) == wl_resource_get_client(surface_resource)) wl_touch_send_down(resource, point->focus_serial, time, surface_resource, id, fx, fy); @@ -272,20 +273,20 @@ pepper_touch_send_down(pepper_touch_t *touch, uint32_t time, uint32_t id, double } PEPPER_API void -pepper_touch_send_up(pepper_touch_t *touch, uint32_t time, uint32_t id) +pepper_touch_send_up(pepper_touch_t *touch, pepper_view_t *view, uint32_t time, uint32_t id) { struct wl_resource *resource; uint32_t serial; pepper_touch_point_t *point = get_touch_point(touch, id); - if (!point || !point->focus || !point->focus->surface || !point->focus->surface->resource) + if (!point || !view || !view->surface || !view->surface->resource) return; serial = wl_display_next_serial(touch->seat->compositor->display); wl_resource_for_each(resource, &touch->resource_list) { - struct wl_resource *surface_resource = point->focus->surface->resource; + struct wl_resource *surface_resource = view->surface->resource; if (wl_resource_get_client(resource) == wl_resource_get_client(surface_resource)) wl_touch_send_up(resource, serial, time, id); @@ -293,7 +294,7 @@ pepper_touch_send_up(pepper_touch_t *touch, uint32_t time, uint32_t id) } PEPPER_API void -pepper_touch_send_motion(pepper_touch_t *touch, uint32_t time, uint32_t id, double x, double y) +pepper_touch_send_motion(pepper_touch_t *touch, pepper_view_t *view, uint32_t time, uint32_t id, double x, double y) { struct wl_resource *resource; @@ -301,12 +302,12 @@ pepper_touch_send_motion(pepper_touch_t *touch, uint32_t time, uint32_t id, doub wl_fixed_t fy = wl_fixed_from_double(y); pepper_touch_point_t *point = get_touch_point(touch, id); - if (!point || !point->focus || !point->focus->surface || !point->focus->surface->resource) + if (!point || !view || !view->surface || !view->surface->resource) return; wl_resource_for_each(resource, &touch->resource_list) { - struct wl_resource *surface_resource = point->focus->surface->resource; + struct wl_resource *surface_resource = view->surface->resource; if (wl_resource_get_client(resource) == wl_resource_get_client(surface_resource)) wl_touch_send_motion(resource, time, id, fx, fy); @@ -314,7 +315,7 @@ pepper_touch_send_motion(pepper_touch_t *touch, uint32_t time, uint32_t id, doub } PEPPER_API void -pepper_touch_send_frame(pepper_touch_t *touch) +pepper_touch_send_frame(pepper_touch_t *touch, pepper_view_t *view) { struct wl_resource *resource; @@ -323,7 +324,7 @@ pepper_touch_send_frame(pepper_touch_t *touch) } PEPPER_API void -pepper_touch_send_cancel(pepper_touch_t *touch) +pepper_touch_send_cancel(pepper_touch_t *touch, pepper_view_t *view) { struct wl_resource *resource; -- 2.7.4