Add view:tiled

This commit is contained in:
buffet 2020-01-07 15:10:51 +00:00
parent 192dfca0ca
commit 09bc31eaf1
4 changed files with 41 additions and 0 deletions

View file

@ -55,6 +55,7 @@ struct kiwmi_view_impl {
void *user_data); void *user_data);
void (*resize)(struct kiwmi_view *view, uint32_t width, uint32_t height); void (*resize)(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_tiled)(struct kiwmi_view *view, bool tiled);
struct wlr_surface *(*surface_at)( struct wlr_surface *(*surface_at)(
struct kiwmi_view *view, struct kiwmi_view *view,
double sx, double sx,
@ -70,6 +71,7 @@ void view_for_each_surface(
void *user_data); void *user_data);
void view_resize(struct kiwmi_view *view, uint32_t width, uint32_t height); 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_activated(struct kiwmi_view *view, bool activated);
void view_set_tiled(struct kiwmi_view *view, bool tiled);
struct wlr_surface *view_surface_at( struct wlr_surface *view_surface_at(
struct kiwmi_view *view, struct kiwmi_view *view,
double sx, double sx,

View file

@ -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 * struct wlr_surface *
view_surface_at( view_surface_at(
struct kiwmi_view *view, struct kiwmi_view *view,

View file

@ -8,6 +8,7 @@
#include "desktop/xdg_shell.h" #include "desktop/xdg_shell.h"
#include <wlr/types/wlr_xdg_shell.h> #include <wlr/types/wlr_xdg_shell.h>
#include <wlr/util/edges.h>
#include <wlr/util/log.h> #include <wlr/util/log.h>
#include "desktop/desktop.h" #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); 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 * struct wlr_surface *
xdg_shell_view_surface_at( xdg_shell_view_surface_at(
struct kiwmi_view *view, 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, .for_each_surface = xdg_shell_view_for_each_surface,
.resize = xdg_shell_view_resize, .resize = xdg_shell_view_resize,
.set_activated = xdg_shell_view_set_activated, .set_activated = xdg_shell_view_set_activated,
.set_tiled = xdg_shell_view_set_tiled,
.surface_at = xdg_shell_view_surface_at, .surface_at = xdg_shell_view_surface_at,
}; };

View file

@ -112,6 +112,20 @@ l_kiwmi_view_show(lua_State *L)
return 0; 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[] = { static const luaL_Reg kiwmi_view_methods[] = {
{"close", l_kiwmi_view_close}, {"close", l_kiwmi_view_close},
{"focus", l_kiwmi_view_focus}, {"focus", l_kiwmi_view_focus},
@ -122,6 +136,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},
{"tiled", l_kiwmi_view_tiled},
{NULL, NULL}, {NULL, NULL},
}; };