summaryrefslogtreecommitdiff
path: root/hw/xquartz/quartz.c
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2010-11-26 15:31:22 -0500
committerJeremy Huddleston <jeremyhu@apple.com>2010-12-03 16:23:04 -0800
commitca431371a23a2b9ad36c1d64e11ea41d5e4e5f04 (patch)
tree9162c44040fffae4e921377ba59f58da220d61c1 /hw/xquartz/quartz.c
parent311cad33155c64ed996418808727fc417168592e (diff)
XQuartz: Disable the Mac OS X screensaver when in full screen mode
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'hw/xquartz/quartz.c')
-rw-r--r--hw/xquartz/quartz.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/hw/xquartz/quartz.c b/hw/xquartz/quartz.c
index e21303ccd..26b2c1f38 100644
--- a/hw/xquartz/quartz.c
+++ b/hw/xquartz/quartz.c
@@ -62,6 +62,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <IOKit/pwr_mgt/IOPMLib.h>
+#include <pthread.h>
#include <rootlessCommon.h>
#include <Xplugin.h>
@@ -246,6 +247,40 @@ void QuartzUpdateScreens(void) {
quartzProcs->UpdateScreen(pScreen);
}
+static void pokeActivityCallback(CFRunLoopTimerRef timer, void *info) {
+ UpdateSystemActivity(OverallAct);
+}
+
+static void QuartzScreenSaver(int state) {
+ static CFRunLoopTimerRef pokeActivityTimer = NULL;
+ static CFRunLoopTimerContext pokeActivityContext = { 0, NULL, NULL, NULL, NULL };
+ static pthread_mutex_t pokeActivityMutex = PTHREAD_MUTEX_INITIALIZER;
+
+ pthread_mutex_lock(&pokeActivityMutex);
+
+ if(state) {
+ if(pokeActivityTimer == NULL)
+ goto QuartzScreenSaverEnd;
+
+ CFRunLoopTimerInvalidate(pokeActivityTimer);
+ CFRelease(pokeActivityTimer);
+ pokeActivityTimer = NULL;
+ } else {
+ if(pokeActivityTimer != NULL)
+ goto QuartzScreenSaverEnd;
+
+ pokeActivityTimer = CFRunLoopTimerCreate(NULL, CFAbsoluteTimeGetCurrent(), 30, 0, 0, pokeActivityCallback, &pokeActivityContext);
+ if(pokeActivityTimer == NULL) {
+ ErrorF("Unable to create pokeActivityTimer.\n");
+ goto QuartzScreenSaverEnd;
+ }
+
+ CFRunLoopAddTimer(CFRunLoopGetMain(), pokeActivityTimer, kCFRunLoopCommonModes);
+ }
+QuartzScreenSaverEnd:
+ pthread_mutex_unlock(&pokeActivityMutex);
+}
+
void QuartzShowFullscreen(int state) {
int i;
@@ -256,6 +291,8 @@ void QuartzShowFullscreen(int state) {
return;
}
+ QuartzScreenSaver(!state);
+
if(XQuartzFullscreenVisible == state)
return;