#include <wlr/types/wlr_input_device.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/types/wlr_keyboard_group.h>
+#include <wlr/types/wlr_layer_shell_v1.h>
#include <wlr/types/wlr_matrix.h>
#include <wlr/types/wlr_output.h>
#include <wlr/types/wlr_output_layout.h>
struct wlr_cursor *cursor;
struct wlr_xcursor_manager *xcursor_manager;
+ /* if set, views cannot receive focus */
+ struct wlr_layer_surface_v1 *focused_layer;
+
struct wl_list inputs;
struct wl_listener new_input;
void seat_init(struct server *server);
void seat_finish(struct server *server);
void seat_focus_surface(struct seat *seat, struct wlr_surface *surface);
+void seat_set_focus_layer(struct seat *seat, struct wlr_layer_surface_v1 *layer);
void interactive_begin(struct view *view, enum input_mode mode,
uint32_t edges);
break;
}
}
+ struct seat *seat = &output->server->seat;
if (topmost) {
- seat_focus_surface(&output->server->seat,
- topmost->layer_surface->surface);
+ seat_set_focus_layer(seat, topmost->layer_surface);
+ } else if (seat->focused_layer &&
+ !seat->focused_layer->current.keyboard_interactive) {
+ seat_set_focus_layer(seat, NULL);
}
}
arrange_layers(output_from_wlr_output(layer->server, wlr_output));
}
+static void
+unmap(struct lab_layer_surface *layer)
+{
+ struct seat *seat = &layer->server->seat;
+ if (seat->focused_layer == layer->layer_surface) {
+ seat_set_focus_layer(seat, NULL);
+ }
+}
+
static void
destroy_notify(struct wl_listener *listener, void *data)
{
struct lab_layer_surface *layer = wl_container_of(
listener, layer, destroy);
+ if (layer->layer_surface->mapped) {
+ unmap(layer);
+ }
wl_list_remove(&layer->link);
wl_list_remove(&layer->destroy.link);
wl_list_remove(&layer->map.link);
free(layer);
}
+static void
+unmap_notify(struct wl_listener *listener, void *data)
+{
+ struct lab_layer_surface *l = wl_container_of(listener, l, unmap);
+ unmap(l);
+}
+
static void
map_notify(struct wl_listener *listener, void *data)
{
surface->map.notify = map_notify;
wl_signal_add(&layer_surface->events.map, &surface->map);
+ surface->unmap.notify = unmap_notify;
+ wl_signal_add(&layer_surface->events.unmap, &surface->unmap);
+
wl_list_insert(&output->layers[layer_surface->client_pending.layer],
&surface->link);
/*
wlr_seat_keyboard_notify_enter(seat->seat, surface, kb->keycodes,
kb->num_keycodes, &kb->modifiers);
}
+
+void
+seat_set_focus_layer(struct seat *seat, struct wlr_layer_surface_v1 *layer)
+{
+ if (!layer) {
+ seat->focused_layer = NULL;
+ desktop_focus_topmost_mapped_view(seat->server);
+ return;
+ }
+ seat_focus_surface(seat, layer->surface);
+ if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP) {
+ seat->focused_layer = layer;
+ }
+}