aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
Diffstat (limited to 'sway')
-rw-r--r--sway/commands.c1
-rw-r--r--sway/commands/focus_on_window_activation.c25
-rw-r--r--sway/desktop/xwayland.c22
-rw-r--r--sway/input/seat.c2
-rw-r--r--sway/meson.build1
-rw-r--r--sway/server.c2
-rw-r--r--sway/tree/view.c23
7 files changed, 72 insertions, 4 deletions
diff --git a/sway/commands.c b/sway/commands.c
index 13f5983e..359856cc 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -106,6 +106,7 @@ static struct cmd_handler handlers[] = {
{ "floating_modifier", cmd_floating_modifier },
{ "focus", cmd_focus },
{ "focus_follows_mouse", cmd_focus_follows_mouse },
+ { "focus_on_window_activation", cmd_focus_on_window_activation },
{ "focus_wrapping", cmd_focus_wrapping },
{ "font", cmd_font },
{ "for_window", cmd_for_window },
diff --git a/sway/commands/focus_on_window_activation.c b/sway/commands/focus_on_window_activation.c
new file mode 100644
index 00000000..1fb07918
--- /dev/null
+++ b/sway/commands/focus_on_window_activation.c
@@ -0,0 +1,25 @@
+#include "sway/commands.h"
+
+struct cmd_results *cmd_focus_on_window_activation(int argc, char **argv) {
+ struct cmd_results *error = NULL;
+ if ((error = checkarg(argc, "focus_on_window_activation",
+ EXPECTED_EQUAL_TO, 1))) {
+ return error;
+ }
+
+ if (strcmp(argv[0], "smart") == 0) {
+ config->focus_on_window_activation = FOWA_SMART;
+ } else if (strcmp(argv[0], "urgent") == 0) {
+ config->focus_on_window_activation = FOWA_URGENT;
+ } else if (strcmp(argv[0], "focus") == 0) {
+ config->focus_on_window_activation = FOWA_FOCUS;
+ } else if (strcmp(argv[0], "none") == 0) {
+ config->focus_on_window_activation = FOWA_NONE;
+ } else {
+ return cmd_results_new(CMD_INVALID, "focus_on_window_activation",
+ "Expected "
+ "'focus_on_window_activation smart|urgent|focus|none'");
+ }
+
+ return cmd_results_new(CMD_SUCCESS, NULL, NULL);
+}
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 2adc28c5..10faf91d 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -218,7 +218,9 @@ static bool wants_floating(struct sway_view *view) {
struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
struct sway_xwayland *xwayland = &server.xwayland;
- // TODO: return true if the NET_WM_STATE is MODAL
+ if (surface->modal) {
+ return true;
+ }
for (size_t i = 0; i < surface->window_type_len; ++i) {
xcb_atom_t type = surface->window_type[i];
@@ -335,6 +337,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
wl_list_remove(&xwayland_view->request_fullscreen.link);
wl_list_remove(&xwayland_view->request_move.link);
wl_list_remove(&xwayland_view->request_resize.link);
+ wl_list_remove(&xwayland_view->request_activate.link);
wl_list_remove(&xwayland_view->set_title.link);
wl_list_remove(&xwayland_view->set_class.link);
wl_list_remove(&xwayland_view->set_window_type.link);
@@ -461,6 +464,19 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
seat_begin_resize_floating(seat, view->swayc, seat->last_button, e->edges);
}
+static void handle_request_activate(struct wl_listener *listener, void *data) {
+ struct sway_xwayland_view *xwayland_view =
+ wl_container_of(listener, xwayland_view, request_activate);
+ struct sway_view *view = &xwayland_view->view;
+ struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
+ if (!xsurface->mapped) {
+ return;
+ }
+ view_request_activate(view);
+
+ transaction_commit_dirty();
+}
+
static void handle_set_title(struct wl_listener *listener, void *data) {
struct sway_xwayland_view *xwayland_view =
wl_container_of(listener, xwayland_view, set_title);
@@ -553,6 +569,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
&xwayland_view->request_fullscreen);
xwayland_view->request_fullscreen.notify = handle_request_fullscreen;
+ wl_signal_add(&xsurface->events.request_activate,
+ &xwayland_view->request_activate);
+ xwayland_view->request_activate.notify = handle_request_activate;
+
wl_signal_add(&xsurface->events.request_move,
&xwayland_view->request_move);
xwayland_view->request_move.notify = handle_request_move;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 5af9e88a..4b7c7893 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -635,7 +635,7 @@ void seat_set_focus_warp(struct sway_seat *seat,
// find new output's old workspace, which might have to be removed if empty
struct sway_container *new_output_last_ws = NULL;
- if (last_output != new_output) {
+ if (new_output && last_output != new_output) {
new_output_last_ws = seat_get_active_child(seat, new_output);
}
diff --git a/sway/meson.build b/sway/meson.build
index bcb44e8b..c14e58dd 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -46,6 +46,7 @@ sway_sources = files(
'commands/floating_modifier.c',
'commands/focus.c',
'commands/focus_follows_mouse.c',
+ 'commands/focus_on_window_activation.c',
'commands/focus_wrapping.c',
'commands/font.c',
'commands/for_window.c',
diff --git a/sway/server.c b/sway/server.c
index 7fa6007e..8b5bc93c 100644
--- a/sway/server.c
+++ b/sway/server.c
@@ -12,7 +12,6 @@
#include <wlr/types/wlr_gamma_control_v1.h>
#include <wlr/types/wlr_idle.h>
#include <wlr/types/wlr_layer_shell.h>
-#include <wlr/types/wlr_linux_dmabuf_v1.h>
#include <wlr/types/wlr_primary_selection.h>
#include <wlr/types/wlr_screencopy_v1.h>
#include <wlr/types/wlr_server_decoration.h>
@@ -117,7 +116,6 @@ bool server_init(struct sway_server *server) {
server->server_decoration.notify = handle_server_decoration;
wl_list_init(&server->decorations);
- wlr_linux_dmabuf_v1_create(server->wl_display, renderer);
wlr_export_dmabuf_manager_v1_create(server->wl_display);
wlr_screencopy_manager_v1_create(server->wl_display);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 1a98c5f2..6bd0ef67 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -280,6 +280,29 @@ void view_set_activated(struct sway_view *view, bool activated) {
}
}
+void view_request_activate(struct sway_view *view) {
+ struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
+ struct sway_seat *seat = input_manager_current_seat(input_manager);
+
+ switch (config->focus_on_window_activation) {
+ case FOWA_SMART:
+ if (workspace_is_visible(ws)) {
+ seat_set_focus(seat, view->swayc);
+ } else {
+ view_set_urgent(view, true);
+ }
+ break;
+ case FOWA_URGENT:
+ view_set_urgent(view, true);
+ break;
+ case FOWA_FOCUS:
+ seat_set_focus(seat, view->swayc);
+ break;
+ case FOWA_NONE:
+ break;
+ }
+}
+
void view_set_tiled(struct sway_view *view, bool tiled) {
if (!tiled) {
view->using_csd = true;