Skip to content
Myr

main: hidpi: config values are absolute

Before adoption: this commit came in with the history the project adopted, so no landing records it.

That is, instead of scaling up everything, use the configuration values as is. This allows the user to, for example, configure a 1px border also on a HiDPI screen. Now, the surface width/height, must then be *divided* by the scaling factor since normally, the surface geometry is absolute, and the rest is scaled. We do the opposite.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent a61eb3e · Browse files · 1 file+19 added−18 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+19 added−18 removed

  • other:+19 added−18 removed

1 file+19 added−18 removed

modified:main.c+19 added-18 removed
955 unmodified lines
956commit_buffer(struct context *c, struct buffer *buf)957{958 assert(buf->busy);959960 const int scale = c->wl.monitor->scale;961 wl_surface_set_buffer_scale(c->wl.surface, scale);960 wl_surface_set_buffer_scale(c->wl.surface, c->wl.monitor->scale);961 wl_surface_attach(c->wl.surface, buf->wl_buf, 0, 0);963 wl_surface_damage(c->wl.surface, 0, 0, scale * buf->width, scale * buf->height);962 wl_surface_damage(c->wl.surface, 0, 0, buf->width, buf->height);963964 struct wl_callback *cb = wl_surface_frame(c->wl.surface);965 wl_callback_add_listener(cb, &frame_listener, c);966
18 unmodified lines
985static void986refresh(struct context *c)987{988 LOG_DBG("refresh");990 const int scale = c->wl.monitor->scale;989992 struct buffer *buf = shm_get_buffer(993 c->wl.shm, scale * c->width, scale * c->height);990 struct buffer *buf = shm_get_buffer(c->wl.shm, c->width, c->height);991992 /* Background + border */993 render_background(c->render, buf);994
179 unmodified lines
1174 .pipe_read_fd = repeat_pipe_fds[0],1175 .pipe_write_fd = repeat_pipe_fds[1],1176 .cmd = REPEAT_STOP,1177 },1181 .width = width,1182 .height = height,1178 };11791180 mtx_init(&c.repeat.mutex, mtx_plain);1181 cnd_init(&c.repeat.cond);
102 unmodified lines
1284 LOG_ERR("failed to create layer shell surface");1285 goto out;1286 }12871288 const int scale = c.wl.monitor->scale;12891290 width /= scale; width *= scale;1291 height /= scale; height *= scale;12921293 c.width = width;1294 c.height = height;12951293 zwlr_layer_surface_v1_set_size(c.wl.layer_surface, width, height);1296 zwlr_layer_surface_v1_set_size(c.wl.layer_surface, width / scale, height / scale);1297 zwlr_layer_surface_v1_set_keyboard_interactivity(c.wl.layer_surface, 1);12981299 zwlr_layer_surface_v1_add_listener(1300 c.wl.layer_surface, &layer_surface_listener, &c.wl);
1 unmodified line
1302 /* Trigger a 'configure' event, after which we'll have the width */1303 wl_surface_commit(c.wl.surface);1304 wl_display_roundtrip(c.wl.display);13051303 const int scale = c.wl.monitor->scale;1304 const double line_height = scale * 2 * y_margin + fextents.height;1305 max_matches = (scale * height - scale * 2 * border_width - line_height) /1306 line_height;1306 const double line_height = 2 * y_margin + fextents.height;1307 max_matches = (height - 2 * border_width - line_height) / line_height;1308 LOG_DBG("max matches: %d", max_matches);13091310 struct options options = {1310 .width = scale * c.width,1311 .height = scale * c.height,1312 .x_margin = scale * x_margin,1313 .y_margin = scale * y_margin,1314 .border_size = scale * border_width,1311 .width = c.width,1312 .height = c.height,1313 .x_margin = x_margin,1314 .y_margin = y_margin,1315 .border_size = border_width,1316 .background_color = hex_to_rgba(background),1317 .border_color = hex_to_rgba(border_color),1318 .text_color = hex_to_rgba(text_color),1319 .match_color = hex_to_rgba(match_color),
110 unmodified lines