]> git.sesse.net Git - nageru/blobdiff - theme.cpp
Add resize(), so that HTML inputs do not need to be locked to the video resolution.
[nageru] / theme.cpp
index 7240cd4c0f2ce3b7d4c2cb571f0b0c2891575a1b..5fc5a7538cee288ae7e3fc335c1550bfdfe1dd2e 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -535,6 +535,16 @@ int HTMLInput_execute_javascript_async(lua_State* L)
        return 0;
 }
 
+int HTMLInput_resize(lua_State* L)
+{
+       assert(lua_gettop(L) == 3);
+       CEFCapture **video_input = (CEFCapture **)luaL_checkudata(L, 1, "HTMLInput");
+       unsigned width = lrint(luaL_checknumber(L, 2));
+       unsigned height = lrint(luaL_checknumber(L, 3));
+       (*video_input)->resize(width, height);
+       return 0;
+}
+
 int HTMLInput_get_signal_num(lua_State* L)
 {
        assert(lua_gettop(L) == 1);
@@ -761,6 +771,7 @@ const luaL_Reg HTMLInput_funcs[] = {
        { "reload", HTMLInput_reload },
        { "set_max_fps", HTMLInput_set_max_fps },
        { "execute_javascript_async", HTMLInput_execute_javascript_async },
+       { "resize", HTMLInput_resize },
        { "get_signal_num", HTMLInput_get_signal_num },
 #endif
        { NULL, NULL }
@@ -1458,6 +1469,7 @@ int Theme::set_theme_menu(lua_State *L)
 
 void Theme::theme_menu_entry_clicked(int lua_ref)
 {
+       unique_lock<mutex> lock(m);
        lua_rawgeti(L, LUA_REGISTRYINDEX, lua_ref);
        if (lua_pcall(L, 0, 0, 0) != 0) {
                fprintf(stderr, "error running menu callback: %s\n", lua_tostring(L, -1));