summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Ryan Dwyer <RyanDwyer@users.noreply.github.com>2018-08-02 23:05:49 +1000
committerLibravatar GitHub <noreply@github.com>2018-08-02 23:05:49 +1000
commit706c0fbe2376e15f8140be60f3c8b0713128ebba (patch)
treeffefcdd261970549f8b83adae8d93b6c3b9ebbbb
parentswaynag: don't drop \n for first line (diff)
parentMerge pull request #2404 from RyanDwyer/move-containers-when-workspace-focused (diff)
downloadsway-706c0fbe2376e15f8140be60f3c8b0713128ebba.tar.gz
sway-706c0fbe2376e15f8140be60f3c8b0713128ebba.tar.zst
sway-706c0fbe2376e15f8140be60f3c8b0713128ebba.zip
Merge branch 'master' into nagbar
-rw-r--r--include/sway/desktop/transaction.h13
-rw-r--r--include/sway/tree/view.h7
-rw-r--r--meson.build2
-rw-r--r--sway/commands/exec_always.c4
-rw-r--r--sway/commands/move.c3
-rw-r--r--sway/config/bar.c4
-rw-r--r--sway/desktop/render.c16
-rw-r--r--sway/desktop/transaction.c58
-rw-r--r--sway/input/seat.c8
-rw-r--r--sway/meson.build10
-rw-r--r--sway/tree/view.c25
11 files changed, 77 insertions, 73 deletions
diff --git a/include/sway/desktop/transaction.h b/include/sway/desktop/transaction.h
index cee4afed..56361d94 100644
--- a/include/sway/desktop/transaction.h
+++ b/include/sway/desktop/transaction.h
@@ -42,17 +42,4 @@ void transaction_notify_view_ready(struct sway_view *view, uint32_t serial);
42void transaction_notify_view_ready_by_size(struct sway_view *view, 42void transaction_notify_view_ready_by_size(struct sway_view *view,
43 int width, int height); 43 int width, int height);
44 44
45/**
46 * Get the saved texture that should be rendered for a view.
47 *
48 * The addresses pointed at by the width and height pointers will be populated
49 * with the surface's dimensions, which may be different to the texture's
50 * dimensions if output scaling is used.
51 *
52 * This function should only be called if it is known that the view has
53 * instructions.
54 */
55struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
56 int *width, int *height);
57
58#endif 45#endif
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index 620c41e0..37fd02bc 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -85,6 +85,9 @@ struct sway_view {
85 bool allow_request_urgent; 85 bool allow_request_urgent;
86 struct wl_event_source *urgent_timer; 86 struct wl_event_source *urgent_timer;
87 87
88 struct wlr_buffer *saved_buffer;
89 int saved_buffer_width, saved_buffer_height;
90
88 bool destroying; 91 bool destroying;
89 92
90 list_t *executed_criteria; // struct criteria * 93 list_t *executed_criteria; // struct criteria *
@@ -339,4 +342,8 @@ void view_set_urgent(struct sway_view *view, bool enable);
339 342
340bool view_is_urgent(struct sway_view *view); 343bool view_is_urgent(struct sway_view *view);
341 344
345void view_remove_saved_buffer(struct sway_view *view);
346
347void view_save_buffer(struct sway_view *view);
348
342#endif 349#endif
diff --git a/meson.build b/meson.build
index 57ed70cb..2a020323 100644
--- a/meson.build
+++ b/meson.build
@@ -44,13 +44,13 @@ systemd = dependency('libsystemd', required: false)
44elogind = dependency('libelogind', required: false) 44elogind = dependency('libelogind', required: false)
45math = cc.find_library('m') 45math = cc.find_library('m')
46rt = cc.find_library('rt') 46rt = cc.find_library('rt')
47xcb = dependency('xcb')
48git = find_program('git', required: false) 47git = find_program('git', required: false)
49 48
50conf_data = configuration_data() 49conf_data = configuration_data()
51 50
52if get_option('enable-xwayland') 51if get_option('enable-xwayland')
53 conf_data.set('HAVE_XWAYLAND', true) 52 conf_data.set('HAVE_XWAYLAND', true)
53 xcb = dependency('xcb')
54else 54else
55 conf_data.set('HAVE_XWAYLAND', false) 55 conf_data.set('HAVE_XWAYLAND', false)
56endif 56endif
diff --git a/sway/commands/exec_always.c b/sway/commands/exec_always.c
index 9bf2b320..c730cb8b 100644
--- a/sway/commands/exec_always.c
+++ b/sway/commands/exec_always.c
@@ -4,6 +4,7 @@
4#include <string.h> 4#include <string.h>
5#include <sys/wait.h> 5#include <sys/wait.h>
6#include <unistd.h> 6#include <unistd.h>
7#include <signal.h>
7#include "sway/commands.h" 8#include "sway/commands.h"
8#include "sway/config.h" 9#include "sway/config.h"
9#include "sway/tree/container.h" 10#include "sway/tree/container.h"
@@ -47,6 +48,9 @@ struct cmd_results *cmd_exec_always(int argc, char **argv) {
47 if ((pid = fork()) == 0) { 48 if ((pid = fork()) == 0) {
48 // Fork child process again 49 // Fork child process again
49 setsid(); 50 setsid();
51 sigset_t set;
52 sigemptyset(&set);
53 sigprocmask(SIG_SETMASK, &set, NULL);
50 close(fd[0]); 54 close(fd[0]);
51 if ((child = fork()) == 0) { 55 if ((child = fork()) == 0) {
52 close(fd[1]); 56 close(fd[1]);
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 46ebcd83..702b42d9 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -59,8 +59,7 @@ static struct cmd_results *cmd_move_container(struct sway_container *current,
59 && strcasecmp(argv[2], "workspace") == 0) { 59 && strcasecmp(argv[2], "workspace") == 0) {
60 // move container to workspace x 60 // move container to workspace x
61 if (current->type == C_WORKSPACE) { 61 if (current->type == C_WORKSPACE) {
62 // TODO: Wrap children in a container and move that 62 current = container_wrap_children(current);
63 return cmd_results_new(CMD_FAILURE, "move", "Unimplemented");
64 } else if (current->type != C_CONTAINER && current->type != C_VIEW) { 63 } else if (current->type != C_CONTAINER && current->type != C_VIEW) {
65 return cmd_results_new(CMD_FAILURE, "move", 64 return cmd_results_new(CMD_FAILURE, "move",
66 "Can only move containers and views."); 65 "Can only move containers and views.");
diff --git a/sway/config/bar.c b/sway/config/bar.c
index 3a74331e..ae9383d6 100644
--- a/sway/config/bar.c
+++ b/sway/config/bar.c
@@ -10,6 +10,7 @@
10#include <sys/stat.h> 10#include <sys/stat.h>
11#include <signal.h> 11#include <signal.h>
12#include <strings.h> 12#include <strings.h>
13#include <signal.h>
13#include "sway/config.h" 14#include "sway/config.h"
14#include "stringop.h" 15#include "stringop.h"
15#include "list.h" 16#include "list.h"
@@ -175,6 +176,9 @@ void invoke_swaybar(struct bar_config *bar) {
175 if (bar->pid == 0) { 176 if (bar->pid == 0) {
176 setpgid(0, 0); 177 setpgid(0, 0);
177 close(filedes[0]); 178 close(filedes[0]);
179 sigset_t set;
180 sigemptyset(&set);
181 sigprocmask(SIG_SETMASK, &set, NULL);
178 182
179 // run custom swaybar 183 // run custom swaybar
180 size_t len = snprintf(NULL, 0, "%s -b %s", 184 size_t len = snprintf(NULL, 0, "%s -b %s",
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index ea4361f2..1f374740 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -222,17 +222,14 @@ static void render_saved_view(struct sway_view *view,
222 struct sway_output *output, pixman_region32_t *damage, float alpha) { 222 struct sway_output *output, pixman_region32_t *damage, float alpha) {
223 struct wlr_output *wlr_output = output->wlr_output; 223 struct wlr_output *wlr_output = output->wlr_output;
224 224
225 int width, height; 225 if (!view->saved_buffer || !view->saved_buffer->texture) {
226 struct wlr_texture *texture =
227 transaction_get_saved_texture(view, &width, &height);
228 if (!texture) {
229 return; 226 return;
230 } 227 }
231 struct wlr_box box = { 228 struct wlr_box box = {
232 .x = view->swayc->current.view_x - output->swayc->current.swayc_x, 229 .x = view->swayc->current.view_x - output->swayc->current.swayc_x,
233 .y = view->swayc->current.view_y - output->swayc->current.swayc_y, 230 .y = view->swayc->current.view_y - output->swayc->current.swayc_y,
234 .width = width, 231 .width = view->saved_buffer_width,
235 .height = height, 232 .height = view->saved_buffer_height,
236 }; 233 };
237 234
238 struct wlr_box output_box = { 235 struct wlr_box output_box = {
@@ -252,7 +249,8 @@ static void render_saved_view(struct sway_view *view,
252 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0, 249 wlr_matrix_project_box(matrix, &box, WL_OUTPUT_TRANSFORM_NORMAL, 0,
253 wlr_output->transform_matrix); 250 wlr_output->transform_matrix);
254 251
255 render_texture(wlr_output, damage, texture, &box, matrix, alpha); 252 render_texture(wlr_output, damage, view->saved_buffer->texture,
253 &box, matrix, alpha);
256} 254}
257 255
258/** 256/**
@@ -261,7 +259,7 @@ static void render_saved_view(struct sway_view *view,
261static void render_view(struct sway_output *output, pixman_region32_t *damage, 259static void render_view(struct sway_output *output, pixman_region32_t *damage,
262 struct sway_container *con, struct border_colors *colors) { 260 struct sway_container *con, struct border_colors *colors) {
263 struct sway_view *view = con->sway_view; 261 struct sway_view *view = con->sway_view;
264 if (view->swayc->instructions->length) { 262 if (view->saved_buffer) {
265 render_saved_view(view, output, damage, view->swayc->alpha); 263 render_saved_view(view, output, damage, view->swayc->alpha);
266 } else { 264 } else {
267 render_view_toplevels(view, output, damage, view->swayc->alpha); 265 render_view_toplevels(view, output, damage, view->swayc->alpha);
@@ -864,7 +862,7 @@ void output_render(struct sway_output *output, struct timespec *when,
864 862
865 // TODO: handle views smaller than the output 863 // TODO: handle views smaller than the output
866 if (fullscreen_con->type == C_VIEW) { 864 if (fullscreen_con->type == C_VIEW) {
867 if (fullscreen_con->instructions->length) { 865 if (fullscreen_con->sway_view->saved_buffer) {
868 render_saved_view(fullscreen_con->sway_view, 866 render_saved_view(fullscreen_con->sway_view,
869 output, damage, 1.0f); 867 output, damage, 1.0f);
870 } else { 868 } else {
diff --git a/sway/desktop/transaction.c b/sway/desktop/transaction.c
index 7975366e..4e6af86a 100644
--- a/sway/desktop/transaction.c
+++ b/sway/desktop/transaction.c
@@ -41,8 +41,6 @@ struct sway_transaction_instruction {
41 struct sway_transaction *transaction; 41 struct sway_transaction *transaction;
42 struct sway_container *container; 42 struct sway_container *container;
43 struct sway_container_state state; 43 struct sway_container_state state;
44 struct wlr_buffer *saved_buffer;
45 int saved_buffer_width, saved_buffer_height;
46 uint32_t serial; 44 uint32_t serial;
47 bool ready; 45 bool ready;
48}; 46};
@@ -57,27 +55,6 @@ static struct sway_transaction *transaction_create() {
57 return transaction; 55 return transaction;
58} 56}
59 57
60static void remove_saved_view_buffer(
61 struct sway_transaction_instruction *instruction) {
62 if (instruction->saved_buffer) {
63 wlr_buffer_unref(instruction->saved_buffer);
64 instruction->saved_buffer = NULL;
65 }
66}
67
68static void save_view_buffer(struct sway_view *view,
69 struct sway_transaction_instruction *instruction) {
70 if (!sway_assert(instruction->saved_buffer == NULL,
71 "Didn't expect instruction to have a saved buffer already")) {
72 remove_saved_view_buffer(instruction);
73 }
74 if (view->surface && wlr_surface_has_buffer(view->surface)) {
75 instruction->saved_buffer = wlr_buffer_ref(view->surface->buffer);
76 instruction->saved_buffer_width = view->surface->current.width;
77 instruction->saved_buffer_height = view->surface->current.height;
78 }
79}
80
81static void transaction_destroy(struct sway_transaction *transaction) { 58static void transaction_destroy(struct sway_transaction *transaction) {
82 // Free instructions 59 // Free instructions
83 for (int i = 0; i < transaction->instructions->length; ++i) { 60 for (int i = 0; i < transaction->instructions->length; ++i) {
@@ -93,7 +70,6 @@ static void transaction_destroy(struct sway_transaction *transaction) {
93 if (con->destroying && !con->instructions->length) { 70 if (con->destroying && !con->instructions->length) {
94 container_free(con); 71 container_free(con);
95 } 72 }
96 remove_saved_view_buffer(instruction);
97 free(instruction); 73 free(instruction);
98 } 74 }
99 list_free(transaction->instructions); 75 list_free(transaction->instructions);
@@ -158,9 +134,6 @@ static void transaction_add_container(struct sway_transaction *transaction,
158 134
159 copy_pending_state(container, &instruction->state); 135 copy_pending_state(container, &instruction->state);
160 136
161 if (container->type == C_VIEW) {
162 save_view_buffer(container->sway_view, instruction);
163 }
164 list_add(transaction->instructions, instruction); 137 list_add(transaction->instructions, instruction);
165} 138}
166 139
@@ -220,6 +193,22 @@ static void transaction_apply(struct sway_transaction *transaction) {
220 193
221 memcpy(&container->current, &instruction->state, 194 memcpy(&container->current, &instruction->state,
222 sizeof(struct sway_container_state)); 195 sizeof(struct sway_container_state));
196
197 if (container->type == C_VIEW) {
198 if (container->destroying) {
199 if (container->instructions->length == 1 &&
200 container->sway_view->saved_buffer) {
201 view_remove_saved_buffer(container->sway_view);
202 }
203 } else {
204 if (container->sway_view->saved_buffer) {
205 view_remove_saved_buffer(container->sway_view);
206 }
207 if (container->instructions->length > 1) {
208 view_save_buffer(container->sway_view);
209 }
210 }
211 }
223 } 212 }
224} 213}
225 214
@@ -295,6 +284,9 @@ static void transaction_commit(struct sway_transaction *transaction) {
295 struct timespec when; 284 struct timespec when;
296 wlr_surface_send_frame_done(con->sway_view->surface, &when); 285 wlr_surface_send_frame_done(con->sway_view->surface, &when);
297 } 286 }
287 if (con->type == C_VIEW && !con->sway_view->saved_buffer) {
288 view_save_buffer(con->sway_view);
289 }
298 list_add(con->instructions, instruction); 290 list_add(con->instructions, instruction);
299 } 291 }
300 transaction->num_configures = transaction->num_waiting; 292 transaction->num_configures = transaction->num_waiting;
@@ -400,18 +392,6 @@ void transaction_notify_view_ready_by_size(struct sway_view *view,
400 } 392 }
401} 393}
402 394
403struct wlr_texture *transaction_get_saved_texture(struct sway_view *view,
404 int *width, int *height) {
405 struct sway_transaction_instruction *instruction =
406 view->swayc->instructions->items[0];
407 if (!instruction->saved_buffer) {
408 return NULL;
409 }
410 *width = instruction->saved_buffer_width;
411 *height = instruction->saved_buffer_height;
412 return instruction->saved_buffer->texture;
413}
414
415void transaction_commit_dirty(void) { 395void transaction_commit_dirty(void) {
416 if (!server.dirty_containers->length) { 396 if (!server.dirty_containers->length) {
417 return; 397 return;
diff --git a/sway/input/seat.c b/sway/input/seat.c
index 869560af..dd4d5c3b 100644
--- a/sway/input/seat.c
+++ b/sway/input/seat.c
@@ -775,8 +775,12 @@ void seat_set_focus_warp(struct sway_seat *seat,
775 } 775 }
776 } 776 }
777 777
778 if (container->type == C_VIEW) { 778 if (container) {
779 ipc_event_window(container, "focus"); 779 if (container->type == C_VIEW) {
780 ipc_event_window(container, "focus");
781 } else if (container->type == C_WORKSPACE) {
782 ipc_event_workspace(NULL, container, "focus");
783 }
780 } 784 }
781 785
782 seat->has_focus = (container != NULL); 786 seat->has_focus = (container != NULL);
diff --git a/sway/meson.build b/sway/meson.build
index d92bb905..a9503c3b 100644
--- a/sway/meson.build
+++ b/sway/meson.build
@@ -153,10 +153,6 @@ sway_sources = files(
153 'tree/output.c', 153 'tree/output.c',
154) 154)
155 155
156if get_option('enable-xwayland')
157 sway_sources += 'desktop/xwayland.c'
158endif
159
160sway_deps = [ 156sway_deps = [
161 cairo, 157 cairo,
162 gdk_pixbuf, 158 gdk_pixbuf,
@@ -170,10 +166,14 @@ sway_deps = [
170 server_protos, 166 server_protos,
171 wayland_server, 167 wayland_server,
172 wlroots, 168 wlroots,
173 xcb,
174 xkbcommon, 169 xkbcommon,
175] 170]
176 171
172if get_option('enable-xwayland')
173 sway_sources += 'desktop/xwayland.c'
174 sway_deps += xcb
175endif
176
177executable( 177executable(
178 'sway', 178 'sway',
179 sway_sources, 179 sway_sources,
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 02a33c10..97318daa 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -2,6 +2,7 @@
2#include <stdlib.h> 2#include <stdlib.h>
3#include <wayland-server.h> 3#include <wayland-server.h>
4#include <wlr/render/wlr_renderer.h> 4#include <wlr/render/wlr_renderer.h>
5#include <wlr/types/wlr_buffer.h>
5#include <wlr/types/wlr_output_layout.h> 6#include <wlr/types/wlr_output_layout.h>
6#include "config.h" 7#include "config.h"
7#ifdef HAVE_XWAYLAND 8#ifdef HAVE_XWAYLAND
@@ -495,7 +496,7 @@ static struct sway_container *select_workspace(struct sway_view *view) {
495 } 496 }
496 497
497 // Use the focused workspace 498 // Use the focused workspace
498 ws = seat_get_focus(seat); 499 ws = seat_get_focus_inactive(seat, &root_container);
499 if (ws->type != C_WORKSPACE) { 500 if (ws->type != C_WORKSPACE) {
500 ws = container_parent(ws, C_WORKSPACE); 501 ws = container_parent(ws, C_WORKSPACE);
501 } 502 }
@@ -504,7 +505,8 @@ static struct sway_container *select_workspace(struct sway_view *view) {
504 505
505static bool should_focus(struct sway_view *view) { 506static bool should_focus(struct sway_view *view) {
506 struct sway_seat *seat = input_manager_current_seat(input_manager); 507 struct sway_seat *seat = input_manager_current_seat(input_manager);
507 struct sway_container *prev_focus = seat_get_focus(seat); 508 struct sway_container *prev_focus =
509 seat_get_focus_inactive(seat, &root_container);
508 struct sway_container *prev_ws = prev_focus->type == C_WORKSPACE ? 510 struct sway_container *prev_ws = prev_focus->type == C_WORKSPACE ?
509 prev_focus : container_parent(prev_focus, C_WORKSPACE); 511 prev_focus : container_parent(prev_focus, C_WORKSPACE);
510 struct sway_container *map_ws = container_parent(view->swayc, C_WORKSPACE); 512 struct sway_container *map_ws = container_parent(view->swayc, C_WORKSPACE);
@@ -1093,3 +1095,22 @@ void view_set_urgent(struct sway_view *view, bool enable) {
1093bool view_is_urgent(struct sway_view *view) { 1095bool view_is_urgent(struct sway_view *view) {
1094 return view->urgent.tv_sec || view->urgent.tv_nsec; 1096 return view->urgent.tv_sec || view->urgent.tv_nsec;
1095} 1097}
1098
1099void view_remove_saved_buffer(struct sway_view *view) {
1100 if (!sway_assert(view->saved_buffer, "Expected a saved buffer")) {
1101 return;
1102 }
1103 wlr_buffer_unref(view->saved_buffer);
1104 view->saved_buffer = NULL;
1105}
1106
1107void view_save_buffer(struct sway_view *view) {
1108 if (!sway_assert(!view->saved_buffer, "Didn't expect saved buffer")) {
1109 view_remove_saved_buffer(view);
1110 }
1111 if (view->surface && wlr_surface_has_buffer(view->surface)) {
1112 view->saved_buffer = wlr_buffer_ref(view->surface->buffer);
1113 view->saved_buffer_width = view->surface->current.width;
1114 view->saved_buffer_height = view->surface->current.height;
1115 }
1116}