summaryrefslogtreecommitdiffstats
path: root/sway/tree/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r--sway/tree/view.c25
1 files changed, 23 insertions, 2 deletions
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}