Add view:size
This commit is contained in:
parent
866a8a2cad
commit
6fb13b2871
4 changed files with 37 additions and 0 deletions
|
@ -54,6 +54,7 @@ struct kiwmi_view_impl {
|
||||||
struct kiwmi_view *view,
|
struct kiwmi_view *view,
|
||||||
wlr_surface_iterator_func_t iterator,
|
wlr_surface_iterator_func_t iterator,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
void (*get_size)(struct kiwmi_view *view, uint32_t *width, uint32_t *height);
|
||||||
void (*set_activated)(struct kiwmi_view *view, bool activated);
|
void (*set_activated)(struct kiwmi_view *view, bool activated);
|
||||||
void (*set_size)(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
void (*set_size)(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
||||||
void (*set_tiled)(struct kiwmi_view *view, enum wlr_edges edges);
|
void (*set_tiled)(struct kiwmi_view *view, enum wlr_edges edges);
|
||||||
|
@ -70,6 +71,7 @@ void view_for_each_surface(
|
||||||
struct kiwmi_view *view,
|
struct kiwmi_view *view,
|
||||||
wlr_surface_iterator_func_t iterator,
|
wlr_surface_iterator_func_t iterator,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
void view_get_size(struct kiwmi_view *view, uint32_t *width, uint32_t *height);
|
||||||
void view_set_activated(struct kiwmi_view *view, bool activated);
|
void view_set_activated(struct kiwmi_view *view, bool activated);
|
||||||
void view_set_size(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
void view_set_size(struct kiwmi_view *view, uint32_t width, uint32_t height);
|
||||||
void view_set_tiled(struct kiwmi_view *view, enum wlr_edges edges);
|
void view_set_tiled(struct kiwmi_view *view, enum wlr_edges edges);
|
||||||
|
|
|
@ -31,6 +31,14 @@ view_for_each_surface(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
view_get_size(struct kiwmi_view *view, uint32_t *width, uint32_t *height)
|
||||||
|
{
|
||||||
|
if (view->impl->get_size) {
|
||||||
|
view->impl->get_size(view, width, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
view_set_activated(struct kiwmi_view *view, bool activated)
|
view_set_activated(struct kiwmi_view *view, bool activated)
|
||||||
{
|
{
|
||||||
|
|
|
@ -70,6 +70,15 @@ xdg_shell_view_for_each_surface(
|
||||||
wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, user_data);
|
wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xdg_shell_view_get_size(struct kiwmi_view *view, uint32_t *width, uint32_t *height)
|
||||||
|
{
|
||||||
|
struct wlr_box *geom = &view->xdg_surface->geometry;
|
||||||
|
|
||||||
|
*width = geom->width;
|
||||||
|
*height = geom->height;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated)
|
xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated)
|
||||||
{
|
{
|
||||||
|
@ -105,6 +114,7 @@ xdg_shell_view_surface_at(
|
||||||
static const struct kiwmi_view_impl xdg_shell_view_impl = {
|
static const struct kiwmi_view_impl xdg_shell_view_impl = {
|
||||||
.close = xdg_shell_view_close,
|
.close = xdg_shell_view_close,
|
||||||
.for_each_surface = xdg_shell_view_for_each_surface,
|
.for_each_surface = xdg_shell_view_for_each_surface,
|
||||||
|
.get_size = xdg_shell_view_get_size,
|
||||||
.set_activated = xdg_shell_view_set_activated,
|
.set_activated = xdg_shell_view_set_activated,
|
||||||
.set_size = xdg_shell_view_set_size,
|
.set_size = xdg_shell_view_set_size,
|
||||||
.set_tiled = xdg_shell_view_set_tiled,
|
.set_tiled = xdg_shell_view_set_tiled,
|
||||||
|
|
|
@ -115,6 +115,22 @@ l_kiwmi_view_show(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
l_kiwmi_view_size(lua_State *L)
|
||||||
|
{
|
||||||
|
struct kiwmi_view *view =
|
||||||
|
*(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view");
|
||||||
|
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
view_get_size(view, &width, &height);
|
||||||
|
|
||||||
|
lua_pushinteger(L, width);
|
||||||
|
lua_pushinteger(L, height);
|
||||||
|
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
l_kiwmi_view_tiled(lua_State *L)
|
l_kiwmi_view_tiled(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -182,6 +198,7 @@ static const luaL_Reg kiwmi_view_methods[] = {
|
||||||
{"pos", l_kiwmi_view_pos},
|
{"pos", l_kiwmi_view_pos},
|
||||||
{"resize", l_kiwmi_view_resize},
|
{"resize", l_kiwmi_view_resize},
|
||||||
{"show", l_kiwmi_view_show},
|
{"show", l_kiwmi_view_show},
|
||||||
|
{"size", l_kiwmi_view_size},
|
||||||
{"tiled", l_kiwmi_view_tiled},
|
{"tiled", l_kiwmi_view_tiled},
|
||||||
{NULL, NULL},
|
{NULL, NULL},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue