From 460ec217dd5e265f318b930bd30d0a3eff081f83 Mon Sep 17 00:00:00 2001 From: Charlotte Meyer Date: Tue, 31 Dec 2019 17:31:18 +0000 Subject: [PATCH] Add hidden, hide and show to views --- include/desktop/view.h | 1 + kiwmi/desktop/output.c | 2 +- kiwmi/desktop/view.c | 5 +++++ kiwmi/luak.c | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/desktop/view.h b/include/desktop/view.h index e023990..285618d 100644 --- a/include/desktop/view.h +++ b/include/desktop/view.h @@ -40,6 +40,7 @@ struct kiwmi_view { double y; bool mapped; + bool hidden; }; struct kiwmi_view_impl { diff --git a/kiwmi/desktop/output.c b/kiwmi/desktop/output.c index 958522c..2e32c2e 100644 --- a/kiwmi/desktop/output.c +++ b/kiwmi/desktop/output.c @@ -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; } diff --git a/kiwmi/desktop/view.c b/kiwmi/desktop/view.c index 709473b..df0891f 100644 --- a/kiwmi/desktop/view.c +++ b/kiwmi/desktop/view.c @@ -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; diff --git a/kiwmi/luak.c b/kiwmi/luak.c index fb7593a..7782429 100644 --- a/kiwmi/luak.c +++ b/kiwmi/luak.c @@ -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}, };