Add hidden, hide and show to views

This commit is contained in:
buffet 2019-12-31 17:31:18 +00:00
parent a107bda0be
commit 77f7d14fe1
4 changed files with 43 additions and 1 deletions

View file

@ -40,6 +40,7 @@ struct kiwmi_view {
double y;
bool mapped;
bool hidden;
};
struct kiwmi_view_impl {

View file

@ -97,7 +97,7 @@ output_frame_notify(struct wl_listener *listener, void *data)
struct kiwmi_view *view;
wl_list_for_each_reverse (view, &desktop->views, link) {
if (!view->mapped) {
if (view->hidden || !view->mapped) {
continue;
}

View file

@ -124,6 +124,10 @@ view_at(
{
struct kiwmi_view *view;
wl_list_for_each (view, &desktop->views, link) {
if (view->hidden || !view->mapped) {
continue;
}
if (surface_at(view, surface, lx, ly, sx, sy)) {
return view;
}
@ -148,6 +152,7 @@ view_create(
view->type = type;
view->impl = impl;
view->mapped = false;
view->hidden = true;
view->x = 0;
view->y = 0;

View file

@ -97,6 +97,28 @@ l_kiwmi_view_focus(lua_State *L)
return 0;
}
static int
l_kiwmi_view_hidden(lua_State *L)
{
struct kiwmi_view *view =
*(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view");
lua_pushboolean(L, view->hidden);
return 1;
}
static int
l_kiwmi_view_hide(lua_State *L)
{
struct kiwmi_view *view =
*(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view");
view->hidden = true;
return 0;
}
static int
l_kiwmi_view_move(lua_State *L)
{
@ -112,10 +134,24 @@ l_kiwmi_view_move(lua_State *L)
return 0;
}
static int
l_kiwmi_view_show(lua_State *L)
{
struct kiwmi_view *view =
*(struct kiwmi_view **)luaL_checkudata(L, 1, "kiwmi_view");
view->hidden = false;
return 0;
}
static const luaL_Reg kiwmi_view_methods[] = {
{"close", l_kiwmi_view_close},
{"focus", l_kiwmi_view_focus},
{"hidden", l_kiwmi_view_hidden},
{"hide", l_kiwmi_view_hide},
{"move", l_kiwmi_view_move},
{"show", l_kiwmi_view_show},
{NULL, NULL},
};