PATCH - implement LockWorkStation using xdg-screensaver

Marcus Meissner marcus at jet.franken.de
Sat May 12 08:51:32 CDT 2007


On Sat, May 12, 2007 at 06:13:42AM -0400, Steven Edwards wrote:
> 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

> 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
> 
> + *		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;
> +    }

You should use either stat/lstat or just check for failure from execve.
   
> +    argv = xmalloc(sizeof(lock_command));
> +    memcpy( argv[1] , lock_command, sizeof(lock_command));

This is not going to work.

char *argv[2];

argv[0] = "/usr/bin/xdg-screensaver";
argv[1] = "lock";
argv[2] = NULL;

> +    execv( screensaver, argv );

And actually you cannot use execve(), since it replaces the current process with
the new one.

Use system("/usr/bin/xdg-screensaver lock") or CreateProcess().

Ciao, Marcus



More information about the wine-devel mailing list