Fix coding style following 824282dd

This commit is contained in:
Johan Malm 2021-08-25 19:59:49 +01:00
parent 824282dd2e
commit a9042e3cde
5 changed files with 59 additions and 49 deletions

View file

@ -382,11 +382,11 @@ void action(struct server *server, const char *action, const char *command);
/* update onscreen display 'alt-tab' texture */ /* update onscreen display 'alt-tab' texture */
void osd_update(struct server *server); void osd_update(struct server *server);
/* wlroots "input inhibitor" extension (required for swaylock) blocks /*
* wlroots "input inhibitor" extension (required for swaylock) blocks
* any client other than the requesting client from receiving events * any client other than the requesting client from receiving events
*/ */
bool input_inhibit_blocks_surface(struct seat *seat, bool input_inhibit_blocks_surface(struct seat *seat,
struct wl_resource *resource); struct wl_resource *resource);
#endif /* __LABWC_H */ #endif /* __LABWC_H */

View file

@ -105,10 +105,10 @@ set_cursor(struct server *server, const char *cursor_name)
server->seat.xcursor_manager, cursor_name, server->seat.cursor); server->seat.xcursor_manager, cursor_name, server->seat.cursor);
} }
bool input_inhibit_blocks_surface(struct seat *seat, bool
struct wl_resource *resource) input_inhibit_blocks_surface(struct seat *seat, struct wl_resource *resource)
{ {
struct wl_client * inhibiting_client = struct wl_client *inhibiting_client =
seat->active_client_while_inhibited; seat->active_client_while_inhibited;
return (inhibiting_client != NULL) && return (inhibiting_client != NULL) &&
inhibiting_client != wl_resource_get_client(resource); inhibiting_client != wl_resource_get_client(resource);
@ -171,7 +171,7 @@ process_cursor_motion(struct server *server, uint32_t time)
damage_all_outputs(server); damage_all_outputs(server);
if (surface && if (surface &&
! input_inhibit_blocks_surface(&server->seat, surface->resource)) { !input_inhibit_blocks_surface(&server->seat, surface->resource)) {
bool focus_changed = bool focus_changed =
wlr_seat->pointer_state.focused_surface != surface; wlr_seat->pointer_state.focused_surface != surface;
/* /*
@ -419,9 +419,11 @@ cursor_init(struct seat *seat)
wl_signal_add(&seat->cursor->events.frame, &seat->cursor_frame); wl_signal_add(&seat->cursor->events.frame, &seat->cursor_frame);
seat->request_cursor.notify = request_cursor_notify; seat->request_cursor.notify = request_cursor_notify;
wl_signal_add(&seat->seat->events.request_set_cursor, &seat->request_cursor); wl_signal_add(&seat->seat->events.request_set_cursor,
&seat->request_cursor);
seat->request_set_selection.notify = request_set_selection_notify; seat->request_set_selection.notify = request_set_selection_notify;
wl_signal_add(&seat->seat->events.request_set_selection, &seat->request_set_selection); wl_signal_add(&seat->seat->events.request_set_selection,
&seat->request_set_selection);
seat->request_set_primary_selection.notify = seat->request_set_primary_selection.notify =
request_set_primary_selection_notify; request_set_primary_selection_notify;

View file

@ -76,8 +76,9 @@ desktop_set_focus_view_only(struct seat *seat, struct view *view)
if (!view || view->minimized || !view->mapped) { if (!view || view->minimized || !view->mapped) {
return; return;
} }
if(input_inhibit_blocks_surface(seat, view->surface->resource)) if (input_inhibit_blocks_surface(seat, view->surface->resource)) {
return; return;
}
struct wlr_surface *prev_surface; struct wlr_surface *prev_surface;
prev_surface = seat->seat->keyboard_state.focused_surface; prev_surface = seat->seat->keyboard_state.focused_surface;
@ -99,8 +100,9 @@ desktop_focus_view(struct seat *seat, struct view *view)
seat_focus_surface(seat, NULL); seat_focus_surface(seat, NULL);
return; return;
} }
if(input_inhibit_blocks_surface(seat, view->surface->resource)) if (input_inhibit_blocks_surface(seat, view->surface->resource)) {
return; return;
}
if (view->minimized) { if (view->minimized) {
/* this will unmap and then focus */ /* this will unmap and then focus */
@ -131,7 +133,7 @@ desktop_focus_view(struct seat *seat, struct view *view)
/* /*
* Some xwayland apps produce unmapped surfaces on startup and also leave * Some xwayland apps produce unmapped surfaces on startup and also leave
* some unmapped surfaces kicking around on 'close' (for example * leafpad's * some unmapped surfaces kicking around on 'close' (for example leafpad's
* "about" dialogue). Whilst this is not normally a problem, we have to be * "about" dialogue). Whilst this is not normally a problem, we have to be
* careful when cycling between views. The only views we should focus are * careful when cycling between views. The only views we should focus are
* those that are already mapped and those that have been minimized. * those that are already mapped and those that have been minimized.

View file

@ -43,7 +43,7 @@ handle_keybinding(struct server *server, uint32_t modifiers, xkb_keysym_t sym)
static bool static bool
handle_compositor_keybindings(struct wl_listener *listener, handle_compositor_keybindings(struct wl_listener *listener,
struct wlr_event_keyboard_key *event) struct wlr_event_keyboard_key *event)
{ {
struct seat *seat = wl_container_of(listener, seat, keyboard_key); struct seat *seat = wl_container_of(listener, seat, keyboard_key);
struct server *server = seat->server; struct server *server = seat->server;
@ -66,7 +66,7 @@ handle_compositor_keybindings(struct wl_listener *listener,
/* end cycle */ /* end cycle */
desktop_focus_view(&server->seat, server->cycle_view); desktop_focus_view(&server->seat, server->cycle_view);
server->cycle_view = NULL; server->cycle_view = NULL;
/* XXX should we handled=true here? */ /* TODO should we handled=true here? */
} else if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { } else if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
/* cycle to next */ /* cycle to next */
server->cycle_view = server->cycle_view =
@ -96,13 +96,10 @@ handle_compositor_keybindings(struct wl_listener *listener,
} }
return handled; return handled;
} }
static void static void
keyboard_key_notify(struct wl_listener *listener, void *data) keyboard_key_notify(struct wl_listener *listener, void *data)
{ {
/* XXX need to check if input inhibited before doing any
* compositor bindings
*/
/* This event is raised when a key is pressed or released. */ /* This event is raised when a key is pressed or released. */
struct seat *seat = wl_container_of(listener, seat, keyboard_key); struct seat *seat = wl_container_of(listener, seat, keyboard_key);
struct server *server = seat->server; struct server *server = seat->server;
@ -112,9 +109,10 @@ keyboard_key_notify(struct wl_listener *listener, void *data)
bool handled = false; bool handled = false;
if(!seat->active_client_while_inhibited) /* ignore labwc keybindings if input is inhibited */
/* ignore labwc keybindings if input is inhibited */ if (!seat->active_client_while_inhibited) {
handled = handle_compositor_keybindings(listener, event); handled = handle_compositor_keybindings(listener, event);
}
if (!handled) { if (!handled) {
wlr_seat_set_keyboard(wlr_seat, device); wlr_seat_set_keyboard(wlr_seat, device);

View file

@ -79,62 +79,68 @@ drop_permissions(void)
} }
} }
static void seat_inhibit_input(struct seat *seat, struct wl_client *active_client) static void
seat_inhibit_input(struct seat *seat, struct wl_client *active_client)
{ {
seat->active_client_while_inhibited = active_client; seat->active_client_while_inhibited = active_client;
if(seat->focused_layer && if (seat->focused_layer &&
(wl_resource_get_client(seat->focused_layer->resource) != (wl_resource_get_client(seat->focused_layer->resource) !=
active_client)) active_client)) {
{
seat_set_focus_layer(seat, NULL); seat_set_focus_layer(seat, NULL);
} }
struct wlr_surface * previous_kb_surface = seat->seat->keyboard_state.focused_surface; struct wlr_surface *previous_kb_surface =
seat->seat->keyboard_state.focused_surface;
if (previous_kb_surface && if (previous_kb_surface &&
wl_resource_get_client(previous_kb_surface->resource) != active_client) { wl_resource_get_client(previous_kb_surface->resource) != active_client) {
seat_focus_surface(seat, NULL); /* keyboard focus */ seat_focus_surface(seat, NULL); /* keyboard focus */
} }
struct wlr_seat_client * previous_ptr_client = seat->seat->pointer_state.focused_client; struct wlr_seat_client *previous_ptr_client =
seat->seat->pointer_state.focused_client;
if (previous_ptr_client && if (previous_ptr_client &&
(previous_ptr_client->client != active_client)) { (previous_ptr_client->client != active_client)) {
wlr_seat_pointer_clear_focus(seat->seat); wlr_seat_pointer_clear_focus(seat->seat);
} }
} }
static void seat_disinhibit_input(struct seat *seat) static void
seat_disinhibit_input(struct seat *seat)
{ {
seat->active_client_while_inhibited = NULL; seat->active_client_while_inhibited = NULL;
// Triggers a refocus of the topmost surface layer if necessary
// TODO: Make layer surface focus per-output based on cursor position
/*
* Triggers a refocus of the topmost surface layer if necessary
* TODO: Make layer surface focus per-output based on cursor position
*/
struct output *output; struct output *output;
wl_list_for_each(output, &seat->server->outputs, link) wl_list_for_each(output, &seat->server->outputs, link) {
arrange_layers(output); arrange_layers(output);
}
} }
static void handle_input_inhibit(struct wl_listener *listener, void *data) { static void
handle_input_inhibit(struct wl_listener *listener, void *data)
{
wlr_log(WLR_INFO, "activate input inhibit"); wlr_log(WLR_INFO, "activate input inhibit");
struct server *server = wl_container_of( struct server *server =
listener, server, input_inhibit_activate); wl_container_of(listener, server, input_inhibit_activate);
seat_inhibit_input(&server->seat, server->input_inhibit->active_client);
seat_inhibit_input(&server->seat,
server->input_inhibit->active_client);
} }
static void handle_input_disinhibit(struct wl_listener *listener, void *data) { static void
handle_input_disinhibit(struct wl_listener *listener, void *data)
{
wlr_log(WLR_INFO, "deactivate input inhibit"); wlr_log(WLR_INFO, "deactivate input inhibit");
struct server *server = wl_container_of( struct server *server =
listener, server, input_inhibit_deactivate); wl_container_of(listener, server, input_inhibit_deactivate);
seat_disinhibit_input(&server->seat); seat_disinhibit_input(&server->seat);
} }
void void
server_init(struct server *server) server_init(struct server *server)
{ {
@ -260,17 +266,19 @@ server_init(struct server *server)
wlr_data_control_manager_v1_create(server->wl_display); wlr_data_control_manager_v1_create(server->wl_display);
wlr_gamma_control_manager_v1_create(server->wl_display); wlr_gamma_control_manager_v1_create(server->wl_display);
// struct wlr_input_inhibit_manager *input_inhibit_mgr = NULL; server->input_inhibit =
server->input_inhibit = wlr_input_inhibit_manager_create(server->wl_display); wlr_input_inhibit_manager_create(server->wl_display);
if (!server->input_inhibit) { if (!server->input_inhibit) {
wlr_log(WLR_ERROR, "unable to create the input inhibit manager"); wlr_log(WLR_ERROR, "unable to create input inhibit manager");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
wl_signal_add(&server->input_inhibit->events.activate, &server->input_inhibit_activate); wl_signal_add(&server->input_inhibit->events.activate,
&server->input_inhibit_activate);
server->input_inhibit_activate.notify = handle_input_inhibit; server->input_inhibit_activate.notify = handle_input_inhibit;
wl_signal_add(&server->input_inhibit->events.deactivate, &server->input_inhibit_deactivate); wl_signal_add(&server->input_inhibit->events.deactivate,
&server->input_inhibit_deactivate);
server->input_inhibit_deactivate.notify = handle_input_disinhibit; server->input_inhibit_deactivate.notify = handle_input_disinhibit;
server->foreign_toplevel_manager = server->foreign_toplevel_manager =