Alexandre Julliard : explorer: Added desktop option.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 7 06:12:55 CST 2006


Module: wine
Branch: refs/heads/master
Commit: a93b6a5945b2ffd29cc950fe8e8d6cd6cdf73261
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=a93b6a5945b2ffd29cc950fe8e8d6cd6cdf73261

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar  7 11:41:52 2006 +0100

explorer: Added desktop option.

The /desktop option causes explorer to create and manage the desktop
window.

---

 programs/explorer/Makefile.in        |    1 
 programs/explorer/desktop.c          |   74 ++++++++++++++++++++++++++++++++++
 programs/explorer/explorer.c         |   16 ++++++-
 programs/explorer/explorer_private.h |   26 ++++++++++++
 4 files changed, 115 insertions(+), 2 deletions(-)
 create mode 100644 programs/explorer/desktop.c
 create mode 100644 programs/explorer/explorer_private.h

diff --git a/programs/explorer/Makefile.in b/programs/explorer/Makefile.in
index a73d6dd..3756a94 100644
--- a/programs/explorer/Makefile.in
+++ b/programs/explorer/Makefile.in
@@ -7,6 +7,7 @@ APPMODE   = -mwindows
 IMPORTS   = user32 gdi32 advapi32 kernel32
 
 C_SRCS = \
+	desktop.c \
 	explorer.c \
 	systray.c
 
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
new file mode 100644
index 0000000..032a1c2
--- /dev/null
+++ b/programs/explorer/desktop.c
@@ -0,0 +1,74 @@
+/*
+ * Explorer desktop support
+ *
+ * Copyright 2006 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <windows.h>
+#include <wine/debug.h>
+#include "explorer_private.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(explorer);
+
+#define DESKTOP_CLASS_ATOM MAKEINTATOMW(32769)
+
+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 );
+
+    switch(message)
+    {
+    case WM_SYSCOMMAND:
+        if ((wp & 0xfff0) == SC_CLOSE) ExitWindows( 0, 0 );
+        break;
+
+    case WM_SETCURSOR:
+        return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
+
+    case WM_NCHITTEST:
+        return HTCLIENT;
+
+    case WM_ERASEBKGND:
+        PaintDesktop( (HDC)wp );
+        return TRUE;
+
+    case WM_PAINT:
+        {
+            PAINTSTRUCT ps;
+            BeginPaint( hwnd, &ps );
+            if (ps.fErase) PaintDesktop( ps.hdc );
+            EndPaint( hwnd, &ps );
+        }
+        return 0;
+    }
+    return 0;
+}
+
+void manage_desktop(void)
+{
+    MSG msg;
+    HWND hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL,
+                                 WS_POPUP | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+                                 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
+                                 0, 0, 0, NULL );
+    if (hwnd != GetDesktopWindow()) return;  /* some other process beat us to it */
+    SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc );
+
+    WINE_TRACE( "explorer starting on hwnd %p\n", hwnd );
+    while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
+    WINE_TRACE( "explorer exiting for hwnd %p\n", hwnd );
+}
diff --git a/programs/explorer/explorer.c b/programs/explorer/explorer.c
index 3a51085..25287b7 100644
--- a/programs/explorer/explorer.c
+++ b/programs/explorer/explorer.c
@@ -23,7 +23,7 @@
 #include <ctype.h>
 
 #include <wine/debug.h>
-
+#include "explorer_private.h"
 #include <systray.h>
 
 WINE_DEFAULT_DEBUG_CHANNEL(explorer);
@@ -33,6 +33,7 @@ unsigned int shell_refs = 0;
 typedef struct parametersTAG {
     BOOL    explorer_mode;
     BOOL    systray_mode;
+    BOOL    desktop_mode;
     WCHAR   root[MAX_PATH];
     WCHAR   selection[MAX_PATH];
 } parameters_struct;
@@ -143,6 +144,11 @@ static void ParseCommandLine(LPSTR comma
             parameters->systray_mode = TRUE;
             p+=7;
         }
+        else if (strncmp(p,"desktop",7)==0)
+        {
+            parameters->desktop_mode = TRUE;
+            p+=7;
+        }
         p2 = p;
         p = strchr(p,'/');
     }
@@ -216,7 +222,13 @@ int WINAPI WinMain(HINSTANCE hinstance,
         do_systray_loop();
         return 0;
     }
-    else if (parameters.selection[0])
+    if (parameters.desktop_mode)
+    {
+        manage_desktop();
+        return 0;
+    }
+
+    if (parameters.selection[0])
     {
         len += lstrlenW(parameters.selection) + 2;
         winefile_commandline = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h
new file mode 100644
index 0000000..e2f0010
--- /dev/null
+++ b/programs/explorer/explorer_private.h
@@ -0,0 +1,26 @@
+/*
+ * Explorer private definitions
+ *
+ * Copyright 2006 Alexandre Julliard
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef __WINE_EXPLORER_PRIVATE_H
+#define __WINE_EXPLORER_PRIVATE_H
+
+extern void manage_desktop(void);
+
+#endif  /* __WINE_EXPLORER_PRIVATE_H */




More information about the wine-cvs mailing list