Commit 1281a36e authored by Derek Foreman's avatar Derek Foreman Committed by Bryce Harrington

input: Don't test keyboard/pointer/touch pointers

Keyboards and pointers aren't freed when devices are removed, so we should
really be testing keyboard_device_count and pointer_device_count in most
cases, not the actual pointers. Otherwise we end up with different
behaviour after removing a device than we had before it was inserted.

This commit renames the touch/keyboard/pointer pointers and adds helper
functions to get them that hide this complexity and return NULL when
*_device_count is 0.
Signed-off-by: default avatarDerek Foreman <derekf@osg.samsung.com>
Reviewed-by: Jonas Ådahl's avatarJonas Ådahl <jadahl@gmail.com>
parent b41b59e2
......@@ -525,14 +525,16 @@ static enum exposay_layout_state
exposay_set_inactive(struct desktop_shell *shell)
{
struct weston_seat *seat = shell->exposay.seat;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (seat->pointer_device_count)
weston_pointer_end_grab(seat->pointer);
if (pointer)
weston_pointer_end_grab(pointer);
if (seat->keyboard_device_count) {
weston_keyboard_end_grab(seat->keyboard);
if (seat->keyboard->input_method_resource)
seat->keyboard->grab = &seat->keyboard->input_method_grab;
if (keyboard) {
weston_keyboard_end_grab(keyboard);
if (keyboard->input_method_resource)
keyboard->grab = &keyboard->input_method_grab;
}
return EXPOSAY_LAYOUT_INACTIVE;
......@@ -566,28 +568,30 @@ static enum exposay_layout_state
exposay_transition_active(struct desktop_shell *shell)
{
struct weston_seat *seat = shell->exposay.seat;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct shell_output *shell_output;
bool animate = false;
shell->exposay.workspace = get_current_workspace(shell);
shell->exposay.focus_prev = get_default_view (seat->keyboard->focus);
shell->exposay.focus_current = get_default_view (seat->keyboard->focus);
shell->exposay.focus_prev = get_default_view(keyboard->focus);
shell->exposay.focus_current = get_default_view(keyboard->focus);
shell->exposay.clicked = NULL;
wl_list_init(&shell->exposay.surface_list);
lower_fullscreen_layer(shell, NULL);
shell->exposay.grab_kbd.interface = &exposay_kbd_grab;
weston_keyboard_start_grab(seat->keyboard,
weston_keyboard_start_grab(keyboard,
&shell->exposay.grab_kbd);
weston_keyboard_set_focus(seat->keyboard, NULL);
weston_keyboard_set_focus(keyboard, NULL);
shell->exposay.grab_ptr.interface = &exposay_ptr_grab;
if (seat->pointer_device_count) {
weston_pointer_start_grab(seat->pointer,
if (pointer) {
weston_pointer_start_grab(pointer,
&shell->exposay.grab_ptr);
weston_pointer_set_focus(seat->pointer, NULL,
seat->pointer->x,
seat->pointer->y);
weston_pointer_set_focus(pointer, NULL,
pointer->x,
pointer->y);
}
wl_list_for_each(shell_output, &shell->output_list, link) {
enum exposay_layout_state state;
......
......@@ -68,9 +68,12 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
float x, y;
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
if (!seat->keyboard || !seat->keyboard->focus)
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (!keyboard || !keyboard->focus)
continue;
focus = weston_surface_get_main_surface(seat->keyboard->focus);
focus = weston_surface_get_main_surface(keyboard->focus);
ipsurf->output = focus->output;
x = ipsurf->output->x + (ipsurf->output->width - ipsurf->surface->width) / 2;
y = ipsurf->output->y + ipsurf->output->height - ipsurf->surface->height;
......
This diff is collapsed.
......@@ -96,15 +96,17 @@ static void
seat_caps_changed(struct wl_listener *l, void *data)
{
struct weston_seat *seat = data;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct pointer_focus_listener *listener;
struct fs_output *fsout;
listener = container_of(l, struct pointer_focus_listener, seat_caps);
/* no pointer */
if (seat->pointer_device_count) {
if (pointer) {
if (!listener->pointer_focus.link.prev) {
wl_signal_add(&seat->pointer->focus_signal,
wl_signal_add(&pointer->focus_signal,
&listener->pointer_focus);
}
} else {
......@@ -113,7 +115,7 @@ seat_caps_changed(struct wl_listener *l, void *data)
}
}
if (seat->keyboard_device_count && seat->keyboard->focus != NULL) {
if (keyboard && keyboard->focus != NULL) {
wl_list_for_each(fsout, &listener->shell->output_list, link) {
if (fsout->surface) {
weston_surface_activate(fsout->surface, seat);
......@@ -681,7 +683,10 @@ fullscreen_shell_present_surface(struct wl_client *client,
if (surface) {
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
if (seat->keyboard && seat->keyboard->focus == NULL)
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (keyboard && !keyboard->focus)
weston_surface_activate(surface, seat);
}
}
......@@ -729,7 +734,10 @@ fullscreen_shell_present_surface_for_mode(struct wl_client *client,
fsout, mode_feedback_destroyed);
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
if (seat->keyboard && seat->keyboard->focus == NULL)
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (keyboard && !keyboard->focus)
weston_surface_activate(surface, seat);
}
}
......
......@@ -1469,15 +1469,18 @@ enum HMI_GRAB_DEVICE {
static enum HMI_GRAB_DEVICE
get_hmi_grab_device(struct weston_seat *seat, uint32_t serial)
{
if (seat->pointer &&
seat->pointer->focus &&
seat->pointer->button_count &&
seat->pointer->grab_serial == serial)
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_touch *touch = weston_seat_get_touch(seat);
if (pointer &&
pointer->focus &&
pointer->button_count &&
pointer->grab_serial == serial)
return HMI_GRAB_DEVICE_POINTER;
if (seat->touch &&
seat->touch->focus &&
seat->touch->grab_serial == serial)
if (touch &&
touch->focus &&
touch->grab_serial == serial)
return HMI_GRAB_DEVICE_TOUCH;
return HMI_GRAB_DEVICE_NONE;
......@@ -1568,6 +1571,9 @@ ivi_hmi_controller_workspace_control(struct wl_client *client,
struct pointer_move_grab *pnt_move_grab = NULL;
struct touch_move_grab *tch_move_grab = NULL;
struct weston_seat *seat = NULL;
struct weston_pointer *pointer;
struct weston_touch *touch;
enum HMI_GRAB_DEVICE device;
if (hmi_ctrl->workspace_count < 2)
......@@ -1586,21 +1592,23 @@ ivi_hmi_controller_workspace_control(struct wl_client *client,
switch (device) {
case HMI_GRAB_DEVICE_POINTER:
pnt_move_grab = create_workspace_pointer_move(seat->pointer,
pointer = weston_seat_get_pointer(seat);
pnt_move_grab = create_workspace_pointer_move(pointer,
resource);
pointer_grab_start(&pnt_move_grab->base, layer,
&pointer_move_grab_workspace_interface,
seat->pointer);
pointer);
break;
case HMI_GRAB_DEVICE_TOUCH:
tch_move_grab = create_workspace_touch_move(seat->touch,
touch = weston_seat_get_touch(seat);
tch_move_grab = create_workspace_touch_move(touch,
resource);
touch_grab_start(&tch_move_grab->base, layer,
&touch_move_grab_workspace_interface,
seat->touch);
touch);
break;
default:
......
......@@ -70,9 +70,12 @@ show_input_panel_surface(struct input_panel_surface *ipsurf)
float x, y;
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
if (!seat->keyboard || !seat->keyboard->focus)
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (!keyboard || !keyboard->focus)
continue;
focus = weston_surface_get_main_surface(seat->keyboard->focus);
focus = weston_surface_get_main_surface(keyboard->focus);
ipsurf->output = focus->output;
x = ipsurf->output->x + (ipsurf->output->width - ipsurf->surface->width) / 2;
y = ipsurf->output->y + ipsurf->output->height - ipsurf->surface->height;
......
......@@ -2075,6 +2075,7 @@ setup_output_seat_constraint(struct drm_backend *b,
const char *s)
{
if (strcmp(s, "") != 0) {
struct weston_pointer *pointer;
struct udev_seat *seat;
seat = udev_seat_get_named(&b->input, s);
......@@ -2083,10 +2084,11 @@ setup_output_seat_constraint(struct drm_backend *b,
seat->base.output = output;
if (seat->base.pointer)
weston_pointer_clamp(seat->base.pointer,
&seat->base.pointer->x,
&seat->base.pointer->y);
pointer = weston_seat_get_pointer(&seat->base);
if (pointer)
weston_pointer_clamp(pointer,
&pointer->x,
&pointer->y);
}
}
......
......@@ -1479,7 +1479,7 @@ input_handle_keymap(void *data, struct wl_keyboard *keyboard, uint32_t format,
close(fd);
if (input->base.keyboard)
if (weston_seat_get_keyboard(&input->base))
weston_seat_update_keymap(&input->base, keymap);
else
weston_seat_init_keyboard(&input->base, keymap);
......@@ -1569,11 +1569,12 @@ input_handle_key(void *data, struct wl_keyboard *keyboard,
}
static void
input_handle_modifiers(void *data, struct wl_keyboard *keyboard,
input_handle_modifiers(void *data, struct wl_keyboard *wl_keyboard,
uint32_t serial_in, uint32_t mods_depressed,
uint32_t mods_latched, uint32_t mods_locked,
uint32_t group)
{
struct weston_keyboard *keyboard;
struct wayland_input *input = data;
struct wayland_backend *b = input->backend;
uint32_t serial_out;
......@@ -1586,7 +1587,8 @@ input_handle_modifiers(void *data, struct wl_keyboard *keyboard,
else
serial_out = wl_display_next_serial(b->compositor->wl_display);
xkb_state_update_mask(input->base.keyboard->xkb_state.state,
keyboard = weston_seat_get_keyboard(&input->base);
xkb_state_update_mask(keyboard->xkb_state.state,
mods_depressed, mods_latched,
mods_locked, 0, 0, group);
notify_modifiers(&input->base, serial_out);
......
......@@ -174,7 +174,9 @@ x11_backend_get_keymap(struct x11_backend *b)
static uint32_t
get_xkb_mod_mask(struct x11_backend *b, uint32_t in)
{
struct weston_xkb_info *info = b->core_seat.keyboard->xkb_info;
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(&b->core_seat);
struct weston_xkb_info *info = keyboard->xkb_info;
uint32_t ret = 0;
if ((in & ShiftMask) && info->shift_mod != XKB_MOD_INVALID)
......@@ -206,6 +208,7 @@ x11_backend_setup_xkb(struct x11_backend *b)
b->xkb_event_base = 0;
return;
#else
struct weston_keyboard *keyboard;
const xcb_query_extension_reply_t *ext;
xcb_generic_error_t *error;
xcb_void_cookie_t select;
......@@ -285,7 +288,8 @@ x11_backend_setup_xkb(struct x11_backend *b)
return;
}
xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
keyboard = weston_seat_get_keyboard(&b->core_seat);
xkb_state_update_mask(keyboard->xkb_state.state,
get_xkb_mod_mask(b, state_reply->baseMods),
get_xkb_mod_mask(b, state_reply->latchedMods),
get_xkb_mod_mask(b, state_reply->lockedMods),
......@@ -975,7 +979,10 @@ static void delete_cb(void *data)
static void
update_xkb_state(struct x11_backend *b, xcb_xkb_state_notify_event_t *state)
{
xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(&b->core_seat);
xkb_state_update_mask(keyboard->xkb_state.state,
get_xkb_mod_mask(b, state->baseMods),
get_xkb_mod_mask(b, state->latchedMods),
get_xkb_mod_mask(b, state->lockedMods),
......@@ -1003,9 +1010,10 @@ static void
update_xkb_state_from_core(struct x11_backend *b, uint16_t x11_mask)
{
uint32_t mask = get_xkb_mod_mask(b, x11_mask);
struct weston_keyboard *keyboard = b->core_seat.keyboard;
struct weston_keyboard *keyboard
= weston_seat_get_keyboard(&b->core_seat);
xkb_state_update_mask(b->core_seat.keyboard->xkb_state.state,
xkb_state_update_mask(keyboard->xkb_state.state,
keyboard->modifiers.mods_depressed & mask,
keyboard->modifiers.mods_latched & mask,
keyboard->modifiers.mods_locked & mask,
......
......@@ -95,7 +95,7 @@ static void weston_mode_switch_finish(struct weston_output *output,
/* If a pointer falls outside the outputs new geometry, move it to its
* lower-right corner */
wl_list_for_each(seat, &output->compositor->seat_list, link) {
struct weston_pointer *pointer = seat->pointer;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
int32_t x, y;
if (!pointer)
......@@ -1752,15 +1752,20 @@ weston_view_unmap(struct weston_view *view)
return;
wl_list_for_each(seat, &view->surface->compositor->seat_list, link) {
if (seat->keyboard && seat->keyboard->focus == view->surface)
weston_keyboard_set_focus(seat->keyboard, NULL);
if (seat->pointer && seat->pointer->focus == view)
weston_pointer_set_focus(seat->pointer,
struct weston_touch *touch = weston_seat_get_touch(seat);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (keyboard && keyboard->focus == view->surface)
weston_keyboard_set_focus(keyboard, NULL);
if (pointer && pointer->focus == view)
weston_pointer_set_focus(pointer,
NULL,
wl_fixed_from_int(0),
wl_fixed_from_int(0));
if (seat->touch && seat->touch->focus == view)
weston_touch_set_focus(seat->touch, NULL);
if (touch && touch->focus == view)
weston_touch_set_focus(touch, NULL);
}
}
......@@ -4587,10 +4592,10 @@ weston_compositor_set_default_pointer_grab(struct weston_compositor *ec,
ec->default_pointer_grab = interface;
wl_list_for_each(seat, &ec->seat_list, link) {
if (seat->pointer) {
weston_pointer_set_default_grab(seat->pointer,
interface);
}
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (pointer)
weston_pointer_set_default_grab(pointer, interface);
}
}
......
......@@ -503,9 +503,9 @@ struct weston_seat {
struct wl_list base_resource_list;
struct wl_global *global;
struct weston_pointer *pointer;
struct weston_keyboard *keyboard;
struct weston_touch *touch;
struct weston_pointer *pointer_state;
struct weston_keyboard *keyboard_state;
struct weston_touch *touch_state;
int pointer_device_count;
int keyboard_device_count;
int touch_device_count;
......@@ -1587,6 +1587,15 @@ weston_parse_transform(const char *transform, uint32_t *out);
const char *
weston_transform_to_string(uint32_t output_transform);
struct weston_keyboard *
weston_seat_get_keyboard(struct weston_seat *seat);
struct weston_pointer *
weston_seat_get_pointer(struct weston_seat *seat);
struct weston_touch *
weston_seat_get_touch(struct weston_seat *seat);
#ifdef __cplusplus
}
#endif
......
......@@ -662,23 +662,25 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
struct wl_resource *icon_resource, uint32_t serial)
{
struct weston_seat *seat = wl_resource_get_user_data(resource);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
struct weston_touch *touch = weston_seat_get_touch(seat);
struct weston_surface *origin = wl_resource_get_user_data(origin_resource);
struct weston_data_source *source = NULL;
struct weston_surface *icon = NULL;
int is_pointer_grab, is_touch_grab;
int32_t ret = 0;
is_pointer_grab = seat->pointer &&
seat->pointer->button_count == 1 &&
seat->pointer->grab_serial == serial &&
seat->pointer->focus &&
seat->pointer->focus->surface == origin;
is_pointer_grab = pointer &&
pointer->button_count == 1 &&
pointer->grab_serial == serial &&
pointer->focus &&
pointer->focus->surface == origin;
is_touch_grab = seat->touch &&
seat->touch->num_tp == 1 &&
seat->touch->grab_serial == serial &&
seat->touch->focus &&
seat->touch->focus->surface == origin;
is_touch_grab = touch &&
touch->num_tp == 1 &&
touch->grab_serial == serial &&
touch->focus &&
touch->focus->surface == origin;
if (!is_pointer_grab && !is_touch_grab)
return;
......@@ -698,9 +700,9 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
}
if (is_pointer_grab)
ret = weston_pointer_start_drag(seat->pointer, source, icon, client);
ret = weston_pointer_start_drag(pointer, source, icon, client);
else if (is_touch_grab)
ret = weston_touch_start_drag(seat->touch, source, icon, client);
ret = weston_touch_start_drag(touch, source, icon, client);
if (ret < 0)
wl_resource_post_no_memory(resource);
......@@ -711,13 +713,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data)
{
struct weston_seat *seat = container_of(listener, struct weston_seat,
selection_data_source_listener);
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct wl_resource *data_device;
struct weston_surface *focus = NULL;
seat->selection_data_source = NULL;
if (seat->keyboard)
focus = seat->keyboard->focus;
if (keyboard)
focus = keyboard->focus;
if (focus && focus->resource) {
data_device = wl_resource_find_for_client(&seat->drag_resource_list,
wl_resource_get_client(focus->resource));
......@@ -766,6 +769,7 @@ weston_seat_set_selection(struct weston_seat *seat,
struct weston_data_source *source, uint32_t serial)
{
struct weston_surface *focus = NULL;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
if (seat->selection_data_source &&
seat->selection_serial - serial < UINT32_MAX / 2)
......@@ -780,8 +784,8 @@ weston_seat_set_selection(struct weston_seat *seat,
seat->selection_data_source = source;
seat->selection_serial = serial;
if (seat->keyboard)
focus = seat->keyboard->focus;
if (keyboard)
focus = keyboard->focus;
if (focus && focus->resource) {
weston_seat_send_selection(seat, wl_resource_get_client(focus->resource));
}
......@@ -939,11 +943,12 @@ WL_EXPORT void
wl_data_device_set_keyboard_focus(struct weston_seat *seat)
{
struct weston_surface *focus;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
if (!seat->keyboard)
if (!keyboard)
return;
focus = seat->keyboard->focus;
focus = keyboard->focus;
if (!focus || !focus->resource)
return;
......
This diff is collapsed.
......@@ -60,6 +60,7 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
struct libinput_seat *libinput_seat;
struct weston_seat *seat;
struct udev_seat *udev_seat;
struct weston_pointer *pointer;
c = input->compositor;
libinput_seat = libinput_device_get_seat(libinput_device);
......@@ -77,10 +78,11 @@ device_added(struct udev_input *input, struct libinput_device *libinput_device)
udev_seat = (struct udev_seat *) seat;
wl_list_insert(udev_seat->devices_list.prev, &device->link);
if (seat->output && seat->pointer)
weston_pointer_clamp(seat->pointer,
&seat->pointer->x,
&seat->pointer->y);
pointer = weston_seat_get_pointer(seat);
if (seat->output && pointer)
weston_pointer_clamp(pointer,
&pointer->x,
&pointer->y);
output_name = libinput_device_get_output_name(libinput_device);
if (output_name) {
......@@ -378,8 +380,11 @@ udev_seat_create(struct udev_input *input, const char *seat_name)
static void
udev_seat_destroy(struct udev_seat *seat)
{
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(&seat->base);
udev_seat_remove_devices(seat);
if (seat->base.keyboard)
if (keyboard)
notify_keyboard_focus_out(&seat->base);
weston_seat_release(&seat->base);
wl_list_remove(&seat->output_create_listener.link);
......
......@@ -798,8 +798,11 @@ int main(int argc, char *argv[])
weston_config_section_get_bool(section, "numlock-on", &numlock_on, 0);
if (numlock_on) {
wl_list_for_each(seat, &ec->seat_list, link) {
if (seat->keyboard)
weston_keyboard_set_locks(seat->keyboard,
struct weston_keyboard *keyboard =
weston_seat_get_keyboard(seat);
if (keyboard)
weston_keyboard_set_locks(keyboard,
WESTON_NUM_LOCK,
WESTON_NUM_LOCK);
}
......
......@@ -658,7 +658,7 @@ input_method_context_grab_keyboard(struct wl_client *client,
wl_resource_get_user_data(resource);
struct wl_resource *cr;
struct weston_seat *seat = context->input_method->seat;
struct weston_keyboard *keyboard = seat->keyboard;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
cr = wl_resource_create(client, &wl_keyboard_interface, 1, id);
wl_resource_set_implementation(cr, NULL, context, unbind_keyboard);
......@@ -687,7 +687,7 @@ input_method_context_key(struct wl_client *client,
struct input_method_context *context =
wl_resource_get_user_data(resource);
struct weston_seat *seat = context->input_method->seat;
struct weston_keyboard *keyboard = seat->keyboard;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
default_grab->interface->key(default_grab, time, key, state_w);
......@@ -706,7 +706,7 @@ input_method_context_modifiers(struct wl_client *client,
wl_resource_get_user_data(resource);
struct weston_seat *seat = context->input_method->seat;
struct weston_keyboard *keyboard = seat->keyboard;
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
struct weston_keyboard_grab *default_grab = &keyboard->default_grab;
default_grab->interface->modifiers(default_grab,
......@@ -812,10 +812,11 @@ input_method_context_end_keyboard_grab(struct input_method_context *context)
struct weston_keyboard_grab *grab;
struct weston_keyboard *keyboard;
if (!context->input_method->seat->keyboard)
keyboard = weston_seat_get_keyboard(context->input_method->seat);
if (!keyboard)
return;
grab = &context->input_method->seat->keyboard->input_method_grab;
grab = &keyboard->input_method_grab;
keyboard = grab->keyboard;
if (!keyboard)
return;
......@@ -907,15 +908,17 @@ handle_keyboard_focus(struct wl_listener *listener, void *data)
static void
input_method_init_seat(struct weston_seat *seat)
{
struct weston_keyboard *keyboard = weston_seat_get_keyboard(seat);
if (seat->input_method->focus_listener_initialized)
return;
if (seat->keyboard) {
if (keyboard) {
seat->input_method->keyboard_focus_listener.notify =
handle_keyboard_focus;
wl_signal_add(&seat->keyboard->focus_signal,
wl_signal_add(&keyboard->focus_signal,
&seat->input_method->keyboard_focus_listener);
seat->keyboard->input_method_grab.interface =
keyboard->input_method_grab.interface =
&input_method_context_grab;
}
......
......@@ -129,11 +129,12 @@ WL_EXPORT void
weston_output_update_zoom(struct weston_output *output)
{
struct weston_seat *seat = output->zoom.seat;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
assert(output->zoom.active);
output->zoom.current.x = seat->pointer->x;
output->zoom.current.y = seat->pointer->y;
output->zoom.current.x = pointer->x;
output->zoom.current.y = pointer->y;
weston_zoom_transition(output);
weston_output_update_zoom_transform(output);
......@@ -154,13 +155,15 @@ WL_EXPORT void
weston_output_activate_zoom(struct weston_output *output,
struct weston_seat *seat)
{
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
if (output->zoom.active)
return;
output->zoom.active = true;
output->zoom.seat = seat;
output->disable_planes++;
wl_signal_add(&seat->pointer->motion_signal,
wl_signal_add(&pointer->motion_signal,
&output->zoom.motion_listener);
}
......
......@@ -139,6 +139,7 @@ trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
char fname[1024];
struct weston_surface *surface;
struct weston_seat *seat = keyboard->seat;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
int width, height;
char desc[512];
void *pixels;
......@@ -147,12 +148,10 @@ trigger_binding(struct weston_keyboard *keyboard, uint32_t time, uint32_t key,
int ret;
FILE *fp;
if (seat->pointer_device_count == 0 ||
!seat->pointer ||
!seat->pointer->focus)
if (!pointer || !pointer->focus)
return;
surface = seat->pointer->focus->surface;
surface = pointer->focus->surface;
weston_surface_get_content_size(surface, &width, &height);
......
......@@ -83,7 +83,7 @@ static void
notify_pointer_position(struct weston_test *test, struct wl_resource *resource)
{
struct weston_seat *seat = get_seat(test);
struct weston_pointer *pointer = seat->pointer;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
weston_test_send_pointer_position(resource, pointer->x, pointer->y);
}
......@@ -144,7 +144,7 @@ move_pointer(struct wl_client *client, struct wl_resource *resource,
{
struct weston_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat = get_seat(test);
struct weston_pointer *pointer = seat->pointer;
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
notify_motion(seat, 100,
wl_fixed_from_int(x) - pointer->x,
......@@ -171,12 +171,13 @@ activate_surface(struct wl_client *client, struct wl_resource *resource,
wl_resource_get_user_data(surface_resource) : NULL;
struct weston_test *test = wl_resource_get_user_data(resource);
struct weston_seat *seat;
struct weston_keyboard *keyboard;
seat = get_seat(test);
keyboard = weston_seat_get_keyboard(seat);
if (surface) {
weston_surface_activate(surface, seat);
notify_keyboard_focus_in(seat, &seat->keyboard->keys,
notify_keyboard_focus_in(seat, &keyboard->keys,
STATE_UPDATE_AUTOMATIC);
}
else {
......
......@@ -154,6 +154,7 @@ handle_enter(struct weston_wm *wm, xcb_client_message_event_t *client_message)
{
struct dnd_data_source *source;
struct weston_seat *seat = weston_wm_pick_seat(wm);
struct weston_pointer *pointer = weston_seat_get_pointer(seat);
char **p;
const char *name;
uint32_t *types;
......@@ -213,7 +214,7 @@ handle_enter(struct weston_wm *wm, xcb_client_message_event_t *client_message)
}
free(reply);
weston_pointer_start_drag(seat->pointer, &source->base, NULL, NULL);
weston_pointer_start_drag(pointer, &source->base, NULL, NULL);
}
int
......