#include "ivi-compositor.h"
#include "shared/helpers.h"
-struct ivi_shell_seat {
- struct weston_seat *seat;
- struct weston_surface *focused_surface;
-
- bool hide_cursor;
- bool new_caps_sent;
-
- struct wl_listener seat_destroy_listener;
- struct wl_listener caps_changed_listener;
- struct wl_listener keyboard_focus_listener;
- struct wl_listener pointer_focus_listener;
-};
-
-static struct ivi_surface *
+struct ivi_surface *
get_ivi_shell_surface(struct weston_surface *surface)
{
struct weston_desktop_surface *desktop_surface =
free(shseat);
}
-static struct ivi_shell_seat *
+struct ivi_shell_seat *
get_ivi_shell_seat(struct weston_seat *seat)
{
struct wl_listener *listener;
+ if (!seat)
+ return NULL;
+
+
listener = wl_signal_get(&seat->destroy_signal,
ivi_shell_seat_handle_destroy);
- assert(listener != NULL);
+ if (!listener)
+ return NULL;
return container_of(listener,
struct ivi_shell_seat, seat_destroy_listener);
}
-
-static void
-ivi_shell_seat_handle_keyboard_focus(struct wl_listener *listener, void *data)
+struct weston_seat *
+get_ivi_shell_weston_first_seat(struct ivi_compositor *ivi)
{
- struct weston_keyboard *keyboard = data;
- struct ivi_shell_seat *shseat = get_ivi_shell_seat(keyboard->seat);
-
- if (shseat->focused_surface) {
- struct ivi_surface *surf =
- get_ivi_shell_surface(shseat->focused_surface);
- if (surf && --surf->focus_count == 0)
- weston_desktop_surface_set_activated(surf->dsurface, false);
- }
+ struct wl_list *node;
+ struct weston_compositor *compositor = ivi->compositor;
- shseat->focused_surface = weston_surface_get_main_surface(keyboard->focus);
+ if (wl_list_empty(&compositor->seat_list))
+ return NULL;
- if (shseat->focused_surface) {
- struct ivi_surface *surf =
- get_ivi_shell_surface(shseat->focused_surface);
- if (surf && surf->focus_count++ == 0)
- weston_desktop_surface_set_activated(surf->dsurface, true);
- }
+ node = compositor->seat_list.next;
+ return container_of(node, struct weston_seat, link);
}
static void
static void
ivi_shell_seat_handle_caps_changed(struct wl_listener *listener, void *data)
{
- struct weston_keyboard *keyboard;
struct weston_pointer *pointer;
struct ivi_shell_seat *shseat;
shseat = container_of(listener, struct ivi_shell_seat,
caps_changed_listener);
- keyboard = weston_seat_get_keyboard(shseat->seat);
pointer = weston_seat_get_pointer(shseat->seat);
if (pointer && wl_list_empty(&shseat->pointer_focus_listener.link)) {
wl_list_remove(&shseat->pointer_focus_listener.link);
wl_list_init(&shseat->pointer_focus_listener.link);
}
-
- if (keyboard &&
- wl_list_empty(&shseat->keyboard_focus_listener.link)) {
- wl_signal_add(&keyboard->focus_signal,
- &shseat->keyboard_focus_listener);
- } else if (!keyboard) {
- wl_list_remove(&shseat->keyboard_focus_listener.link);
- wl_list_init(&shseat->keyboard_focus_listener.link);
- }
}
static struct ivi_shell_seat *
shseat->seat_destroy_listener.notify = ivi_shell_seat_handle_destroy;
wl_signal_add(&seat->destroy_signal, &shseat->seat_destroy_listener);
- shseat->keyboard_focus_listener.notify =
- ivi_shell_seat_handle_keyboard_focus;
wl_list_init(&shseat->keyboard_focus_listener.link);
shseat->pointer_focus_listener.notify =