aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/view.h2
-rw-r--r--sway/desktop/xdg_shell_v6.c1
-rw-r--r--sway/tree/view.c42
3 files changed, 45 insertions, 0 deletions
diff --git a/include/sway/view.h b/include/sway/view.h
index ac33e11a..b2886211 100644
--- a/include/sway/view.h
+++ b/include/sway/view.h
@@ -115,4 +115,6 @@ void view_set_activated(struct sway_view *view, bool activated);
115 115
116void view_close(struct sway_view *view); 116void view_close(struct sway_view *view);
117 117
118void view_update_outputs(struct sway_view *view, const struct wlr_box *before);
119
118#endif 120#endif
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c
index b44d9e54..7371b829 100644
--- a/sway/desktop/xdg_shell_v6.c
+++ b/sway/desktop/xdg_shell_v6.c
@@ -72,6 +72,7 @@ static void handle_commit(struct wl_listener *listener, void *data) {
72 wl_container_of(listener, sway_surface, commit); 72 wl_container_of(listener, sway_surface, commit);
73 struct sway_view *view = sway_surface->view; 73 struct sway_view *view = sway_surface->view;
74 // NOTE: We intentionally discard the view's desired width here 74 // NOTE: We intentionally discard the view's desired width here
75 // TODO: Store this for restoration when moving to floating plane
75 // TODO: Let floating views do whatever 76 // TODO: Let floating views do whatever
76 view->width = sway_surface->pending_width; 77 view->width = sway_surface->pending_width;
77 view->height = sway_surface->pending_height; 78 view->height = sway_surface->pending_height;
diff --git a/sway/tree/view.c b/sway/tree/view.c
index b46c3b17..9499adca 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -1,3 +1,7 @@
1#include <wayland-server.h>
2#include <wlr/types/wlr_output_layout.h>
3#include "sway/container.h"
4#include "sway/layout.h"
1#include "sway/view.h" 5#include "sway/view.h"
2 6
3const char *view_get_title(struct sway_view *view) { 7const char *view_get_title(struct sway_view *view) {
@@ -30,13 +34,27 @@ const char *view_get_instance(struct sway_view *view) {
30 34
31void view_set_size(struct sway_view *view, int width, int height) { 35void view_set_size(struct sway_view *view, int width, int height) {
32 if (view->iface.set_size) { 36 if (view->iface.set_size) {
37 struct wlr_box box = {
38 .x = view->swayc->x,
39 .y = view->swayc->y,
40 .width = view->width,
41 .height = view->height,
42 };
33 view->iface.set_size(view, width, height); 43 view->iface.set_size(view, width, height);
44 view_update_outputs(view, &box);
34 } 45 }
35} 46}
36 47
37void view_set_position(struct sway_view *view, double ox, double oy) { 48void view_set_position(struct sway_view *view, double ox, double oy) {
38 if (view->iface.set_position) { 49 if (view->iface.set_position) {
50 struct wlr_box box = {
51 .x = view->swayc->x,
52 .y = view->swayc->y,
53 .width = view->width,
54 .height = view->height,
55 };
39 view->iface.set_position(view, ox, oy); 56 view->iface.set_position(view, ox, oy);
57 view_update_outputs(view, &box);
40 } 58 }
41} 59}
42 60
@@ -51,3 +69,27 @@ void view_close(struct sway_view *view) {
51 view->iface.close(view); 69 view->iface.close(view);
52 } 70 }
53} 71}
72
73void view_update_outputs(struct sway_view *view, const struct wlr_box *before) {
74 struct wlr_output_layout *output_layout =
75 root_container.sway_root->output_layout;
76 struct wlr_box box = {
77 .x = view->swayc->x,
78 .y = view->swayc->y,
79 .width = view->width,
80 .height = view->height,
81 };
82 struct wlr_output_layout_output *layout_output;
83 wl_list_for_each(layout_output, &output_layout->outputs, link) {
84 bool intersected = before != NULL && wlr_output_layout_intersects(
85 output_layout, layout_output->output, before);
86 bool intersects = wlr_output_layout_intersects(output_layout,
87 layout_output->output, &box);
88 if (intersected && !intersects) {
89 wlr_surface_send_leave(view->surface, layout_output->output);
90 }
91 if (!intersected && intersects) {
92 wlr_surface_send_enter(view->surface, layout_output->output);
93 }
94 }
95}