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);
};
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,
add_project_arguments(
[
'-DWLR_USE_UNSTABLE',
+ '-Wno-enum-compare',
],
language: 'c',
)
+#include <assert.h>
#include "labwc.h"
#include "menu/menu.h"
/* 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)
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)
{
}
}
+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)
{
.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,
};
(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)
{
.close = _close,
.for_each_surface = for_each_surface,
.map = map,
+ .move = move,
.unmap = unmap,
};