Implement LockWorkstation using xdg-screensaver from explorer
Steven Edwards
winehacker at gmail.com
Fri Jul 27 03:21:19 CDT 2007
This time in explorer....
With this patch, Process Explorer no longer crashes when locking the
workstation from within the application. If xdg-screensaver is not
present on the system, explorer simply returns in which case
LockWorkstion thinks it still succeeded. I still like the idea of
having our own screensaver for Desktop mode and running that when
LockWorkstation is called. If this is accepted then I will either add
a check for desktop mode to avoid the call to xdg-screensaver or write
a wine scr that only runs in Desktop mode.
--
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 91c4b55fbc31ff282c44e109e2d84ecbfff70f8b Mon Sep 17 00:00:00 2001
From: Steven Edwards <winehacker at gmail.com>
Date: Fri, 27 Jul 2007 04:49:25 -0400
Subject: [PATCH] (partly) implement LockWorkstation using xdg-screensaver
---
dlls/user32/user32.spec | 2 +-
dlls/user32/user_main.c | 27 +++++++++++++++++++++++++++
programs/explorer/desktop.c | 13 +++++++++++++
programs/explorer/explorer.c | 5 +++++
programs/explorer/explorer_private.h | 1 +
5 files changed, 47 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 @@ # @ stub LoadKeyboardLayoutEx
@ 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 e572220..591ff16 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -318,3 +318,30 @@ BOOL WINAPI ExitWindowsEx( UINT flags, D
CloseHandle( pi.hThread );
return TRUE;
}
+
+/***********************************************************************
+ * LockWorkStation (USER32.@)
+ */
+BOOL WINAPI LockWorkStation( void )
+{
+ static const WCHAR cmdW[] =
+ {'\\','e','x','p','l','o','r','e','r','.','e','x','e',' ','/','l','o','c','k',0};
+
+ WCHAR cmdline[MAX_PATH + 64];
+ PROCESS_INFORMATION pi;
+ STARTUPINFOW si;
+
+ GetSystemDirectoryW( cmdline, MAX_PATH );
+ lstrcatW( cmdline, cmdW );
+
+ memset( &si, 0, sizeof si );
+ si.cb = sizeof si;
+ if (!CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &si, &pi ))
+ {
+ ERR( "Failed to run %s\n", debugstr_w(cmdline) );
+ return FALSE;
+ }
+ CloseHandle( pi.hProcess );
+ CloseHandle( pi.hThread );
+ return TRUE;
+}
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 7f2e23f..86bce5d 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -19,6 +19,7 @@
*/
#include <stdio.h>
+#include <unistd.h>
#define OEMRESOURCE
@@ -211,3 +212,15 @@ void manage_desktop( char *arg )
ExitProcess( 0 );
}
+
+void lock_desktop( void )
+{
+ /* FIXME: do something here about running in desktop mode */
+ const char *argv[3];
+
+ argv[0] = "xdg-screensaver";
+ argv[1] = "lock";
+ argv[2] = NULL;
+ execvp( "xdg-screensaver1", (char **)argv );
+ return;
+}
diff --git a/programs/explorer/explorer.c b/programs/explorer/explorer.c
index 0f7c257..4aecf4c 100644
--- a/programs/explorer/explorer.c
+++ b/programs/explorer/explorer.c
@@ -135,6 +135,11 @@ static void ParseCommandLine(LPSTR comma
{
manage_desktop( p + 7 ); /* the rest of the command line is handled by desktop mode */
}
+ else if (strncmp(p,"lock",5)==0)
+ {
+ lock_desktop();
+ return;
+ }
p2 = p;
p = strchr(p,'/');
}
diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h
index 59667eb..94c8534 100644
--- a/programs/explorer/explorer_private.h
+++ b/programs/explorer/explorer_private.h
@@ -26,6 +26,7 @@ extern BOOL add_dos_device( const char *
extern BOOL remove_dos_device( const char *udi );
extern void manage_desktop( char *arg );
+extern void lock_desktop( void );
extern void initialize_diskarbitration(void);
extern void initialize_hal(void);
extern void initialize_systray(void);
--
1.4.1
More information about the wine-patches
mailing list