aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-09-12 02:23:30 +0200
committerdec05eba <dec05eba@protonmail.com>2022-09-12 02:23:30 +0200
commita6f23372c0e9c26bd6e23c3ebec047e4211dcb93 (patch)
treef213e580b49578a6ed8ce1e5599594767fefae99 /src/QuickMedia.cpp
parentc944b7b874ce2296b0c67cd9e7c670304c514e1f (diff)
Fix key/button state when window loses focus (check state on call to is_**_pressed)
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 3e77797..c2a7c6b 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -4528,6 +4528,9 @@ namespace QuickMedia {
std::deque<int> comment_navigation_stack;
std::deque<int> comment_page_scroll_stack;
+ bool moving_captcha_left = false;
+ bool moving_captcha_right = false;
+
mgl::Clock frame_timer;
while (current_page == PageType::IMAGE_BOARD_THREAD && window.is_open()) {
const float frame_elapsed_time_sec = frame_timer.restart();
@@ -4556,6 +4559,18 @@ namespace QuickMedia {
idle_active_handler();
}
+ if(event.type == mgl::Event::KeyPressed) {
+ if(event.key.code == mgl::Keyboard::Left)
+ moving_captcha_left = true;
+ if(event.key.code == mgl::Keyboard::Right)
+ moving_captcha_right = true;
+ } else if(event.type == mgl::Event::KeyReleased) {
+ if(event.key.code == mgl::Keyboard::Left)
+ moving_captcha_left = false;
+ if(event.key.code == mgl::Keyboard::Right)
+ moving_captcha_right = false;
+ }
+
if(event.type == mgl::Event::Resized || event.type == mgl::Event::GainedFocus)
redraw = true;
else if(navigation_stage == NavigationStage::VIEWING_COMMENTS && event.type == mgl::Event::KeyPressed) {
@@ -4924,11 +4939,11 @@ namespace QuickMedia {
if(navigation_stage == NavigationStage::SOLVING_POST_CAPTCHA && captcha_texture.is_valid()) {
const float slide_speed = 0.5f;
const bool window_has_focus = window.has_focus();
- if(window_has_focus && window.is_key_pressed(mgl::Keyboard::Left)) {
+ if(window_has_focus && moving_captcha_left) {
captcha_slide -= (slide_speed * frame_elapsed_time_sec);
if(captcha_slide < 0.0f)
captcha_slide = 0.0f;
- } else if(window_has_focus && window.is_key_pressed(mgl::Keyboard::Right)) {
+ } else if(window_has_focus && moving_captcha_right) {
captcha_slide += (slide_speed * frame_elapsed_time_sec);
if(captcha_slide > 1.0f)
captcha_slide = 1.0f;