Commit f1ce42f997455f6ade987ed637de56374848ab61 Parent: 97cc262356e06759da4c61b2364590182934320c Author: mcol <mcol@posteo.net> Date: 2020-11-13 11:11:23 +0000 Committer: mcol <mcol@posteo.net> Committed: 2020-11-13 11:11:23 +0000 add min and max zoom bounds
src/types.h Modified
@@ -52,6 +52,7 @@ double grab_x, grab_y; struct wlr_box grab_geobox; uint32_t resize_edges; + double zoom_min, zoom_max; }; struct view {
src/desk.c Modified
@@ -78,10 +78,17 @@ void zoom_desk(struct desk *desk, int dir) { /* dir > 0 ? zoom in : zoom out */ + struct server *server = desk->server; double f = dir > 0 ? 1.015 : 1/1.015; + if ( + (f > 1 && desk->zoom >= server->zoom_max) || + (f < 1 && desk->zoom <= server->zoom_min) + ) { + return; + } desk->zoom *= f; - double fx = desk->server->cursor->x * (f - 1) / desk->zoom; - double fy = desk->server->cursor->y * (f - 1) / desk->zoom; + double fx = server->cursor->x * (f - 1) / desk->zoom; + double fy = server->cursor->y * (f - 1) / desk->zoom; struct view *view; wl_list_for_each(view, &desk->views, link) { view->x -= fx;
src/config.c Modified
@@ -10,6 +10,8 @@ #include "desk.h" #include "types.h" +#define is_decimal(s) (strspn(s, "0123456789.") == strlen(s)) + void assign_colour(char *hex, float dest[4]) { if (strlen(hex) != 7 || hex[0] != '#') { @@ -86,6 +88,8 @@ add_desk(server); server->current_desk = wl_container_of(server->desks.next, server->current_desk, link); + server->zoom_min = 0.5; + server->zoom_max = 3; } @@ -123,7 +127,14 @@ if ((s = strtok(NULL, " \t\n\r"))) { set_wallpaper(server, s); } - } else if (!strcasecmp(s, "modifier")) { + } else if (!strcasecmp(s, "zoom_min")) { + if ((s = strtok(NULL, " \t\n\r")) && is_decimal(s)) { + server->zoom_min = strtod(s, NULL); + } + } else if (!strcasecmp(s, "zoom_max")) { + if ((s = strtok(NULL, " \t\n\r")) && is_decimal(s)) { + server->zoom_max = strtod(s, NULL); + } } } fclose(fd);
deskwm.conf Modified
@@ -10,7 +10,12 @@ # example deskwm configuration file # # All possible options are described here. Lines that start with '#' are -# ignored. +# ignored. Options that are commented out contain their default values. + + +# These specify the min and max magnification bounds when zooming. +#zoom_min 0.5 +#zoom_max 3 ## Configure desks