feat: add support layershell protocol
This commit is contained in:
84
seat.c
84
seat.c
@ -1,9 +1,11 @@
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
#include <wlr/types/wlr_input_device.h>
|
||||
#include <wlr/types/wlr_data_device.h>
|
||||
#include <wlr/types/wlr_cursor.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "seat.h"
|
||||
#include "desktop.h"
|
||||
|
||||
|
||||
static void keyboard_handle_modifiers(
|
||||
struct wl_listener *listener, void *data)
|
||||
@ -40,13 +42,13 @@ static bool handle_keybinding(struct diyac_server *server, xkb_keysym_t sym)
|
||||
break;
|
||||
case XKB_KEY_F1:
|
||||
/* Cycle to the next toplevel */
|
||||
if (wl_list_length(&server->toplevels) < 2)
|
||||
if (wl_list_length(&server->views) < 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
struct diyac_toplevel *next_toplevel =
|
||||
wl_container_of(server->toplevels.prev, next_toplevel, link);
|
||||
diyac_focus_toplevel(next_toplevel, next_toplevel->xdg_toplevel->base->surface);
|
||||
struct diyac_view *next_toplevel =
|
||||
wl_container_of(server->views.prev, next_toplevel, link);
|
||||
diyac_focus_view(next_toplevel);
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
@ -156,7 +158,7 @@ static void server_new_input(struct wl_listener *listener, void *data)
|
||||
{
|
||||
/* This event is raised by the backend when a new input device becomes
|
||||
* available. */
|
||||
struct diyac_seat* seat =
|
||||
struct diyac_seat *seat =
|
||||
wl_container_of(listener, seat, new_input);
|
||||
struct wlr_input_device *device = data;
|
||||
switch (device->type)
|
||||
@ -222,7 +224,7 @@ static void seat_request_set_selection(struct wl_listener *listener, void *data)
|
||||
*/
|
||||
void diyac_init_seat(struct diyac_server *server)
|
||||
{
|
||||
//server->seat = calloc(1, sizeof(struct diyac_seat));
|
||||
// server->seat = calloc(1, sizeof(struct diyac_seat));
|
||||
server->seat.server = server;
|
||||
server->seat.new_input.notify = server_new_input;
|
||||
wl_signal_add(&server->backend->events.new_input, &server->seat.new_input);
|
||||
@ -233,4 +235,72 @@ void diyac_init_seat(struct diyac_server *server)
|
||||
server->seat.request_set_selection.notify = seat_request_set_selection;
|
||||
wl_signal_add(&server->seat.wlr_seat->events.request_set_selection,
|
||||
&server->seat.request_set_selection);
|
||||
}
|
||||
|
||||
static void seat_focus(struct diyac_seat *seat, struct wlr_surface *surface, bool is_lock_surface)
|
||||
{
|
||||
wlr_log(WLR_INFO, "seat_focus");
|
||||
/*
|
||||
* Respect session lock. This check is critical, DO NOT REMOVE.
|
||||
* It should also come before the !surface condition, or the
|
||||
* lock screen may lose focus and become impossible to unlock.
|
||||
*/
|
||||
struct diyac_server *server = seat->server;
|
||||
/*if (server->session_lock && !is_lock_surface)
|
||||
{
|
||||
return;
|
||||
}*/
|
||||
|
||||
if (!surface)
|
||||
{
|
||||
wlr_seat_keyboard_notify_clear_focus(seat->wlr_seat);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Respect input inhibit (also used by some lock screens) */
|
||||
/*
|
||||
if (input_inhibit_blocks_surface(seat, surface->resource)) {
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat);
|
||||
if (keyboard)
|
||||
{
|
||||
wlr_seat_keyboard_notify_enter(seat->wlr_seat, surface,
|
||||
keyboard->keycodes, keyboard->num_keycodes, &keyboard->modifiers);
|
||||
}
|
||||
|
||||
/*
|
||||
struct wlr_pointer_constraint_v1 *constraint =
|
||||
wlr_pointer_constraints_v1_constraint_for_surface(server->constraints,
|
||||
surface, seat->seat);
|
||||
constrain_cursor(server, constraint);
|
||||
*/
|
||||
}
|
||||
|
||||
void diyac_seat_focus_surface(struct diyac_seat *seat, struct wlr_surface *surface)
|
||||
{
|
||||
wlr_log(WLR_INFO, "diyac_seat_focus_surface");
|
||||
/* Respect layer-shell exclusive keyboard-interactivity. */
|
||||
if (seat->focused_layer && seat->focused_layer->current.keyboard_interactive == ZWLR_LAYER_SURFACE_V1_KEYBOARD_INTERACTIVITY_EXCLUSIVE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
seat_focus(seat, surface, /*is_lock_surface*/ false);
|
||||
}
|
||||
|
||||
void diyac_seat_focus_layer(struct diyac_seat *seat, struct wlr_layer_surface_v1 *layer)
|
||||
{
|
||||
if (!layer)
|
||||
{
|
||||
seat->focused_layer = NULL;
|
||||
diyac_focus_topmost_view(seat->server);
|
||||
return;
|
||||
}
|
||||
seat_focus(seat, layer->surface, /*is_lock_surface*/ false);
|
||||
if (layer->current.layer >= ZWLR_LAYER_SHELL_V1_LAYER_TOP)
|
||||
{
|
||||
seat->focused_layer = layer;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user