Add view:tiled
This commit is contained in:
parent
a1716e56d7
commit
0d6965192c
4 changed files with 41 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "desktop/xdg_shell.h"
|
||||
|
||||
#include <wlr/types/wlr_xdg_shell.h>
|
||||
#include <wlr/util/edges.h>
|
||||
#include <wlr/util/log.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);
|
||||
}
|
||||
|
||||
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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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},
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue