Skip to content

Commit

Permalink
Prevent screen-blanking/screen-saver/sleep on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoo-sel committed Jun 2, 2023
1 parent e2ad0a2 commit c8f13f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
15 changes: 15 additions & 0 deletions src/display/prevent_screensaver_windows.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* 2023 Arnaud Sellier
*
* Software: VCS
*
*/

#include <windows.h>
#include "main.h"

subsystem_releaser_t kd_prevent_screensaver(void)
{
SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED);
return []{}; // no need to unset, OS takes care of that
}
16 changes: 9 additions & 7 deletions vcs.pro
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ linux {
-lopencv_highgui \
-lopencv_core \
-lopencv_photo

contains(DEFINES, VCS_FOR_X11) {
SOURCES += src/display/prevent_screensaver_x11.cpp
LIBS += -lX11 -lXext
} else {
SOURCES += src/display/prevent_screensaver_null.cpp
}
}

win32 {
Expand All @@ -42,6 +49,8 @@ win32 {
-L"../opencv-3.4.14/mingw/install/x64/mingw/lib" \
-lopencv_world3414

SOURCES += src/display/prevent_screensaver_windows.cpp

RC_ICONS = "src/display/qt/images/icons/appicon.ico"
}

Expand Down Expand Up @@ -306,13 +315,6 @@ contains(DEFINES, CAPTURE_BACKEND_RGBEASY) {
}
}

contains(DEFINES, VCS_FOR_X11) {
SOURCES += src/display/prevent_screensaver_x11.cpp
LIBS += -lX11 -lXext
} else {
SOURCES += src/display/prevent_screensaver_null.cpp
}

QT += core gui widgets opengl openglwidgets
TARGET = vcs
TEMPLATE = app
Expand Down

0 comments on commit c8f13f6

Please sign in to comment.