fix: turn off vsync while not focused

This commit is contained in:
2026-01-13 00:28:28 +03:00
parent 2b1c6d59c4
commit 56a499502f
7 changed files with 14 additions and 17 deletions

View File

@@ -1,6 +1,6 @@
# Maintainer: Daniel Dada <dan@binarygoose.dev> # Maintainer: Daniel Dada <dan@binarygoose.dev>
pkgname=clrsync pkgname=clrsync
pkgver=1.0.4 pkgver=1.0.5
pkgrel=1 pkgrel=1
pkgdesc="Color scheme manager" pkgdesc="Color scheme manager"
arch=('x86_64') arch=('x86_64')

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.25) cmake_minimum_required(VERSION 3.25)
project(clrsync VERSION 1.0.4 LANGUAGES CXX) project(clrsync VERSION 1.0.5 LANGUAGES CXX)
include(GNUInstallDirs) include(GNUInstallDirs)

View File

@@ -1 +1 @@
1.0.4 1.0.5

View File

@@ -6,7 +6,7 @@
namespace clrsync::core namespace clrsync::core
{ {
const std::string GIT_SEMVER = "1.0.3+git.gd852d58"; const std::string GIT_SEMVER = "1.0.4+git.g2b1c6d5";
const std::string version_string(); const std::string version_string();
} // namespace clrsync::core } // namespace clrsync::core

View File

@@ -16,6 +16,11 @@ glfw_opengl_backend::~glfw_opengl_backend()
glfw_opengl_backend::shutdown(); glfw_opengl_backend::shutdown();
} }
void glfw_opengl_backend::focus_callback(GLFWwindow*, int focused)
{
glfwSwapInterval(focused ? 1 : 0);
}
bool glfw_opengl_backend::initialize(const window_config &config) bool glfw_opengl_backend::initialize(const window_config &config)
{ {
glfwSetErrorCallback([](int error, const char* description) { glfwSetErrorCallback([](int error, const char* description) {
@@ -48,6 +53,7 @@ bool glfw_opengl_backend::initialize(const window_config &config)
glfwMakeContextCurrent(m_window); glfwMakeContextCurrent(m_window);
glfwSwapInterval(1); glfwSwapInterval(1);
glfwSetWindowFocusCallback(m_window, focus_callback);
return true; return true;
} }

View File

@@ -32,6 +32,8 @@ namespace clrsync::gui::backend{
void imgui_render_draw_data(void* draw_data) override; void imgui_render_draw_data(void* draw_data) override;
private: private:
static void focus_callback(GLFWwindow* window, int focused);
GLFWwindow* m_window = nullptr; GLFWwindow* m_window = nullptr;
}; };
} }

View File

@@ -10,8 +10,6 @@
std::string font_loader::find_font_linux(const char *font_name) std::string font_loader::find_font_linux(const char *font_name)
{ {
glfwPollEvents();
FcInit(); FcInit();
FcPattern *pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_name)); FcPattern *pattern = FcNameParse(reinterpret_cast<const FcChar8 *>(font_name));
@@ -67,9 +65,6 @@ void font_loader::pop_font()
std::vector<std::string> font_loader::get_system_fonts() std::vector<std::string> font_loader::get_system_fonts()
{ {
std::vector<std::string> fonts; std::vector<std::string> fonts;
glfwPollEvents();
FcInit(); FcInit();
FcPattern *pattern = FcPatternCreate(); FcPattern *pattern = FcPatternCreate();
FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, nullptr); FcObjectSet *os = FcObjectSetBuild(FC_FAMILY, nullptr);
@@ -79,12 +74,6 @@ std::vector<std::string> font_loader::get_system_fonts()
{ {
for (int i = 0; i < fs->nfont; i++) for (int i = 0; i < fs->nfont; i++)
{ {
// TODO: should change this to something sane
if (i % 100 == 0)
{
glfwPollEvents();
}
FcChar8 *family = nullptr; FcChar8 *family = nullptr;
if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch) if (FcPatternGetString(fs->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch)
{ {