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

Commit 13c16c0fd4d24757e553feef04ff3590ad583042
Parent: 31bba27e9af42c41a8323a60771331fc1ac04105
Author: mcol <mcol@posteo.net>
Date: 2021-01-28 18:54:58 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-01-28 18:54:58 +0000

grab window when moving so it doesnt get dropped by fast motion

src/cursor.c Modified

@@ -162,8 +162,12 @@
 	    }
 	}
 	wimp.cursor_mode = CURSOR_PASSTHROUGH;
+	if (wimp.grabbed_view) {
+	    wimp.grabbed_view = NULL;
+	}
 
     } else if (wimp.cursor_mode == CURSOR_MOD) {
+	bool grab = true;
 	switch (event->button) {
 	    case BTN_LEFT:
 		wimp.on_mouse_motion = wimp.on_drag1;
@@ -174,8 +178,14 @@
 	    case BTN_RIGHT:
 		wimp.on_mouse_motion = wimp.on_drag3;
 		break;
+	    default:
+		grab = false;
+	}
+	if (grab) {
+	    struct wlr_surface *surface;
+	    double sx, sy;
+	    wimp.grabbed_view = view_at(wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy);
 	}
-
 
     } else {
 	double sx, sy;

src/action.c Modified

@@ -48,11 +48,15 @@
 void move_window(void *data) {
     struct wlr_surface *surface;
     double sx, sy;
-    struct view *view = view_at(
-	wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy
-    );
-    if (!view) {
-	return;
+    struct view *view;
+
+    if (wimp.grabbed_view) {
+	view = wimp.grabbed_view;
+    } else {
+	view = view_at(wimp.cursor->x, wimp.cursor->y, &surface, &sx, &sy);
+	if (!view) {
+	    return;
+	}
     }
     struct motion motion = *(struct motion*)data;
     view->x += motion.dx;