diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-11-25 15:49:10 -0500 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2017-11-25 15:49:10 -0500 |
commit | a57d46292694e388d74add7b0869bcafdb42b2bd (patch) | |
tree | 74b91247e749c1b67f89bd2271f31762b659545b | |
parent | Arrange windows on desktop (diff) | |
download | sway-a57d46292694e388d74add7b0869bcafdb42b2bd.tar.gz sway-a57d46292694e388d74add7b0869bcafdb42b2bd.tar.zst sway-a57d46292694e388d74add7b0869bcafdb42b2bd.zip |
Fix rendering issues, wire up some xdg listeners
-rw-r--r-- | include/sway/view.h | 3 | ||||
-rw-r--r-- | sway/desktop/output.c | 6 | ||||
-rw-r--r-- | sway/desktop/xdg_shell_v6.c | 22 | ||||
-rw-r--r-- | sway/tree/layout.c | 5 |
4 files changed, 29 insertions, 7 deletions
diff --git a/include/sway/view.h b/include/sway/view.h index 9d503674..fca444b7 100644 --- a/include/sway/view.h +++ b/include/sway/view.h | |||
@@ -14,6 +14,8 @@ struct sway_xdg_surface_v6 { | |||
14 | struct wl_listener request_move; | 14 | struct wl_listener request_move; |
15 | struct wl_listener request_resize; | 15 | struct wl_listener request_resize; |
16 | struct wl_listener request_maximize; | 16 | struct wl_listener request_maximize; |
17 | |||
18 | int pending_width, pending_height; | ||
17 | }; | 19 | }; |
18 | 20 | ||
19 | enum sway_view_type { | 21 | enum sway_view_type { |
@@ -40,6 +42,7 @@ struct sway_view { | |||
40 | enum sway_view_type type; | 42 | enum sway_view_type type; |
41 | struct sway_container *swayc; | 43 | struct sway_container *swayc; |
42 | struct wlr_surface *surface; | 44 | struct wlr_surface *surface; |
45 | int width, height; | ||
43 | 46 | ||
44 | union { | 47 | union { |
45 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; | 48 | struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; |
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 033a4c44..99c74d89 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -27,8 +27,8 @@ static void output_frame_view(swayc_t *view, void *data) { | |||
27 | } | 27 | } |
28 | // TODO | 28 | // TODO |
29 | // - Deal with wlr_output_layout | 29 | // - Deal with wlr_output_layout |
30 | int width = sway_view->swayc->width; | 30 | int width = sway_view->width; |
31 | int height = sway_view->swayc->height; | 31 | int height = sway_view->height; |
32 | int render_width = width * wlr_output->scale; | 32 | int render_width = width * wlr_output->scale; |
33 | int render_height = height * wlr_output->scale; | 33 | int render_height = height * wlr_output->scale; |
34 | double ox = view->x, oy = view->y; | 34 | double ox = view->x, oy = view->y; |
@@ -122,6 +122,8 @@ void output_add_notify(struct wl_listener *listener, void *data) { | |||
122 | 122 | ||
123 | output->resolution.notify = output_resolution_notify; | 123 | output->resolution.notify = output_resolution_notify; |
124 | wl_signal_add(&wlr_output->events.resolution, &output->resolution); | 124 | wl_signal_add(&wlr_output->events.resolution, &output->resolution); |
125 | |||
126 | arrange_windows(output->swayc, -1, -1); | ||
125 | } | 127 | } |
126 | 128 | ||
127 | void output_remove_notify(struct wl_listener *listener, void *data) { | 129 | void output_remove_notify(struct wl_listener *listener, void *data) { |
diff --git a/sway/desktop/xdg_shell_v6.c b/sway/desktop/xdg_shell_v6.c index 8f1885c1..94682fcd 100644 --- a/sway/desktop/xdg_shell_v6.c +++ b/sway/desktop/xdg_shell_v6.c | |||
@@ -29,9 +29,24 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) { | |||
29 | } | 29 | } |
30 | 30 | ||
31 | static void set_dimensions(struct sway_view *view, int width, int height) { | 31 | static void set_dimensions(struct sway_view *view, int width, int height) { |
32 | if (assert_xdg(view)) { | 32 | if (!assert_xdg(view)) { |
33 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | 33 | return; |
34 | } | 34 | } |
35 | view->sway_xdg_surface_v6->pending_width = width; | ||
36 | view->sway_xdg_surface_v6->pending_height = height; | ||
37 | wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); | ||
38 | } | ||
39 | |||
40 | static void handle_commit(struct wl_listener *listener, void *data) { | ||
41 | struct sway_xdg_surface_v6 *sway_surface = | ||
42 | wl_container_of(listener, sway_surface, commit); | ||
43 | struct sway_view *view = sway_surface->view; | ||
44 | sway_log(L_DEBUG, "xdg surface commit %dx%d", | ||
45 | sway_surface->pending_width, sway_surface->pending_height); | ||
46 | // NOTE: We intentionally discard the view's desired width here | ||
47 | // TODO: Don't do that for floating views | ||
48 | view->width = sway_surface->pending_width; | ||
49 | view->height = sway_surface->pending_height; | ||
35 | } | 50 | } |
36 | 51 | ||
37 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | 52 | void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { |
@@ -72,6 +87,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { | |||
72 | // - Look up pid and open on appropriate workspace | 87 | // - Look up pid and open on appropriate workspace |
73 | // - Set new view to maximized so it behaves nicely | 88 | // - Set new view to maximized so it behaves nicely |
74 | // - Criteria | 89 | // - Criteria |
90 | |||
91 | sway_surface->commit.notify = handle_commit; | ||
92 | wl_signal_add(&xdg_surface->events.commit, &sway_surface->commit); | ||
75 | 93 | ||
76 | // TODO: actual focus semantics | 94 | // TODO: actual focus semantics |
77 | swayc_t *parent = root_container.children->items[0]; | 95 | swayc_t *parent = root_container.children->items[0]; |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 3d6b404d..6e2586a7 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -129,11 +129,10 @@ void arrange_windows(swayc_t *container, double width, double height) { | |||
129 | case C_WORKSPACE: | 129 | case C_WORKSPACE: |
130 | { | 130 | { |
131 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); | 131 | swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); |
132 | width = output->width, height = output->height; | 132 | container->width = output->width; |
133 | container->height = output->height; | ||
133 | container->x = x; | 134 | container->x = x; |
134 | container->y = y; | 135 | container->y = y; |
135 | width = container->width; | ||
136 | height = container->height; | ||
137 | sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", | 136 | sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", |
138 | container->name, container->x, container->y); | 137 | container->name, container->x, container->y); |
139 | } | 138 | } |