aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-08 10:38:28 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-08 10:38:28 +0200
commitad678b5a1b7f457378b1d8ae7cdaf3ee7a08eb75 (patch)
tree3f73f5301a3990a94e29055c08f0a36afae33108 /src/QuickMedia.cpp
parent0878a8e2f5e7cbc88ee9350caef8f068920707fb (diff)
Fix manga scroll view jumping, clamp to top/bottom, remove direct dependency on opengl
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp85
1 files changed, 1 insertions, 84 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index fc9db2f..d06a0b7 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -55,7 +55,6 @@
#include <json/writer.h>
#include <X11/keysym.h>
#include <X11/extensions/Xrandr.h>
-#include <GL/glx.h>
static int FPS_IDLE;
static const double IDLE_TIMEOUT_SEC = 2.0;
@@ -175,79 +174,6 @@ static void get_screen_resolution(Display *display, int *width, int *height) {
*height = DefaultScreenOfDisplay(display)->height;
}
-static bool has_gl_ext(Display *disp, const char *ext) {
- const char *extensions = glXQueryExtensionsString(disp, DefaultScreen(disp));
- if(!extensions)
- return false;
-
- int ext_len = strlen(ext);
- while(true) {
- const char *loc = strstr(extensions, ext);
- if(!loc)
- return false;
-
- const char *terminator = loc + ext_len;
- if((loc == extensions || *(loc - 1) == ' ') && (*terminator == ' ' || *terminator == '\0'))
- return true;
-
- extensions = terminator;
- }
-}
-
-static PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA = nullptr;
-static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = nullptr;
-static PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = nullptr;
-static bool vsync_loaded = false;
-static bool vsync_set = false;
-
-static bool test_vsync(Display *disp, Window window) {
- unsigned int swap = 0;
- glXQueryDrawable(disp, window, GLX_SWAP_INTERVAL_EXT, &swap);
- fprintf(stderr, "The swap interval is %u\n", swap);
- return swap == 1;
-}
-
-static bool enable_vsync(Display *disp, Window window) {
- if(vsync_loaded) {
- if(glXSwapIntervalMESA)
- return glXSwapIntervalMESA(1) == 0;
- if(glXSwapIntervalSGI)
- return glXSwapIntervalSGI(1) == 0;
- if(glXSwapIntervalEXT) {
- glXSwapIntervalEXT(disp, window, 1);
- return true;
- }
- return false;
- }
- vsync_loaded = true;
-
- if(has_gl_ext(disp, "GLX_MESA_swap_control")) {
- fprintf(stderr, "vsync method: GLX_MESA_swap_control\n");
- glXSwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalMESA");
- if(glXSwapIntervalMESA && glXSwapIntervalMESA(1) == 0 && test_vsync(disp, window))
- return true;
- }
-
- if(has_gl_ext(disp, "GLX_SGI_swap_control")) {
- fprintf(stderr, "vsync method: GLX_SGI_swap_control\n");
- glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalSGI");
- if(glXSwapIntervalSGI && glXSwapIntervalSGI(1) == 0 && test_vsync(disp, window))
- return true;
- }
-
- if(has_gl_ext(disp, "GLX_EXT_swap_control")) {
- fprintf(stderr, "vsync method: GLX_EXT_swap_control\n");
- glXSwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)glXGetProcAddress((const GLubyte*)"glXSwapIntervalEXT");
- if(glXSwapIntervalEXT) {
- glXSwapIntervalEXT(disp, window, 1);
- return test_vsync(disp, window);
- }
- }
-
- fprintf(stderr, "vsync method: none\n");
- return false;
-}
-
static sf::Color interpolate_colors(sf::Color source, sf::Color target, double progress) {
int diff_r = (int)target.r - (int)source.r;
int diff_g = (int)target.g - (int)source.g;
@@ -711,19 +637,10 @@ namespace QuickMedia {
XSetErrorHandler(x_error_handler);
XSetIOErrorHandler(x_io_error_handler);
- window.setVerticalSyncEnabled(true);
+ window.setVerticalSyncEnabled(false);
monitor_hz = get_monitor_max_hz(disp);
window.setFramerateLimit(monitor_hz);
idle = false;
- vsync_set = false;
- /*
- if(enable_vsync(disp, window.getSystemHandle())) {
- vsync_set = true;
- } else {
- fprintf(stderr, "Failed to enable vsync, fallback to frame limiting\n");
- window.setFramerateLimit(monitor_hz);
- }
- */
fprintf(stderr, "Monitor hz: %d\n", monitor_hz);
if(create_directory_recursive(get_cache_dir().join("media")) != 0) {