diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-11-19 21:41:02 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-11-19 21:41:02 +0100 |
commit | b85c9839ae86247179a4adf7f2e90f194380cb93 (patch) | |
tree | 6acc70d99ea5671900f75fddac5fed93656d6692 /src | |
parent | 1e436a6b791f631eb18281bc63366f43a7c8ba8a (diff) |
Dont set fps, let vsync handle that
Diffstat (limited to 'src')
-rw-r--r-- | src/ImageViewer.cpp | 2 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 22 | ||||
-rw-r--r-- | src/Tabs.cpp | 2 |
3 files changed, 6 insertions, 20 deletions
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<const char*, const char*> valid_plugins[] = { std::make_pair("launcher", nullptr), @@ -151,19 +152,6 @@ static void for_each_active_monitor_output(Display *display, std::function<void( XRRFreeScreenResources(screen_res); } -static int get_monitor_max_hz(Display *display) { - unsigned long max_hz = 0; - for_each_active_monitor_output(display, [&max_hz](const XRRCrtcInfo*, const XRRModeInfo *mode_info) { - unsigned long total = mode_info->hTotal * 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)); |