aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sway/tree/view.h5
-rw-r--r--sway/desktop/xdg_shell.c14
-rw-r--r--sway/desktop/xwayland.c2
-rw-r--r--sway/tree/view.c44
4 files changed, 28 insertions, 37 deletions
diff --git a/include/sway/tree/view.h b/include/sway/tree/view.h
index c2225bcb..1ded601c 100644
--- a/include/sway/tree/view.h
+++ b/include/sway/tree/view.h
@@ -38,6 +38,7 @@ struct sway_view_impl {
38 const char *(*get_string_prop)(struct sway_view *view, 38 const char *(*get_string_prop)(struct sway_view *view,
39 enum sway_view_prop prop); 39 enum sway_view_prop prop);
40 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop); 40 uint32_t (*get_int_prop)(struct sway_view *view, enum sway_view_prop prop);
41 void (*get_geometry)(struct sway_view *view, struct wlr_box *box);
41 uint32_t (*configure)(struct sway_view *view, double lx, double ly, 42 uint32_t (*configure)(struct sway_view *view, double lx, double ly,
42 int width, int height); 43 int width, int height);
43 void (*set_activated)(struct sway_view *view, bool activated); 44 void (*set_activated)(struct sway_view *view, bool activated);
@@ -285,10 +286,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface);
285 286
286void view_unmap(struct sway_view *view); 287void view_unmap(struct sway_view *view);
287 288
288void view_update_position(struct sway_view *view, double lx, double ly);
289
290void view_update_size(struct sway_view *view, int width, int height);
291
292void view_child_init(struct sway_view_child *child, 289void view_child_init(struct sway_view_child *child,
293 const struct sway_view_child_impl *impl, struct sway_view *view, 290 const struct sway_view_child_impl *impl, struct sway_view *view,
294 struct wlr_surface *surface); 291 struct wlr_surface *surface);
diff --git a/sway/desktop/xdg_shell.c b/sway/desktop/xdg_shell.c
index 6a7a3f7f..2b260357 100644
--- a/sway/desktop/xdg_shell.c
+++ b/sway/desktop/xdg_shell.c
@@ -107,7 +107,8 @@ static void get_constraints(struct sway_view *view, double *min_width,
107 *max_height = state->max_height > 0 ? state->max_height : DBL_MAX; 107 *max_height = state->max_height > 0 ? state->max_height : DBL_MAX;
108} 108}
109 109
110static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { 110static const char *get_string_prop(struct sway_view *view,
111 enum sway_view_prop prop) {
111 if (xdg_shell_view_from_view(view) == NULL) { 112 if (xdg_shell_view_from_view(view) == NULL) {
112 return NULL; 113 return NULL;
113 } 114 }
@@ -121,6 +122,16 @@ static const char *get_string_prop(struct sway_view *view, enum sway_view_prop p
121 } 122 }
122} 123}
123 124
125static void get_geometry(struct sway_view *view, struct wlr_box *box) {
126 struct sway_xdg_shell_view *xdg_shell_view =
127 xdg_shell_view_from_view(view);
128 if (xdg_shell_view == NULL) {
129 return;
130 }
131 struct wlr_xdg_surface *surface = view->wlr_xdg_surface;
132 wlr_xdg_surface_get_geometry(surface, box);
133}
134
124static uint32_t configure(struct sway_view *view, double lx, double ly, 135static uint32_t configure(struct sway_view *view, double lx, double ly,
125 int width, int height) { 136 int width, int height) {
126 struct sway_xdg_shell_view *xdg_shell_view = 137 struct sway_xdg_shell_view *xdg_shell_view =
@@ -231,6 +242,7 @@ static void destroy(struct sway_view *view) {
231static const struct sway_view_impl view_impl = { 242static const struct sway_view_impl view_impl = {
232 .get_constraints = get_constraints, 243 .get_constraints = get_constraints,
233 .get_string_prop = get_string_prop, 244 .get_string_prop = get_string_prop,
245 .get_geometry = get_geometry,
234 .configure = configure, 246 .configure = configure,
235 .set_activated = set_activated, 247 .set_activated = set_activated,
236 .set_tiled = set_tiled, 248 .set_tiled = set_tiled,
diff --git a/sway/desktop/xwayland.c b/sway/desktop/xwayland.c
index 14f59b9c..dca62fb1 100644
--- a/sway/desktop/xwayland.c
+++ b/sway/desktop/xwayland.c
@@ -287,8 +287,6 @@ static void handle_commit(struct wl_listener *listener, void *data) {
287 if (view->swayc->instruction) { 287 if (view->swayc->instruction) {
288 transaction_notify_view_ready_by_size(view, 288 transaction_notify_view_ready_by_size(view,
289 surface_state->width, surface_state->height); 289 surface_state->width, surface_state->height);
290 } else if (container_is_floating(view->swayc)) {
291 view_update_size(view, surface_state->width, surface_state->height);
292 } 290 }
293 291
294 view_damage_from(view); 292 view_damage_from(view);
diff --git a/sway/tree/view.c b/sway/tree/view.c
index 950494d8..fba0b52d 100644
--- a/sway/tree/view.c
+++ b/sway/tree/view.c
@@ -162,6 +162,20 @@ void view_get_constraints(struct sway_view *view, double *min_width,
162 } 162 }
163} 163}
164 164
165void view_get_geometry(struct sway_view *view, struct wlr_box *box) {
166 if (view->surface == NULL) {
167 box->x = box->y = box->width = box->height = 0;
168 return;
169 }
170 if (view->impl->get_geometry) {
171 view->impl->get_geometry(view, box);
172 return;
173 }
174 box->x = box->y = 0;
175 box->width = view->surface->current.width;
176 box->height = view->surface->current.height;
177}
178
165uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, 179uint32_t view_configure(struct sway_view *view, double lx, double ly, int width,
166 int height) { 180 int height) {
167 if (view->impl->configure) { 181 if (view->impl->configure) {
@@ -615,36 +629,6 @@ void view_unmap(struct sway_view *view) {
615 view->surface = NULL; 629 view->surface = NULL;
616} 630}
617 631
618void view_update_position(struct sway_view *view, double lx, double ly) {
619 if (view->x == lx && view->y == ly) {
620 return;
621 }
622 container_damage_whole(view->swayc);
623 view->x = lx;
624 view->y = ly;
625 view->swayc->current.view_x = lx;
626 view->swayc->current.view_y = ly;
627 if (container_is_floating(view->swayc)) {
628 container_set_geometry_from_floating_view(view->swayc);
629 }
630 container_damage_whole(view->swayc);
631}
632
633void view_update_size(struct sway_view *view, int width, int height) {
634 if (view->width == width && view->height == height) {
635 return;
636 }
637 container_damage_whole(view->swayc);
638 view->width = width;
639 view->height = height;
640 view->swayc->current.view_width = width;
641 view->swayc->current.view_height = height;
642 if (container_is_floating(view->swayc)) {
643 container_set_geometry_from_floating_view(view->swayc);
644 }
645 container_damage_whole(view->swayc);
646}
647
648static void view_subsurface_create(struct sway_view *view, 632static void view_subsurface_create(struct sway_view *view,
649 struct wlr_subsurface *subsurface) { 633 struct wlr_subsurface *subsurface) {
650 struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child)); 634 struct sway_view_child *child = calloc(1, sizeof(struct sway_view_child));