From 61184e3208c28b24a84aae5f5f0005311283826d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Mon, 5 Sep 2016 10:32:21 -0400 Subject: [PATCH] Initial testing on hidpi clients --- include/client/registry.h | 1 + swaybar/bar.c | 2 +- wayland/buffers.c | 1 + wayland/registry.c | 4 +++- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/client/registry.h b/include/client/registry.h index 9ac10c27..24b4d358 100644 --- a/include/client/registry.h +++ b/include/client/registry.h @@ -34,6 +34,7 @@ struct output_state { struct wl_output *output; uint32_t flags; uint32_t width, height; + uint32_t scale; }; struct xkb { diff --git a/swaybar/bar.c b/swaybar/bar.c index c6596864..f3767409 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c @@ -152,7 +152,7 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { struct output_state *output = bar_output->registry->outputs->items[bar_output->idx]; - bar_output->window = window_setup(bar_output->registry, output->width, 30, false); + bar_output->window = window_setup(bar_output->registry, output->width * output->scale, 30 * output->scale, false); if (!bar_output->window) { sway_abort("Failed to create window."); } diff --git a/wayland/buffers.c b/wayland/buffers.c index ba783b37..ff1e5ecf 100644 --- a/wayland/buffers.c +++ b/wayland/buffers.c @@ -75,6 +75,7 @@ static struct buffer *create_buffer(struct window *window, struct buffer *buf, buf->surface = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride); buf->cairo = cairo_create(buf->surface); buf->pango = pango_cairo_create_context(buf->cairo); + pango_cairo_context_set_resolution(buf->pango, 96 * 2); wl_buffer_add_listener(buf->buffer, &buffer_listener, buf); return buf; diff --git a/wayland/registry.c b/wayland/registry.c index 622571f0..2d66b7eb 100644 --- a/wayland/registry.c +++ b/wayland/registry.c @@ -32,7 +32,8 @@ static void display_handle_done(void *data, struct wl_output *wl_output) { } static void display_handle_scale(void *data, struct wl_output *wl_output, int32_t factor) { - // this space intentionally left blank + struct output_state *state = data; + state->scale = factor; } static const struct wl_output_listener output_listener = { @@ -220,6 +221,7 @@ static void registry_global(void *data, struct wl_registry *registry, struct wl_output *output = wl_registry_bind(registry, name, &wl_output_interface, version); struct output_state *ostate = malloc(sizeof(struct output_state)); ostate->output = output; + ostate->scale = 1; wl_output_add_listener(output, &output_listener, ostate); list_add(reg->outputs, ostate); } else if (strcmp(interface, desktop_shell_interface.name) == 0) {