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

Commit 8486ce04ddfa601cef2aba7284b08c2a98e7993c
Parent: 9655c265f61a092b009d88562af8daa708cc5289
Author: mcol <mcol@posteo.net>
Date: 2020-11-08 21:05:28 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2020-11-08 21:05:28 +0000

use desk.{x,y} to calculate position of views

src/types.h Modified

@@ -59,7 +59,7 @@
     struct wl_listener destroy_listener;
     struct wl_listener request_move_listener;
     struct wl_listener request_resize_listener;
-    int x, y;
+    double x, y;
 };
 
 struct keyboard {
@@ -75,7 +75,7 @@
     struct server *server;
     struct wl_list views;
     float background[4];
-    int x, y;
+    double x, y;
     int index;
 };
 

src/output.c Modified

@@ -12,23 +12,29 @@
     struct render_data *rdata = data;
     struct view *view = rdata->view;
     struct wlr_output *output = rdata->output;
+    struct server *server = view->server;
 
     struct wlr_texture *texture = wlr_surface_get_texture(surface);
     if (texture == NULL) {
 	return;
     }
 
-    // get output-relative coordinates
-    double ox = 0, oy = 0;
-    wlr_output_layout_output_coords(
-	view->server->output_layout, output, &ox, &oy
-    );
-    ox += view->x + sx, oy += view->y + sy;
+    double x = 0, y = 0;
+    struct wlr_output_layout_output *ol;
+    wl_list_for_each(ol, &server->output_layout->outputs, link) {
+	if (ol->output == output) {
+	    x = - (double)ol->x;
+	    y = - (double)ol->y;
+	    break;
+	}
+    }
+    x += view->x + sx - server->current_desk->x;
+    y += view->y + sy - server->current_desk->y;
 
     // scale for HiDPI
     struct wlr_box box = {
-	.x = ox * output->scale,
-	.y = oy * output->scale,
+	.x = x * output->scale,
+	.y = y * output->scale,
 	.width = surface->current.width * output->scale,
 	.height = surface->current.height * output->scale,
     };

src/input.c Modified

@@ -210,6 +210,14 @@
 	next_desk(server);
 	break;
 
+    case XKB_KEY_Up:
+	server->current_desk->y -= 10;
+	break;
+
+    case XKB_KEY_Down:
+	server->current_desk->y += 10;
+	break;
+
     default:
 	return false;
     }

src/desk.c Modified

@@ -13,6 +13,7 @@
     desk->server = server;
     wl_list_init(&desk->views);
     assign_colour("#5D479D", desk->background);
+    desk->x = desk->y = 0;
     desk->index = num_desks;
     num_desks++;
 }