C.W. Betts : winemac: Implement getting and setting screen saver state on OS X.
Alexandre Julliard
julliard at winehq.org
Fri Mar 29 12:17:58 CDT 2013
Module: wine
Branch: master
Commit: 95daa45dbcbca59a4eedc9d34966ebc309b6c330
URL: http://source.winehq.org/git/wine.git/?a=commit;h=95daa45dbcbca59a4eedc9d34966ebc309b6c330
Author: C.W. Betts <computers57 at hotmail.com>
Date: Mon Jan 28 12:32:21 2013 -0700
winemac: Implement getting and setting screen saver state on OS X.
---
dlls/winemac.drv/Makefile.in | 2 +-
dlls/winemac.drv/macdrv_main.c | 72 +++++++++++++++++++++++++++++++++++++
dlls/winemac.drv/winemac.drv.spec | 1 +
3 files changed, 74 insertions(+), 1 deletions(-)
diff --git a/dlls/winemac.drv/Makefile.in b/dlls/winemac.drv/Makefile.in
index 6bbac42..3e196e7 100644
--- a/dlls/winemac.drv/Makefile.in
+++ b/dlls/winemac.drv/Makefile.in
@@ -1,7 +1,7 @@
MODULE = winemac.drv
IMPORTS = uuid user32 gdi32 advapi32
DELAYIMPORTS = ole32 shell32
-EXTRALIBS = -framework AppKit -framework Carbon -framework Security -framework OpenGL
+EXTRALIBS = -framework AppKit -framework Carbon -framework Security -framework OpenGL -framework IOKit
C_SRCS = \
clipboard.c \
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c
index a801109..353b4ca 100644
--- a/dlls/winemac.drv/macdrv_main.c
+++ b/dlls/winemac.drv/macdrv_main.c
@@ -22,12 +22,20 @@
#include "config.h"
#include <Security/AuthSession.h>
+#include <IOKit/pwr_mgt/IOPMLib.h>
#include "macdrv.h"
+#include "winuser.h"
#include "wine/server.h"
WINE_DEFAULT_DEBUG_CHANNEL(macdrv);
+#ifndef kIOPMAssertionTypePreventUserIdleDisplaySleep
+#define kIOPMAssertionTypePreventUserIdleDisplaySleep CFSTR("PreventUserIdleDisplaySleep")
+#endif
+#ifndef kCFCoreFoundationVersionNumber10_7
+#define kCFCoreFoundationVersionNumber10_7 635.00
+#endif
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
@@ -206,3 +214,67 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved)
}
return ret;
}
+
+/***********************************************************************
+ * SystemParametersInfo (MACDRV.@)
+ */
+BOOL CDECL macdrv_SystemParametersInfo( UINT action, UINT int_param, void *ptr_param, UINT flags )
+{
+ switch (action)
+ {
+ case SPI_GETSCREENSAVEACTIVE:
+ if (ptr_param)
+ {
+ CFDictionaryRef assertionStates;
+ IOReturn status = IOPMCopyAssertionsStatus(&assertionStates);
+ if (status == kIOReturnSuccess)
+ {
+ CFNumberRef count = CFDictionaryGetValue(assertionStates, kIOPMAssertionTypeNoDisplaySleep);
+ CFNumberRef count2 = CFDictionaryGetValue(assertionStates, kIOPMAssertionTypePreventUserIdleDisplaySleep);
+ long longCount = 0, longCount2 = 0;
+
+ if (count)
+ CFNumberGetValue(count, kCFNumberLongType, &longCount);
+ if (count2)
+ CFNumberGetValue(count2, kCFNumberLongType, &longCount2);
+
+ *(BOOL *)ptr_param = !longCount && !longCount2;
+ CFRelease(assertionStates);
+ }
+ else
+ {
+ WARN("Could not determine screen saver state, error code %d\n", status);
+ *(BOOL *)ptr_param = TRUE;
+ }
+ return TRUE;
+ }
+ break;
+
+ case SPI_SETSCREENSAVEACTIVE:
+ {
+ static IOPMAssertionID powerAssertion = kIOPMNullAssertionID;
+ if (int_param)
+ {
+ if (powerAssertion != kIOPMNullAssertionID)
+ {
+ IOPMAssertionRelease(powerAssertion);
+ powerAssertion = kIOPMNullAssertionID;
+ }
+ }
+ else if (powerAssertion == kIOPMNullAssertionID)
+ {
+ CFStringRef assertName;
+ /*Are we running Lion or later?*/
+ if (kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber10_7)
+ assertName = kIOPMAssertionTypePreventUserIdleDisplaySleep;
+ else
+ assertName = kIOPMAssertionTypeNoDisplaySleep;
+ IOPMAssertionCreateWithName( assertName, kIOPMAssertionLevelOn,
+ CFSTR("Wine Process requesting no screen saver"),
+ &powerAssertion);
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
diff --git a/dlls/winemac.drv/winemac.drv.spec b/dlls/winemac.drv/winemac.drv.spec
index 9eb416a..460d0ed 100644
--- a/dlls/winemac.drv/winemac.drv.spec
+++ b/dlls/winemac.drv/winemac.drv.spec
@@ -46,6 +46,7 @@
@ cdecl WindowMessage(long long long long) macdrv_WindowMessage
@ cdecl WindowPosChanged(long long long ptr ptr ptr ptr ptr) macdrv_WindowPosChanged
@ cdecl WindowPosChanging(long long long ptr ptr ptr ptr) macdrv_WindowPosChanging
+@ cdecl SystemParametersInfo(long long ptr long) macdrv_SystemParametersInfo
# System tray
@ cdecl wine_notify_icon(long ptr)
More information about the wine-cvs
mailing list