diff options
Diffstat (limited to 'sway')
-rw-r--r-- | sway/config.c | 17 | ||||
-rw-r--r-- | sway/config/bar.c | 2 | ||||
-rw-r--r-- | sway/input/cursor.c | 25 | ||||
-rw-r--r-- | sway/input/seat.c | 12 | ||||
-rw-r--r-- | sway/server.c | 28 |
5 files changed, 67 insertions, 17 deletions
diff --git a/sway/config.c b/sway/config.c index 347d9e73..e9e7057d 100644 --- a/sway/config.c +++ b/sway/config.c @@ -57,38 +57,41 @@ static void free_mode(struct sway_mode *mode) { void free_config(struct sway_config *config) { config_clear_handler_context(config); - int i; - if (!config) { return; } // TODO: handle all currently unhandled lists as we add implementations if (config->symbols) { - for (i = 0; i < config->symbols->length; i++) { + for (int i = 0; i < config->symbols->length; ++i) { free_sway_variable(config->symbols->items[i]); } list_free(config->symbols); } if (config->modes) { - for (i = 0; i < config->modes->length; i++) { + for (int i = 0; i < config->modes->length; ++i) { free_mode(config->modes->items[i]); } list_free(config->modes); } - list_free(config->bars); + if (config->bars) { + for (int i = 0; i < config->bars->length; ++i) { + free_bar_config(config->bars->items[i]); + } + list_free(config->bars); + } list_free(config->cmd_queue); list_free(config->workspace_outputs); list_free(config->pid_workspaces); list_free(config->output_configs); if (config->input_configs) { - for (i = 0; i < config->input_configs->length; i++) { + for (int i = 0; i < config->input_configs->length; i++) { free_input_config(config->input_configs->items[i]); } list_free(config->input_configs); } if (config->seat_configs) { - for (i = 0; i < config->seat_configs->length; i++) { + for (int i = 0; i < config->seat_configs->length; i++) { free_seat_config(config->seat_configs->items[i]); } list_free(config->seat_configs); diff --git a/sway/config/bar.c b/sway/config/bar.c index 48b2fc7c..2913f059 100644 --- a/sway/config/bar.c +++ b/sway/config/bar.c @@ -16,6 +16,7 @@ #include "log.h" static void terminate_swaybar(pid_t pid) { + wlr_log(L_DEBUG, "Terminating swaybar %d", pid); int ret = kill(pid, SIGTERM); if (ret != 0) { wlr_log_errno(L_ERROR, "Unable to terminate swaybar %d", pid); @@ -185,6 +186,7 @@ void invoke_swaybar(struct bar_config *bar) { execvp(cmd[0], cmd); exit(1); } + wlr_log(L_DEBUG, "Spawned swaybar %d", bar->pid); close(filedes[0]); ssize_t len; if (read(filedes[1], &len, sizeof(int)) == sizeof(int)) { diff --git a/sway/input/cursor.c b/sway/input/cursor.c index 7390816f..74af6426 100644 --- a/sway/input/cursor.c +++ b/sway/input/cursor.c @@ -63,7 +63,7 @@ static struct sway_container *container_at_cursor(struct sway_cursor *cursor, *surface = xsurface->surface; *sx = cursor->x - box.x; *sy = cursor->y - box.y; - return view->swayc; + return NULL; } } } @@ -175,7 +175,28 @@ static void handle_cursor_button(struct wl_listener *listener, void *data) { double sx, sy; struct sway_container *cont = container_at_cursor(cursor, &surface, &sx, &sy); - sway_seat_set_focus(cursor->seat, cont); + // Avoid moving keyboard focus from a surface that accepts it to one + // that does not unless the change would move us to a new workspace. + // + // This prevents, for example, losing focus when clicking on swaybar. + // + // TODO: Replace this condition with something like + // !surface_accepts_keyboard_input + if (surface && cont && cont->type != C_VIEW) { + struct sway_container *new_ws = cont; + if (new_ws && new_ws->type != C_WORKSPACE) { + new_ws = container_parent(new_ws, C_WORKSPACE); + } + struct sway_container *old_ws = sway_seat_get_focus(cursor->seat); + if (old_ws && old_ws->type != C_WORKSPACE) { + old_ws = container_parent(old_ws, C_WORKSPACE); + } + if (new_ws != old_ws) { + sway_seat_set_focus(cursor->seat, cont); + } + } else { + sway_seat_set_focus(cursor->seat, cont); + } } wlr_seat_pointer_notify_button(cursor->seat->wlr_seat, event->time_msec, diff --git a/sway/input/seat.c b/sway/input/seat.c index ae536264..8d592872 100644 --- a/sway/input/seat.c +++ b/sway/input/seat.c @@ -259,11 +259,11 @@ void sway_seat_remove_device(struct sway_seat *seat, void sway_seat_configure_xcursor(struct sway_seat *seat) { // TODO configure theme and size - const char *cursor_theme = "default"; + const char *cursor_theme = NULL; if (!seat->cursor->xcursor_manager) { seat->cursor->xcursor_manager = - wlr_xcursor_manager_create("default", 24); + wlr_xcursor_manager_create(cursor_theme, 24); if (sway_assert(seat->cursor->xcursor_manager, "Cannot create XCursor manager for theme %s", cursor_theme)) { @@ -291,7 +291,8 @@ void sway_seat_configure_xcursor(struct sway_seat *seat) { seat->cursor->cursor->y); } -void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *container) { +void sway_seat_set_focus(struct sway_seat *seat, + struct sway_container *container) { struct sway_container *last_focus = sway_seat_get_focus(seat); if (container && last_focus == container) { @@ -311,6 +312,11 @@ void sway_seat_set_focus(struct sway_seat *seat, struct sway_container *containe if (container->type == C_VIEW) { struct sway_view *view = container->sway_view; view_set_activated(view, true); + if (view->type == SWAY_XWAYLAND_VIEW) { + struct wlr_xwayland *xwayland = + seat->input->server->xwayland; + wlr_xwayland_set_seat(xwayland, seat->wlr_seat); + } struct wlr_keyboard *keyboard = wlr_seat_get_keyboard(seat->wlr_seat); if (keyboard) { diff --git a/sway/server.c b/sway/server.c index 728e624e..f5cc199c 100644 --- a/sway/server.c +++ b/sway/server.c @@ -8,9 +8,12 @@ #include <wlr/render/wlr_renderer.h> #include <wlr/types/wlr_compositor.h> #include <wlr/types/wlr_gamma_control.h> +#include <wlr/types/wlr_linux_dmabuf.h> #include <wlr/types/wlr_layer_shell.h> +#include <wlr/types/wlr_primary_selection.h> #include <wlr/types/wlr_screenshooter.h> #include <wlr/types/wlr_wl_shell.h> +#include <wlr/types/wlr_xcursor_manager.h> #include <wlr/util/log.h> // TODO WLR: make Xwayland optional #include <wlr/xwayland.h> @@ -53,6 +56,7 @@ bool server_init(struct sway_server *server) { wlr_screenshooter_create(server->wl_display); wlr_gamma_control_manager_create(server->wl_display); + wlr_primary_selection_device_manager_create(server->wl_display); server->new_output.notify = handle_new_output; wl_signal_add(&server->backend->events.new_output, &server->new_output); @@ -67,6 +71,11 @@ bool server_init(struct sway_server *server) { &server->xdg_shell_v6_surface); server->xdg_shell_v6_surface.notify = handle_xdg_shell_v6_surface; + server->wl_shell = wlr_wl_shell_create(server->wl_display); + wl_signal_add(&server->wl_shell->events.new_surface, + &server->wl_shell_surface); + server->wl_shell_surface.notify = handle_wl_shell_surface; + // TODO make xwayland optional server->xwayland = wlr_xwayland_create(server->wl_display, server->compositor); @@ -78,10 +87,20 @@ bool server_init(struct sway_server *server) { // TODO: call server_ready now if xwayland is not enabled server->xwayland_ready.notify = server_ready; - server->wl_shell = wlr_wl_shell_create(server->wl_display); - wl_signal_add(&server->wl_shell->events.new_surface, - &server->wl_shell_surface); - server->wl_shell_surface.notify = handle_wl_shell_surface; + // TODO: configurable cursor theme and size + server->xcursor_manager = wlr_xcursor_manager_create(NULL, 24); + wlr_xcursor_manager_load(server->xcursor_manager, 1); + struct wlr_xcursor *xcursor = wlr_xcursor_manager_get_xcursor( + server->xcursor_manager, "left_ptr", 1); + if (xcursor != NULL) { + struct wlr_xcursor_image *image = xcursor->images[0]; + wlr_xwayland_set_cursor(server->xwayland, image->buffer, + image->width * 4, image->width, image->height, image->hotspot_x, + image->hotspot_y); + } + + struct wlr_egl *egl = wlr_backend_get_egl(server->backend); + wlr_linux_dmabuf_create(server->wl_display, egl); server->socket = wl_display_add_socket_auto(server->wl_display); if (!server->socket) { @@ -91,7 +110,6 @@ bool server_init(struct sway_server *server) { } input_manager = sway_input_manager_create(server); - return true; } |