update wine to wine-1.1.19
[sugaredwine.git] / patches / 0007-explorer-add-a-mostly-empty-taskbar.patch
blob4ebd8b87a051e58ba44769d1f17421fc2911d99c
1 From ebee1a917aad39526e5325735ff139cc79021f17 Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Sat, 9 Aug 2008 11:06:11 -0500
4 Subject: [PATCH] explorer: add a mostly empty taskbar
6 ---
7 programs/explorer/Makefile.in | 3 +-
8 programs/explorer/desktop.c | 5 +-
9 programs/explorer/explorer_private.h | 3 +-
10 programs/explorer/systray.c | 31 ++++--
11 programs/explorer/taskbar.c | 183 ++++++++++++++++++++++++++++++++++
12 5 files changed, 213 insertions(+), 12 deletions(-)
13 create mode 100644 programs/explorer/taskbar.c
15 diff --git a/programs/explorer/Makefile.in b/programs/explorer/Makefile.in
16 index ceb80a9..e9286af 100644
17 --- a/programs/explorer/Makefile.in
18 +++ b/programs/explorer/Makefile.in
19 @@ -12,7 +12,8 @@ C_SRCS = \
20 appbar.c \
21 desktop.c \
22 explorer.c \
23 - systray.c
24 + systray.c \
25 + taskbar.c
27 @MAKE_PROG_RULES@
29 diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
30 index 480d245..3518603 100644
31 --- a/programs/explorer/desktop.c
32 +++ b/programs/explorer/desktop.c
33 @@ -333,7 +333,10 @@ void manage_desktop( WCHAR *arg )
34 SetDeskWallPaper( (LPSTR)-1 );
35 initialize_display_settings( hwnd );
36 initialize_appbar();
37 - initialize_systray();
38 + if (using_root)
39 + initialize_systray(NULL);
40 + else
41 + initialize_taskbar();
43 else
45 diff --git a/programs/explorer/explorer_private.h b/programs/explorer/explorer_private.h
46 index 650552b..a20bf80 100644
47 --- a/programs/explorer/explorer_private.h
48 +++ b/programs/explorer/explorer_private.h
49 @@ -22,7 +22,8 @@
50 #define __WINE_EXPLORER_PRIVATE_H
52 extern void manage_desktop( WCHAR *arg );
53 -extern void initialize_systray(void);
54 +extern HWND initialize_systray(HWND parent);
55 +extern void initialize_taskbar(void);
56 extern void initialize_appbar(void);
58 #endif /* __WINE_EXPLORER_PRIVATE_H */
59 diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c
60 index 9be95bb..35443e2 100644
61 --- a/programs/explorer/systray.c
62 +++ b/programs/explorer/systray.c
63 @@ -58,9 +58,10 @@ static unsigned int nb_displayed;
64 static struct icon **displayed; /* array of currently displayed icons */
66 static BOOL hide_systray;
67 +static HWND parent_window;
68 static int icon_cx, icon_cy;
70 -#define MIN_DISPLAYED 8
71 +#define MIN_DISPLAYED (parent_window?0:8)
72 #define ICON_BORDER 2
74 /* Retrieves icon record by owner window and ID */
75 @@ -539,13 +540,15 @@ static BOOL is_systray_hidden(void)
76 return ret;
79 -/* this function creates the listener window */
80 -void initialize_systray(void)
81 +/* create a "bare" systray window */
82 +HWND initialize_systray(HWND parent)
84 HMODULE x11drv;
85 SIZE size;
86 WNDCLASSEXW class;
87 - static const WCHAR classname[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
88 + const WCHAR * classname;
89 + static const WCHAR tray_classname[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
90 + static const WCHAR child_classname[] = {'S','y','s','t','r','a','y',0};
91 static const WCHAR winname[] = {'W','i','n','e',' ','S','y','s','t','e','m',' ','T','r','a','y',0};
93 if ((x11drv = GetModuleHandleA( "winex11.drv" )))
94 @@ -555,6 +558,13 @@ void initialize_systray(void)
95 icon_cy = GetSystemMetrics( SM_CYSMICON ) + 2*ICON_BORDER;
96 hide_systray = is_systray_hidden();
98 + parent_window = parent;
100 + if (parent_window)
101 + classname = child_classname;
102 + else
103 + classname = tray_classname;
105 /* register the systray listener window class */
106 ZeroMemory(&class, sizeof(class));
107 class.cbSize = sizeof(class);
108 @@ -564,24 +574,27 @@ void initialize_systray(void)
109 class.hIcon = LoadIconW(0, (LPCWSTR)IDI_WINLOGO);
110 class.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
111 class.hbrBackground = (HBRUSH) COLOR_WINDOW;
112 - class.lpszClassName = (WCHAR *) &classname;
113 + class.lpszClassName = classname;
115 if (!RegisterClassExW(&class))
117 WINE_ERR("Could not register SysTray window class\n");
118 - return;
119 + return 0;
122 size = get_window_size();
123 - tray_window = CreateWindowW( classname, winname, WS_OVERLAPPED | WS_CAPTION,
124 - CW_USEDEFAULT, CW_USEDEFAULT, size.cx, size.cy, 0, 0, 0, 0 );
125 + tray_window = CreateWindowW( classname, winname, parent_window ? WS_CHILD : WS_OVERLAPPED | WS_CAPTION,
126 + CW_USEDEFAULT, CW_USEDEFAULT, size.cx, size.cy, parent_window, 0, 0, 0 );
127 if (!tray_window)
129 WINE_ERR("Could not create tray window\n");
130 - return;
131 + return 0;
134 if (hide_systray) do_hide_systray();
136 SetTimer( tray_window, 1, 2000, NULL );
138 + return tray_window;
141 diff --git a/programs/explorer/taskbar.c b/programs/explorer/taskbar.c
142 new file mode 100644
143 index 0000000..dd388c1
144 --- /dev/null
145 +++ b/programs/explorer/taskbar.c
146 @@ -0,0 +1,183 @@
148 + * Copyright (C) 2008 Vincent Povirk
150 + * This library is free software; you can redistribute it and/or
151 + * modify it under the terms of the GNU Lesser General Public
152 + * License as published by the Free Software Foundation; either
153 + * version 2.1 of the License, or (at your option) any later version.
155 + * This library is distributed in the hope that it will be useful,
156 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
157 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
158 + * Lesser General Public License for more details.
160 + * You should have received a copy of the GNU Lesser General Public
161 + * License along with this library; if not, write to the Free Software
162 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
163 + */
165 +#define UNICODE
166 +#include <windows.h>
167 +#include "wine/debug.h"
168 +#include "explorer_private.h"
170 +WINE_DEFAULT_DEBUG_CHANNEL(explorer);
172 +UINT_PTR (WINAPI *pSHAppBarMessage)(DWORD,PAPPBARDATA);
174 +#define MSG_APPBAR WM_USER
176 +#define TASKBAR_HEIGHT 25
178 +static HWND taskbar_window;
179 +static HWND systray_window;
181 +static void taskbar_setpos(void)
183 + APPBARDATA abd;
185 + /* ask for an acceptable rect */
186 + ZeroMemory(&abd, sizeof(abd));
187 + abd.cbSize = sizeof(abd);
188 + abd.hWnd = taskbar_window;
189 + abd.uEdge = ABE_BOTTOM;
190 + abd.rc.left = 0;
191 + abd.rc.right = GetSystemMetrics(SM_CXSCREEN);
192 + abd.rc.bottom = GetSystemMetrics(SM_CYSCREEN);
193 + abd.rc.top = abd.rc.bottom - TASKBAR_HEIGHT;
194 + pSHAppBarMessage(ABM_QUERYPOS, &abd);
196 + /* actually reserve a rect that has the correct height if QUERYPOS moved the bottom */
197 + abd.rc.top = abd.rc.bottom - TASKBAR_HEIGHT;
198 + pSHAppBarMessage(ABM_SETPOS, &abd);
200 + MoveWindow(taskbar_window, abd.rc.left, abd.rc.top, abd.rc.right-abd.rc.left, abd.rc.bottom-abd.rc.top, TRUE);
202 + /* FIXME: adjust child positions */
205 +static LRESULT WINAPI taskbar_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
207 + APPBARDATA abd;
209 + switch (msg)
211 + case WM_COPYDATA:
212 + return SendMessageW(systray_window, msg, wparam, lparam);
214 + case WM_CLOSE:
215 + /* FIXME: does this even make sense? */
216 + ShowWindow( hwnd, SW_HIDE );
217 + return 0;
219 + case MSG_APPBAR:
220 + switch(wparam)
222 + case ABN_POSCHANGED:
223 + taskbar_setpos();
224 + break;
225 + case ABN_FULLSCREENAPP:
226 + SetWindowPos(hwnd, lparam?HWND_BOTTOM:HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
227 + break;
228 + case ABN_STATECHANGE:
229 + break;
230 + default:
231 + WINE_FIXME("appbar notification wparam=%x, lparam=%x\n", (unsigned int)wparam, (unsigned int)lparam);
233 + break;
235 +#if 0
236 + /* MSDN says we should send notification of these messages, but they would
237 + cause FIXME's to be printed whenever a virtual desktop is used */
238 + case WM_WINDOWPOSCHANGED:
239 + abd.cbSize = sizeof(abd);
240 + abd.hWnd = hwnd;
241 + pSHAppBarMessage(ABM_WINDOWPOSCHANGED, &abd);
242 + break;
244 + case WM_ACTIVATE:
245 + abd.cbSize = sizeof(abd);
246 + abd.hWnd = hwnd;
247 + pSHAppBarMessage(ABM_ACTIVATE, &abd);
248 + break;
249 +#endif
251 + case WM_DESTROY:
252 + abd.cbSize = sizeof(abd);
253 + abd.hWnd = hwnd;
254 + pSHAppBarMessage(ABM_REMOVE, &abd);
255 + break;
257 + return DefWindowProcW( hwnd, msg, wparam, lparam );
260 +/* create a taskbar, and put the systray inside it */
261 +void initialize_taskbar(void)
263 + WNDCLASSEXW class;
264 + APPBARDATA abd;
265 + HMODULE hshell32;
266 + static const WCHAR classname[] = {'S','h','e','l','l','_','T','r','a','y','W','n','d',0};
267 + static const WCHAR winname[] = {'W','i','n','e',' ','T','a','s','k','b','a','r',0};
269 + /* FIXME: what if (is_systray_hidden()) ? */
271 + hshell32 = LoadLibraryA("shell32.dll");
272 + if (!hshell32)
274 + WINE_ERR("Couldn't load shell32.dll\n");
275 + return;
278 + pSHAppBarMessage = (void *)GetProcAddress(hshell32, "SHAppBarMessage");
279 + if (!pSHAppBarMessage)
281 + WINE_ERR("Couldn't load SHAppBarMessage symbol\n");
282 + return;
285 + /* register the taskbar window class */
286 + ZeroMemory(&class, sizeof(class));
287 + class.cbSize = sizeof(class);
288 + class.style = CS_DBLCLKS;
289 + class.lpfnWndProc = taskbar_wndproc;
290 + class.hInstance = NULL;
291 + class.hIcon = LoadIconW(0, (LPCWSTR)IDI_WINLOGO);
292 + class.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW);
293 + class.hbrBackground = (HBRUSH) COLOR_WINDOW;
294 + class.lpszClassName = (WCHAR *) &classname;
296 + if (!RegisterClassExW(&class))
298 + WINE_ERR("Could not register Taskbar window class\n");
299 + return;
302 + /* create the taskbar */
303 + taskbar_window = CreateWindowExW( WS_EX_TOOLWINDOW, classname, winname,
304 + WS_BORDER|WS_POPUP|WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, 0, 0 );
305 + if (!taskbar_window)
307 + WINE_ERR("Could not create taskbar window\n");
308 + return;
311 + abd.cbSize = sizeof(abd);
312 + abd.hWnd = taskbar_window;
313 + abd.uCallbackMessage = MSG_APPBAR;
314 + if (!pSHAppBarMessage(ABM_NEW, &abd))
316 + WINE_ERR("Couldn't register taskbar as an appbar.\n");
317 + DestroyWindow(taskbar_window);
318 + taskbar_window = NULL;
319 + return;
322 + systray_window = initialize_systray(taskbar_window);
324 + taskbar_setpos();
325 + ShowWindow(systray_window, SW_SHOW);
326 + ShowWindow(taskbar_window, SW_SHOW);
331 1.5.6.5