diff options
author | Kristian Høgsberg <krh@bitplanet.net> | 2013-05-08 21:03:21 -0400 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-05-08 21:03:23 -0400 |
commit | be6403ed5c4fdab884d391778e2572aae109f1a0 (patch) | |
tree | 88791c42c0dce25c3de6a5cda23b72ce2e54dce1 /src/shell.c | |
parent | e122b7ba58bf321a2e5c8fdadf17aa1ef511f30a (diff) | |
download | weston-be6403ed5c4fdab884d391778e2572aae109f1a0.tar.gz weston-be6403ed5c4fdab884d391778e2572aae109f1a0.tar.bz2 weston-be6403ed5c4fdab884d391778e2572aae109f1a0.zip |
input: Get rid of grab focus concept
This was another complication that we had to have to support the
split between libwayland-server and weston. Different grabs want to send
events relative to different surfaces at different times. The default
grab switches between sending coordinates relative to the 'current' surface,
that is the surface the pointer is currently above, or the 'clicked'
surface, in case of an implicit grab.
The grab focus was set by the grab implementation and the core input code
would transform the pointer position to surface relative coordinates for the
grab focus and store in grab->x/y.
Now we can just let the grab implementation transform the pointer
coordinates itself, leaving the implementation free to transform
according to whichever surface it wants. Or not transform at all if
it doesn't need surface relative coordinates (like the shell move and resize
grabs).
Diffstat (limited to 'src/shell.c')
-rw-r--r-- | src/shell.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/src/shell.c b/src/shell.c index bed0e4ed..3f4833d6 100644 --- a/src/shell.c +++ b/src/shell.c @@ -324,7 +324,6 @@ shell_grab_start(struct shell_grab *grab, &grab->shsurf_destroy_listener); grab->pointer = pointer; - grab->grab.focus = shsurf->surface; weston_pointer_start_grab(pointer, &grab->grab); desktop_shell_send_grab_cursor(shell->child.desktop_shell, cursor); @@ -1017,12 +1016,10 @@ static void noop_grab_focus(struct weston_pointer_grab *grab, struct weston_surface *surface, wl_fixed_t x, wl_fixed_t y) { - grab->focus = NULL; } static void -move_grab_motion(struct weston_pointer_grab *grab, - uint32_t time, wl_fixed_t x, wl_fixed_t y) +move_grab_motion(struct weston_pointer_grab *grab, uint32_t time) { struct weston_move_grab *move = (struct weston_move_grab *) grab; struct weston_pointer *pointer = grab->pointer; @@ -1113,8 +1110,7 @@ struct weston_resize_grab { }; static void -resize_grab_motion(struct weston_pointer_grab *grab, - uint32_t time, wl_fixed_t x, wl_fixed_t y) +resize_grab_motion(struct weston_pointer_grab *grab, uint32_t time) { struct weston_resize_grab *resize = (struct weston_resize_grab *) grab; struct weston_pointer *pointer = grab->pointer; @@ -1239,15 +1235,14 @@ busy_cursor_grab_focus(struct weston_pointer_grab *base, { struct shell_grab *grab = (struct shell_grab *) base; - if (grab->grab.focus != surface) { + if (grab->shsurf->surface != surface) { shell_grab_end(grab); free(grab); } } static void -busy_cursor_grab_motion(struct weston_pointer_grab *grab, - uint32_t time, int32_t x, int32_t y) +busy_cursor_grab_motion(struct weston_pointer_grab *grab, uint32_t time) { } @@ -1912,24 +1907,25 @@ popup_grab_focus(struct weston_pointer_grab *grab, if (surface && surface->resource.client == client) { weston_pointer_set_focus(pointer, surface, x, y); - grab->focus = surface; } else { weston_pointer_set_focus(pointer, NULL, wl_fixed_from_int(0), wl_fixed_from_int(0)); - grab->focus = NULL; } } static void -popup_grab_motion(struct weston_pointer_grab *grab, - uint32_t time, wl_fixed_t sx, wl_fixed_t sy) +popup_grab_motion(struct weston_pointer_grab *grab, uint32_t time) { - struct wl_resource *resource; + struct weston_pointer *pointer = grab->pointer; + wl_fixed_t sx, sy; - resource = grab->pointer->focus_resource; - if (resource) - wl_pointer_send_motion(resource, time, sx, sy); + if (pointer->focus_resource) { + weston_surface_from_global_fixed(pointer->focus, + pointer->x, pointer->y, + &sx, &sy); + wl_pointer_send_motion(pointer->focus_resource, time, sx, sy); + } } static void @@ -2649,8 +2645,7 @@ terminate_binding(struct weston_seat *seat, uint32_t time, uint32_t key, } static void -rotate_grab_motion(struct weston_pointer_grab *grab, - uint32_t time, wl_fixed_t x, wl_fixed_t y) +rotate_grab_motion(struct weston_pointer_grab *grab, uint32_t time) { struct rotate_grab *rotate = container_of(grab, struct rotate_grab, base.grab); |