diff options
author | Drew DeVault <ddevault@linode.com> | 2016-09-05 11:36:48 -0400 |
---|---|---|
committer | Drew DeVault <ddevault@linode.com> | 2016-09-05 11:36:48 -0400 |
commit | b2226ac6551f18275fadbcb3bc16a06d2a3dd97f (patch) | |
tree | 65628cb83abaa546c5f0e2cd8949c55aacb40360 /swaybar | |
parent | Initial testing on hidpi clients (diff) | |
download | sway-b2226ac6551f18275fadbcb3bc16a06d2a3dd97f.tar.gz sway-b2226ac6551f18275fadbcb3bc16a06d2a3dd97f.tar.zst sway-b2226ac6551f18275fadbcb3bc16a06d2a3dd97f.zip |
Add client support for HiDPI
This adds HiDPI support to swaybar, swaybg, and swaylock.
Diffstat (limited to 'swaybar')
-rw-r--r-- | swaybar/bar.c | 9 | ||||
-rw-r--r-- | swaybar/render.c | 21 |
2 files changed, 18 insertions, 12 deletions
diff --git a/swaybar/bar.c b/swaybar/bar.c index f3767409..7ec3e0ea 100644 --- a/swaybar/bar.c +++ b/swaybar/bar.c | |||
@@ -152,12 +152,15 @@ void bar_setup(struct bar *bar, const char *socket_path, const char *bar_id) { | |||
152 | 152 | ||
153 | struct output_state *output = bar_output->registry->outputs->items[bar_output->idx]; | 153 | struct output_state *output = bar_output->registry->outputs->items[bar_output->idx]; |
154 | 154 | ||
155 | bar_output->window = window_setup(bar_output->registry, output->width * output->scale, 30 * output->scale, false); | 155 | bar_output->window = window_setup(bar_output->registry, |
156 | output->width / output->scale, 30, output->scale, false); | ||
156 | if (!bar_output->window) { | 157 | if (!bar_output->window) { |
157 | sway_abort("Failed to create window."); | 158 | sway_abort("Failed to create window."); |
158 | } | 159 | } |
159 | desktop_shell_set_panel(bar_output->registry->desktop_shell, output->output, bar_output->window->surface); | 160 | desktop_shell_set_panel(bar_output->registry->desktop_shell, |
160 | desktop_shell_set_panel_position(bar_output->registry->desktop_shell, bar->config->position); | 161 | output->output, bar_output->window->surface); |
162 | desktop_shell_set_panel_position(bar_output->registry->desktop_shell, | ||
163 | bar->config->position); | ||
161 | 164 | ||
162 | window_make_shell(bar_output->window); | 165 | window_make_shell(bar_output->window); |
163 | 166 | ||
diff --git a/swaybar/render.c b/swaybar/render.c index 83b4cec7..58325050 100644 --- a/swaybar/render.c +++ b/swaybar/render.c | |||
@@ -8,6 +8,7 @@ | |||
8 | #include "swaybar/config.h" | 8 | #include "swaybar/config.h" |
9 | #include "swaybar/status_line.h" | 9 | #include "swaybar/status_line.h" |
10 | #include "swaybar/render.h" | 10 | #include "swaybar/render.h" |
11 | #include "log.h" | ||
11 | 12 | ||
12 | 13 | ||
13 | /* internal spacing */ | 14 | /* internal spacing */ |
@@ -283,7 +284,8 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
283 | 284 | ||
284 | if (line->protocol == TEXT) { | 285 | if (line->protocol == TEXT) { |
285 | get_text_size(window->cairo, window->font, &width, &height, config->pango_markup, "%s", line->text_line); | 286 | get_text_size(window->cairo, window->font, &width, &height, config->pango_markup, "%s", line->text_line); |
286 | cairo_move_to(cairo, window->width - margin - width, margin); | 287 | cairo_move_to(cairo, (window->width * window->scale) |
288 | - margin - width, margin); | ||
287 | pango_printf(window->cairo, window->font, config->pango_markup, "%s", line->text_line); | 289 | pango_printf(window->cairo, window->font, config->pango_markup, "%s", line->text_line); |
288 | } else if (line->protocol == I3BAR && line->block_line) { | 290 | } else if (line->protocol == I3BAR && line->block_line) { |
289 | double pos = window->width - 0.5; | 291 | double pos = window->width - 0.5; |
@@ -315,12 +317,13 @@ void render(struct output *output, struct config *config, struct status_line *li | |||
315 | } | 317 | } |
316 | 318 | ||
317 | void set_window_height(struct window *window, int height) { | 319 | void set_window_height(struct window *window, int height) { |
318 | int text_width, text_height; | 320 | int text_width, text_height; |
319 | get_text_size(window->cairo, window->font, &text_width, &text_height, false, | 321 | get_text_size(window->cairo, window->font, |
320 | "Test string for measuring purposes"); | 322 | &text_width, &text_height, false, |
321 | if (height > 0) { | 323 | "Test string for measuring purposes"); |
322 | margin = (height - text_height) / 2; | 324 | if (height > 0) { |
323 | ws_vertical_padding = margin - 1.5; | 325 | margin = (height - text_height) / 2; |
324 | } | 326 | ws_vertical_padding = margin - 1.5; |
325 | window->height = text_height + margin * 2; | 327 | } |
328 | window->height = (text_height + margin * 2) / window->scale; | ||
326 | } | 329 | } |