[PATCH v5] winemac.drv: Wake up the display on user input.

Ken Thomases ken at codeweavers.com
Thu Jul 5 16:02:32 CDT 2018


From: Zebediah Figura <zfigura at codeweavers.com>

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
Signed-off-by: Ken Thomases <ken at codeweavers.com>
---
v5: include IOPMLib.h to fix build, call UpdateSystemActivity() to also reset screen saver
---
 dlls/winemac.drv/window.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c
index e49a445..6558824 100644
--- a/dlls/winemac.drv/window.c
+++ b/dlls/winemac.drv/window.c
@@ -23,6 +23,13 @@
 
 #include "config.h"
 
+#include <IOKit/pwr_mgt/IOPMLib.h>
+#define GetCurrentThread Mac_GetCurrentThread
+#define LoadResource Mac_LoadResource
+#include <CoreServices/CoreServices.h>
+#undef GetCurrentThread
+#undef LoadResource
+
 #include "macdrv.h"
 #include "winuser.h"
 #include "wine/unicode.h"
@@ -1551,13 +1558,44 @@ BOOL CDECL macdrv_CreateDesktopWindow(HWND hwnd)
 }
 
 
+static WNDPROC desktop_orig_wndproc;
+
+#define WM_WINE_NOTIFY_ACTIVITY WM_USER
+
+static LRESULT CALLBACK desktop_wndproc_wrapper( HWND hwnd, UINT msg, WPARAM wp, LPARAM lp )
+{
+    switch (msg)
+    {
+    case WM_WINE_NOTIFY_ACTIVITY:
+    {
+        /* This wakes from display sleep, but doesn't affect the screen saver. */
+        static IOPMAssertionID assertion;
+        IOPMAssertionDeclareUserActivity(CFSTR("Wine user input"), kIOPMUserActiveLocal, &assertion);
+
+        /* This prevents the screen saver, but doesn't wake from display sleep. */
+        /* It's deprecated, but there's no better alternative. */
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+        UpdateSystemActivity(UsrActivity);
+#pragma clang diagnostic pop
+        break;
+    }
+    }
+    return desktop_orig_wndproc( hwnd, msg, wp, lp );
+}
+
 /**********************************************************************
  *              CreateWindow   (MACDRV.@)
  */
 BOOL CDECL macdrv_CreateWindow(HWND hwnd)
 {
     if (hwnd == GetDesktopWindow())
+    {
+        desktop_orig_wndproc = (WNDPROC)SetWindowLongPtrW( GetDesktopWindow(),
+            GWLP_WNDPROC, (LONG_PTR)desktop_wndproc_wrapper );
+
         macdrv_init_clipboard();
+    }
     return TRUE;
 }
 
-- 
2.10.2




More information about the wine-devel mailing list