Signed-off-by: Slendi <slendi@socopon.com>
This commit is contained in:
2025-10-16 19:48:02 +03:00
parent a67b787386
commit d368760f78
20 changed files with 9358 additions and 108 deletions

View File

@@ -139,6 +139,50 @@ App::App()
init_egl();
init_signal();
init_theme_portal();
{
auto const env = getenv("XDG_DATA_HOME");
if (env && *env) {
if (std::filesystem::exists(env)) {
m_data_home_dir = env;
}
}
if (m_data_home_dir.empty()) {
auto const home = getenv("HOME");
assert(home && *home);
m_data_home_dir = std::filesystem::path(home) / ".local" / "share";
std::filesystem::create_directories(m_data_home_dir);
}
m_data_home_dir /= "waylight";
std::filesystem::create_directories(m_data_home_dir);
}
m_db = std::make_shared<SQLite::Database>(m_data_home_dir / "data.db",
SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
SQLite::Statement(*m_db, R"(
CREATE TABLE IF NOT EXISTS ApplicationCache (
id INTEGER PRIMARY KEY NOT NULL,
type INTEGER NOT NULL,
desktop_entry_path TEXT NOT NULL,
terminal BOOL NOT NULL,
no_display BOOL NOT NULL,
path TEXT,
comment TEXT,
dbus_activatable BOOL NOT NULL
);
CREATE TABLE IF NOT EXISTS ApplicationActionCache (
id INTEGER PRIMARY KEY NOT NULL,
id_app INTEGER NOT NULL,
name TEXT NOT NULL,
exec TEXT,
icon TEXT,
FOREIGN KEY (id_app) REFERENCES ApplicationCache(id)
);
)")
.exec();
m_cache = Waylight::Cache(m_db);
}
App::~App()
@@ -146,9 +190,8 @@ App::~App()
if (m_sfd != -1)
close(m_sfd);
for (auto &[_, tex] : m_textures) {
for (auto &[_, tex] : m_textures)
UnloadTexture(tex);
}
destroy_layer_surface();
@@ -383,8 +426,10 @@ auto App::init_wayland() -> void
static zwp_text_input_v3_listener text_input_listener {};
{
auto ti_enter
= [](void *data, zwp_text_input_v3 *, wl_surface *surface) -> void {
auto ti_enter =
[](void *data, zwp_text_input_v3 *,
wl_surface *surface) // cppcheck-suppress constParameterPointer
-> void {
auto *app { static_cast<App *>(data) };
bool const focused_surface
= surface && surface == app->m_wayland.surface;
@@ -660,6 +705,13 @@ auto App::init_egl() -> void
ensure_egl_surface();
{
auto const *env = getenv("WAYLIGHT_DEBUG");
if (env && *env) {
SetTraceLogLevel(LOG_DEBUG);
}
}
InitWindow(m_win_w, m_win_h, "");
m_tr = std::make_shared<TextRenderer>();
@@ -1061,17 +1113,17 @@ auto App::update_text_input_state(
= std::max(1, static_cast<int32_t>(std::round(rect.width)));
int32_t const height
= std::max(1, static_cast<int32_t>(std::round(rect.height)));
bool const visible = cursor_info->visible;
bool const cur_visible = cursor_info->visible;
if (rect.x != m_ime.last_cursor_rect.x
|| rect.y != m_ime.last_cursor_rect.y
|| rect.width != m_ime.last_cursor_rect.width
|| rect.height != m_ime.last_cursor_rect.height
|| visible != m_ime.last_cursor_visible) {
|| cur_visible != m_ime.last_cursor_visible) {
zwp_text_input_v3_set_cursor_rectangle(
m_wayland.text_input, x, y, width, height);
m_ime.last_cursor_rect = rect;
m_ime.last_cursor_visible = visible;
m_ime.last_cursor_visible = cur_visible;
state_dirty = true;
}
}
@@ -1100,7 +1152,7 @@ auto App::pump_events() -> void
if (ret > 0 && (fds[0].revents & POLLIN)) {
if (prepared) {
wl_display_read_events(m_wayland.display);
prepared = false;
prepared = false; // cppcheck-suppress unreadVariable
}
} else if (prepared) {
wl_display_cancel_read(m_wayland.display);