gimp but for windows: a wayland compositor
git clone https://github.com/m-col/wimp
Files | Refs | Readme

Commit 6a4418e222bb4b800264836449c4a24a01261c3c
Parent: bc4199994ead3c8b05d3891258294298ba958dcb
Author: mcol <mcol@posteo.net>
Date: 2020-11-12 22:21:06 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-11-12 22:21:06 +0000

translate windows relative to cursor when zooming, and zoom wallpaper too

src/output.c Modified

@@ -65,17 +65,22 @@
     }
 
     int width, height;
+    double zoom = desk->zoom;
     wlr_output_effective_resolution(output->wlr_output, &width, &height);
     wlr_renderer_begin(renderer, width, height);
     wlr_renderer_clear(renderer, desk->background);
+
+    // paint wallpaper
     struct wallpaper *wallpaper = desk->wallpaper;
     if (wallpaper != NULL) {
 	int wh = wallpaper->height;
 	int ww = wallpaper->width;
-	for (int x = ((int)desk->panned_x % ww) - ww; x < width; x += ww) {
-	    for (int y = ((int)desk->panned_y % wh) - wh; y < height; y += wh) {
-		wlr_render_texture(renderer, wallpaper->texture,
-		    output->wlr_output->transform_matrix, x, y, 1.0f);
+	float mat[9];
+	memcpy(mat, output->wlr_output->transform_matrix, 9 * sizeof(float));
+	wlr_matrix_scale(mat, zoom, zoom);
+	for (int x = ((int)desk->panned_x % ww) - ww; x < width / zoom; x += ww) {
+	    for (int y = ((int)desk->panned_y % wh) - wh; y < height / zoom; y += wh) {
+		wlr_render_texture(renderer, wallpaper->texture, mat, x, y, 1.0f);
 	    }
 	}
     }
@@ -87,7 +92,7 @@
 	    .view = view,
 	    .renderer = renderer,
 	    .when = &now,
-	    .zoom = desk->zoom,
+	    .zoom = zoom,
 	};
 	wlr_xdg_surface_for_each_surface(
 	    view->surface, render_surface, &rdata

src/desk.c Modified

@@ -80,4 +80,13 @@
     /* dir > 0 ? zoom in : zoom out */
     double f = dir > 0 ? 1.015 : 1/1.015;
     desk->zoom *= f;
+    double fx = desk->server->cursor->x * (f - 1) / desk->zoom;
+    double fy = desk->server->cursor->y * (f - 1) / desk->zoom;
+    struct view *view;
+    wl_list_for_each(view, &desk->views, link) {
+	view->x -= fx;
+	view->y -= fy;
+    }
+    desk->panned_x -= fx;
+    desk->panned_y -= fy;
 }