Skip to content
Commits on Source (5)
......@@ -1873,40 +1873,19 @@ handle_pointer_focus(struct wl_listener *listener, void *data)
}
static void
shell_surface_lose_keyboard_focus(struct shell_surface *shsurf)
shell_surface_deactivate(struct shell_surface *shsurf)
{
if (--shsurf->focus_count == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface, false);
}
static void
shell_surface_gain_keyboard_focus(struct shell_surface *shsurf)
shell_surface_activate(struct shell_surface *shsurf)
{
if (shsurf->focus_count++ == 0)
weston_desktop_surface_set_activated(shsurf->desktop_surface, true);
}
static void
handle_keyboard_focus(struct wl_listener *listener, void *data)
{
struct weston_keyboard *keyboard = data;
struct shell_seat *seat = get_shell_seat(keyboard->seat);
if (seat->focused_surface) {
struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
if (shsurf)
shell_surface_lose_keyboard_focus(shsurf);
}
seat->focused_surface = weston_surface_get_main_surface(keyboard->focus);
if (seat->focused_surface) {
struct shell_surface *shsurf = get_shell_surface(seat->focused_surface);
if (shsurf)
shell_surface_gain_keyboard_focus(shsurf);
}
}
/* The surface will be inserted into the list immediately after the link
* returned by this function (i.e. will be stacked immediately above the
* returned link). */
......@@ -2256,6 +2235,7 @@ get_focused_output(struct weston_compositor *compositor)
static void
desktop_shell_destroy_seat(struct shell_seat *shseat)
{
wl_list_remove(&shseat->keyboard_focus_listener.link);
wl_list_remove(&shseat->caps_changed_listener.link);
wl_list_remove(&shseat->pointer_focus_listener.link);
......@@ -2278,23 +2258,12 @@ destroy_shell_seat(struct wl_listener *listener, void *data)
static void
shell_seat_caps_changed(struct wl_listener *listener, void *data)
{
struct weston_keyboard *keyboard;
struct weston_pointer *pointer;
struct shell_seat *seat;
seat = container_of(listener, struct shell_seat, caps_changed_listener);
keyboard = weston_seat_get_keyboard(seat->seat);
pointer = weston_seat_get_pointer(seat->seat);
if (keyboard &&
wl_list_empty(&seat->keyboard_focus_listener.link)) {
wl_signal_add(&keyboard->focus_signal,
&seat->keyboard_focus_listener);
} else if (!keyboard) {
wl_list_remove(&seat->keyboard_focus_listener.link);
wl_list_init(&seat->keyboard_focus_listener.link);
}
if (pointer &&
wl_list_empty(&seat->pointer_focus_listener.link)) {
wl_signal_add(&pointer->focus_signal,
......@@ -2322,7 +2291,6 @@ create_shell_seat(struct desktop_shell *shell, struct weston_seat *seat)
wl_signal_add(&seat->destroy_signal,
&shseat->seat_destroy_listener);
shseat->keyboard_focus_listener.notify = handle_keyboard_focus;
wl_list_init(&shseat->keyboard_focus_listener.link);
shseat->pointer_focus_listener.notify = handle_pointer_focus;
......@@ -2450,8 +2418,6 @@ desktop_surface_added(struct weston_desktop_surface *desktop_surface,
wl_list_init(&shsurf->children_link);
weston_desktop_surface_set_user_data(desktop_surface, shsurf);
weston_desktop_surface_set_activated(desktop_surface,
shsurf->focus_count > 0);
}
static void
......@@ -2463,6 +2429,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
struct shell_surface *shsurf_child, *tmp;
struct weston_surface *surface =
weston_desktop_surface_get_surface(desktop_surface);
struct weston_seat *seat;
if (!shsurf)
return;
......@@ -2473,6 +2440,18 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
}
wl_list_remove(&shsurf->children_link);
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link) {
struct shell_seat *shseat = get_shell_seat(seat);
/* activate() controls the focused surface activation and
* removal of a surface requires invalidating the
* focused_surface to avoid activate() use a stale (and just
* removed) surface when attempting to de-activate it. It will
* also update the focused_surface once it has a chance to run.
*/
if (surface == shseat->focused_surface)
shseat->focused_surface = NULL;
}
wl_signal_emit(&shsurf->destroy_signal, shsurf);
if (shsurf->fullscreen.black_view)
......@@ -3869,6 +3848,7 @@ activate(struct desktop_shell *shell, struct weston_view *view,
struct workspace *ws;
struct weston_surface *old_es;
struct shell_surface *shsurf, *shsurf_child;
struct shell_seat *shseat = get_shell_seat(seat);
main_surface = weston_surface_get_main_surface(es);
shsurf = get_shell_surface(main_surface);
......@@ -3886,7 +3866,17 @@ activate(struct desktop_shell *shell, struct weston_view *view,
if (shsurf->output)
lower_fullscreen_layer(shell, shsurf->output);
weston_view_activate(view, seat, flags);
weston_view_activate_input(view, seat, flags);
if (shseat->focused_surface) {
struct shell_surface *current_focus =
get_shell_surface(shseat->focused_surface);
assert(current_focus);
shell_surface_deactivate(current_focus);
}
shseat->focused_surface = main_surface;
shell_surface_activate(shsurf);
state = ensure_focus_state(shell, seat);
if (state == NULL)
......
......@@ -1626,9 +1626,9 @@ weston_view_from_global_fixed(struct weston_view *view,
wl_fixed_t *vx, wl_fixed_t *vy);
void
weston_view_activate(struct weston_view *view,
struct weston_seat *seat,
uint32_t flags);
weston_view_activate_input(struct weston_view *view,
struct weston_seat *seat,
uint32_t flags);
void
notify_modifiers(struct weston_seat *seat, uint32_t serial);
......
......@@ -664,7 +664,7 @@ desktop_surface_removed(struct weston_desktop_surface *desktop_surface,
wl_list_for_each(seat, &shell->compositor->seat_list, link) {
struct weston_keyboard *keyboard = seat->keyboard_state;
if (keyboard && keyboard->focus == surface)
weston_view_activate(focus_view, seat, 0);
weston_view_activate_input(focus_view, seat, 0);
}
}
......@@ -719,7 +719,7 @@ desktop_surface_committed(struct weston_desktop_surface *desktop_surface,
surface->is_mapped = true;
wl_list_for_each(seat, &shsurf->shell->compositor->seat_list, link)
weston_view_activate(shsurf->view, seat, 0);
weston_view_activate_input(shsurf->view, seat, 0);
}
if (!is_fullscreen && (sx != 0 || sy != 0)) {
......@@ -927,7 +927,7 @@ kiosk_shell_activate_view(struct kiosk_shell *shell,
weston_surface_damage(view->surface);
}
weston_view_activate(view, seat, flags);
weston_view_activate_input(view, seat, flags);
}
static void
......
......@@ -1864,7 +1864,7 @@ inc_activate_serial(struct weston_compositor *c)
}
WL_EXPORT void
weston_view_activate(struct weston_view *view,
weston_view_activate_input(struct weston_view *view,
struct weston_seat *seat,
uint32_t flags)
{
......