@@ -32,6 +32,8 @@
|
|||||||
#include "blur-client-protocol.h"
|
#include "blur-client-protocol.h"
|
||||||
#include "ext-background-effect-v1-client-protocol.h"
|
#include "ext-background-effect-v1-client-protocol.h"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr usize MAX_SURROUNDING_BYTES = 4000;
|
constexpr usize MAX_SURROUNDING_BYTES = 4000;
|
||||||
@@ -1240,3 +1242,5 @@ auto App::clipboard(std::string_view const &str) -> void
|
|||||||
m_wayland.ddev, m_wayland.curr_source, m_last_serial);
|
m_wayland.ddev, m_wayland.curr_source, m_last_serial);
|
||||||
wl_display_flush(m_wayland.display);
|
wl_display_flush(m_wayland.display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ extern "C" {
|
|||||||
#include "Theme.hpp"
|
#include "Theme.hpp"
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
struct TypingBuffer : std::pmr::vector<u32> {
|
struct TypingBuffer : std::pmr::vector<u32> {
|
||||||
void push_utf8(char const *s);
|
void push_utf8(char const *s);
|
||||||
};
|
};
|
||||||
@@ -219,7 +221,7 @@ private:
|
|||||||
enum_array<Theme, ColorScheme> m_themes { make_default_themes() };
|
enum_array<Theme, ColorScheme> m_themes { make_default_themes() };
|
||||||
Theme m_active_theme { Theme::Light };
|
Theme m_active_theme { Theme::Light };
|
||||||
IconRegistry m_ir;
|
IconRegistry m_ir;
|
||||||
std::optional<Waylight::Cache> m_cache;
|
std::optional<Cache> m_cache;
|
||||||
|
|
||||||
int m_win_w { 800 };
|
int m_win_w { 800 };
|
||||||
int m_win_h { 600 };
|
int m_win_h { 600 };
|
||||||
@@ -232,3 +234,5 @@ private:
|
|||||||
std::shared_ptr<SQLite::Database> m_db {};
|
std::shared_ptr<SQLite::Database> m_db {};
|
||||||
int m_sfd { -1 };
|
int m_sfd { -1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
void replace_all(
|
void replace_all(
|
||||||
std::string &str, std::string const &from, std::string const &to)
|
std::string &str, std::string const &from, std::string const &to)
|
||||||
{
|
{
|
||||||
@@ -25,8 +27,6 @@ void replace_all(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Waylight {
|
|
||||||
|
|
||||||
Cache::Cache(std::shared_ptr<SQLite::Database> db)
|
Cache::Cache(std::shared_ptr<SQLite::Database> db)
|
||||||
: m_db(db)
|
: m_db(db)
|
||||||
{
|
{
|
||||||
@@ -432,4 +432,4 @@ void Cache::load()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Cache
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <lunasvg.h>
|
#include <lunasvg.h>
|
||||||
#include <mini/ini.h>
|
#include <mini/ini.h>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
static inline auto color_to_string(Color const &c) -> std::string
|
static inline auto color_to_string(Color const &c) -> std::string
|
||||||
{
|
{
|
||||||
auto const r { c.r / 255.0 }, g { c.g / 255.0 }, b { c.b / 255.0 };
|
auto const r { c.r / 255.0 }, g { c.g / 255.0 }, b { c.b / 255.0 };
|
||||||
@@ -443,3 +445,5 @@ auto IconRegistry::lookup_cached(std::string_view const name,
|
|||||||
|
|
||||||
throw std::runtime_error(std::format("Failed to find icon `{}`!", name));
|
throw std::runtime_error(std::format("Failed to find icon `{}`!", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
struct Icon {
|
struct Icon {
|
||||||
Icon(std::filesystem::path path, Texture2D texture, int size)
|
Icon(std::filesystem::path path, Texture2D texture, int size)
|
||||||
: m_path(path)
|
: m_path(path)
|
||||||
@@ -87,3 +89,5 @@ private:
|
|||||||
std::unordered_map<std::string, Icon> m_cached_icons;
|
std::unordered_map<std::string, Icon> m_cached_icons;
|
||||||
std::optional<std::string> m_preferred_theme;
|
std::optional<std::string> m_preferred_theme;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct CodepointSpan {
|
struct CodepointSpan {
|
||||||
@@ -786,3 +788,5 @@ auto ImGui::list_view(usize id, Rectangle bounds, usize elements,
|
|||||||
|
|
||||||
return submitted;
|
return submitted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
#include "TextRenderer.hpp"
|
#include "TextRenderer.hpp"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
constexpr float DEFAULT_FONT_SIZE { 24 };
|
constexpr float DEFAULT_FONT_SIZE { 24 };
|
||||||
|
|
||||||
struct TextInputOptions {
|
struct TextInputOptions {
|
||||||
@@ -158,3 +160,5 @@ struct ImGuiGuard {
|
|||||||
private:
|
private:
|
||||||
std::shared_ptr<ImGui> m_imgui { nullptr };
|
std::shared_ptr<ImGui> m_imgui { nullptr };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -37,6 +37,8 @@
|
|||||||
#include <ext/import-font.h>
|
#include <ext/import-font.h>
|
||||||
#include <msdfgen.h>
|
#include <msdfgen.h>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
constexpr int ATLAS_DIMENSION = 1024;
|
constexpr int ATLAS_DIMENSION = 1024;
|
||||||
@@ -839,3 +841,5 @@ auto find_font_path(std::string_view path)
|
|||||||
}
|
}
|
||||||
return final_path;
|
return final_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace msdfgen {
|
|||||||
class FontHandle;
|
class FontHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
struct FontHandle { // cppcheck-supress noConstructor
|
struct FontHandle { // cppcheck-supress noConstructor
|
||||||
FontHandle() = default;
|
FontHandle() = default;
|
||||||
|
|
||||||
@@ -145,3 +147,5 @@ private:
|
|||||||
|
|
||||||
auto find_font_path(std::string_view path = "sans-serif:style=Regular")
|
auto find_font_path(std::string_view path = "sans-serif:style=Regular")
|
||||||
-> std::optional<std::filesystem::path>;
|
-> std::optional<std::filesystem::path>;
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
#include "enum_array.hpp"
|
#include "enum_array.hpp"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
struct ColorScheme {
|
struct ColorScheme {
|
||||||
Color foreground;
|
Color foreground;
|
||||||
Color foreground_preedit;
|
Color foreground_preedit;
|
||||||
@@ -40,3 +42,5 @@ constexpr auto make_default_themes() -> enum_array<Theme, ColorScheme> const
|
|||||||
};
|
};
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
auto App::tick() -> void
|
auto App::tick() -> void
|
||||||
{
|
{
|
||||||
static std::pmr::string text_input_data {};
|
static std::pmr::string text_input_data {};
|
||||||
@@ -76,3 +78,5 @@ auto App::tick() -> void
|
|||||||
|
|
||||||
eglSwapBuffers(m_gl.edpy, m_gl.esurf);
|
eglSwapBuffers(m_gl.edpy, m_gl.esurf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
using u8 = std::uint8_t;
|
using u8 = std::uint8_t;
|
||||||
using i8 = std::int8_t;
|
using i8 = std::int8_t;
|
||||||
using u16 = std::uint16_t;
|
using u16 = std::uint16_t;
|
||||||
@@ -38,3 +40,5 @@ using isize = std::intptr_t;
|
|||||||
|
|
||||||
return utf8.data();
|
return utf8.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
#include "common.hpp"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
template<class E> struct enum_traits;
|
template<class E> struct enum_traits;
|
||||||
|
|
||||||
template<class E>
|
template<class E>
|
||||||
@@ -76,3 +80,5 @@ constexpr auto make_enum_array(T &&first_val, U &&...rest)
|
|||||||
arr._data = { std::forward<T>(first_val), std::forward<U>(rest)... };
|
arr._data = { std::forward<T>(first_val), std::forward<U>(rest)... };
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|||||||
70
src/main.cpp
70
src/main.cpp
@@ -17,43 +17,12 @@
|
|||||||
|
|
||||||
#include "App.hpp"
|
#include "App.hpp"
|
||||||
|
|
||||||
|
namespace Waylight {
|
||||||
|
|
||||||
bool signal_running();
|
bool signal_running();
|
||||||
|
|
||||||
std::optional<App> g_app {};
|
std::optional<App> g_app {};
|
||||||
|
|
||||||
auto main() -> int
|
|
||||||
{
|
|
||||||
if (signal_running()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::signal(SIGINT, [](int) {
|
|
||||||
if (g_app)
|
|
||||||
g_app->stop();
|
|
||||||
});
|
|
||||||
|
|
||||||
CPPTRACE_TRY
|
|
||||||
{
|
|
||||||
g_app.emplace();
|
|
||||||
g_app->run();
|
|
||||||
}
|
|
||||||
CPPTRACE_CATCH(std::exception const &e)
|
|
||||||
{
|
|
||||||
std::string what { e.what() };
|
|
||||||
std::ranges::replace(what, '"', '.');
|
|
||||||
std::ranges::replace(what, '\'', '.');
|
|
||||||
std::ranges::replace(what, '`', '.');
|
|
||||||
if (what.empty()) {
|
|
||||||
std::println(std::cerr, "Unexpected exception!");
|
|
||||||
} else {
|
|
||||||
std::println(std::cerr, "Unexpected exception! Error: {}", what);
|
|
||||||
}
|
|
||||||
cpptrace::from_current_exception().print();
|
|
||||||
tinyfd_messageBox(
|
|
||||||
"Unexpected exception", what.c_str(), "ok", "error", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool signal_running()
|
bool signal_running()
|
||||||
{
|
{
|
||||||
char const *lock_path = "/tmp/waylight.lock";
|
char const *lock_path = "/tmp/waylight.lock";
|
||||||
@@ -82,3 +51,38 @@ bool signal_running()
|
|||||||
dprintf(fd, "%d\n", getpid());
|
dprintf(fd, "%d\n", getpid());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Waylight
|
||||||
|
|
||||||
|
auto main() -> int
|
||||||
|
{
|
||||||
|
if (Waylight::signal_running()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::signal(SIGINT, [](int) {
|
||||||
|
if (Waylight::g_app)
|
||||||
|
Waylight::g_app->stop();
|
||||||
|
});
|
||||||
|
|
||||||
|
CPPTRACE_TRY
|
||||||
|
{
|
||||||
|
Waylight::g_app.emplace();
|
||||||
|
Waylight::g_app->run();
|
||||||
|
}
|
||||||
|
CPPTRACE_CATCH(std::exception const &e)
|
||||||
|
{
|
||||||
|
std::string what { e.what() };
|
||||||
|
std::ranges::replace(what, '"', '.');
|
||||||
|
std::ranges::replace(what, '\'', '.');
|
||||||
|
std::ranges::replace(what, '`', '.');
|
||||||
|
if (what.empty()) {
|
||||||
|
std::println(std::cerr, "Unexpected exception!");
|
||||||
|
} else {
|
||||||
|
std::println(std::cerr, "Unexpected exception! Error: {}", what);
|
||||||
|
}
|
||||||
|
cpptrace::from_current_exception().print();
|
||||||
|
tinyfd_messageBox(
|
||||||
|
"Unexpected exception", what.c_str(), "ok", "error", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user