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

Commit 626d7e0695f4a3c7fba7c7861a5a2178e9e63552
Parent: 881484955c2a528e79832f6360c6ab1658c1327f
Author: mcol <mcol@posteo.net>
Date: 2021-02-13 14:18:21 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-02-13 14:18:21 +0000

centre cursor position when resetting zoom

Closes #32

src/action.c Modified

@@ -178,28 +178,6 @@
 }
 
 
-void reset_zoom(void *data) {
-    struct desk *desk = wimp.current_desk;
-    double f = 1 / desk->zoom;
-    if (f == 1) {
-	return;
-    }
-    unfullscreen();
-    struct wlr_box *extents = wlr_output_layout_get_box(wimp.output_layout, NULL);
-    double fx = extents->width * (f - 1) / 2;
-    double fy = extents->height * (f - 1) / 2;
-    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;
-    desk->zoom = 1;
-    damage_all_outputs();
-}
-
-
 void zoom(void *data) {
     /* Passed value (data) is the percentage step (+ve or -ve) */
     struct desk *desk = wimp.current_desk;
@@ -226,6 +204,12 @@
 }
 
 
+void reset_zoom(void *data) {
+    double dz = 100 * 1 / wimp.current_desk->zoom - 100;
+    zoom(&dz);
+}
+
+
 void zoom_scroll(void *data) {
     struct motion motion = *(struct motion*)data;
     double dz = - motion.dx - motion.dy;