diff options
author | emersion <contact@emersion.fr> | 2018-07-02 23:06:44 +0100 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-08-18 10:39:38 +1000 |
commit | b3ee9af0c837bcb48eb30021eaa42c882426e66a (patch) | |
tree | 8f2635471aaee001a51e11e922ddb01952ed0f55 /sway | |
parent | Merge pull request #2472 from RyanDwyer/refactor-seat-get-focus (diff) | |
download | sway-b3ee9af0c837bcb48eb30021eaa42c882426e66a.tar.gz sway-b3ee9af0c837bcb48eb30021eaa42c882426e66a.tar.zst sway-b3ee9af0c837bcb48eb30021eaa42c882426e66a.zip |
Add view_get_geometry
Diffstat (limited to 'sway')
-rw-r--r-- | sway/desktop/xdg_shell.c | 14 | ||||
-rw-r--r-- | sway/desktop/xwayland.c | 2 | ||||
-rw-r--r-- | sway/tree/view.c | 44 |
3 files changed, 27 insertions, 33 deletions
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 | ||
110 | static const char *get_string_prop(struct sway_view *view, enum sway_view_prop prop) { | 110 | static 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 | ||
125 | static 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 | |||
124 | static uint32_t configure(struct sway_view *view, double lx, double ly, | 135 | static 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) { | |||
231 | static const struct sway_view_impl view_impl = { | 242 | static 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 | ||
165 | void 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 | |||
165 | uint32_t view_configure(struct sway_view *view, double lx, double ly, int width, | 179 | uint32_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 | ||
618 | void 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 | |||
633 | void 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 | |||
648 | static void view_subsurface_create(struct sway_view *view, | 632 | static 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)); |