#include "App.hpp" #include #include #include #include #include #include #include namespace Waylight { auto App::tick() -> void { static std::pmr::string text_input_data {}; m_ime.bound_text = &text_input_data; m_ime.bound_id = 1; process_pending_text_input(); if (!m_visible || m_gl.edpy == EGL_NO_DISPLAY || m_gl.esurf == EGL_NO_SURFACE) return; glViewport(0, 0, m_win_w, m_win_h); if (m_kbd.is_sym_pressed(XKB_KEY_Escape)) { set_visible(!visible()); if (m_kbd.ctrl() && m_kbd.shift()) { m_running = false; } } BeginDrawing(); ClearBackground(theme().window.background); { assert(m_gui); m_gui->style().preedit_color = theme().foreground_preedit; m_gui->style().text_color = theme().foreground; m_gui->style().selection_color = m_accent_color; m_gui->style().selection_text_color = WHITE; u32 rune { 0 }; if (!m_kbd.typing.empty()) { rune = m_kbd.typing.back(); m_kbd.typing.clear(); } ImGuiGuard gui_scope(m_gui, rune, m_kbd.ctrl(), m_kbd.shift(), clipboard(), [this](std::string_view const &str) { clipboard(str); }); Rectangle const input_rect { 0.0f, 0.0f, static_cast(GetScreenWidth()), static_cast(GetScreenHeight()), }; ; if (auto const result = m_gui->text_input(1, text_input_data, input_rect); result.test(1)) { m_ime.surrounding_dirty = true; } else if (result.test(0)) { if (text_input_data == "kitty") { execute_command(false, "kitty"); } else if (text_input_data == "nvim") { execute_command(true, "nvim"); } text_input_data = ""; } update_text_input_state(text_input_data, 1, input_rect); } DrawTexture(m_ir.lookup("folder", 48).texture(), 48, 48, WHITE); EndDrawing(); eglSwapBuffers(m_gl.edpy, m_gl.esurf); } } // namespace Waylight