mirror of
https://github.com/labwc/labwc.git
synced 2025-10-31 22:25:34 -04:00
Add view_move()
This commit is contained in:
parent
c646343c1d
commit
cb44f047f3
6 changed files with 31 additions and 9 deletions
|
|
@ -145,6 +145,7 @@ struct view_impl {
|
||||||
void (*for_each_surface)(struct view *view,
|
void (*for_each_surface)(struct view *view,
|
||||||
wlr_surface_iterator_func_t iterator, void *data);
|
wlr_surface_iterator_func_t iterator, void *data);
|
||||||
void (*map)(struct view *view);
|
void (*map)(struct view *view);
|
||||||
|
void (*move)(struct view *view, double x, double y);
|
||||||
void (*unmap)(struct view *view);
|
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_get_surface_geometry(struct view *view);
|
||||||
struct wlr_box view_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_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_minimize(struct view *view);
|
||||||
void view_unminimize(struct view *view);
|
void view_unminimize(struct view *view);
|
||||||
void view_for_each_surface(struct view *view,
|
void view_for_each_surface(struct view *view,
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ project(
|
||||||
add_project_arguments(
|
add_project_arguments(
|
||||||
[
|
[
|
||||||
'-DWLR_USE_UNSTABLE',
|
'-DWLR_USE_UNSTABLE',
|
||||||
|
'-Wno-enum-compare',
|
||||||
],
|
],
|
||||||
language: 'c',
|
language: 'c',
|
||||||
)
|
)
|
||||||
|
|
|
||||||
12
src/cursor.c
12
src/cursor.c
|
|
@ -1,3 +1,4 @@
|
||||||
|
#include <assert.h>
|
||||||
#include "labwc.h"
|
#include "labwc.h"
|
||||||
#include "menu/menu.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. */
|
/* Move the grabbed view to the new position. */
|
||||||
double dx = server->seat.cursor->x - server->grab_x;
|
double dx = server->seat.cursor->x - server->grab_x;
|
||||||
double dy = server->seat.cursor->y - server->grab_y;
|
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;
|
struct view *view = server->grabbed_view;
|
||||||
wlr_xwayland_surface_configure(view->xwayland_surface, view->x, view->y,
|
assert(view);
|
||||||
view->xwayland_surface->width,
|
view->impl->move(view, server->grab_box.x + dx, server->grab_box.y + dy);
|
||||||
view->xwayland_surface->height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MIN_VIEW_WIDTH (100)
|
#define MIN_VIEW_WIDTH (100)
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,12 @@ view_move_resize(struct view *view, struct wlr_box geo)
|
||||||
view->impl->configure(view, geo);
|
view->impl->configure(view, geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
view_move(struct view *view, double x, double y)
|
||||||
|
{
|
||||||
|
view->impl->move(view, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_minimize(struct view *view)
|
view_minimize(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -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
|
static void
|
||||||
xdg_toplevel_view_close(struct view *view)
|
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,
|
.close = xdg_toplevel_view_close,
|
||||||
.for_each_surface = xdg_toplevel_view_for_each_surface,
|
.for_each_surface = xdg_toplevel_view_for_each_surface,
|
||||||
.map = xdg_toplevel_view_map,
|
.map = xdg_toplevel_view_map,
|
||||||
|
.move = xdg_toplevel_view_move,
|
||||||
.unmap = xdg_toplevel_view_unmap,
|
.unmap = xdg_toplevel_view_unmap,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,16 @@ configure(struct view *view, struct wlr_box geo)
|
||||||
(uint16_t)geo.height);
|
(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
|
static void
|
||||||
_close(struct view *view)
|
_close(struct view *view)
|
||||||
{
|
{
|
||||||
|
|
@ -144,6 +154,7 @@ static const struct view_impl xwl_view_impl = {
|
||||||
.close = _close,
|
.close = _close,
|
||||||
.for_each_surface = for_each_surface,
|
.for_each_surface = for_each_surface,
|
||||||
.map = map,
|
.map = map,
|
||||||
|
.move = move,
|
||||||
.unmap = unmap,
|
.unmap = unmap,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue