input: Eliminate weston_seat::has_pointer/keyboard/touch

We can just look at weston_seat::pointer/keyboard/touch now.
dev
Kristian Høgsberg 12 years ago
parent aad8099c2f
commit 2bf876282f
  1. 3
      src/compositor.h
  2. 16
      src/input.c
  3. 4
      src/shell.c
  4. 2
      src/text-backend.c

@ -441,11 +441,8 @@ struct weston_seat {
struct weston_touch *touch; struct weston_touch *touch;
struct weston_pointer pointer_instance; struct weston_pointer pointer_instance;
int has_pointer;
struct weston_keyboard keyboard_instance; struct weston_keyboard keyboard_instance;
int has_keyboard;
struct weston_touch touch_instance; struct weston_touch touch_instance;
int has_touch;
struct wl_signal destroy_signal; struct wl_signal destroy_signal;
struct weston_compositor *compositor; struct weston_compositor *compositor;

@ -1444,7 +1444,7 @@ weston_compositor_build_global_keymap(struct weston_compositor *ec)
WL_EXPORT int WL_EXPORT int
weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap) weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
{ {
if (seat->has_keyboard) if (seat->keyboard)
return 0; return 0;
if (keymap != NULL) { if (keymap != NULL) {
@ -1469,33 +1469,27 @@ weston_seat_init_keyboard(struct weston_seat *seat, struct xkb_keymap *keymap)
weston_keyboard_init(&seat->keyboard_instance); weston_keyboard_init(&seat->keyboard_instance);
weston_seat_set_keyboard(seat, &seat->keyboard_instance); weston_seat_set_keyboard(seat, &seat->keyboard_instance);
seat->has_keyboard = 1;
return 0; return 0;
} }
WL_EXPORT void WL_EXPORT void
weston_seat_init_pointer(struct weston_seat *seat) weston_seat_init_pointer(struct weston_seat *seat)
{ {
if (seat->has_pointer) if (seat->pointer)
return; return;
weston_pointer_init(&seat->pointer_instance); weston_pointer_init(&seat->pointer_instance);
weston_seat_set_pointer(seat, &seat->pointer_instance); weston_seat_set_pointer(seat, &seat->pointer_instance);
seat->has_pointer = 1;
} }
WL_EXPORT void WL_EXPORT void
weston_seat_init_touch(struct weston_seat *seat) weston_seat_init_touch(struct weston_seat *seat)
{ {
if (seat->has_touch) if (seat->touch)
return; return;
weston_touch_init(&seat->touch_instance); weston_touch_init(&seat->touch_instance);
weston_seat_set_touch(seat, &seat->touch_instance); weston_seat_set_touch(seat, &seat->touch_instance);
seat->has_touch = 1;
} }
WL_EXPORT void WL_EXPORT void
@ -1509,10 +1503,6 @@ weston_seat_init(struct weston_seat *seat, struct weston_compositor *ec)
wl_list_init(&seat->drag_resource_list); wl_list_init(&seat->drag_resource_list);
wl_signal_init(&seat->destroy_signal); wl_signal_init(&seat->destroy_signal);
seat->has_pointer = 0;
seat->has_keyboard = 0;
seat->has_touch = 0;
wl_display_add_global(ec->wl_display, &wl_seat_interface, seat, wl_display_add_global(ec->wl_display, &wl_seat_interface, seat,
bind_seat); bind_seat);

@ -900,7 +900,7 @@ move_surface_to_workspace(struct desktop_shell *shell,
drop_focus_state(shell, from, surface); drop_focus_state(shell, from, surface);
wl_list_for_each(seat, &shell->compositor->seat_list, link) wl_list_for_each(seat, &shell->compositor->seat_list, link)
if (seat->has_keyboard && if (seat->keyboard &&
seat->keyboard->focus == &surface->surface) seat->keyboard->focus == &surface->surface)
weston_keyboard_set_focus(seat->keyboard, NULL); weston_keyboard_set_focus(seat->keyboard, NULL);
@ -3127,7 +3127,7 @@ weston_surface_set_initial_position (struct weston_surface *surface,
* TODO: Do something clever for touch too? * TODO: Do something clever for touch too?
*/ */
wl_list_for_each(seat, &compositor->seat_list, link) { wl_list_for_each(seat, &compositor->seat_list, link) {
if (seat->has_pointer) { if (seat->pointer) {
ix = wl_fixed_to_int(seat->pointer->x); ix = wl_fixed_to_int(seat->pointer->x);
iy = wl_fixed_to_int(seat->pointer->y); iy = wl_fixed_to_int(seat->pointer->y);
break; break;

@ -810,7 +810,7 @@ input_method_init_seat(struct weston_seat *seat)
if (seat->input_method->focus_listener_initialized) if (seat->input_method->focus_listener_initialized)
return; return;
if (seat->has_keyboard) { if (seat->keyboard) {
seat->input_method->keyboard_focus_listener.notify = handle_keyboard_focus; seat->input_method->keyboard_focus_listener.notify = handle_keyboard_focus;
wl_signal_add(&seat->keyboard->focus_signal, &seat->input_method->keyboard_focus_listener); wl_signal_add(&seat->keyboard->focus_signal, &seat->input_method->keyboard_focus_listener);
seat->keyboard->input_method_grab.interface = &input_method_context_grab; seat->keyboard->input_method_grab.interface = &input_method_context_grab;

Loading…
Cancel
Save