From 09bc31eaf10e96d4b20953b74898f7cc94dabf71 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Tue, 7 Jan 2020 15:10:51 +0000 Subject: [PATCH] Add view:tiled --- include/desktop/view.h | 2 ++ kiwmi/desktop/view.c | 8 ++++++++ kiwmi/desktop/xdg_shell.c | 16 ++++++++++++++++ kiwmi/luak/kiwmi_view.c | 15 +++++++++++++++ 4 files changed, 41 insertions(+) diff --git a/include/desktop/view.h b/include/desktop/view.h index e094d23..38725c2 100644 --- a/include/desktop/view.h +++ b/include/desktop/view.h @@ -55,6 +55,7 @@ struct kiwmi_view_impl { void *user_data); void (*resize)(struct kiwmi_view *view, uint32_t width, uint32_t height); void (*set_activated)(struct kiwmi_view *view, bool activated); + void (*set_tiled)(struct kiwmi_view *view, bool tiled); struct wlr_surface *(*surface_at)( struct kiwmi_view *view, double sx, @@ -70,6 +71,7 @@ void view_for_each_surface( 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); +void view_set_tiled(struct kiwmi_view *view, bool tiled); struct wlr_surface *view_surface_at( struct kiwmi_view *view, double sx, diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 5808153..7adbdda 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -47,6 +47,14 @@ view_set_activated(struct kiwmi_view *view, bool activated) } } +void +view_set_tiled(struct kiwmi_view *view, bool tiled) +{ + if (view->impl->set_tiled) { + view->impl->set_tiled(view, tiled); + } +} + struct wlr_surface * view_surface_at( struct kiwmi_view *view, diff --git a/kiwmi/desktop/xdg_shell.c b/kiwmi/desktop/xdg_shell.c index 353f4c0..c9256c9 100644 --- a/kiwmi/desktop/xdg_shell.c +++ b/kiwmi/desktop/xdg_shell.c @@ -8,6 +8,7 @@ #include "desktop/xdg_shell.h" #include +#include #include #include "desktop/desktop.h" @@ -81,6 +82,20 @@ xdg_shell_view_set_activated(struct kiwmi_view *view, bool activated) wlr_xdg_toplevel_set_activated(view->xdg_surface, activated); } +static void +xdg_shell_view_set_tiled(struct kiwmi_view *view, bool tiled) +{ + enum wlr_edges edges; + + if (tiled) { + edges = WLR_EDGE_TOP | WLR_EDGE_BOTTOM | WLR_EDGE_LEFT | WLR_EDGE_RIGHT; + } else { + edges = WLR_EDGE_NONE; + } + + wlr_xdg_toplevel_set_tiled(view->xdg_surface, edges); +} + struct wlr_surface * xdg_shell_view_surface_at( struct kiwmi_view *view, @@ -97,6 +112,7 @@ static const struct kiwmi_view_impl xdg_shell_view_impl = { .for_each_surface = xdg_shell_view_for_each_surface, .resize = xdg_shell_view_resize, .set_activated = xdg_shell_view_set_activated, + .set_tiled = xdg_shell_view_set_tiled, .surface_at = xdg_shell_view_surface_at, }; diff --git a/kiwmi/luak/kiwmi_view.c b/kiwmi/luak/kiwmi_view.c index 16e4ed3..240729d 100644 --- a/kiwmi/luak/kiwmi_view.c +++ b/kiwmi/luak/kiwmi_view.c @@ -112,6 +112,20 @@ l_kiwmi_view_show(lua_State *L) return 0; } +static int +l_kiwmi_view_tiled(lua_State *L) +{ + struct kiwmi_view *view = + *(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view"); + luaL_checktype(L, 2, LUA_TBOOLEAN); + + bool tiled = lua_toboolean(L, 2); + + view_set_tiled(view, tiled); + + return 0; +} + static const luaL_Reg kiwmi_view_methods[] = { {"close", l_kiwmi_view_close}, {"focus", l_kiwmi_view_focus}, @@ -122,6 +136,7 @@ static const luaL_Reg kiwmi_view_methods[] = { {"pos", l_kiwmi_view_pos}, {"resize", l_kiwmi_view_resize}, {"show", l_kiwmi_view_show}, + {"tiled", l_kiwmi_view_tiled}, {NULL, NULL}, };