Initial pass on HiDPI support
This commit is contained in:
parent
a5af3bce98
commit
6ea02f3064
|
@ -81,6 +81,7 @@ struct output_config {
|
||||||
int enabled;
|
int enabled;
|
||||||
int width, height;
|
int width, height;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
int scale;
|
||||||
char *background;
|
char *background;
|
||||||
char *background_option;
|
char *background_option;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1585,6 +1585,7 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
output->x = output->y = output->width = output->height = -1;
|
output->x = output->y = output->width = output->height = -1;
|
||||||
output->name = strdup(name);
|
output->name = strdup(name);
|
||||||
output->enabled = -1;
|
output->enabled = -1;
|
||||||
|
output->scale = 1;
|
||||||
|
|
||||||
// TODO: atoi doesn't handle invalid numbers
|
// TODO: atoi doesn't handle invalid numbers
|
||||||
|
|
||||||
|
@ -1642,6 +1643,11 @@ static struct cmd_results *cmd_output(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
output->x = x;
|
output->x = x;
|
||||||
output->y = y;
|
output->y = y;
|
||||||
|
} else if (strcasecmp(command, "scale") == 0) {
|
||||||
|
if (++i >= argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, "output", "Missing scale parameter.");
|
||||||
|
}
|
||||||
|
output->scale = atoi(argv[i]);
|
||||||
} else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) {
|
} else if (strcasecmp(command, "background") == 0 || strcasecmp(command, "bg") == 0) {
|
||||||
wordexp_t p;
|
wordexp_t p;
|
||||||
if (++i >= argc) {
|
if (++i >= argc) {
|
||||||
|
|
|
@ -867,6 +867,9 @@ void apply_output_config(struct output_config *oc, swayc_t *output) {
|
||||||
struct wlc_size new_size = { .w = oc->width, .h = oc->height };
|
struct wlc_size new_size = { .w = oc->width, .h = oc->height };
|
||||||
wlc_output_set_resolution(output->handle, &new_size);
|
wlc_output_set_resolution(output->handle, &new_size);
|
||||||
}
|
}
|
||||||
|
if (oc && oc->scale != 1) {
|
||||||
|
wlc_output_set_scale(output->handle, (int32_t)oc->scale);
|
||||||
|
}
|
||||||
|
|
||||||
// Find position for it
|
// Find position for it
|
||||||
if (oc && oc->x != -1 && oc->y != -1) {
|
if (oc && oc->x != -1 && oc->y != -1) {
|
||||||
|
|
|
@ -102,7 +102,8 @@ static void update_root_geometry() {
|
||||||
// New containers
|
// New containers
|
||||||
|
|
||||||
swayc_t *new_output(wlc_handle handle) {
|
swayc_t *new_output(wlc_handle handle) {
|
||||||
const struct wlc_size *size = wlc_output_get_resolution(handle);
|
struct wlc_size size;
|
||||||
|
wlc_output_get_scaled_size(handle, &size);
|
||||||
const char *name = wlc_output_get_name(handle);
|
const char *name = wlc_output_get_name(handle);
|
||||||
// Find current outputs to see if this already exists
|
// Find current outputs to see if this already exists
|
||||||
{
|
{
|
||||||
|
@ -148,8 +149,8 @@ swayc_t *new_output(wlc_handle handle) {
|
||||||
swayc_t *output = new_swayc(C_OUTPUT);
|
swayc_t *output = new_swayc(C_OUTPUT);
|
||||||
output->handle = handle;
|
output->handle = handle;
|
||||||
output->name = name ? strdup(name) : NULL;
|
output->name = name ? strdup(name) : NULL;
|
||||||
output->width = size->w;
|
output->width = size.w;
|
||||||
output->height = size->h;
|
output->height = size.h;
|
||||||
output->unmanaged = create_list();
|
output->unmanaged = create_list();
|
||||||
output->bg_pid = 0;
|
output->bg_pid = 0;
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,8 @@ static struct background_config *if_background_find_config(struct wl_client *cli
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct wlc_geometry compute_panel_geometry(struct panel_config *config) {
|
static struct wlc_geometry compute_panel_geometry(struct panel_config *config) {
|
||||||
const struct wlc_size resolution = *wlc_output_get_resolution(config->output);
|
struct wlc_size resolution;
|
||||||
|
wlc_output_get_scaled_size(config->output, &resolution);
|
||||||
const struct wlc_geometry *old = wlc_view_get_geometry(config->handle);
|
const struct wlc_geometry *old = wlc_view_get_geometry(config->handle);
|
||||||
struct wlc_geometry new;
|
struct wlc_geometry new;
|
||||||
|
|
||||||
|
|
|
@ -406,20 +406,21 @@ static void update_border_geometry_floating(swayc_t *c, struct wlc_geometry *geo
|
||||||
c->actual_geometry = g;
|
c->actual_geometry = g;
|
||||||
|
|
||||||
swayc_t *output = swayc_parent_by_type(c, C_OUTPUT);
|
swayc_t *output = swayc_parent_by_type(c, C_OUTPUT);
|
||||||
const struct wlc_size *res = wlc_output_get_resolution(output->handle);
|
struct wlc_size res;
|
||||||
|
wlc_output_get_scaled_size(output->handle, &res);
|
||||||
|
|
||||||
switch (c->border_type) {
|
switch (c->border_type) {
|
||||||
case B_NONE:
|
case B_NONE:
|
||||||
break;
|
break;
|
||||||
case B_PIXEL:
|
case B_PIXEL:
|
||||||
adjust_border_geometry(c, &g, res, c->border_thickness,
|
adjust_border_geometry(c, &g, &res, c->border_thickness,
|
||||||
c->border_thickness, c->border_thickness, c->border_thickness);
|
c->border_thickness, c->border_thickness, c->border_thickness);
|
||||||
break;
|
break;
|
||||||
case B_NORMAL:
|
case B_NORMAL:
|
||||||
{
|
{
|
||||||
int title_bar_height = config->font_height + 4; // borders + padding
|
int title_bar_height = config->font_height + 4; // borders + padding
|
||||||
|
|
||||||
adjust_border_geometry(c, &g, res, c->border_thickness,
|
adjust_border_geometry(c, &g, &res, c->border_thickness,
|
||||||
c->border_thickness, title_bar_height, c->border_thickness);
|
c->border_thickness, title_bar_height, c->border_thickness);
|
||||||
|
|
||||||
struct wlc_geometry title_bar = {
|
struct wlc_geometry title_bar = {
|
||||||
|
@ -545,13 +546,15 @@ void update_geometry(swayc_t *container) {
|
||||||
gap = update_gap_geometry(container, &geometry);
|
gap = update_gap_geometry(container, &geometry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
|
||||||
|
struct wlc_size size;
|
||||||
|
wlc_output_get_scaled_size(output->handle, &size);
|
||||||
|
|
||||||
if (swayc_is_fullscreen(container)) {
|
if (swayc_is_fullscreen(container)) {
|
||||||
swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
|
|
||||||
const struct wlc_size *size = wlc_output_get_resolution(output->handle);
|
|
||||||
geometry.origin.x = 0;
|
geometry.origin.x = 0;
|
||||||
geometry.origin.y = 0;
|
geometry.origin.y = 0;
|
||||||
geometry.size.w = size->w;
|
geometry.size.w = size.w;
|
||||||
geometry.size.h = size->h;
|
geometry.size.h = size.h;
|
||||||
if (op->focused == workspace) {
|
if (op->focused == workspace) {
|
||||||
wlc_view_bring_to_front(container->handle);
|
wlc_view_bring_to_front(container->handle);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +579,9 @@ void update_geometry(swayc_t *container) {
|
||||||
border_left = 0;
|
border_left = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geometry.origin.x + geometry.size.w == workspace->x + workspace->width) {
|
if (geometry.origin.x + geometry.size.w == size.w ||
|
||||||
|
geometry.size.w == container->x + container->width) {
|
||||||
|
// should work for swaybar at right
|
||||||
border_right = 0;
|
border_right = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -586,7 +591,9 @@ void update_geometry(swayc_t *container) {
|
||||||
border_top = 0;
|
border_top = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (geometry.origin.y + geometry.size.h == workspace->y + workspace->height) {
|
if (geometry.origin.y + geometry.size.h == size.h ||
|
||||||
|
geometry.size.h == container->y + container->height) {
|
||||||
|
// this works for swaybar at bottom
|
||||||
border_bottom = 0;
|
border_bottom = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -721,7 +728,8 @@ static void arrange_windows_r(swayc_t *container, double width, double height) {
|
||||||
return;
|
return;
|
||||||
case C_OUTPUT:
|
case C_OUTPUT:
|
||||||
{
|
{
|
||||||
struct wlc_size resolution = *wlc_output_get_resolution(container->handle);
|
struct wlc_size resolution;
|
||||||
|
wlc_output_get_scaled_size(container->handle, &resolution);
|
||||||
width = resolution.w; height = resolution.h;
|
width = resolution.w; height = resolution.h;
|
||||||
// output must have correct size due to e.g. seamless mouse,
|
// output must have correct size due to e.g. seamless mouse,
|
||||||
// but a workspace might be smaller depending on panels.
|
// but a workspace might be smaller depending on panels.
|
||||||
|
|
Loading…
Reference in a new issue