tinyds: Place toplevel surfaces on random position 27/279827/1
authorSeunghun Lee <shiin.lee@samsung.com>
Tue, 16 Aug 2022 10:14:03 +0000 (19:14 +0900)
committerTizen Window System <tizen.windowsystem@gmail.com>
Thu, 18 Aug 2022 07:37:50 +0000 (16:37 +0900)
This is to make drag and drop test easier.

Change-Id: I11d8da198a42398e11c21b9901db3952f3daef59

examples/tinyds.c

index cdadfac..0c2e3f0 100644 (file)
@@ -128,6 +128,7 @@ struct tinyds_view
 
     int x, y;
     bool mapped;
+    bool placed;
 };
 
 static bool server_init(struct tinyds_server *server,
@@ -1093,8 +1094,22 @@ static void
 view_handle_surface_commit(struct wl_listener *listener, void *data)
 {
     struct tinyds_view *view;
+    struct ds_buffer *buffer;
+    int w = 0, h = 0;
 
     view = wl_container_of(listener, view, surface_commit);
+
+    buffer = ds_surface_get_buffer(
+            ds_xdg_surface_get_surface(view->xdg_surface));
+    if (!view->placed && buffer) {
+        view->placed = true;
+
+        ds_buffer_get_size(buffer, &w, &h);
+
+        view->x = rand() % (OUTPUT_WIDTH - w);
+        view->y = rand() % (OUTPUT_HEIGHT - h);
+    }
+
     output_damage(view->server->output);
 }
 
@@ -1115,7 +1130,7 @@ view_composite(struct tinyds_view *view, pixman_image_t *dst_image)
             src_image,
             NULL,
             dst_image,
-            0, 0, 0, 0, 0, 0,
+            0, 0, 0, 0, view->x, view->y,
             pixman_image_get_width(src_image),
             pixman_image_get_height(src_image));
     pixman_image_unref(src_image);