diff --git a/include/luak/kiwmi_renderer.h b/include/luak/kiwmi_renderer.h deleted file mode 100644 index 0f722cf..0000000 --- a/include/luak/kiwmi_renderer.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c), Charlotte Meyer - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#ifndef KIWMI_LUAK_KIWMI_RENDERER_H -#define KIWMI_LUAK_KIWMI_RENDERER_H - -#include - -int luaK_kiwmi_renderer_new(lua_State *L); -int luaK_kiwmi_renderer_register(lua_State *L); - -#endif /* KIWMI_LUAK_KIWMI_RENDERER_H */ diff --git a/kiwmi/luak/kiwmi_output.c b/kiwmi/luak/kiwmi_output.c index ec38f46..7c8c391 100644 --- a/kiwmi/luak/kiwmi_output.c +++ b/kiwmi/luak/kiwmi_output.c @@ -98,23 +98,6 @@ l_kiwmi_output_pos(lua_State *L) return 2; } -static int -l_kiwmi_output_redraw(lua_State *L) -{ - struct kiwmi_object *obj = - *(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_output"); - - if (!obj->valid) { - return luaL_error(L, "kiwmi_output no longer valid"); - } - - struct kiwmi_output *output = obj->object; - - output_damage(output); - - return 0; -} - static int l_kiwmi_output_size(lua_State *L) { @@ -168,7 +151,6 @@ static const luaL_Reg kiwmi_output_methods[] = { {"name", l_kiwmi_output_name}, {"on", luaK_callback_register_dispatch}, {"pos", l_kiwmi_output_pos}, - {"redraw", l_kiwmi_output_redraw}, {"size", l_kiwmi_output_size}, {"usable_area", l_kiwmi_output_usable_area}, {NULL, NULL}, diff --git a/kiwmi/luak/kiwmi_renderer.c b/kiwmi/luak/kiwmi_renderer.c deleted file mode 100644 index 33bac48..0000000 --- a/kiwmi/luak/kiwmi_renderer.c +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (c), Charlotte Meyer - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include "luak/kiwmi_renderer.h" - -#include -#include - -#include -#include -#include -#include - -#include "color.h" -#include "desktop/output.h" -#include "luak/lua_compat.h" -#include "luak/luak.h" - -struct kiwmi_renderer { - struct wlr_renderer *wlr_renderer; - struct kiwmi_output *output; -}; - -static int -l_kiwmi_renderer_draw_rect(lua_State *L) -{ - struct kiwmi_renderer *renderer = - (struct kiwmi_renderer *)luaL_checkudata(L, 1, "kiwmi_renderer"); - luaL_checktype(L, 2, LUA_TSTRING); // color - luaL_checktype(L, 3, LUA_TNUMBER); // x - luaL_checktype(L, 4, LUA_TNUMBER); // y - luaL_checktype(L, 5, LUA_TNUMBER); // width - luaL_checktype(L, 6, LUA_TNUMBER); // height - - struct wlr_renderer *wlr_renderer = renderer->wlr_renderer; - struct kiwmi_output *output = renderer->output; - struct wlr_output *wlr_output = output->wlr_output; - - float color[4]; - if (!color_parse(lua_tostring(L, 2), color)) { - return luaL_argerror(L, 2, "not a valid color"); - } - - struct wlr_box box = { - .x = lua_tonumber(L, 3), - .y = lua_tonumber(L, 4), - .width = lua_tonumber(L, 5), - .height = lua_tonumber(L, 6), - }; - - wlr_render_rect(wlr_renderer, &box, color, wlr_output->transform_matrix); - - return 0; -} - -static const luaL_Reg kiwmi_renderer_methods[] = { - {"draw_rect", l_kiwmi_renderer_draw_rect}, - {NULL, NULL}, -}; - -int -luaK_kiwmi_renderer_new(lua_State *L) -{ - luaL_checktype(L, 1, LUA_TLIGHTUSERDATA); // kiwmi_lua - luaL_checktype(L, 2, LUA_TLIGHTUSERDATA); // wlr_renderer - luaL_checktype(L, 3, LUA_TLIGHTUSERDATA); // wlr_output - - struct kiwmi_lua *UNUSED(lua) = lua_touserdata(L, 1); - struct wlr_renderer *wlr_renderer = lua_touserdata(L, 2); - struct kiwmi_output *output = lua_touserdata(L, 3); - - struct kiwmi_renderer *renderer_ud = - lua_newuserdata(L, sizeof(*renderer_ud)); - luaL_getmetatable(L, "kiwmi_renderer"); - lua_setmetatable(L, -2); - - renderer_ud->wlr_renderer = wlr_renderer; - renderer_ud->output = output; - - return 1; -} - -int -luaK_kiwmi_renderer_register(lua_State *L) -{ - luaL_newmetatable(L, "kiwmi_renderer"); - - lua_pushvalue(L, -1); - lua_setfield(L, -2, "__index"); - luaC_setfuncs(L, kiwmi_renderer_methods, 0); - - lua_pushcfunction(L, luaK_usertype_ref_equal); - lua_setfield(L, -2, "__eq"); - - return 0; -} diff --git a/kiwmi/luak/kiwmi_view.c b/kiwmi/luak/kiwmi_view.c index 931f755..aa5f408 100644 --- a/kiwmi/luak/kiwmi_view.c +++ b/kiwmi/luak/kiwmi_view.c @@ -21,7 +21,6 @@ #include "input/seat.h" #include "luak/kiwmi_lua_callback.h" #include "luak/kiwmi_output.h" -#include "luak/kiwmi_renderer.h" #include "luak/lua_compat.h" #include "server.h" @@ -471,65 +470,6 @@ kiwmi_view_on_destroy_notify(struct wl_listener *listener, void *data) } } -static void -kiwmi_view_on_render_notify(struct wl_listener *listener, void *data) -{ - struct kiwmi_lua_callback *lc = wl_container_of(listener, lc, listener); - struct kiwmi_server *server = lc->server; - lua_State *L = server->lua->L; - struct kiwmi_render_data *rdata = data; - - struct kiwmi_view *view = rdata->data; - struct wlr_renderer *renderer = rdata->renderer; - struct kiwmi_output *output = rdata->output->data; - - lua_rawgeti(L, LUA_REGISTRYINDEX, lc->callback_ref); - - lua_newtable(L); - - lua_pushcfunction(L, luaK_kiwmi_view_new); - lua_pushlightuserdata(L, server->lua); - lua_pushlightuserdata(L, view); - - if (lua_pcall(L, 2, 1, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return; - } - - lua_setfield(L, -2, "view"); - - lua_pushcfunction(L, luaK_kiwmi_output_new); - lua_pushlightuserdata(L, server->lua); - lua_pushlightuserdata(L, output); - - if (lua_pcall(L, 2, 1, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return; - } - - lua_setfield(L, -2, "output"); - - lua_pushcfunction(L, luaK_kiwmi_renderer_new); - lua_pushlightuserdata(L, server->lua); - lua_pushlightuserdata(L, renderer); - lua_pushlightuserdata(L, output); - - if (lua_pcall(L, 3, 1, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - return; - } - - lua_setfield(L, -2, "renderer"); - - if (lua_pcall(L, 1, 0, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - lua_pop(L, 1); - } -} - static void kiwmi_view_on_request_move_notify(struct wl_listener *listener, void *data) { @@ -644,62 +584,16 @@ l_kiwmi_view_on_destroy(lua_State *L) } static int -l_kiwmi_view_on_post_render(lua_State *L) +l_kiwmi_view_on_post_render(lua_State *UNUSED(L)) { - struct kiwmi_object *obj = - *(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_view"); - luaL_checktype(L, 2, LUA_TFUNCTION); - - if (!obj->valid) { - return luaL_error(L, "kiwmi_view no longer valid"); - } - - struct kiwmi_view *view = obj->object; - struct kiwmi_desktop *desktop = view->desktop; - struct kiwmi_server *server = wl_container_of(desktop, server, desktop); - - lua_pushcfunction(L, luaK_kiwmi_lua_callback_new); - lua_pushlightuserdata(L, server); - lua_pushvalue(L, 2); - lua_pushlightuserdata(L, kiwmi_view_on_render_notify); - lua_pushlightuserdata(L, &view->events.post_render); - lua_pushlightuserdata(L, obj); - - if (lua_pcall(L, 5, 0, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - return 0; - } - + // noop return 0; } static int -l_kiwmi_view_on_pre_render(lua_State *L) +l_kiwmi_view_on_pre_render(lua_State *UNUSED(L)) { - struct kiwmi_object *obj = - *(struct kiwmi_object **)luaL_checkudata(L, 1, "kiwmi_view"); - luaL_checktype(L, 2, LUA_TFUNCTION); - - if (!obj->valid) { - return luaL_error(L, "kiwmi_view no longer valid"); - } - - struct kiwmi_view *view = obj->object; - struct kiwmi_desktop *desktop = view->desktop; - struct kiwmi_server *server = wl_container_of(desktop, server, desktop); - - lua_pushcfunction(L, luaK_kiwmi_lua_callback_new); - lua_pushlightuserdata(L, server); - lua_pushvalue(L, 2); - lua_pushlightuserdata(L, kiwmi_view_on_render_notify); - lua_pushlightuserdata(L, &view->events.pre_render); - lua_pushlightuserdata(L, obj); - - if (lua_pcall(L, 5, 0, 0)) { - wlr_log(WLR_ERROR, "%s", lua_tostring(L, -1)); - return 0; - } - + // noop return 0; } diff --git a/kiwmi/luak/luak.c b/kiwmi/luak/luak.c index 8a094e9..cdf9e15 100644 --- a/kiwmi/luak/luak.c +++ b/kiwmi/luak/luak.c @@ -18,7 +18,6 @@ #include "luak/kiwmi_keyboard.h" #include "luak/kiwmi_lua_callback.h" #include "luak/kiwmi_output.h" -#include "luak/kiwmi_renderer.h" #include "luak/kiwmi_server.h" #include "luak/kiwmi_view.h" @@ -220,8 +219,6 @@ luaK_create(struct kiwmi_server *server) error |= lua_pcall(L, 0, 0, 0); lua_pushcfunction(L, luaK_kiwmi_output_register); error |= lua_pcall(L, 0, 0, 0); - lua_pushcfunction(L, luaK_kiwmi_renderer_register); - error |= lua_pcall(L, 0, 0, 0); lua_pushcfunction(L, luaK_kiwmi_server_register); error |= lua_pcall(L, 0, 0, 0); lua_pushcfunction(L, luaK_kiwmi_view_register); diff --git a/kiwmi/meson.build b/kiwmi/meson.build index 13f7c9b..b61fac3 100644 --- a/kiwmi/meson.build +++ b/kiwmi/meson.build @@ -17,7 +17,6 @@ kiwmi_sources = files( 'luak/kiwmi_keyboard.c', 'luak/kiwmi_lua_callback.c', 'luak/kiwmi_output.c', - 'luak/kiwmi_renderer.c', 'luak/kiwmi_server.c', 'luak/kiwmi_view.c', 'luak/lua_compat.c', diff --git a/lua_docs.md b/lua_docs.md index 3eb0b26..7f63b60 100644 --- a/lua_docs.md +++ b/lua_docs.md @@ -240,10 +240,6 @@ Used to register event listeners. Get the position of the output. Returns two parameters: `x` and `y`. -#### output:redraw() - -Force the output to redraw. Useful e.g. when you know the view `pre_render`/`post_render` callbacks are going to change. - #### output:size() Get the size of the output. @@ -270,17 +266,6 @@ Callback receives a table containing the `output`, the new `width`, and the new The usable area of this output has changed, e.g. because the output was resized or the bars around it changed. Callback receives a table containing the `output` and the new `x`, `y`, `width` and `height`. -## kiwmi_renderer - -Represents a rendering context, to draw on the output. - -### Methods - -#### renderer:draw_rect(color, x, y, w, h) - -Draws a rect at the given position. -Color is a string in the form #rrggbb or #rrggbbaa. - ## kiwmi_view Represents a view (a window in kiwmi terms). @@ -373,17 +358,11 @@ Callback receives the view. #### post_render -The view finished being rendered. -Callback receives a table with the `view`, the `renderer` and the `output`. - -This event occurs once per output the view might be drawn on. +This is a no-op event. Temporarily preserved only to make config migration easier. #### pre_render -The view is about to be rendered. -Callback receives a table with the `view`, the `renderer` and the `output`. - -This event occurs once per output the view might be drawn on. +This is a no-op event. Temporarily preserved only to make config migration easier. #### request_move