summaryrefslogtreecommitdiff
path: root/lib/liboda/src/window.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-08-04 02:38:09 -0400
committerIan Moffett <ian@osmora.org>2025-08-04 02:40:55 -0400
commitafb0d03fa58685ad4ae4feb609124121e61b8c27 (patch)
treefa9f829b446dea3793c3dd255ea7142e43a4f7a7 /lib/liboda/src/window.c
parent73ea756a08dfaeabda30158cb8a64dc2bcbcd8dc (diff)
liboda: Add oda_movewin()expt
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'lib/liboda/src/window.c')
-rw-r--r--lib/liboda/src/window.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/liboda/src/window.c b/lib/liboda/src/window.c
index 8e91fac..216b106 100644
--- a/lib/liboda/src/window.c
+++ b/lib/liboda/src/window.c
@@ -35,6 +35,7 @@
#include <liboda/odavar.h>
#include <liboda/types.h>
#include <libgfx/gfx.h>
+#include <libgfx/draw.h>
/*
* The window cache is used to reduce how many
@@ -341,6 +342,61 @@ oda_reqwin(struct oda_wattr *params, struct oda_window **res)
}
/*
+ * Move a window to a new position on the
+ * screen.
+ *
+ * @state: ODA state pointer
+ * @params: Arguments to this function
+ */
+int
+oda_movewin(struct oda_state *state, struct oda_movewin *params)
+{
+ struct oda_window *win;
+ struct gfx_shape *wsurf;
+ struct gfx_region r;
+ odadimm_t w, h;
+ odapos_t x, y, x_f, y_f;
+ odapos_t to_x, to_y;
+ uint32_t i = 0;
+ int error;
+
+ /* Make sure arguments are valid */
+ if (state == NULL || params == NULL) {
+ return -EINVAL;
+ }
+
+ /* We need the window */
+ if ((win = params->wp) == NULL) {
+ return -EINVAL;
+ }
+
+ /* Verify state cookie */
+ if ((error = oda_cookie_verify(state)) != 0) {
+ return error;
+ }
+
+ wsurf = &win->surface;
+ to_x = params->to_x;
+ to_y = params->to_y;
+
+ r.x = wsurf->x;
+ r.y = wsurf->y;
+ r.width = wsurf->width;
+ r.height = wsurf->height;
+
+ /*
+ * We will copy the window to the new location and
+ * fill where the old window was with GFX_BLACK.
+ *
+ * TODO: Handle overlapping of windows
+ */
+ gfx_copy_region(&state->gctx, &r, to_x, to_y);
+ wsurf->x = to_x;
+ wsurf->y = to_y;
+ return 0;
+}
+
+/*
* Register a window into the current ODA state.
* Everytime a compositor requests a window, we
* must keep track of it.