diff --git a/src/main.cpp b/src/main.cpp index a72768c..c4368ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,8 +42,6 @@ bool g_bFilterGameWindow = true; bool g_bBorderlessOutputWindow = false; -bool g_bTakeScreenshot = false; - bool g_bNiceCap = false; int g_nOldNice = 0; int g_nNewNice = 0; diff --git a/src/main.hpp b/src/main.hpp index 389292d..dc75135 100644 --- a/src/main.hpp +++ b/src/main.hpp @@ -23,8 +23,6 @@ extern bool g_bFilterGameWindow; extern bool g_bBorderlessOutputWindow; -extern bool g_bTakeScreenshot; - extern bool g_bNiceCap; extern int g_nOldNice; extern int g_nNewNice; diff --git a/src/sdlwindow.cpp b/src/sdlwindow.cpp index d2bd59c..fc05618 100644 --- a/src/sdlwindow.cpp +++ b/src/sdlwindow.cpp @@ -160,7 +160,7 @@ void inputSDLThreadRun( void ) g_bFilterGameWindow = !g_bFilterGameWindow; break; case KEY_S: - g_bTakeScreenshot = true; + take_screenshot(); break; default: handled = false; diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp index 13f1ef0..91cf291 100644 --- a/src/steamcompmgr.cpp +++ b/src/steamcompmgr.cpp @@ -276,12 +276,13 @@ static Bool drawDebugInfo = False; static Bool debugEvents = False; static Bool steamMode = False; static Bool alwaysComposite = False; -static Bool takeScreenshot = False; static Bool useXRes = True; std::mutex wayland_commit_lock; std::vector wayland_commit_queue; +static std::atomic< bool > g_bTakeScreenshot{false}; + static int g_nudgePipe[2]; // poor man's semaphore @@ -1249,11 +1250,7 @@ paint_all(Display *dpy, MouseCursor *cursor) bool bDoComposite = true; // Handoff from whatever thread to this one since we check ours twice - if ( g_bTakeScreenshot == true ) - { - takeScreenshot = true; - g_bTakeScreenshot = false; - } + bool takeScreenshot = g_bTakeScreenshot.exchange(false); if ( BIsNested() == false && alwaysComposite == False && takeScreenshot == False ) { @@ -2913,6 +2910,11 @@ void nudge_steamcompmgr( void ) perror( "nudge_steamcompmgr: write failed" ); } +void take_screenshot( void ) +{ + g_bTakeScreenshot = true; +} + void check_new_wayland_res( void ) { // When importing buffer, we'll potentially need to perform operations with diff --git a/src/steamcompmgr.hpp b/src/steamcompmgr.hpp index 0e54798..c1364e0 100644 --- a/src/steamcompmgr.hpp +++ b/src/steamcompmgr.hpp @@ -89,3 +89,4 @@ extern float focusedWindowOffsetX; extern float focusedWindowOffsetY; void nudge_steamcompmgr( void ); +void take_screenshot( void ); diff --git a/src/wlserver.cpp b/src/wlserver.cpp index a567b6f..37a98e0 100644 --- a/src/wlserver.cpp +++ b/src/wlserver.cpp @@ -71,7 +71,7 @@ void sig_handler(int signal) { if ( signal == SIGUSR2 ) { - g_bTakeScreenshot = true; + take_screenshot(); return; }