diff --git a/include/desktop/view.h b/include/desktop/view.h index d1e7b33..e094d23 100644 --- a/include/desktop/view.h +++ b/include/desktop/view.h @@ -53,6 +53,7 @@ struct kiwmi_view_impl { struct kiwmi_view *view, wlr_surface_iterator_func_t iterator, void *user_data); + void (*resize)(struct kiwmi_view *view, uint32_t width, uint32_t height); void (*set_activated)(struct kiwmi_view *view, bool activated); struct wlr_surface *(*surface_at)( struct kiwmi_view *view, @@ -67,6 +68,7 @@ void view_for_each_surface( struct kiwmi_view *view, wlr_surface_iterator_func_t iterator, void *user_data); +void view_resize(struct kiwmi_view *view, uint32_t width, uint32_t height); void view_set_activated(struct kiwmi_view *view, bool activated); struct wlr_surface *view_surface_at( struct kiwmi_view *view, diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 349d715..5808153 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -31,6 +31,14 @@ view_for_each_surface( } } +void +view_resize(struct kiwmi_view *view, uint32_t width, uint32_t height) +{ + if (view->impl->resize) { + view->impl->resize(view, width, height); + } +} + void view_set_activated(struct kiwmi_view *view, bool activated) { diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index 3c7851c..353f4c0 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -69,6 +69,12 @@ xdg_shell_view_for_each_surface( wlr_xdg_surface_for_each_surface(view->xdg_surface, iterator, user_data); } +static void +xdg_shell_view_resize(struct kiwmi_view *view, uint32_t width, uint32_t height) +{ + wlr_xdg_toplevel_set_size(view->xdg_surface, width, height); +} + static void xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated) { @@ -89,6 +95,7 @@ xdg_shell_view_surface_at( static const struct kiwmi_view_impl xdg_shell_view_impl = { .close = xdg_shell_view_close, .for_each_surface = xdg_shell_view_for_each_surface, + .resize = xdg_shell_view_resize, .set_activated = xdg_shell_view_set_activated, .surface_at = xdg_shell_view_surface_at, }; diff --git a/kiwmi/luak/kiwmi_view.c b/kiwmi/luak/kiwmi_view.c index e142368..16e4ed3 100644 --- a/kiwmi/luak/kiwmi_view.c +++ b/kiwmi/luak/kiwmi_view.c @@ -73,6 +73,34 @@ l_kiwmi_view_move(lua_State *L) return 0; } +static int +l_kiwmi_view_pos(lua_State *L) +{ + struct kiwmi_view *view = + *(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view"); + + lua_pushnumber(L, view->x); + lua_pushnumber(L, view->y); + + return 2; +} + +static int +l_kiwmi_view_resize(lua_State *L) +{ + struct kiwmi_view *view = + *(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view"); + luaL_checktype(L, 2, LUA_TNUMBER); // w + luaL_checktype(L, 3, LUA_TNUMBER); // h + + double w = lua_tonumber(L, 2); + double h = lua_tonumber(L, 3); + + view_resize(view, w, h); + + return 0; +} + static int l_kiwmi_view_show(lua_State *L) { @@ -91,6 +119,8 @@ static const luaL_Reg kiwmi_view_methods[] = { {"hide", l_kiwmi_view_hide}, {"move", l_kiwmi_view_move}, {"on", luaK_callback_register_dispatch}, + {"pos", l_kiwmi_view_pos}, + {"resize", l_kiwmi_view_resize}, {"show", l_kiwmi_view_show}, {NULL, NULL}, };