forked from Mirrors/wine-wine
x11drv: Moved desktop mode handling to the explorer process.
Per-application desktop mode settings are no longer supported. Apps can be launched in a specific desktop window by using: explorer /desktop=name[,widthxheight] app.exe [args] If the named desktop already exists the app is launched inside it. The default desktop is cleverly named "default".oldstable
parent
ba1517fa80
commit
db6608ac9f
|
@ -31,80 +31,6 @@
|
||||||
|
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
WINE_DEFAULT_DEBUG_CHANNEL(x11drv);
|
||||||
|
|
||||||
|
|
||||||
/* desktop window procedure */
|
|
||||||
static LRESULT WINAPI desktop_winproc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
|
|
||||||
{
|
|
||||||
switch(message)
|
|
||||||
{
|
|
||||||
case WM_NCCREATE:
|
|
||||||
SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
|
|
||||||
SetDeskWallPaper( (LPSTR)-1 );
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_ERASEBKGND:
|
|
||||||
PaintDesktop( (HDC)wParam );
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
case WM_SYSCOMMAND:
|
|
||||||
if ((wParam & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
|
|
||||||
break;
|
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
|
||||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
|
|
||||||
|
|
||||||
case WM_NCHITTEST:
|
|
||||||
return HTCLIENT;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* desktop window manager thread */
|
|
||||||
static DWORD CALLBACK desktop_thread( LPVOID driver_data )
|
|
||||||
{
|
|
||||||
Display *display;
|
|
||||||
MSG msg;
|
|
||||||
HWND hwnd;
|
|
||||||
Atom atom = x11drv_atom(WM_DELETE_WINDOW);
|
|
||||||
|
|
||||||
TlsSetValue( thread_data_tls_index, driver_data );
|
|
||||||
display = thread_display();
|
|
||||||
hwnd = GetDesktopWindow();
|
|
||||||
|
|
||||||
SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_winproc );
|
|
||||||
wine_tsx11_lock();
|
|
||||||
XSaveContext( display, root_window, winContext, (char *)hwnd );
|
|
||||||
XChangeProperty ( display, root_window, x11drv_atom(WM_PROTOCOLS),
|
|
||||||
XA_ATOM, 32, PropModeReplace, (unsigned char *)&atom, 1 );
|
|
||||||
XMapWindow( display, root_window );
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
|
|
||||||
while (GetMessageW( &msg, hwnd, 0, 0 )) DispatchMessageW( &msg );
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
|
||||||
* X11DRV_create_desktop_thread
|
|
||||||
*
|
|
||||||
* Create the thread that manages the desktop window
|
|
||||||
*/
|
|
||||||
void X11DRV_create_desktop_thread(void)
|
|
||||||
{
|
|
||||||
HANDLE handle = CreateThread( NULL, 0, desktop_thread,
|
|
||||||
TlsGetValue( thread_data_tls_index ), 0, &desktop_tid );
|
|
||||||
if (!handle)
|
|
||||||
{
|
|
||||||
MESSAGE( "Could not create desktop thread\n" );
|
|
||||||
ExitProcess(1);
|
|
||||||
}
|
|
||||||
/* we transferred our driver data to the new thread */
|
|
||||||
TlsSetValue( thread_data_tls_index, NULL );
|
|
||||||
CloseHandle( handle );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* data for resolution changing */
|
/* data for resolution changing */
|
||||||
static LPDDHALMODEINFO dd_modes;
|
static LPDDHALMODEINFO dd_modes;
|
||||||
static unsigned int dd_mode_count;
|
static unsigned int dd_mode_count;
|
||||||
|
@ -209,72 +135,36 @@ static void X11DRV_desktop_SetCurrentMode(int mode)
|
||||||
*
|
*
|
||||||
* Create the X11 desktop window for the desktop mode.
|
* Create the X11 desktop window for the desktop mode.
|
||||||
*/
|
*/
|
||||||
Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
|
Window X11DRV_create_desktop( UINT width, UINT height )
|
||||||
{
|
{
|
||||||
int x = 0, y = 0, flags;
|
|
||||||
unsigned int width = 640, height = 480; /* Default size = 640x480 */
|
|
||||||
char *name = GetCommandLineA();
|
|
||||||
XSizeHints *size_hints;
|
|
||||||
XWMHints *wm_hints;
|
|
||||||
XClassHint *class_hints;
|
|
||||||
XSetWindowAttributes win_attr;
|
XSetWindowAttributes win_attr;
|
||||||
XTextProperty window_name;
|
|
||||||
Window win;
|
Window win;
|
||||||
Display *display = thread_display();
|
Display *display = thread_display();
|
||||||
|
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
flags = XParseGeometry( geometry, &x, &y, &width, &height );
|
|
||||||
max_width = screen_width;
|
max_width = screen_width;
|
||||||
max_height = screen_height;
|
max_height = screen_height;
|
||||||
screen_width = width;
|
screen_width = width;
|
||||||
screen_height = height;
|
screen_height = height;
|
||||||
|
|
||||||
/* Create window */
|
/* Create window */
|
||||||
win_attr.background_pixel = BlackPixel(display, 0);
|
|
||||||
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
|
win_attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask |
|
||||||
PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
|
PointerMotionMask | ButtonPressMask | ButtonReleaseMask;
|
||||||
win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
|
win_attr.cursor = XCreateFontCursor( display, XC_top_left_arrow );
|
||||||
|
|
||||||
if (desktop_vi)
|
if (visual != DefaultVisual( display, DefaultScreen(display) ))
|
||||||
win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
|
win_attr.colormap = XCreateColormap( display, DefaultRootWindow(display),
|
||||||
visual, AllocNone );
|
visual, AllocNone );
|
||||||
else
|
else
|
||||||
win_attr.colormap = None;
|
win_attr.colormap = None;
|
||||||
|
|
||||||
win = XCreateWindow( display, DefaultRootWindow(display),
|
win = XCreateWindow( display, DefaultRootWindow(display),
|
||||||
x, y, width, height, 0, screen_depth, InputOutput, visual,
|
0, 0, width, height, 0, screen_depth, InputOutput, visual,
|
||||||
CWBackPixel | CWEventMask | CWCursor | CWColormap, &win_attr );
|
CWEventMask | CWCursor | CWColormap, &win_attr );
|
||||||
|
|
||||||
/* Set window manager properties */
|
|
||||||
size_hints = XAllocSizeHints();
|
|
||||||
wm_hints = XAllocWMHints();
|
|
||||||
class_hints = XAllocClassHint();
|
|
||||||
if (!size_hints || !wm_hints || !class_hints)
|
|
||||||
{
|
|
||||||
MESSAGE("Not enough memory for window manager hints.\n" );
|
|
||||||
ExitProcess(1);
|
|
||||||
}
|
|
||||||
size_hints->min_width = size_hints->max_width = width;
|
|
||||||
size_hints->min_height = size_hints->max_height = height;
|
|
||||||
size_hints->flags = PMinSize | PMaxSize;
|
|
||||||
if (flags & (XValue | YValue)) size_hints->flags |= USPosition;
|
|
||||||
if (flags & (WidthValue | HeightValue)) size_hints->flags |= USSize;
|
|
||||||
else size_hints->flags |= PSize;
|
|
||||||
|
|
||||||
wm_hints->flags = InputHint | StateHint;
|
|
||||||
wm_hints->input = True;
|
|
||||||
wm_hints->initial_state = NormalState;
|
|
||||||
class_hints->res_name = "wine";
|
|
||||||
class_hints->res_class = "Wine";
|
|
||||||
|
|
||||||
XStringListToTextProperty( &name, 1, &window_name );
|
|
||||||
XSetWMProperties( display, win, &window_name, &window_name,
|
|
||||||
NULL, 0, size_hints, wm_hints, class_hints );
|
|
||||||
XFree( size_hints );
|
|
||||||
XFree( wm_hints );
|
|
||||||
XFree( class_hints );
|
|
||||||
XFlush( display );
|
XFlush( display );
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
|
if (win == None) return None;
|
||||||
|
|
||||||
/* initialize the available resolutions */
|
/* initialize the available resolutions */
|
||||||
dd_modes = X11DRV_Settings_SetHandlers("desktop",
|
dd_modes = X11DRV_Settings_SetHandlers("desktop",
|
||||||
X11DRV_desktop_GetCurrentMode,
|
X11DRV_desktop_GetCurrentMode,
|
||||||
|
@ -284,5 +174,6 @@ Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry )
|
||||||
X11DRV_Settings_AddDepthModes();
|
X11DRV_Settings_AddDepthModes();
|
||||||
dd_mode_count = X11DRV_Settings_GetModeCount();
|
dd_mode_count = X11DRV_Settings_GetModeCount();
|
||||||
X11DRV_Settings_SetDefaultMode(0);
|
X11DRV_Settings_SetDefaultMode(0);
|
||||||
|
root_window = win;
|
||||||
return win;
|
return win;
|
||||||
}
|
}
|
||||||
|
|
|
@ -846,30 +846,58 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* fill in the desktop X window id in the x11drv_win_data structure */
|
||||||
|
static void get_desktop_xwin( Display *display, struct x11drv_win_data *data )
|
||||||
|
{
|
||||||
|
RECT rect;
|
||||||
|
Window win = (Window)GetPropA( data->hwnd, whole_window_prop );
|
||||||
|
|
||||||
|
if (win)
|
||||||
|
{
|
||||||
|
/* retrieve the real size of the desktop */
|
||||||
|
SERVER_START_REQ( get_window_rectangles )
|
||||||
|
{
|
||||||
|
req->handle = data->hwnd;
|
||||||
|
if (!wine_server_call( req ))
|
||||||
|
{
|
||||||
|
screen_width = reply->window.right - reply->window.left;
|
||||||
|
screen_height = reply->window.bottom - reply->window.top;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SERVER_END_REQ;
|
||||||
|
data->whole_window = root_window = win;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VisualID visualid;
|
||||||
|
|
||||||
|
wine_tsx11_lock();
|
||||||
|
visualid = XVisualIDFromVisual(visual);
|
||||||
|
wine_tsx11_unlock();
|
||||||
|
SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
|
||||||
|
SetPropA( data->hwnd, visual_id_prop, (HANDLE)visualid );
|
||||||
|
data->whole_window = root_window;
|
||||||
|
SetRect( &rect, 0, 0, screen_width, screen_height );
|
||||||
|
X11DRV_set_window_pos( data->hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL );
|
||||||
|
if (root_window != DefaultRootWindow( display ))
|
||||||
|
{
|
||||||
|
data->managed = TRUE;
|
||||||
|
SetPropA( data->hwnd, managed_prop, (HANDLE)1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CreateDesktopWindow (X11DRV.@)
|
* CreateDesktopWindow (X11DRV.@)
|
||||||
*/
|
*/
|
||||||
BOOL X11DRV_CreateDesktopWindow( HWND hwnd )
|
BOOL X11DRV_CreateDesktopWindow( HWND hwnd )
|
||||||
{
|
{
|
||||||
Display *display = thread_display();
|
Display *display = thread_display();
|
||||||
VisualID visualid;
|
|
||||||
struct x11drv_win_data *data;
|
struct x11drv_win_data *data;
|
||||||
RECT rect;
|
|
||||||
|
|
||||||
if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
|
if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
|
||||||
data->whole_window = root_window;
|
|
||||||
|
|
||||||
SetRect( &rect, 0, 0, screen_width, screen_height );
|
get_desktop_xwin( display, data );
|
||||||
X11DRV_set_window_pos( hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL );
|
|
||||||
|
|
||||||
wine_tsx11_lock();
|
|
||||||
visualid = XVisualIDFromVisual(visual);
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
|
|
||||||
SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
|
|
||||||
SetPropA( data->hwnd, visual_id_prop, (HANDLE)visualid );
|
|
||||||
|
|
||||||
if (root_window != DefaultRootWindow(display) && !desktop_tid) X11DRV_create_desktop_thread();
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -922,6 +950,10 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
|
||||||
{
|
{
|
||||||
if (!create_whole_window( display, data, cs->style )) goto failed;
|
if (!create_whole_window( display, data, cs->style )) goto failed;
|
||||||
}
|
}
|
||||||
|
else if (hwnd == GetDesktopWindow())
|
||||||
|
{
|
||||||
|
get_desktop_xwin( display, data );
|
||||||
|
}
|
||||||
|
|
||||||
/* get class or window DC if needed */
|
/* get class or window DC if needed */
|
||||||
alloc_window_dce( data );
|
alloc_window_dce( data );
|
||||||
|
|
|
@ -123,5 +123,8 @@
|
||||||
@ cdecl -norelay wine_tsx11_lock()
|
@ cdecl -norelay wine_tsx11_lock()
|
||||||
@ cdecl -norelay wine_tsx11_unlock()
|
@ cdecl -norelay wine_tsx11_unlock()
|
||||||
|
|
||||||
|
# Desktop
|
||||||
|
@ cdecl wine_create_desktop(long long) X11DRV_create_desktop
|
||||||
|
|
||||||
# XIM
|
# XIM
|
||||||
@ cdecl ForceXIMReset(long) X11DRV_ForceXIMReset
|
@ cdecl ForceXIMReset(long) X11DRV_ForceXIMReset
|
||||||
|
|
|
@ -676,8 +676,6 @@ extern int X11DRV_check_error(void);
|
||||||
extern void X11DRV_set_iconic_state( HWND hwnd );
|
extern void X11DRV_set_iconic_state( HWND hwnd );
|
||||||
extern void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect );
|
extern void X11DRV_window_to_X_rect( struct x11drv_win_data *data, RECT *rect );
|
||||||
extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect );
|
extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect );
|
||||||
extern void X11DRV_create_desktop_thread(void);
|
|
||||||
extern Window X11DRV_create_desktop( XVisualInfo *desktop_vi, const char *geometry );
|
|
||||||
extern void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data );
|
extern void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data );
|
||||||
extern void X11DRV_sync_window_position( Display *display, struct x11drv_win_data *data,
|
extern void X11DRV_sync_window_position( Display *display, struct x11drv_win_data *data,
|
||||||
UINT swp_flags, const RECT *new_client_rect,
|
UINT swp_flags, const RECT *new_client_rect,
|
||||||
|
|
|
@ -87,7 +87,6 @@ int alloc_system_colors = 256;
|
||||||
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
|
DWORD thread_data_tls_index = TLS_OUT_OF_INDEXES;
|
||||||
|
|
||||||
static BOOL desktop_dbl_buf = TRUE;
|
static BOOL desktop_dbl_buf = TRUE;
|
||||||
static char *desktop_geometry;
|
|
||||||
|
|
||||||
static x11drv_error_callback err_callback; /* current callback for error */
|
static x11drv_error_callback err_callback; /* current callback for error */
|
||||||
static Display *err_callback_display; /* display callback is set for */
|
static Display *err_callback_display; /* display callback is set for */
|
||||||
|
@ -296,14 +295,6 @@ static void setup_options(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_config_key( hkey, appkey, "Desktop", buffer, sizeof(buffer) ))
|
|
||||||
{
|
|
||||||
/* Imperfect validation: If Desktop=N, then we don't turn on
|
|
||||||
** the --desktop option. We should really validate for a correct
|
|
||||||
** sizing entry */
|
|
||||||
if (!IS_OPTION_FALSE(buffer[0])) desktop_geometry = strdup(buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!get_config_key( hkey, appkey, "Managed", buffer, sizeof(buffer) ))
|
if (!get_config_key( hkey, appkey, "Managed", buffer, sizeof(buffer) ))
|
||||||
managed_mode = IS_OPTION_TRUE( buffer[0] );
|
managed_mode = IS_OPTION_TRUE( buffer[0] );
|
||||||
|
|
||||||
|
@ -409,6 +400,7 @@ static BOOL process_attach(void)
|
||||||
visual = desktop_vi->visual;
|
visual = desktop_vi->visual;
|
||||||
screen = ScreenOfDisplay(display, desktop_vi->screen);
|
screen = ScreenOfDisplay(display, desktop_vi->screen);
|
||||||
screen_depth = desktop_vi->depth;
|
screen_depth = desktop_vi->depth;
|
||||||
|
XFree(desktop_vi);
|
||||||
}
|
}
|
||||||
|
|
||||||
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
|
XInternAtoms( display, (char **)atom_names, NB_XATOMS - FIRST_XATOM, False, X11DRV_Atoms );
|
||||||
|
@ -420,13 +412,6 @@ static BOOL process_attach(void)
|
||||||
|
|
||||||
X11DRV_Settings_Init();
|
X11DRV_Settings_Init();
|
||||||
|
|
||||||
if (desktop_geometry)
|
|
||||||
{
|
|
||||||
root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
|
|
||||||
}
|
|
||||||
if(desktop_vi)
|
|
||||||
XFree(desktop_vi);
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBXXF86VM
|
#ifdef HAVE_LIBXXF86VM
|
||||||
/* initialize XVidMode */
|
/* initialize XVidMode */
|
||||||
X11DRV_XF86VM_Init();
|
X11DRV_XF86VM_Init();
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <wine/debug.h>
|
#include <wine/debug.h>
|
||||||
#include "explorer_private.h"
|
#include "explorer_private.h"
|
||||||
|
@ -25,7 +26,9 @@
|
||||||
WINE_DEFAULT_DEBUG_CHANNEL(explorer);
|
WINE_DEFAULT_DEBUG_CHANNEL(explorer);
|
||||||
|
|
||||||
#define DESKTOP_CLASS_ATOM MAKEINTATOMW(32769)
|
#define DESKTOP_CLASS_ATOM MAKEINTATOMW(32769)
|
||||||
|
#define DESKTOP_ALL_ACCESS 0x01ff
|
||||||
|
|
||||||
|
/* window procedure for the desktop window */
|
||||||
static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPARAM lp )
|
static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPARAM lp )
|
||||||
{
|
{
|
||||||
WINE_TRACE( "got msg %x wp %x lp %lx\n", message, wp, lp );
|
WINE_TRACE( "got msg %x wp %x lp %lx\n", message, wp, lp );
|
||||||
|
@ -34,7 +37,7 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
|
||||||
{
|
{
|
||||||
case WM_SYSCOMMAND:
|
case WM_SYSCOMMAND:
|
||||||
if ((wp & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
|
if ((wp & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
|
||||||
break;
|
return 0;
|
||||||
|
|
||||||
case WM_SETCURSOR:
|
case WM_SETCURSOR:
|
||||||
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
|
return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
|
||||||
|
@ -54,24 +57,139 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
|
||||||
EndPaint( hwnd, &ps );
|
EndPaint( hwnd, &ps );
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
default:
|
||||||
|
return DefWindowProcW( hwnd, message, wp, lp );
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void manage_desktop(void)
|
/* create the desktop and the associated X11 window, and make it the current desktop */
|
||||||
|
static unsigned long create_desktop( const char *name, unsigned int width, unsigned int height )
|
||||||
|
{
|
||||||
|
HMODULE x11drv = GetModuleHandleA( "winex11.drv" );
|
||||||
|
HDESK desktop;
|
||||||
|
unsigned long xwin = 0;
|
||||||
|
unsigned long (*create_desktop_func)(unsigned int, unsigned int);
|
||||||
|
|
||||||
|
desktop = CreateDesktopA( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
|
||||||
|
if (!desktop)
|
||||||
|
{
|
||||||
|
WINE_ERR( "failed to create desktop %s error %ld\n", wine_dbgstr_a(name), GetLastError() );
|
||||||
|
ExitProcess( 1 );
|
||||||
|
}
|
||||||
|
/* magic: desktop "root" means use the X11 root window */
|
||||||
|
if (x11drv && strcasecmp( name, "root" ))
|
||||||
|
{
|
||||||
|
create_desktop_func = (void *)GetProcAddress( x11drv, "wine_create_desktop" );
|
||||||
|
if (create_desktop_func) xwin = create_desktop_func( width, height );
|
||||||
|
}
|
||||||
|
SetThreadDesktop( desktop );
|
||||||
|
return xwin;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* retrieve the default desktop size from the X11 driver config */
|
||||||
|
/* FIXME: this is for backwards compatibility, should probably be changed */
|
||||||
|
static BOOL get_default_desktop_size( unsigned int *width, unsigned int *height )
|
||||||
|
{
|
||||||
|
HKEY hkey;
|
||||||
|
char buffer[64];
|
||||||
|
DWORD size = sizeof(buffer);
|
||||||
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
|
/* @@ Wine registry key: HKCU\Software\Wine\X11 Driver */
|
||||||
|
if (RegOpenKeyA( HKEY_CURRENT_USER, "Software\\Wine\\X11 Driver", &hkey )) return FALSE;
|
||||||
|
if (!RegQueryValueExA( hkey, "Desktop", 0, NULL, (LPBYTE)buffer, &size ))
|
||||||
|
ret = (sscanf( buffer, "%ux%u", width, height ) == 2);
|
||||||
|
RegCloseKey( hkey );
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* main desktop management function */
|
||||||
|
void manage_desktop( char *arg )
|
||||||
{
|
{
|
||||||
MSG msg;
|
MSG msg;
|
||||||
HWND hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL,
|
HWND hwnd;
|
||||||
WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
unsigned long xwin = 0;
|
||||||
0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
|
unsigned int width, height;
|
||||||
0, 0, 0, NULL );
|
char *cmdline = NULL;
|
||||||
if (hwnd != GetDesktopWindow()) return; /* some other process beat us to it */
|
char *p = arg;
|
||||||
SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc );
|
static const WCHAR desktop_nameW[] = {'W','i','n','e',' ','d','e','s','k','t','o','p',0};
|
||||||
|
|
||||||
WINE_TRACE( "explorer starting on hwnd %p\n", hwnd );
|
/* get the rest of the command line (if any) */
|
||||||
|
while (*p && !isspace(*p)) p++;
|
||||||
|
if (*p)
|
||||||
|
{
|
||||||
|
*p++ = 0;
|
||||||
|
while (*p && isspace(*p)) p++;
|
||||||
|
if (*p) cmdline = p;
|
||||||
|
}
|
||||||
|
|
||||||
initialize_systray();
|
/* parse the desktop option */
|
||||||
while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
|
/* the option is of the form /desktop=name[,widthxheight] */
|
||||||
|
if (*arg == '=' || *arg == ',')
|
||||||
|
{
|
||||||
|
arg++;
|
||||||
|
if ((p = strchr( arg, ',' ))) *p++ = 0;
|
||||||
|
if (!p || sscanf( p, "%ux%u", &width, &height ) != 2)
|
||||||
|
{
|
||||||
|
width = 800;
|
||||||
|
height = 600;
|
||||||
|
}
|
||||||
|
xwin = create_desktop( arg, width, height );
|
||||||
|
}
|
||||||
|
else if (get_default_desktop_size( &width, &height ))
|
||||||
|
{
|
||||||
|
xwin = create_desktop( "Default", width, height );
|
||||||
|
}
|
||||||
|
|
||||||
WINE_TRACE( "explorer exiting for hwnd %p\n", hwnd );
|
if (!xwin) /* using the root window */
|
||||||
|
{
|
||||||
|
width = GetSystemMetrics(SM_CXSCREEN);
|
||||||
|
height = GetSystemMetrics(SM_CYSCREEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* create the desktop window */
|
||||||
|
hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL,
|
||||||
|
WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
|
||||||
|
0, 0, width, height, 0, 0, 0, NULL );
|
||||||
|
if (hwnd == GetDesktopWindow())
|
||||||
|
{
|
||||||
|
SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc );
|
||||||
|
SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( 0, MAKEINTRESOURCEW(OIC_WINLOGO)));
|
||||||
|
SetWindowTextW( hwnd, desktop_nameW );
|
||||||
|
SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
|
||||||
|
SetDeskWallPaper( (LPSTR)-1 );
|
||||||
|
initialize_systray();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DestroyWindow( hwnd ); /* someone beat us to it */
|
||||||
|
hwnd = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if we have a command line, execute it */
|
||||||
|
if (cmdline)
|
||||||
|
{
|
||||||
|
STARTUPINFOA si;
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
|
||||||
|
memset( &si, 0, sizeof(si) );
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
WINE_TRACE( "starting %s\n", wine_dbgstr_a(cmdline) );
|
||||||
|
if (CreateProcessA( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
|
||||||
|
{
|
||||||
|
CloseHandle( pi.hThread );
|
||||||
|
CloseHandle( pi.hProcess );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* run the desktop message loop */
|
||||||
|
if (hwnd)
|
||||||
|
{
|
||||||
|
WINE_TRACE( "desktop message loop starting on hwnd %p\n", hwnd );
|
||||||
|
while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
|
||||||
|
WINE_TRACE( "desktop message loop exiting for hwnd %p\n", hwnd );
|
||||||
|
}
|
||||||
|
|
||||||
|
ExitProcess( 0 );
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(explorer);
|
||||||
|
|
||||||
typedef struct parametersTAG {
|
typedef struct parametersTAG {
|
||||||
BOOL explorer_mode;
|
BOOL explorer_mode;
|
||||||
BOOL desktop_mode;
|
|
||||||
WCHAR root[MAX_PATH];
|
WCHAR root[MAX_PATH];
|
||||||
WCHAR selection[MAX_PATH];
|
WCHAR selection[MAX_PATH];
|
||||||
} parameters_struct;
|
} parameters_struct;
|
||||||
|
@ -137,8 +136,7 @@ static void ParseCommandLine(LPSTR commandline,parameters_struct *parameters)
|
||||||
}
|
}
|
||||||
else if (strncmp(p,"desktop",7)==0)
|
else if (strncmp(p,"desktop",7)==0)
|
||||||
{
|
{
|
||||||
parameters->desktop_mode = TRUE;
|
manage_desktop( p + 7 ); /* the rest of the command line is handled by desktop mode */
|
||||||
p+=7;
|
|
||||||
}
|
}
|
||||||
p2 = p;
|
p2 = p;
|
||||||
p = strchr(p,'/');
|
p = strchr(p,'/');
|
||||||
|
@ -170,12 +168,6 @@ int WINAPI WinMain(HINSTANCE hinstance,
|
||||||
ParseCommandLine(cmdline,¶meters);
|
ParseCommandLine(cmdline,¶meters);
|
||||||
len = lstrlenW(winefile) +1;
|
len = lstrlenW(winefile) +1;
|
||||||
|
|
||||||
if (parameters.desktop_mode)
|
|
||||||
{
|
|
||||||
manage_desktop();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parameters.selection[0])
|
if (parameters.selection[0])
|
||||||
{
|
{
|
||||||
len += lstrlenW(parameters.selection) + 2;
|
len += lstrlenW(parameters.selection) + 2;
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef __WINE_EXPLORER_PRIVATE_H
|
#ifndef __WINE_EXPLORER_PRIVATE_H
|
||||||
#define __WINE_EXPLORER_PRIVATE_H
|
#define __WINE_EXPLORER_PRIVATE_H
|
||||||
|
|
||||||
extern void manage_desktop(void);
|
extern void manage_desktop( char *arg );
|
||||||
extern void initialize_systray(void);
|
extern void initialize_systray(void);
|
||||||
|
|
||||||
#endif /* __WINE_EXPLORER_PRIVATE_H */
|
#endif /* __WINE_EXPLORER_PRIVATE_H */
|
||||||
|
|
Loading…
Reference in New Issue