From b85c9839ae86247179a4adf7f2e90f194380cb93 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 19 Nov 2021 21:41:02 +0100 Subject: Dont set fps, let vsync handle that --- depends/mglpp | 2 +- include/QuickMedia.hpp | 1 - src/ImageViewer.cpp | 2 +- src/QuickMedia.cpp | 22 ++++------------------ src/Tabs.cpp | 2 +- 5 files changed, 7 insertions(+), 22 deletions(-) diff --git a/depends/mglpp b/depends/mglpp index b137699..c56af6c 160000 --- a/depends/mglpp +++ b/depends/mglpp @@ -1 +1 @@ -Subproject commit b1376994950a48684f8a223172b196aae4454d42 +Subproject commit c56af6cf176671182e42afc27ac4392fb13b2c4a diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index d4166ec..f476396 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -156,7 +156,6 @@ namespace QuickMedia { mgl::Window window; Matrix *matrix = nullptr; bool is_login_sync = false; - int monitor_hz; mgl::vec2i window_size; const char *plugin_name = nullptr; mgl::Texture plugin_logo; diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index 731099f..9071214 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -358,7 +358,7 @@ namespace QuickMedia { window->draw(page_text_background); auto page_text_bounds = page_text.get_bounds(); - page_text.set_position(mgl::vec2f(std::floor(window_size.x * 0.5f - page_text_bounds.size.x * 0.5f), std::floor(window_size.y - background_height * 0.5f - font_height * 0.6f))); + page_text.set_position(mgl::vec2f(std::floor(window_size.x * 0.5f - page_text_bounds.size.x * 0.5f), std::floor(window_size.y - background_height * 0.5f - font_height * 0.7f))); window->draw(page_text); // Free pages that are not visible on the screen diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 0afd824..b364fe0 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -68,6 +68,7 @@ static int FPS_IDLE; static const double IDLE_TIMEOUT_SEC = 2.0; static const mgl::vec2i AVATAR_THUMBNAIL_SIZE(std::floor(32), std::floor(32)); static const float more_items_height = 2.0f; +static const int FPS_SYNC_TO_VSYNC = 0; static const std::pair valid_plugins[] = { std::make_pair("launcher", nullptr), @@ -151,19 +152,6 @@ static void for_each_active_monitor_output(Display *display, std::functionhTotal * mode_info->vTotal; - if(total > 0) - max_hz = std::max(max_hz, (unsigned long)std::round((double)mode_info->dotClock / (double)total)); - }); - - if(max_hz == 0) - return 60; - return std::min(max_hz, 144UL); -} - static int get_largest_monitor_height(Display *display) { int max_height = 0; @@ -674,10 +662,8 @@ namespace QuickMedia { XSetErrorHandler(x_error_handler); XSetIOErrorHandler(x_io_error_handler); - monitor_hz = get_monitor_max_hz(disp); - window.set_framerate_limit(monitor_hz); + window.set_framerate_limit(FPS_SYNC_TO_VSYNC); idle = false; - fprintf(stderr, "Monitor hz: %d\n", monitor_hz); if(create_directory_recursive(get_cache_dir().join("media")) != 0) { show_notification("QuickMedia", "Failed to create media directory", Urgency::CRITICAL); @@ -1322,7 +1308,7 @@ namespace QuickMedia { void Program::idle_active_handler() { if(idle) - window.set_framerate_limit(monitor_hz); + window.set_framerate_limit(FPS_SYNC_TO_VSYNC); idle = false; idle_timer.restart(); } @@ -3702,7 +3688,7 @@ namespace QuickMedia { window.draw(chapter_text_background); auto text_bounds = chapter_text.get_bounds(); - chapter_text.set_position(vec2f_floor(window_size.x * 0.5f - text_bounds.size.x * 0.5f, window_size.y - bottom_panel_height * 0.5f - font_height * 0.6f)); + chapter_text.set_position(vec2f_floor(window_size.x * 0.5f - text_bounds.size.x * 0.5f, window_size.y - bottom_panel_height * 0.5f - font_height * 0.7f)); window.draw(chapter_text); window.display(); diff --git a/src/Tabs.cpp b/src/Tabs.cpp index db25ffb..3d0dc76 100644 --- a/src/Tabs.cpp +++ b/src/Tabs.cpp @@ -99,7 +99,7 @@ namespace QuickMedia { const int num_visible_tabs = std::min((int)tabs.size(), std::max(1, (int)(width / tab_min_width))); width_per_tab = std::floor(width / num_visible_tabs); - const float tab_text_y = std::floor(pos.y + tab_height*0.5f - (tab_text_size + 13.0f*get_config().scale)*0.5f); + const float tab_text_y = std::floor(pos.y + tab_height*0.5f - tab_text_size); tab_background_width = std::floor(width_per_tab - tab_margin_x*2.0f); background.set_size(mgl::vec2f(tab_background_width, tab_height)); -- cgit v1.2.3