Introduce thread-safe take_screenshot
This commit is contained in:
parent
501eff233e
commit
82ef0372d5
6 changed files with 11 additions and 12 deletions
|
@ -42,8 +42,6 @@ bool g_bFilterGameWindow = true;
|
||||||
|
|
||||||
bool g_bBorderlessOutputWindow = false;
|
bool g_bBorderlessOutputWindow = false;
|
||||||
|
|
||||||
bool g_bTakeScreenshot = false;
|
|
||||||
|
|
||||||
bool g_bNiceCap = false;
|
bool g_bNiceCap = false;
|
||||||
int g_nOldNice = 0;
|
int g_nOldNice = 0;
|
||||||
int g_nNewNice = 0;
|
int g_nNewNice = 0;
|
||||||
|
|
|
@ -23,8 +23,6 @@ extern bool g_bFilterGameWindow;
|
||||||
|
|
||||||
extern bool g_bBorderlessOutputWindow;
|
extern bool g_bBorderlessOutputWindow;
|
||||||
|
|
||||||
extern bool g_bTakeScreenshot;
|
|
||||||
|
|
||||||
extern bool g_bNiceCap;
|
extern bool g_bNiceCap;
|
||||||
extern int g_nOldNice;
|
extern int g_nOldNice;
|
||||||
extern int g_nNewNice;
|
extern int g_nNewNice;
|
||||||
|
|
|
@ -160,7 +160,7 @@ void inputSDLThreadRun( void )
|
||||||
g_bFilterGameWindow = !g_bFilterGameWindow;
|
g_bFilterGameWindow = !g_bFilterGameWindow;
|
||||||
break;
|
break;
|
||||||
case KEY_S:
|
case KEY_S:
|
||||||
g_bTakeScreenshot = true;
|
take_screenshot();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
handled = false;
|
handled = false;
|
||||||
|
|
|
@ -276,12 +276,13 @@ static Bool drawDebugInfo = False;
|
||||||
static Bool debugEvents = False;
|
static Bool debugEvents = False;
|
||||||
static Bool steamMode = False;
|
static Bool steamMode = False;
|
||||||
static Bool alwaysComposite = False;
|
static Bool alwaysComposite = False;
|
||||||
static Bool takeScreenshot = False;
|
|
||||||
static Bool useXRes = True;
|
static Bool useXRes = True;
|
||||||
|
|
||||||
std::mutex wayland_commit_lock;
|
std::mutex wayland_commit_lock;
|
||||||
std::vector<ResListEntry_t> wayland_commit_queue;
|
std::vector<ResListEntry_t> wayland_commit_queue;
|
||||||
|
|
||||||
|
static std::atomic< bool > g_bTakeScreenshot{false};
|
||||||
|
|
||||||
static int g_nudgePipe[2];
|
static int g_nudgePipe[2];
|
||||||
|
|
||||||
// poor man's semaphore
|
// poor man's semaphore
|
||||||
|
@ -1249,11 +1250,7 @@ paint_all(Display *dpy, MouseCursor *cursor)
|
||||||
bool bDoComposite = true;
|
bool bDoComposite = true;
|
||||||
|
|
||||||
// Handoff from whatever thread to this one since we check ours twice
|
// Handoff from whatever thread to this one since we check ours twice
|
||||||
if ( g_bTakeScreenshot == true )
|
bool takeScreenshot = g_bTakeScreenshot.exchange(false);
|
||||||
{
|
|
||||||
takeScreenshot = true;
|
|
||||||
g_bTakeScreenshot = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( BIsNested() == false && alwaysComposite == False && takeScreenshot == False )
|
if ( BIsNested() == false && alwaysComposite == False && takeScreenshot == False )
|
||||||
{
|
{
|
||||||
|
@ -2913,6 +2910,11 @@ void nudge_steamcompmgr( void )
|
||||||
perror( "nudge_steamcompmgr: write failed" );
|
perror( "nudge_steamcompmgr: write failed" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void take_screenshot( void )
|
||||||
|
{
|
||||||
|
g_bTakeScreenshot = true;
|
||||||
|
}
|
||||||
|
|
||||||
void check_new_wayland_res( void )
|
void check_new_wayland_res( void )
|
||||||
{
|
{
|
||||||
// When importing buffer, we'll potentially need to perform operations with
|
// When importing buffer, we'll potentially need to perform operations with
|
||||||
|
|
|
@ -89,3 +89,4 @@ extern float focusedWindowOffsetX;
|
||||||
extern float focusedWindowOffsetY;
|
extern float focusedWindowOffsetY;
|
||||||
|
|
||||||
void nudge_steamcompmgr( void );
|
void nudge_steamcompmgr( void );
|
||||||
|
void take_screenshot( void );
|
||||||
|
|
|
@ -71,7 +71,7 @@ void sig_handler(int signal)
|
||||||
{
|
{
|
||||||
if ( signal == SIGUSR2 )
|
if ( signal == SIGUSR2 )
|
||||||
{
|
{
|
||||||
g_bTakeScreenshot = true;
|
take_screenshot();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue