diff options
author | Drew DeVault <[email protected]> | 2016-09-05 11:36:48 -0400 |
---|---|---|
committer | Drew DeVault <[email protected]> | 2016-09-05 11:36:48 -0400 |
commit | b2226ac6551f18275fadbcb3bc16a06d2a3dd97f (patch) | |
tree | 65628cb83abaa546c5f0e2cd8949c55aacb40360 /wayland/window.c | |
parent | 61184e3208c28b24a84aae5f5f0005311283826d (diff) |
Add client support for HiDPI
This adds HiDPI support to swaybar, swaybg, and swaylock.
Diffstat (limited to 'wayland/window.c')
-rw-r--r-- | wayland/window.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/wayland/window.c b/wayland/window.c index 3f48d39f..8a506656 100644 --- a/wayland/window.c +++ b/wayland/window.c @@ -93,11 +93,13 @@ void window_make_shell(struct window *window) { wl_shell_surface_set_toplevel(window->shell_surface); } -struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, bool shell_surface) { +struct window *window_setup(struct registry *registry, uint32_t width, uint32_t height, + int32_t scale, bool shell_surface) { struct window *window = malloc(sizeof(struct window)); memset(window, 0, sizeof(struct window)); window->width = width; window->height = height; + window->scale = scale; window->registry = registry; window->font = "monospace 10"; @@ -121,15 +123,18 @@ struct window *window_setup(struct registry *registry, uint32_t width, uint32_t cursor_size = "16"; } + sway_log(L_DEBUG, "Cursor scale: %d", scale); window->cursor.cursor_theme = wl_cursor_theme_load(cursor_theme, - atoi(cursor_size), registry->shm); + atoi(cursor_size) * scale, registry->shm); window->cursor.cursor = wl_cursor_theme_get_cursor(window->cursor.cursor_theme, "left_ptr"); window->cursor.surface = wl_compositor_create_surface(registry->compositor); struct wl_cursor_image *image = window->cursor.cursor->images[0]; struct wl_buffer *cursor_buf = wl_cursor_image_get_buffer(image); wl_surface_attach(window->cursor.surface, cursor_buf, 0, 0); - wl_surface_damage(window->cursor.surface, 0, 0, image->width, image->height); + wl_surface_set_buffer_scale(window->cursor.surface, scale); + wl_surface_damage(window->cursor.surface, 0, 0, + image->width, image->height); wl_surface_commit(window->cursor.surface); } @@ -159,8 +164,9 @@ int window_render(struct window *window) { window->frame_cb = wl_surface_frame(window->surface); wl_callback_add_listener(window->frame_cb, &listener, window); - wl_surface_damage(window->surface, 0, 0, window->buffer->width, window->buffer->height); wl_surface_attach(window->surface, window->buffer->buffer, 0, 0); + wl_surface_set_buffer_scale(window->surface, window->scale); + wl_surface_damage(window->surface, 0, 0, window->width, window->height); wl_surface_commit(window->surface); return 1; |