diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-07-29 07:35:43 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-07-29 07:35:43 -0400 |
commit | 966127222439620233c27ab835062f6cc69e23ea (patch) | |
tree | 7e233c68e7063b7c0c7857a73111e95141fb5b44 | |
parent | Merge pull request #802 from acrisci/feature/timestamp-log-messages (diff) | |
parent | Update IPC JSON responses for HiDPI setups (diff) | |
download | sway-4ab01e98832fa105c7c01f72f6a6d24994514a06.tar.gz sway-4ab01e98832fa105c7c01f72f6a6d24994514a06.tar.zst sway-4ab01e98832fa105c7c01f72f6a6d24994514a06.zip |
Merge remote-tracking branch 'origin/hidpi'0.9-rc2
-rw-r--r-- | include/config.h | 1 | ||||
-rw-r--r-- | include/output.h | 2 | ||||
-rw-r--r-- | sway/commands.c | 12 | ||||
-rw-r--r-- | sway/config.c | 7 | ||||
-rw-r--r-- | sway/container.c | 7 | ||||
-rw-r--r-- | sway/handlers.c | 3 | ||||
-rw-r--r-- | sway/ipc-json.c | 15 | ||||
-rw-r--r-- | sway/layout.c | 28 | ||||
-rw-r--r-- | sway/output.c | 7 |
9 files changed, 61 insertions, 21 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/include/output.h b/include/output.h index 10c5bb53..e8afd5ed 100644 --- a/include/output.h +++ b/include/output.h | |||
@@ -19,4 +19,6 @@ void get_absolute_center_position(swayc_t *container, struct wlc_point *point); | |||
19 | // stable sort workspaces on this output | 19 | // stable sort workspaces on this output |
20 | void sort_workspaces(swayc_t *output); | 20 | void sort_workspaces(swayc_t *output); |
21 | 21 | ||
22 | void output_get_scaled_size(wlc_handle handle, struct wlc_size *size); | ||
23 | |||
22 | #endif | 24 | #endif |
diff --git a/sway/commands.c b/sway/commands.c index d572afa0..053b5792 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) { |
@@ -1700,10 +1706,10 @@ static struct cmd_results *cmd_output(int argc, char **argv) { | |||
1700 | list_add(config->output_configs, output); | 1706 | list_add(config->output_configs, output); |
1701 | } | 1707 | } |
1702 | 1708 | ||
1703 | sway_log(L_DEBUG, "Config stored for output %s (enabled:%d) (%d x %d @ %d, %d) (bg %s %s)", | 1709 | sway_log(L_DEBUG, "Config stored for output %s (enabled:%d) (%d x %d @ %d, %d scale %d) (bg %s %s)", |
1704 | output->name, output->enabled, output->width, | 1710 | output->name, output->enabled, output->width, |
1705 | output->height, output->x, output->y, output->background, | 1711 | output->height, output->x, output->y, output->scale, |
1706 | output->background_option); | 1712 | output->background, output->background_option); |
1707 | 1713 | ||
1708 | if (output->name) { | 1714 | if (output->name) { |
1709 | // Try to find the output container and apply configuration now. If | 1715 | // Try to find the output container and apply configuration now. If |
diff --git a/sway/config.c b/sway/config.c index 5e1887a6..25566213 100644 --- a/sway/config.c +++ b/sway/config.c | |||
@@ -863,9 +863,12 @@ void apply_output_config(struct output_config *oc, swayc_t *output) { | |||
863 | output->width = oc->width; | 863 | output->width = oc->width; |
864 | output->height = oc->height; | 864 | output->height = oc->height; |
865 | 865 | ||
866 | sway_log(L_DEBUG, "Set %s size to %ix%i", oc->name, oc->width, oc->height); | 866 | sway_log(L_DEBUG, "Set %s size to %ix%i (%d)", oc->name, oc->width, oc->height, oc->scale); |
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, (uint32_t)oc->scale); |
869 | } else if (oc && oc->scale != 1) { | ||
870 | const struct wlc_size *new_size = wlc_output_get_resolution(output->handle); | ||
871 | wlc_output_set_resolution(output->handle, new_size, (uint32_t)oc->scale); | ||
869 | } | 872 | } |
870 | 873 | ||
871 | // Find position for it | 874 | // Find position for it |
diff --git a/sway/container.c b/sway/container.c index 67aa6851..c922bac3 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 | ||
104 | swayc_t *new_output(wlc_handle handle) { | 104 | swayc_t *new_output(wlc_handle handle) { |
105 | const struct wlc_size *size = wlc_output_get_resolution(handle); | 105 | struct wlc_size size; |
106 | 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 405df1c8..cb608bec 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 | ||
58 | static struct wlc_geometry compute_panel_geometry(struct panel_config *config) { | 58 | static 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 | 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/ipc-json.c b/sway/ipc-json.c index 4e5ea896..228e551d 100644 --- a/sway/ipc-json.c +++ b/sway/ipc-json.c | |||
@@ -11,8 +11,17 @@ static json_object *ipc_json_create_rect(swayc_t *c) { | |||
11 | 11 | ||
12 | json_object_object_add(rect, "x", json_object_new_int((int32_t)c->x)); | 12 | json_object_object_add(rect, "x", json_object_new_int((int32_t)c->x)); |
13 | json_object_object_add(rect, "y", json_object_new_int((int32_t)c->y)); | 13 | json_object_object_add(rect, "y", json_object_new_int((int32_t)c->y)); |
14 | json_object_object_add(rect, "width", json_object_new_int((int32_t)c->width)); | 14 | |
15 | json_object_object_add(rect, "height", json_object_new_int((int32_t)c->height)); | 15 | struct wlc_size size; |
16 | if (c->type == C_OUTPUT) { | ||
17 | size = *wlc_output_get_resolution(c->handle); | ||
18 | } else { | ||
19 | size.w = c->width; | ||
20 | size.h = c->height; | ||
21 | } | ||
22 | |||
23 | json_object_object_add(rect, "width", json_object_new_int((int32_t)size.w)); | ||
24 | json_object_object_add(rect, "height", json_object_new_int((int32_t)size.h)); | ||
16 | 25 | ||
17 | return rect; | 26 | return rect; |
18 | } | 27 | } |
@@ -111,12 +120,14 @@ static float ipc_json_child_percentage(swayc_t *c) { | |||
111 | } | 120 | } |
112 | 121 | ||
113 | static void ipc_json_describe_output(swayc_t *output, json_object *object) { | 122 | static void ipc_json_describe_output(swayc_t *output, json_object *object) { |
123 | uint32_t scale = wlc_output_get_scale(output->handle); | ||
114 | json_object_object_add(object, "active", json_object_new_boolean(true)); | 124 | json_object_object_add(object, "active", json_object_new_boolean(true)); |
115 | json_object_object_add(object, "primary", json_object_new_boolean(false)); | 125 | json_object_object_add(object, "primary", json_object_new_boolean(false)); |
116 | json_object_object_add(object, "layout", json_object_new_string("output")); | 126 | json_object_object_add(object, "layout", json_object_new_string("output")); |
117 | json_object_object_add(object, "type", json_object_new_string("output")); | 127 | json_object_object_add(object, "type", json_object_new_string("output")); |
118 | json_object_object_add(object, "current_workspace", | 128 | json_object_object_add(object, "current_workspace", |
119 | (output->focused) ? json_object_new_string(output->focused->name) : NULL); | 129 | (output->focused) ? json_object_new_string(output->focused->name) : NULL); |
130 | json_object_object_add(object, "scale", json_object_new_int(scale)); | ||
120 | } | 131 | } |
121 | 132 | ||
122 | static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { | 133 | static void ipc_json_describe_workspace(swayc_t *workspace, json_object *object) { |
diff --git a/sway/layout.c b/sway/layout.c index fc7a31b4..db9787f3 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 | 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 | 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 | 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. |
diff --git a/sway/output.c b/sway/output.c index d56a2f30..97b8a4a6 100644 --- a/sway/output.c +++ b/sway/output.c | |||
@@ -5,6 +5,13 @@ | |||
5 | #include "log.h" | 5 | #include "log.h" |
6 | #include "list.h" | 6 | #include "list.h" |
7 | 7 | ||
8 | void output_get_scaled_size(wlc_handle handle, struct wlc_size *size) { | ||
9 | *size = *wlc_output_get_resolution(handle); | ||
10 | uint32_t scale = wlc_output_get_scale(handle); | ||
11 | size->w /= scale; | ||
12 | size->h /= scale; | ||
13 | } | ||
14 | |||
8 | swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos) { | 15 | swayc_t *output_by_name(const char* name, const struct wlc_point *abs_pos) { |
9 | if (strcasecmp(name, "left") == 0) { | 16 | if (strcasecmp(name, "left") == 0) { |
10 | return swayc_adjacent_output(NULL, MOVE_LEFT, abs_pos, true); | 17 | return swayc_adjacent_output(NULL, MOVE_LEFT, abs_pos, true); |