aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <ddevault@linode.com>2016-07-16 10:04:18 -0400
committerLibravatar Drew DeVault <ddevault@linode.com>2016-07-28 14:36:49 -0400
commit6ea02f3064736b7f53e5b28c16ee74f5665ce1b8 (patch)
treecc3c1ac31dd51ec82167f171dfe306ed246ef22f
parentMerge pull request #796 from Hummer12007/ipc_sub (diff)
downloadsway-6ea02f3064736b7f53e5b28c16ee74f5665ce1b8.tar.gz
sway-6ea02f3064736b7f53e5b28c16ee74f5665ce1b8.tar.zst
sway-6ea02f3064736b7f53e5b28c16ee74f5665ce1b8.zip
Initial pass on HiDPI support
-rw-r--r--include/config.h1
-rw-r--r--sway/commands.c6
-rw-r--r--sway/config.c3
-rw-r--r--sway/container.c7
-rw-r--r--sway/handlers.c3
-rw-r--r--sway/layout.c28
6 files changed, 34 insertions, 14 deletions
diff --git a/include/config.h b/include/config.h
index 87e23187..5e1c123e 100644
--- a/include/config.h
+++ b/include/config.h
@@ -81,6 +81,7 @@ struct output_config {
81 int enabled; 81 int enabled;
82 int width, height; 82 int width, height;
83 int x, y; 83 int x, y;
84 int scale;
84 char *background; 85 char *background;
85 char *background_option; 86 char *background_option;
86}; 87};
diff --git a/sway/commands.c b/sway/commands.c
index d572afa0..89d4337c 100644
--- a/sway/commands.c
+++ b/sway/commands.c
@@ -1585,6 +1585,7 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
1585 output->x = output->y = output->width = output->height = -1; 1585 output->x = output->y = output->width = output->height = -1;
1586 output->name = strdup(name); 1586 output->name = strdup(name);
1587 output->enabled = -1; 1587 output->enabled = -1;
1588 output->scale = 1;
1588 1589
1589 // TODO: atoi doesn't handle invalid numbers 1590 // TODO: atoi doesn't handle invalid numbers
1590 1591
@@ -1642,6 +1643,11 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
1642 } 1643 }
1643 output->x = x; 1644 output->x = x;
1644 output->y = y; 1645 output->y = y;
1646 } else if (strcasecmp(command, "scale") == 0) {
1647 if (++i >= argc) {
1648 return cmd_results_new(CMD_INVALID, "output", "Missing scale parameter.");
1649 }
1650 output->scale = atoi(argv[i]);
1645 } else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) { 1651 } else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) {
1646 wordexp_t p; 1652 wordexp_t p;
1647 if (++i >= argc) { 1653 if (++i >= argc) {
diff --git a/sway/config.c b/sway/config.c
index 5e1887a6..83129524 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -867,6 +867,9 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
867 struct wlc_size new_size = { .w = oc->width, .h = oc->height }; 867 struct wlc_size new_size = { .w = oc->width, .h = oc->height };
868 wlc_output_set_resolution(output->handle, &new_size); 868 wlc_output_set_resolution(output->handle, &new_size);
869 } 869 }
870 if (oc && oc->scale != 1) {
871 wlc_output_set_scale(output->handle, (int32_t)oc->scale);
872 }
870 873
871 // Find position for it 874 // Find position for it
872 if (oc && oc->x != -1 && oc->y != -1) { 875 if (oc && oc->x != -1 && oc->y != -1) {
diff --git a/sway/container.c b/sway/container.c
index 67aa6851..df9ce724 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -102,7 +102,8 @@ static void update_root_geometry() {
102// New containers 102// New containers
103 103
104swayc_t *new_output(wlc_handle handle) { 104swayc_t *new_output(wlc_handle handle) {
105 const struct wlc_size *size = wlc_output_get_resolution(handle); 105 struct wlc_size size;
106 wlc_output_get_scaled_size(handle, &size);
106 const char *name = wlc_output_get_name(handle); 107 const char *name = wlc_output_get_name(handle);
107 // Find current outputs to see if this already exists 108 // Find current outputs to see if this already exists
108 { 109 {
@@ -148,8 +149,8 @@ swayc_t *new_output(wlc_handle handle) {
148 swayc_t *output = new_swayc(C_OUTPUT); 149 swayc_t *output = new_swayc(C_OUTPUT);
149 output->handle = handle; 150 output->handle = handle;
150 output->name = name ? strdup(name) : NULL; 151 output->name = name ? strdup(name) : NULL;
151 output->width = size->w; 152 output->width = size.w;
152 output->height = size->h; 153 output->height = size.h;
153 output->unmanaged = create_list(); 154 output->unmanaged = create_list();
154 output->bg_pid = 0; 155 output->bg_pid = 0;
155 156
diff --git a/sway/handlers.c b/sway/handlers.c
index 05da5700..ad035e38 100644
--- a/sway/handlers.c
+++ b/sway/handlers.c
@@ -56,7 +56,8 @@ static struct background_config *if_background_find_config(struct wl_client *cli
56} 56}
57 57
58static struct wlc_geometry compute_panel_geometry(struct panel_config *config) { 58static struct wlc_geometry compute_panel_geometry(struct panel_config *config) {
59 const struct wlc_size resolution = *wlc_output_get_resolution(config->output); 59 struct wlc_size resolution;
60 wlc_output_get_scaled_size(config->output, &resolution);
60 const struct wlc_geometry *old = wlc_view_get_geometry(config->handle); 61 const struct wlc_geometry *old = wlc_view_get_geometry(config->handle);
61 struct wlc_geometry new; 62 struct wlc_geometry new;
62 63
diff --git a/sway/layout.c b/sway/layout.c
index fc7a31b4..2037955e 100644
--- a/sway/layout.c
+++ b/sway/layout.c
@@ -406,20 +406,21 @@ static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geo
406 c->actual_geometry = g; 406 c->actual_geometry = g;
407 407
408 swayc_t *output = swayc_parent_by_type(c, C_OUTPUT); 408 swayc_t *output = swayc_parent_by_type(c, C_OUTPUT);
409 const struct wlc_size *res = wlc_output_get_resolution(output->handle); 409 struct wlc_size res;
410 wlc_output_get_scaled_size(output->handle, &res);
410 411
411 switch (c->border_type) { 412 switch (c->border_type) {
412 case B_NONE: 413 case B_NONE:
413 break; 414 break;
414 case B_PIXEL: 415 case B_PIXEL:
415 adjust_border_geometry(c, &g, res, c->border_thickness, 416 adjust_border_geometry(c, &g, &res, c->border_thickness,
416 c->border_thickness, c->border_thickness, c->border_thickness); 417 c->border_thickness, c->border_thickness, c->border_thickness);
417 break; 418 break;
418 case B_NORMAL: 419 case B_NORMAL:
419 { 420 {
420 int title_bar_height = config->font_height + 4; // borders + padding 421 int title_bar_height = config->font_height + 4; // borders + padding
421 422
422 adjust_border_geometry(c, &g, res, c->border_thickness, 423 adjust_border_geometry(c, &g, &res, c->border_thickness,
423 c->border_thickness, title_bar_height, c->border_thickness); 424 c->border_thickness, title_bar_height, c->border_thickness);
424 425
425 struct wlc_geometry title_bar = { 426 struct wlc_geometry title_bar = {
@@ -545,13 +546,15 @@ void update_geometry(swayc_t *container) {
545 gap = update_gap_geometry(container, &geometry); 546 gap = update_gap_geometry(container, &geometry);
546 } 547 }
547 548
549 swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
550 struct wlc_size size;
551 wlc_output_get_scaled_size(output->handle, &size);
552
548 if (swayc_is_fullscreen(container)) { 553 if (swayc_is_fullscreen(container)) {
549 swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
550 const struct wlc_size *size = wlc_output_get_resolution(output->handle);
551 geometry.origin.x = 0; 554 geometry.origin.x = 0;
552 geometry.origin.y = 0; 555 geometry.origin.y = 0;
553 geometry.size.w = size->w; 556 geometry.size.w = size.w;
554 geometry.size.h = size->h; 557 geometry.size.h = size.h;
555 if (op->focused == workspace) { 558 if (op->focused == workspace) {
556 wlc_view_bring_to_front(container->handle); 559 wlc_view_bring_to_front(container->handle);
557 } 560 }
@@ -576,7 +579,9 @@ void update_geometry(swayc_t *container) {
576 border_left = 0; 579 border_left = 0;
577 } 580 }
578 581
579 if (geometry.origin.x + geometry.size.w == workspace->x + workspace->width) { 582 if (geometry.origin.x + geometry.size.w == size.w ||
583 geometry.size.w == container->x + container->width) {
584 // should work for swaybar at right
580 border_right = 0; 585 border_right = 0;
581 } 586 }
582 } 587 }
@@ -586,7 +591,9 @@ void update_geometry(swayc_t *container) {
586 border_top = 0; 591 border_top = 0;
587 } 592 }
588 593
589 if (geometry.origin.y + geometry.size.h == workspace->y + workspace->height) { 594 if (geometry.origin.y + geometry.size.h == size.h ||
595 geometry.size.h == container->y + container->height) {
596 // this works for swaybar at bottom
590 border_bottom = 0; 597 border_bottom = 0;
591 } 598 }
592 } 599 }
@@ -721,7 +728,8 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
721 return; 728 return;
722 case C_OUTPUT: 729 case C_OUTPUT:
723 { 730 {
724 struct wlc_size resolution = *wlc_output_get_resolution(container->handle); 731 struct wlc_size resolution;
732 wlc_output_get_scaled_size(container->handle, &resolution);
725 width = resolution.w; height = resolution.h; 733 width = resolution.w; height = resolution.h;
726 // output must have correct size due to e.g. seamless mouse, 734 // output must have correct size due to e.g. seamless mouse,
727 // but a workspace might be smaller depending on panels. 735 // but a workspace might be smaller depending on panels.