summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Brian Ashworth <RedSoxFan@users.noreply.github.com>2018-09-03 00:24:28 -0400
committerLibravatar GitHub <noreply@github.com>2018-09-03 00:24:28 -0400
commitafb69688746b04d7667e1d57d9ac844bd2671570 (patch)
treef950fd298c335abd992005a26029dbfba8010136
parentDo not modeset disabled outputs (diff)
parentMerge pull request #2562 from RyanDwyer/ld-library-path (diff)
downloadsway-afb69688746b04d7667e1d57d9ac844bd2671570.tar.gz
sway-afb69688746b04d7667e1d57d9ac844bd2671570.tar.zst
sway-afb69688746b04d7667e1d57d9ac844bd2671570.zip
Merge branch 'master' into disabled-no-modeset
-rw-r--r--include/sway/commands.h1
-rw-r--r--include/sway/config.h11
-rw-r--r--include/sway/tree/view.h6
-rw-r--r--meson.build12
-rw-r--r--meson_options.txt11
-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
12 files changed, 103 insertions, 14 deletions
diff --git a/include/sway/commands.h b/include/sway/commands.h
index 8e91c158..b0b5ed0f 100644
--- a/include/sway/commands.h
+++ b/include/sway/commands.h
@@ -117,6 +117,7 @@ sway_cmd cmd_floating_modifier;
117sway_cmd cmd_floating_scroll; 117sway_cmd cmd_floating_scroll;
118sway_cmd cmd_focus; 118sway_cmd cmd_focus;
119sway_cmd cmd_focus_follows_mouse; 119sway_cmd cmd_focus_follows_mouse;
120sway_cmd cmd_focus_on_window_activation;
120sway_cmd cmd_focus_wrapping; 121sway_cmd cmd_focus_wrapping;
121sway_cmd cmd_font; 122sway_cmd cmd_font;
122sway_cmd cmd_for_window; 123sway_cmd cmd_for_window;
diff --git a/include/sway/config.h b/include/sway/config.h
index 18d10faa..4ee8c3c2 100644
--- a/include/sway/config.h
+++ b/include/sway/config.h
@@ -58,6 +58,16 @@ struct sway_mouse_binding {
58}; 58};
59 59
60/** 60/**
61 * Focus on window activation.
62 */
63enum sway_fowa {
64 FOWA_SMART,
65 FOWA_URGENT,
66 FOWA_FOCUS,
67 FOWA_NONE,
68};
69
70/**
61 * A "mode" of keybindings created via the `mode` command. 71 * A "mode" of keybindings created via the `mode` command.
62 */ 72 */
63struct sway_mode { 73struct sway_mode {
@@ -340,6 +350,7 @@ struct sway_config {
340 size_t font_height; 350 size_t font_height;
341 bool pango_markup; 351 bool pango_markup;
342 size_t urgent_timeout; 352 size_t urgent_timeout;
353 enum sway_fowa focus_on_window_activation;
343 354
344 // Flags 355 // Flags
345 bool focus_follows_mouse; 356 bool focus_follows_mouse;
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index f73ce571..382ab6b9 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -167,6 +167,7 @@ struct sway_xwayland_view {
167 struct wl_listener request_maximize; 167 struct wl_listener request_maximize;
168 struct wl_listener request_configure; 168 struct wl_listener request_configure;
169 struct wl_listener request_fullscreen; 169 struct wl_listener request_fullscreen;
170 struct wl_listener request_activate;
170 struct wl_listener set_title; 171 struct wl_listener set_title;
171 struct wl_listener set_class; 172 struct wl_listener set_class;
172 struct wl_listener set_window_type; 173 struct wl_listener set_window_type;
@@ -259,6 +260,11 @@ void view_autoconfigure(struct sway_view *view);
259 260
260void view_set_activated(struct sway_view *view, bool activated); 261void view_set_activated(struct sway_view *view, bool activated);
261 262
263/**
264 * Called when the view requests to be focused.
265 */
266void view_request_activate(struct sway_view *view);
267
262void view_set_tiled(struct sway_view *view, bool tiled); 268void view_set_tiled(struct sway_view *view, bool tiled);
263 269
264void view_close(struct sway_view *view); 270void view_close(struct sway_view *view);
diff --git a/meson.build b/meson.build
index d5b33e6b..eb5cba84 100644
--- a/meson.build
+++ b/meson.build
@@ -106,7 +106,7 @@ endif
106 106
107add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c') 107add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c')
108 108
109version = get_option('sway_version') 109version = get_option('sway-version')
110if version != '' 110if version != ''
111 version = '"@0@"'.format(version) 111 version = '"@0@"'.format(version)
112else 112else
@@ -120,6 +120,8 @@ else
120endif 120endif
121add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c') 121add_project_arguments('-DSWAY_VERSION=@0@'.format(version), language: 'c')
122 122
123add_project_arguments('-D_LD_LIBRARY_PATH="@0@"'.format(get_option('ld-library-path')), language: 'c')
124
123sway_inc = include_directories('include') 125sway_inc = include_directories('include')
124 126
125subdir('include') 127subdir('include')
@@ -168,7 +170,7 @@ install_data(
168 install_dir: datadir + '/wayland-sessions' 170 install_dir: datadir + '/wayland-sessions'
169) 171)
170 172
171if (get_option('default_wallpaper')) 173if (get_option('default-wallpaper'))
172 wallpaper_files = files( 174 wallpaper_files = files(
173 'assets/Sway_Wallpaper_Blue_768x1024.png', 175 'assets/Sway_Wallpaper_Blue_768x1024.png',
174 'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png', 176 'assets/Sway_Wallpaper_Blue_768x1024_Portrait.png',
@@ -184,7 +186,7 @@ if (get_option('default_wallpaper'))
184 install_data(wallpaper_files, install_dir: wallpaper_install_dir) 186 install_data(wallpaper_files, install_dir: wallpaper_install_dir)
185endif 187endif
186 188
187if (get_option('zsh_completions')) 189if (get_option('zsh-completions'))
188 zsh_files = files( 190 zsh_files = files(
189 'completions/zsh/_sway', 191 'completions/zsh/_sway',
190 'completions/zsh/_swaylock', 192 'completions/zsh/_swaylock',
@@ -195,7 +197,7 @@ if (get_option('zsh_completions'))
195 install_data(zsh_files, install_dir: zsh_install_dir) 197 install_data(zsh_files, install_dir: zsh_install_dir)
196endif 198endif
197 199
198if (get_option('bash_completions')) 200if (get_option('bash-completions'))
199 bash_files = files( 201 bash_files = files(
200 'completions/bash/sway', 202 'completions/bash/sway',
201 'completions/bash/swayidle', 203 'completions/bash/swayidle',
@@ -207,7 +209,7 @@ if (get_option('bash_completions'))
207 install_data(bash_files, install_dir: bash_install_dir) 209 install_data(bash_files, install_dir: bash_install_dir)
208endif 210endif
209 211
210if (get_option('fish_completions')) 212if (get_option('fish-completions'))
211 fish_files = files( 213 fish_files = files(
212 'completions/fish/sway.fish', 214 'completions/fish/sway.fish',
213 'completions/fish/swaylock.fish', 215 'completions/fish/swaylock.fish',
diff --git a/meson_options.txt b/meson_options.txt
index 5e54607f..50d646fd 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,6 +1,7 @@
1option('sway_version', type : 'string', description: 'The version string reported in `sway --version`.') 1option('sway-version', type : 'string', description: 'The version string reported in `sway --version`.')
2option('default_wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.') 2option('ld-library-path', type: 'string', value: '', description: 'The LD_LIBRARY_PATH environment variable.')
3option('zsh_completions', type: 'boolean', value: true, description: 'Install zsh shell completions.') 3option('default-wallpaper', type: 'boolean', value: true, description: 'Install the default wallpaper.')
4option('bash_completions', type: 'boolean', value: true, description: 'Install bash shell completions.') 4option('zsh-completions', type: 'boolean', value: true, description: 'Install zsh shell completions.')
5option('fish_completions', type: 'boolean', value: true, description: 'Install fish shell completions.') 5option('bash-completions', type: 'boolean', value: true, description: 'Install bash shell completions.')
6option('fish-completions', type: 'boolean', value: true, description: 'Install fish shell completions.')
6option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support for X11 applications') 7option('enable-xwayland', type: 'boolean', value: true, description: 'Enable support for X11 applications')
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[] = {
106 { "floating_modifier", cmd_floating_modifier }, 106 { "floating_modifier", cmd_floating_modifier },
107 { "focus", cmd_focus }, 107 { "focus", cmd_focus },
108 { "focus_follows_mouse", cmd_focus_follows_mouse }, 108 { "focus_follows_mouse", cmd_focus_follows_mouse },
109 { "focus_on_window_activation", cmd_focus_on_window_activation },
109 { "focus_wrapping", cmd_focus_wrapping }, 110 { "focus_wrapping", cmd_focus_wrapping },
110 { "font", cmd_font }, 111 { "font", cmd_font },
111 { "for_window", cmd_for_window }, 112 { "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 @@
1#include "sway/commands.h"
2
3struct cmd_results *cmd_focus_on_window_activation(int argc, char **argv) {
4 struct cmd_results *error = NULL;
5 if ((error = checkarg(argc, "focus_on_window_activation",
6 EXPECTED_EQUAL_TO, 1))) {
7 return error;
8 }
9
10 if (strcmp(argv[0], "smart") == 0) {
11 config->focus_on_window_activation = FOWA_SMART;
12 } else if (strcmp(argv[0], "urgent") == 0) {
13 config->focus_on_window_activation = FOWA_URGENT;
14 } else if (strcmp(argv[0], "focus") == 0) {
15 config->focus_on_window_activation = FOWA_FOCUS;
16 } else if (strcmp(argv[0], "none") == 0) {
17 config->focus_on_window_activation = FOWA_NONE;
18 } else {
19 return cmd_results_new(CMD_INVALID, "focus_on_window_activation",
20 "Expected "
21 "'focus_on_window_activation smart|urgent|focus|none'");
22 }
23
24 return cmd_results_new(CMD_SUCCESS, NULL, NULL);
25}
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) {
218 struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface; 218 struct wlr_xwayland_surface *surface = view->wlr_xwayland_surface;
219 struct sway_xwayland *xwayland = &server.xwayland; 219 struct sway_xwayland *xwayland = &server.xwayland;
220 220
221 // TODO: return true if the NET_WM_STATE is MODAL 221 if (surface->modal) {
222 return true;
223 }
222 224
223 for (size_t i = 0; i < surface->window_type_len; ++i) { 225 for (size_t i = 0; i < surface->window_type_len; ++i) {
224 xcb_atom_t type = surface->window_type[i]; 226 xcb_atom_t type = surface->window_type[i];
@@ -335,6 +337,7 @@ static void handle_destroy(struct wl_listener *listener, void *data) {
335 wl_list_remove(&xwayland_view->request_fullscreen.link); 337 wl_list_remove(&xwayland_view->request_fullscreen.link);
336 wl_list_remove(&xwayland_view->request_move.link); 338 wl_list_remove(&xwayland_view->request_move.link);
337 wl_list_remove(&xwayland_view->request_resize.link); 339 wl_list_remove(&xwayland_view->request_resize.link);
340 wl_list_remove(&xwayland_view->request_activate.link);
338 wl_list_remove(&xwayland_view->set_title.link); 341 wl_list_remove(&xwayland_view->set_title.link);
339 wl_list_remove(&xwayland_view->set_class.link); 342 wl_list_remove(&xwayland_view->set_class.link);
340 wl_list_remove(&xwayland_view->set_window_type.link); 343 wl_list_remove(&xwayland_view->set_window_type.link);
@@ -461,6 +464,19 @@ static void handle_request_resize(struct wl_listener *listener, void *data) {
461 seat_begin_resize_floating(seat, view->swayc, seat->last_button, e->edges); 464 seat_begin_resize_floating(seat, view->swayc, seat->last_button, e->edges);
462} 465}
463 466
467static void handle_request_activate(struct wl_listener *listener, void *data) {
468 struct sway_xwayland_view *xwayland_view =
469 wl_container_of(listener, xwayland_view, request_activate);
470 struct sway_view *view = &xwayland_view->view;
471 struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface;
472 if (!xsurface->mapped) {
473 return;
474 }
475 view_request_activate(view);
476
477 transaction_commit_dirty();
478}
479
464static void handle_set_title(struct wl_listener *listener, void *data) { 480static void handle_set_title(struct wl_listener *listener, void *data) {
465 struct sway_xwayland_view *xwayland_view = 481 struct sway_xwayland_view *xwayland_view =
466 wl_container_of(listener, xwayland_view, set_title); 482 wl_container_of(listener, xwayland_view, set_title);
@@ -553,6 +569,10 @@ void handle_xwayland_surface(struct wl_listener *listener, void *data) {
553 &xwayland_view->request_fullscreen); 569 &xwayland_view->request_fullscreen);
554 xwayland_view->request_fullscreen.notify = handle_request_fullscreen; 570 xwayland_view->request_fullscreen.notify = handle_request_fullscreen;
555 571
572 wl_signal_add(&xsurface->events.request_activate,
573 &xwayland_view->request_activate);
574 xwayland_view->request_activate.notify = handle_request_activate;
575
556 wl_signal_add(&xsurface->events.request_move, 576 wl_signal_add(&xsurface->events.request_move,
557 &xwayland_view->request_move); 577 &xwayland_view->request_move);
558 xwayland_view->request_move.notify = handle_request_move; 578 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,
635 635
636 // find new output's old workspace, which might have to be removed if empty 636 // find new output's old workspace, which might have to be removed if empty
637 struct sway_container *new_output_last_ws = NULL; 637 struct sway_container *new_output_last_ws = NULL;
638 if (last_output != new_output) { 638 if (new_output && last_output != new_output) {
639 new_output_last_ws = seat_get_active_child(seat, new_output); 639 new_output_last_ws = seat_get_active_child(seat, new_output);
640 } 640 }
641 641
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(
46 'commands/floating_modifier.c', 46 'commands/floating_modifier.c',
47 'commands/focus.c', 47 'commands/focus.c',
48 'commands/focus_follows_mouse.c', 48 'commands/focus_follows_mouse.c',
49 'commands/focus_on_window_activation.c',
49 'commands/focus_wrapping.c', 50 'commands/focus_wrapping.c',
50 'commands/font.c', 51 'commands/font.c',
51 'commands/for_window.c', 52 '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 @@
12#include <wlr/types/wlr_gamma_control_v1.h> 12#include <wlr/types/wlr_gamma_control_v1.h>
13#include <wlr/types/wlr_idle.h> 13#include <wlr/types/wlr_idle.h>
14#include <wlr/types/wlr_layer_shell.h> 14#include <wlr/types/wlr_layer_shell.h>
15#include <wlr/types/wlr_linux_dmabuf_v1.h>
16#include <wlr/types/wlr_primary_selection.h> 15#include <wlr/types/wlr_primary_selection.h>
17#include <wlr/types/wlr_screencopy_v1.h> 16#include <wlr/types/wlr_screencopy_v1.h>
18#include <wlr/types/wlr_server_decoration.h> 17#include <wlr/types/wlr_server_decoration.h>
@@ -117,7 +116,6 @@ bool server_init(struct sway_server *server) {
117 server->server_decoration.notify = handle_server_decoration; 116 server->server_decoration.notify = handle_server_decoration;
118 wl_list_init(&server->decorations); 117 wl_list_init(&server->decorations);
119 118
120 wlr_linux_dmabuf_v1_create(server->wl_display, renderer);
121 wlr_export_dmabuf_manager_v1_create(server->wl_display); 119 wlr_export_dmabuf_manager_v1_create(server->wl_display);
122 wlr_screencopy_manager_v1_create(server->wl_display); 120 wlr_screencopy_manager_v1_create(server->wl_display);
123 121
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) {
280 } 280 }
281} 281}
282 282
283void view_request_activate(struct sway_view *view) {
284 struct sway_container *ws = container_parent(view->swayc, C_WORKSPACE);
285 struct sway_seat *seat = input_manager_current_seat(input_manager);
286
287 switch (config->focus_on_window_activation) {
288 case FOWA_SMART:
289 if (workspace_is_visible(ws)) {
290 seat_set_focus(seat, view->swayc);
291 } else {
292 view_set_urgent(view, true);
293 }
294 break;
295 case FOWA_URGENT:
296 view_set_urgent(view, true);
297 break;
298 case FOWA_FOCUS:
299 seat_set_focus(seat, view->swayc);
300 break;
301 case FOWA_NONE:
302 break;
303 }
304}
305
283void view_set_tiled(struct sway_view *view, bool tiled) { 306void view_set_tiled(struct sway_view *view, bool tiled) {
284 if (!tiled) { 307 if (!tiled) {
285 view->using_csd = true; 308 view->using_csd = true;