PATCH - implement LockWorkStation using xdg-screensaver

Steven Edwards winehacker at gmail.com
Sat May 12 05:13:42 CDT 2007


Hi,
This patch was an attempt to implemented LockWorkStation using
xdg-screensaver. It works for my simple test app that calls the
function but my real world application Process Explorer ends up
hanging now rather than crashing and still does not properly lock the
workstation. I am not quite sure why. Perhaps someone else is
interested in this to help improve wine usability. Also I guess I
should use HeapAlloc rather than malloc.

-- 
Steven Edwards

"There is one thing stronger than all the armies in the world, and
that is an idea whose time has come." - Victor Hugo
-------------- next part --------------
From 8e7001c9e3309492c881e9c1f717f26e3e379dfb Mon Sep 17 00:00:00 2001
From: Steven Edwards <winehacker at gmail.com>
Date: Sat, 12 May 2007 05:49:52 -0400
Subject: [PATCH] Implemented LockWorkStation using xdg-screensaver

---
 dlls/user32/user32.spec |    2 +-
 dlls/user32/user_main.c |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 1 deletions(-)

diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec
index 7e4ce33..f97afd6 100644
--- a/dlls/user32/user32.spec
+++ b/dlls/user32/user32.spec
@@ -475,7 +475,7 @@
 @ stdcall LockSetForegroundWindow (long)
 @ stub LockWindowStation
 @ stdcall LockWindowUpdate(long)
-@ stub LockWorkStation
+@ stdcall LockWorkStation()
 @ stdcall LookupIconIdFromDirectory(ptr long)
 @ stdcall LookupIconIdFromDirectoryEx(ptr long long long long)
 @ stub MBToWCSEx
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index 8b3d83c..433718e 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -21,6 +21,9 @@
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+
 #include "windef.h"
 #include "winbase.h"
 #include "wingdi.h"
@@ -319,3 +322,42 @@ BOOL WINAPI ExitWindowsEx( UINT flags, DWORD reason )
     CloseHandle( pi.hThread );
     return TRUE;
 }
+
+/* malloc wrapper */
+static inline void *xmalloc( size_t size )
+{
+    void *res;
+
+    if (!size) size = 1;
+    if (!(res = malloc( size ))) 
+    {
+        ERR_(graphics)( "virtual memory exhausted\n");
+    }
+    return res;
+}
+
+/***********************************************************************
+ *		LockWorkStation (USER32.@)
+ */
+BOOL WINAPI LockWorkStation(void)
+{
+    /* Use xdg-screensaver */
+    static const char screensaver[] = "/usr/bin/xdg-screensaver";
+    static const char lock_command[] = "lock";
+    char **argv;
+    
+    FILE *f = fopen( screensaver, "r" );
+    if (!f)
+    {
+        FIXME_(graphics)( "no support for xdg-screensaver detected\n");
+        return 0;
+    }
+    
+    argv = xmalloc(sizeof(lock_command));
+    memcpy( argv[1] , lock_command, sizeof(lock_command));
+    execv( screensaver, argv );
+    free( argv );
+
+    return 1;
+}
+
-- 
1.4.4.2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lock.c
Type: text/x-csrc
Size: 202 bytes
Desc: not available
Url : http://www.winehq.org/pipermail/wine-patches/attachments/20070512/4e956b8a/lock.c


More information about the wine-patches mailing list