]> git.mdlowis.com Git - proto/labwc.git/commitdiff
Add view_move()
authorJohan Malm <jgm323@gmail.com>
Wed, 23 Dec 2020 18:52:46 +0000 (18:52 +0000)
committerJohan Malm <jgm323@gmail.com>
Wed, 23 Dec 2020 18:52:46 +0000 (18:52 +0000)
include/labwc.h
meson.build
src/cursor.c
src/view.c
src/xdg.c
src/xwayland.c

index 0760bec60007f3257384bf05a13e0eff922e432b..9048fe26164b325235b8b3c0b34cab40a8a8f466 100644 (file)
@@ -145,6 +145,7 @@ struct view_impl {
        void (*for_each_surface)(struct view *view,
                wlr_surface_iterator_func_t iterator, void *data);
        void (*map)(struct view *view);
+       void (*move)(struct view *view, double x, double y);
        void (*unmap)(struct view *view);
 };
 
@@ -230,6 +231,7 @@ void xwayland_unmanaged_create(struct server *server,
 struct wlr_box view_get_surface_geometry(struct view *view);
 struct wlr_box view_geometry(struct view *view);
 void view_move_resize(struct view *view, struct wlr_box geo);
+void view_move(struct view *view, double x, double y);
 void view_minimize(struct view *view);
 void view_unminimize(struct view *view);
 void view_for_each_surface(struct view *view,
index 59f6d8c57ee31dbe25ddf091f6453b84360ade39..d72a63ee3fc34c56d90839eea3fbbbdadada03c4 100644 (file)
@@ -11,6 +11,7 @@ project(
 add_project_arguments(
   [
     '-DWLR_USE_UNSTABLE',
+    '-Wno-enum-compare',
   ],
   language: 'c',
 )
index 5ad5e7cbb8203ef7f353f2e35e887c8650ca4087..40ff39e98ae7d3bb681901c20ec6fa2914bf5e79 100644 (file)
@@ -1,3 +1,4 @@
+#include <assert.h>
 #include "labwc.h"
 #include "menu/menu.h"
 
@@ -68,17 +69,10 @@ process_cursor_move(struct server *server, uint32_t time)
        /* Move the grabbed view to the new position. */
        double dx = server->seat.cursor->x - server->grab_x;
        double dy = server->seat.cursor->y - server->grab_y;
-       server->grabbed_view->x = server->grab_box.x + dx;
-       server->grabbed_view->y = server->grab_box.y + dy;
-
-       if (server->grabbed_view->type != LAB_XWAYLAND_VIEW) {
-               return;
-       }
 
        struct view *view = server->grabbed_view;
-       wlr_xwayland_surface_configure(view->xwayland_surface, view->x, view->y,
-                                      view->xwayland_surface->width,
-                                      view->xwayland_surface->height);
+       assert(view);
+       view->impl->move(view, server->grab_box.x + dx, server->grab_box.y + dy);
 }
 
 #define MIN_VIEW_WIDTH (100)
index e3d6991abb101d64170274d6325c81d0b708e50b..a6ab8971e15e1fa3e41eeeae57c4ebbf8c2c8b86 100644 (file)
@@ -6,6 +6,12 @@ view_move_resize(struct view *view, struct wlr_box geo)
        view->impl->configure(view, geo);
 }
 
+void
+view_move(struct view *view, double x, double y)
+{
+       view->impl->move(view, x, y);
+}
+
 void
 view_minimize(struct view *view)
 {
index 62c3f36570007b3e439de9b65d7e51fd9772f0f4..180228ac5c04df265432f8f5d39ec4b9532c7272 100644 (file)
--- a/src/xdg.c
+++ b/src/xdg.c
@@ -168,6 +168,13 @@ xdg_toplevel_view_configure(struct view *view, struct wlr_box geo)
        }
 }
 
+static void
+xdg_toplevel_view_move(struct view *view, double x, double y)
+{
+       view->x = x;
+       view->y = y;
+}
+
 static void
 xdg_toplevel_view_close(struct view *view)
 {
@@ -242,6 +249,7 @@ static const struct view_impl xdg_toplevel_view_impl = {
        .close = xdg_toplevel_view_close,
        .for_each_surface = xdg_toplevel_view_for_each_surface,
        .map = xdg_toplevel_view_map,
+       .move = xdg_toplevel_view_move,
        .unmap = xdg_toplevel_view_unmap,
 };
 
index 0e8d9d14c14d63f7abc0a95b57cedc566d363514..9b2b2d49bfe0c9efb810fdc3ddd118198eb1dc57 100644 (file)
@@ -72,6 +72,16 @@ configure(struct view *view, struct wlr_box geo)
                                       (uint16_t)geo.height);
 }
 
+static void
+move(struct view *view, double x, double y)
+{
+       view->x = x;
+       view->y = y;
+       struct wlr_xwayland_surface *s = view->xwayland_surface;
+       wlr_xwayland_surface_configure(s, (int16_t)x, (int16_t)y,
+               (uint16_t)s->width, (uint16_t)s->height);
+}
+
 static void
 _close(struct view *view)
 {
@@ -144,6 +154,7 @@ static const struct view_impl xwl_view_impl = {
        .close = _close,
        .for_each_surface = for_each_surface,
        .map = map,
+       .move = move,
        .unmap = unmap,
 };