Fix rendering issues, wire up some xdg listeners

This commit is contained in:
Drew DeVault 2017-11-25 15:49:10 -05:00
parent ce1936bc65
commit a57d462926
4 changed files with 29 additions and 7 deletions

View File

@ -14,6 +14,8 @@ struct sway_xdg_surface_v6 {
struct wl_listener request_move; struct wl_listener request_move;
struct wl_listener request_resize; struct wl_listener request_resize;
struct wl_listener request_maximize; struct wl_listener request_maximize;
int pending_width, pending_height;
}; };
enum sway_view_type { enum sway_view_type {
@ -40,6 +42,7 @@ struct sway_view {
enum sway_view_type type; enum sway_view_type type;
struct sway_container *swayc; struct sway_container *swayc;
struct wlr_surface *surface; struct wlr_surface *surface;
int width, height;
union { union {
struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6; struct wlr_xdg_surface_v6 *wlr_xdg_surface_v6;

View File

@ -27,8 +27,8 @@ static void output_frame_view(swayc_t *view, void *data) {
} }
// TODO // TODO
// - Deal with wlr_output_layout // - Deal with wlr_output_layout
int width = sway_view->swayc->width; int width = sway_view->width;
int height = sway_view->swayc->height; int height = sway_view->height;
int render_width = width * wlr_output->scale; int render_width = width * wlr_output->scale;
int render_height = height * wlr_output->scale; int render_height = height * wlr_output->scale;
double ox = view->x, oy = view->y; double ox = view->x, oy = view->y;
@ -122,6 +122,8 @@ void output_add_notify(struct wl_listener *listener, void *data) {
output->resolution.notify = output_resolution_notify; output->resolution.notify = output_resolution_notify;
wl_signal_add(&wlr_output->events.resolution, &output->resolution); wl_signal_add(&wlr_output->events.resolution, &output->resolution);
arrange_windows(output->swayc, -1, -1);
} }
void output_remove_notify(struct wl_listener *listener, void *data) { void output_remove_notify(struct wl_listener *listener, void *data) {

View File

@ -29,9 +29,24 @@ static const char *get_prop(struct sway_view *view, enum sway_view_prop prop) {
} }
static void set_dimensions(struct sway_view *view, int width, int height) { static void set_dimensions(struct sway_view *view, int width, int height) {
if (assert_xdg(view)) { if (!assert_xdg(view)) {
return;
}
view->sway_xdg_surface_v6->pending_width = width;
view->sway_xdg_surface_v6->pending_height = height;
wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height); wlr_xdg_toplevel_v6_set_size(view->wlr_xdg_surface_v6, width, height);
} }
static void handle_commit(struct wl_listener *listener, void *data) {
struct sway_xdg_surface_v6 *sway_surface =
wl_container_of(listener, sway_surface, commit);
struct sway_view *view = sway_surface->view;
sway_log(L_DEBUG, "xdg surface commit %dx%d",
sway_surface->pending_width, sway_surface->pending_height);
// NOTE: We intentionally discard the view's desired width here
// TODO: Don't do that for floating views
view->width = sway_surface->pending_width;
view->height = sway_surface->pending_height;
} }
void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) { void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
@ -73,6 +88,9 @@ void handle_xdg_shell_v6_surface(struct wl_listener *listener, void *data) {
// - Set new view to maximized so it behaves nicely // - Set new view to maximized so it behaves nicely
// - Criteria // - Criteria
sway_surface->commit.notify = handle_commit;
wl_signal_add(&xdg_surface->events.commit, &sway_surface->commit);
// TODO: actual focus semantics // TODO: actual focus semantics
swayc_t *parent = root_container.children->items[0]; swayc_t *parent = root_container.children->items[0];
parent = parent->children->items[0]; // workspace parent = parent->children->items[0]; // workspace

View File

@ -129,11 +129,10 @@ void arrange_windows(swayc_t *container, double width, double height) {
case C_WORKSPACE: case C_WORKSPACE:
{ {
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
width = output->width, height = output->height; container->width = output->width;
container->height = output->height;
container->x = x; container->x = x;
container->y = y; container->y = y;
width = container->width;
height = container->height;
sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f", sway_log(L_DEBUG, "Arranging workspace '%s' at %f, %f",
container->name, container->x, container->y); container->name, container->x, container->y);
} }