diff options
-rw-r--r-- | include/sway/tree/view.h | 21 | ||||
-rw-r--r-- | sway/desktop/wl_shell.c | 23 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 24 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 31 | ||||
-rw-r--r-- | sway/tree/layout.c | 8 | ||||
-rw-r--r-- | sway/tree/output.c | 1 | ||||
-rw-r--r-- | sway/tree/view.c | 137 |
7 files changed, 124 insertions, 121 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h index c68739d6..4e753b2a 100644 --- a/include/sway/tree/view.h +++ b/include/sway/tree/view.h | |||
@@ -69,10 +69,8 @@ enum sway_view_prop { | |||
69 | struct sway_view_impl { | 69 | struct sway_view_impl { |
70 | const char *(*get_prop)(struct sway_view *view, | 70 | const char *(*get_prop)(struct sway_view *view, |
71 | enum sway_view_prop prop); | 71 | enum sway_view_prop prop); |
72 | void (*set_size)(struct sway_view *view, | 72 | void (*configure)(struct sway_view *view, double ox, double oy, int width, |
73 | int width, int height); | 73 | int height); |
74 | void (*set_position)(struct sway_view *view, | ||
75 | double ox, double oy); | ||
76 | void (*set_activated)(struct sway_view *view, bool activated); | 74 | void (*set_activated)(struct sway_view *view, bool activated); |
77 | void (*close)(struct sway_view *view); | 75 | void (*close)(struct sway_view *view); |
78 | }; | 76 | }; |
@@ -114,14 +112,19 @@ const char *view_get_class(struct sway_view *view); | |||
114 | 112 | ||
115 | const char *view_get_instance(struct sway_view *view); | 113 | const char *view_get_instance(struct sway_view *view); |
116 | 114 | ||
117 | void view_set_size(struct sway_view *view, int width, int height); | 115 | void view_configure(struct sway_view *view, double ox, double oy, int width, |
118 | 116 | int height); | |
119 | void view_set_position(struct sway_view *view, double ox, double oy); | ||
120 | 117 | ||
121 | void view_set_activated(struct sway_view *view, bool activated); | 118 | void view_set_activated(struct sway_view *view, bool activated); |
122 | 119 | ||
123 | void view_close(struct sway_view *view); | 120 | void view_close(struct sway_view *view); |
124 | 121 | ||
122 | void view_damage_whole(struct sway_view *view); | ||
123 | |||
124 | void view_damage_from(struct sway_view *view); | ||
125 | |||
126 | // view implementation | ||
127 | |||
125 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); | 128 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface); |
126 | 129 | ||
127 | void view_map_unmanaged(struct sway_view *view, | 130 | void view_map_unmanaged(struct sway_view *view, |
@@ -129,8 +132,8 @@ void view_map_unmanaged(struct sway_view *view, | |||
129 | 132 | ||
130 | void view_unmap(struct sway_view *view); | 133 | void view_unmap(struct sway_view *view); |
131 | 134 | ||
132 | void view_damage_whole(struct sway_view *view); | 135 | void view_update_position(struct sway_view *view, double ox, double oy); |
133 | 136 | ||
134 | void view_damage_from(struct sway_view *view); | 137 | void view_update_size(struct sway_view *view, int width, int height); |
135 | 138 | ||
136 | #endif | 139 | #endif |
diff --git a/sway/desktop/wl_shell.c b/sway/desktop/wl_shell.c index e0909a03..6528a397 100644 --- a/sway/desktop/wl_shell.c +++ b/sway/desktop/wl_shell.c | |||
@@ -30,24 +30,18 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | static void set_size(struct sway_view *view, int width, int height) { | 33 | static void configure(struct sway_view *view, double ox, double oy, int width, |
34 | int height) { | ||
34 | if (!assert_wl_shell(view)) { | 35 | if (!assert_wl_shell(view)) { |
35 | return; | 36 | return; |
36 | } | 37 | } |
38 | view_update_position(view, ox, oy); | ||
37 | view->sway_wl_shell_surface->pending_width = width; | 39 | view->sway_wl_shell_surface->pending_width = width; |
38 | view->sway_wl_shell_surface->pending_height = height; | 40 | view->sway_wl_shell_surface->pending_height = height; |
39 | wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); | 41 | wlr_wl_shell_surface_configure(view->wlr_wl_shell_surface, 0, width, height); |
40 | } | 42 | } |
41 | 43 | ||
42 | static void set_position(struct sway_view *view, double ox, double oy) { | 44 | static void _close(struct sway_view *view) { |
43 | if (!assert_wl_shell(view)) { | ||
44 | return; | ||
45 | } | ||
46 | view->swayc->x = ox; | ||
47 | view->swayc->y = oy; | ||
48 | } | ||
49 | |||
50 | static void close(struct sway_view *view) { | ||
51 | if (!assert_wl_shell(view)) { | 45 | if (!assert_wl_shell(view)) { |
52 | return; | 46 | return; |
53 | } | 47 | } |
@@ -57,9 +51,8 @@ static void close(struct sway_view *view) { | |||
57 | 51 | ||
58 | static const struct sway_view_impl view_impl = { | 52 | static const struct sway_view_impl view_impl = { |
59 | .get_prop = get_prop, | 53 | .get_prop = get_prop, |
60 | .set_size = set_size, | 54 | .configure = configure, |
61 | .set_position = set_position, | 55 | .close = _close, |
62 | .close = close, | ||
63 | }; | 56 | }; |
64 | 57 | ||
65 | static void handle_commit(struct wl_listener *listener, void *data) { | 58 | static void handle_commit(struct wl_listener *listener, void *data) { |
@@ -68,8 +61,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
68 | struct sway_view *view = sway_surface->view; | 61 | struct sway_view *view = sway_surface->view; |
69 | // NOTE: We intentionally discard the view's desired width here | 62 | // NOTE: We intentionally discard the view's desired width here |
70 | // TODO: Let floating views do whatever | 63 | // TODO: Let floating views do whatever |
71 | view->width = sway_surface->pending_width; | 64 | view_update_size(view, sway_surface->pending_width, |
72 | view->height = sway_surface->pending_height; | 65 | sway_surface->pending_height); |
73 | view_damage_from(view); | 66 | view_damage_from(view); |
74 | } | 67 | } |
75 | 68 | ||
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index c1adc7fe..49305b39 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -30,23 +30,18 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
30 | } | 30 | } |
31 | } | 31 | } |
32 | 32 | ||
33 | static void set_size(struct sway_view *view, int width, int height) { | 33 | static void configure(struct sway_view *view, double ox, double oy, int width, |
34 | int height) { | ||
34 | if (!assert_xdg(view)) { | 35 | if (!assert_xdg(view)) { |
35 | return; | 36 | return; |
36 | } | 37 | } |
38 | |||
39 | view_update_position(view, ox, oy); | ||
37 | view->sway_xdg_surface_v6->pending_width = width; | 40 | view->sway_xdg_surface_v6->pending_width = width; |
38 | view->sway_xdg_surface_v6->pending_height = height; | 41 | view->sway_xdg_surface_v6->pending_height = height; |
39 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | 42 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); |
40 | } | 43 | } |
41 | 44 | ||
42 | static void set_position(struct sway_view *view, double ox, double oy) { | ||
43 | if (!assert_xdg(view)) { | ||
44 | return; | ||
45 | } | ||
46 | view->swayc->x = ox; | ||
47 | view->swayc->y = oy; | ||
48 | } | ||
49 | |||
50 | static void set_activated(struct sway_view *view, bool activated) { | 45 | static void set_activated(struct sway_view *view, bool activated) { |
51 | if (!assert_xdg(view)) { | 46 | if (!assert_xdg(view)) { |
52 | return; | 47 | return; |
@@ -57,7 +52,7 @@ static void set_activated(struct sway_view *view, bool activated) { | |||
57 | } | 52 | } |
58 | } | 53 | } |
59 | 54 | ||
60 | static void close(struct sway_view *view) { | 55 | static void _close(struct sway_view *view) { |
61 | if (!assert_xdg(view)) { | 56 | if (!assert_xdg(view)) { |
62 | return; | 57 | return; |
63 | } | 58 | } |
@@ -69,10 +64,9 @@ static void close(struct sway_view *view) { | |||
69 | 64 | ||
70 | static const struct sway_view_impl view_impl = { | 65 | static const struct sway_view_impl view_impl = { |
71 | .get_prop = get_prop, | 66 | .get_prop = get_prop, |
72 | .set_size = set_size, | 67 | .configure = configure, |
73 | .set_position = set_position, | ||
74 | .set_activated = set_activated, | 68 | .set_activated = set_activated, |
75 | .close = close, | 69 | .close = _close, |
76 | }; | 70 | }; |
77 | 71 | ||
78 | static void handle_commit(struct wl_listener *listener, void *data) { | 72 | static void handle_commit(struct wl_listener *listener, void *data) { |
@@ -82,8 +76,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
82 | // NOTE: We intentionally discard the view's desired width here | 76 | // NOTE: We intentionally discard the view's desired width here |
83 | // TODO: Store this for restoration when moving to floating plane | 77 | // TODO: Store this for restoration when moving to floating plane |
84 | // TODO: Let floating views do whatever | 78 | // TODO: Let floating views do whatever |
85 | view->width = sway_surface->pending_width; | 79 | view_update_size(view, sway_surface->pending_width, |
86 | view->height = sway_surface->pending_height; | 80 | sway_surface->pending_height); |
87 | view_damage_from(view); | 81 | view_damage_from(view); |
88 | } | 82 | } |
89 | 83 | ||
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c index 93c78228..39076fab 100644 --- a/sway/desktop/xwayland.c +++ b/sway/desktop/xwayland.c | |||
@@ -33,22 +33,13 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
33 | } | 33 | } |
34 | } | 34 | } |
35 | 35 | ||
36 | static void set_size(struct sway_view *view, int width, int height) { | 36 | static void configure(struct sway_view *view, double ox, double oy, int width, |
37 | int height) { | ||
37 | if (!assert_xwayland(view)) { | 38 | if (!assert_xwayland(view)) { |
38 | return; | 39 | return; |
39 | } | 40 | } |
40 | view->sway_xwayland_surface->pending_width = width; | ||
41 | view->sway_xwayland_surface->pending_height = height; | ||
42 | |||
43 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; | 41 | struct wlr_xwayland_surface *xsurface = view->wlr_xwayland_surface; |
44 | wlr_xwayland_surface_configure(xsurface, xsurface->x, xsurface->y, | ||
45 | width, height); | ||
46 | } | ||
47 | 42 | ||
48 | static void set_position(struct sway_view *view, double ox, double oy) { | ||
49 | if (!assert_xwayland(view)) { | ||
50 | return; | ||
51 | } | ||
52 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 43 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); |
53 | if (!sway_assert(output, "view must be within tree to set position")) { | 44 | if (!sway_assert(output, "view must be within tree to set position")) { |
54 | return; | 45 | return; |
@@ -64,13 +55,12 @@ static void set_position(struct sway_view *view, double ox, double oy) { | |||
64 | return; | 55 | return; |
65 | } | 56 | } |
66 | 57 | ||
67 | view->swayc->x = ox; | 58 | view_update_position(view, ox, oy); |
68 | view->swayc->y = oy; | ||
69 | 59 | ||
70 | wlr_xwayland_surface_configure(view->wlr_xwayland_surface, | 60 | view->sway_xwayland_surface->pending_width = width; |
71 | ox + loutput->x, oy + loutput->y, | 61 | view->sway_xwayland_surface->pending_height = height; |
72 | view->wlr_xwayland_surface->width, | 62 | wlr_xwayland_surface_configure(xsurface, ox + loutput->x, oy + loutput->y, |
73 | view->wlr_xwayland_surface->height); | 63 | width, height); |
74 | } | 64 | } |
75 | 65 | ||
76 | static void set_activated(struct sway_view *view, bool activated) { | 66 | static void set_activated(struct sway_view *view, bool activated) { |
@@ -90,8 +80,7 @@ static void _close(struct sway_view *view) { | |||
90 | 80 | ||
91 | static const struct sway_view_impl view_impl = { | 81 | static const struct sway_view_impl view_impl = { |
92 | .get_prop = get_prop, | 82 | .get_prop = get_prop, |
93 | .set_size = set_size, | 83 | .configure = configure, |
94 | .set_position = set_position, | ||
95 | .set_activated = set_activated, | 84 | .set_activated = set_activated, |
96 | .close = _close, | 85 | .close = _close, |
97 | }; | 86 | }; |
@@ -102,8 +91,8 @@ static void handle_commit(struct wl_listener *listener, void *data) { | |||
102 | struct sway_view *view = sway_surface->view; | 91 | struct sway_view *view = sway_surface->view; |
103 | // NOTE: We intentionally discard the view's desired width here | 92 | // NOTE: We intentionally discard the view's desired width here |
104 | // TODO: Let floating views do whatever | 93 | // TODO: Let floating views do whatever |
105 | view->width = sway_surface->pending_width; | 94 | view_update_size(view, sway_surface->pending_width, |
106 | view->height = sway_surface->pending_height; | 95 | sway_surface->pending_height); |
107 | view_damage_from(view); | 96 | view_damage_from(view); |
108 | } | 97 | } |
109 | 98 | ||
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index ce0682dc..3fec02a1 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -261,7 +261,7 @@ void arrange_windows(struct sway_container *container, | |||
261 | { | 261 | { |
262 | container->width = width; | 262 | container->width = width; |
263 | container->height = height; | 263 | container->height = height; |
264 | view_set_size(container->sway_view, | 264 | view_configure(container->sway_view, container->x, container->y, |
265 | container->width, container->height); | 265 | container->width, container->height); |
266 | wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", | 266 | wlr_log(L_DEBUG, "Set view to %.f x %.f @ %.f, %.f", |
267 | container->width, container->height, | 267 | container->width, container->height, |
@@ -322,7 +322,8 @@ static void apply_horiz_layout(struct sway_container *container, | |||
322 | wlr_log(L_DEBUG, | 322 | wlr_log(L_DEBUG, |
323 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 323 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
324 | child, child->type, width, scale); | 324 | child, child->type, width, scale); |
325 | view_set_position(child->sway_view, child_x, y); | 325 | view_configure(child->sway_view, child_x, y, child->width, |
326 | child->height); | ||
326 | 327 | ||
327 | if (i == end - 1) { | 328 | if (i == end - 1) { |
328 | double remaining_width = x + width - child_x; | 329 | double remaining_width = x + width - child_x; |
@@ -373,7 +374,8 @@ void apply_vert_layout(struct sway_container *container, | |||
373 | wlr_log(L_DEBUG, | 374 | wlr_log(L_DEBUG, |
374 | "Calculating arrangement for %p:%d (will scale %f by %f)", | 375 | "Calculating arrangement for %p:%d (will scale %f by %f)", |
375 | child, child->type, height, scale); | 376 | child, child->type, height, scale); |
376 | view_set_position(child->sway_view, x, child_y); | 377 | view_configure(child->sway_view, x, child_y, child->width, |
378 | child->height); | ||
377 | 379 | ||
378 | if (i == end - 1) { | 380 | if (i == end - 1) { |
379 | double remaining_height = y + height - child_y; | 381 | double remaining_height = y + height - child_y; |
diff --git a/sway/tree/output.c b/sway/tree/output.c index 7248fd00..80a36ac7 100644 --- a/sway/tree/output.c +++ b/sway/tree/output.c | |||
@@ -29,6 +29,7 @@ struct sway_container *container_output_destroy(struct sway_container *output) { | |||
29 | wl_list_remove(&output->sway_output->destroy.link); | 29 | wl_list_remove(&output->sway_output->destroy.link); |
30 | wl_list_remove(&output->sway_output->mode.link); | 30 | wl_list_remove(&output->sway_output->mode.link); |
31 | wl_list_remove(&output->sway_output->transform.link); | 31 | wl_list_remove(&output->sway_output->transform.link); |
32 | wl_list_remove(&output->sway_output->scale.link); | ||
32 | 33 | ||
33 | wl_list_remove(&output->sway_output->damage_destroy.link); | 34 | wl_list_remove(&output->sway_output->damage_destroy.link); |
34 | wl_list_remove(&output->sway_output->damage_frame.link); | 35 | wl_list_remove(&output->sway_output->damage_frame.link); |
diff --git a/sway/tree/view.c b/sway/tree/view.c index d7a52e19..73e3d445 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -62,55 +62,10 @@ const char *view_get_instance(struct sway_view *view) { | |||
62 | return NULL; | 62 | return NULL; |
63 | } | 63 | } |
64 | 64 | ||
65 | static void view_update_outputs(struct sway_view *view, | 65 | void view_configure(struct sway_view *view, double ox, double oy, int width, |
66 | const struct wlr_box *before) { | 66 | int height) { |
67 | struct wlr_output_layout *output_layout = | 67 | if (view->impl->configure) { |
68 | root_container.sway_root->output_layout; | 68 | view->impl->configure(view, ox, oy, width, height); |
69 | struct wlr_box box = { | ||
70 | .x = view->swayc->x, | ||
71 | .y = view->swayc->y, | ||
72 | .width = view->width, | ||
73 | .height = view->height, | ||
74 | }; | ||
75 | struct wlr_output_layout_output *layout_output; | ||
76 | wl_list_for_each(layout_output, &output_layout->outputs, link) { | ||
77 | bool intersected = before != NULL && wlr_output_layout_intersects( | ||
78 | output_layout, layout_output->output, before); | ||
79 | bool intersects = wlr_output_layout_intersects(output_layout, | ||
80 | layout_output->output, &box); | ||
81 | if (intersected && !intersects) { | ||
82 | wlr_surface_send_leave(view->surface, layout_output->output); | ||
83 | } | ||
84 | if (!intersected && intersects) { | ||
85 | wlr_surface_send_enter(view->surface, layout_output->output); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | void view_set_size(struct sway_view *view, int width, int height) { | ||
91 | if (view->impl->set_size) { | ||
92 | struct wlr_box box = { | ||
93 | .x = view->swayc->x, | ||
94 | .y = view->swayc->y, | ||
95 | .width = view->width, | ||
96 | .height = view->height, | ||
97 | }; | ||
98 | view->impl->set_size(view, width, height); | ||
99 | view_update_outputs(view, &box); | ||
100 | } | ||
101 | } | ||
102 | |||
103 | // TODO make view coordinates in layout coordinates | ||
104 | void view_set_position(struct sway_view *view, double ox, double oy) { | ||
105 | if (view->impl->set_position) { | ||
106 | struct wlr_box box = { | ||
107 | .x = view->swayc->x, | ||
108 | .y = view->swayc->y, | ||
109 | .width = view->width, | ||
110 | .height = view->height, | ||
111 | }; | ||
112 | view->impl->set_position(view, ox, oy); | ||
113 | view_update_outputs(view, &box); | ||
114 | } | 69 | } |
115 | } | 70 | } |
116 | 71 | ||
@@ -136,6 +91,56 @@ struct sway_container *container_view_destroy(struct sway_container *view) { | |||
136 | return parent; | 91 | return parent; |
137 | } | 92 | } |
138 | 93 | ||
94 | void view_damage_whole(struct sway_view *view) { | ||
95 | for (int i = 0; i < root_container.children->length; ++i) { | ||
96 | struct sway_container *cont = root_container.children->items[i]; | ||
97 | if (cont->type == C_OUTPUT) { | ||
98 | output_damage_whole_view(cont->sway_output, view); | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | |||
103 | void view_damage_from(struct sway_view *view) { | ||
104 | // TODO | ||
105 | view_damage_whole(view); | ||
106 | } | ||
107 | |||
108 | static void view_get_layout_box(struct sway_view *view, struct wlr_box *box) { | ||
109 | struct sway_container *cont = container_parent(view->swayc, C_OUTPUT); | ||
110 | |||
111 | struct wlr_output_layout *output_layout = | ||
112 | root_container.sway_root->output_layout; | ||
113 | struct wlr_box *output_box = wlr_output_layout_get_box(output_layout, | ||
114 | cont->sway_output->wlr_output); | ||
115 | |||
116 | box->x = output_box->x + view->swayc->x; | ||
117 | box->y = output_box->y + view->swayc->y; | ||
118 | box->width = view->width; | ||
119 | box->height = view->height; | ||
120 | } | ||
121 | |||
122 | static void view_update_outputs(struct sway_view *view, | ||
123 | const struct wlr_box *before) { | ||
124 | struct wlr_box box; | ||
125 | view_get_layout_box(view, &box); | ||
126 | |||
127 | struct wlr_output_layout *output_layout = | ||
128 | root_container.sway_root->output_layout; | ||
129 | struct wlr_output_layout_output *layout_output; | ||
130 | wl_list_for_each(layout_output, &output_layout->outputs, link) { | ||
131 | bool intersected = before != NULL && wlr_output_layout_intersects( | ||
132 | output_layout, layout_output->output, before); | ||
133 | bool intersects = wlr_output_layout_intersects(output_layout, | ||
134 | layout_output->output, &box); | ||
135 | if (intersected && !intersects) { | ||
136 | wlr_surface_send_leave(view->surface, layout_output->output); | ||
137 | } | ||
138 | if (!intersected && intersects) { | ||
139 | wlr_surface_send_enter(view->surface, layout_output->output); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | |||
139 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | 144 | void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { |
140 | if (!sway_assert(view->surface == NULL, "cannot map mapped view")) { | 145 | if (!sway_assert(view->surface == NULL, "cannot map mapped view")) { |
141 | return; | 146 | return; |
@@ -153,6 +158,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
153 | sway_input_manager_set_focus(input_manager, cont); | 158 | sway_input_manager_set_focus(input_manager, cont); |
154 | 159 | ||
155 | view_damage_whole(view); | 160 | view_damage_whole(view); |
161 | view_update_outputs(view, NULL); | ||
156 | } | 162 | } |
157 | 163 | ||
158 | void view_map_unmanaged(struct sway_view *view, | 164 | void view_map_unmanaged(struct sway_view *view, |
@@ -168,6 +174,8 @@ void view_map_unmanaged(struct sway_view *view, | |||
168 | &view->unmanaged_view_link); | 174 | &view->unmanaged_view_link); |
169 | 175 | ||
170 | view_damage_whole(view); | 176 | view_damage_whole(view); |
177 | // TODO: make this work for unmanaged views | ||
178 | //view_update_outputs(view, NULL); | ||
171 | } | 179 | } |
172 | 180 | ||
173 | void view_unmap(struct sway_view *view) { | 181 | void view_unmap(struct sway_view *view) { |
@@ -186,17 +194,30 @@ void view_unmap(struct sway_view *view) { | |||
186 | view->surface = NULL; | 194 | view->surface = NULL; |
187 | } | 195 | } |
188 | 196 | ||
189 | void view_damage_whole(struct sway_view *view) { | 197 | void view_update_position(struct sway_view *view, double ox, double oy) { |
190 | struct sway_container *cont = NULL; | 198 | if (view->swayc->x == ox && view->swayc->y == oy) { |
191 | for (int i = 0; i < root_container.children->length; ++i) { | 199 | return; |
192 | cont = root_container.children->items[i]; | ||
193 | if (cont->type == C_OUTPUT) { | ||
194 | output_damage_whole_view(cont->sway_output, view); | ||
195 | } | ||
196 | } | 200 | } |
201 | |||
202 | struct wlr_box box; | ||
203 | view_get_layout_box(view, &box); | ||
204 | view_damage_whole(view); | ||
205 | view->swayc->x = ox; | ||
206 | view->swayc->y = oy; | ||
207 | view_update_outputs(view, &box); | ||
208 | view_damage_whole(view); | ||
197 | } | 209 | } |
198 | 210 | ||
199 | void view_damage_from(struct sway_view *view) { | 211 | void view_update_size(struct sway_view *view, int width, int height) { |
200 | // TODO | 212 | if (view->width == width && view->height == height) { |
213 | return; | ||
214 | } | ||
215 | |||
216 | struct wlr_box box; | ||
217 | view_get_layout_box(view, &box); | ||
218 | view_damage_whole(view); | ||
219 | view->width = width; | ||
220 | view->height = height; | ||
221 | view_update_outputs(view, &box); | ||
201 | view_damage_whole(view); | 222 | view_damage_whole(view); |
202 | } | 223 | } |