mirror of
https://github.com/swaywm/sway.git
synced 2025-10-31 22:25:26 -04:00
Add client support for HiDPI
This adds HiDPI support to swaybar, swaybg, and swaylock.
This commit is contained in:
parent
61184e3208
commit
b2226ac655
9 changed files with 96 additions and 61 deletions
|
|
@ -152,12 +152,15 @@ 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 * output->scale, 30 * output->scale, 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.");
|
||||
}
|
||||
desktop_shell_set_panel(bar_output->registry->desktop_shell, output->output, bar_output->window->surface);
|
||||
desktop_shell_set_panel_position(bar_output->registry->desktop_shell, bar->config->position);
|
||||
desktop_shell_set_panel(bar_output->registry->desktop_shell,
|
||||
output->output, bar_output->window->surface);
|
||||
desktop_shell_set_panel_position(bar_output->registry->desktop_shell,
|
||||
bar->config->position);
|
||||
|
||||
window_make_shell(bar_output->window);
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "swaybar/config.h"
|
||||
#include "swaybar/status_line.h"
|
||||
#include "swaybar/render.h"
|
||||
#include "log.h"
|
||||
|
||||
|
||||
/* internal spacing */
|
||||
|
|
@ -283,7 +284,8 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
|
||||
if (line->protocol == TEXT) {
|
||||
get_text_size(window->cairo, window->font, &width, &height, config->pango_markup, "%s", line->text_line);
|
||||
cairo_move_to(cairo, window->width - margin - width, margin);
|
||||
cairo_move_to(cairo, (window->width * window->scale)
|
||||
- margin - width, margin);
|
||||
pango_printf(window->cairo, window->font, config->pango_markup, "%s", line->text_line);
|
||||
} else if (line->protocol == I3BAR && line->block_line) {
|
||||
double pos = window->width - 0.5;
|
||||
|
|
@ -315,12 +317,13 @@ void render(struct output *output, struct config *config, struct status_line *li
|
|||
}
|
||||
|
||||
void set_window_height(struct window *window, int height) {
|
||||
int text_width, text_height;
|
||||
get_text_size(window->cairo, window->font, &text_width, &text_height, false,
|
||||
"Test string for measuring purposes");
|
||||
if (height > 0) {
|
||||
margin = (height - text_height) / 2;
|
||||
ws_vertical_padding = margin - 1.5;
|
||||
}
|
||||
window->height = text_height + margin * 2;
|
||||
int text_width, text_height;
|
||||
get_text_size(window->cairo, window->font,
|
||||
&text_width, &text_height, false,
|
||||
"Test string for measuring purposes");
|
||||
if (height > 0) {
|
||||
margin = (height - text_height) / 2;
|
||||
ws_vertical_padding = margin - 1.5;
|
||||
}
|
||||
window->height = (text_height + margin * 2) / window->scale;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue