Update wine to 1.2.
[sugaredwine.git] / patches / 0013-tasklist-draw-icons.patch
blob7bef722ab7b3ee9d4dece08ba13891410a706744
1 From 037e122fd109f6532a0b9ef8e01912474ce13bd6 Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Tue, 2 Sep 2008 10:23:26 -0500
4 Subject: [PATCH] tasklist: draw icons
6 ---
7 programs/explorer/tasklist.c | 58 +++++++++++++++++++++++++++++++++++++++---
8 1 files changed, 54 insertions(+), 4 deletions(-)
10 diff --git a/programs/explorer/tasklist.c b/programs/explorer/tasklist.c
11 index af8359b..c99341d 100644
12 --- a/programs/explorer/tasklist.c
13 +++ b/programs/explorer/tasklist.c
14 @@ -35,6 +35,7 @@ struct toplevel_window
15 BOOL still_alive;
16 HWND button;
17 LPWSTR caption;
18 + HICON icon;
21 static struct toplevel_window *toplevels=NULL;
22 @@ -83,10 +84,35 @@ static void refresh_buttons(void)
26 -static void update_window_caption(int index)
27 +static void set_icon(int index, HICON icon)
29 + if (toplevels[index].icon)
30 + DestroyIcon(toplevels[index].icon);
32 + toplevels[index].icon = icon;
34 + /* FIXME: queue a redraw */
37 +static VOID CALLBACK update_icon_async(HWND hwnd, UINT msg, ULONG_PTR data, LRESULT result)
39 + int index = (int)data;
41 + if (index >= toplevels_len && toplevels[index].hwnd != hwnd)
42 + {
43 + index = get_toplevel(hwnd);
44 + if (index == -1)
45 + return;
46 + }
48 + set_icon(index, (HICON)result);
51 +static void update_window(int index)
53 int length;
54 LPWSTR caption;
55 + HICON icon=NULL;
57 HeapFree(GetProcessHeap(), 0, toplevels[index].caption);
59 @@ -97,6 +123,16 @@ static void update_window_caption(int index)
60 caption[0] = 0;
62 toplevels[index].caption = caption;
63 +#if 0
64 + /* FIXME: this is useless because we don't support getting class icons cross-process */
65 + icon = (HICON)GetClassLongPtrW(toplevels[index].hwnd, GCLP_HICONSM);
66 + if (!icon) icon = (HICON)GetClassLongPtrW(toplevels[index].hwnd, GCLP_HICON);
67 +#endif
68 + if (icon)
69 + set_icon(index, icon);
70 + else /* FIXME: don't allow WM_GETICON messages to build up */
71 + SendMessageCallbackW(toplevels[index].hwnd, WM_GETICON, ICON_BIG, 0,
72 + update_icon_async, (ULONG_PTR)index);
75 /* add a window to the list and return its index */
76 @@ -120,12 +156,13 @@ static int add_hwnd(HWND hwnd)
77 toplevels[result].hwnd = hwnd;
79 toplevels[result].button = CreateWindowW(buttonW, buttonW, WS_VISIBLE|WS_CHILD|BS_PUSHBUTTON|BS_LEFT|BS_OWNERDRAW, 0, 0, 0, 0, tasklist, (HMENU)result, NULL, NULL);
81 orig_button_proc = (WNDPROC)SetWindowLongPtrW(toplevels[result].button, GWLP_WNDPROC, (LONG_PTR)button_wndproc);
83 + toplevels[result].icon = NULL;
85 toplevels[result].caption = NULL;
87 - update_window_caption(result);
88 + update_window(result);
90 refresh_buttons();
92 @@ -223,7 +260,7 @@ static BOOL CALLBACK handle_enumwindow(HWND hwnd, LPARAM lparam)
94 else
96 - update_window_caption(window);
97 + update_window(window);
100 toplevels[window].still_alive = TRUE;
101 @@ -320,17 +357,30 @@ static LRESULT WINAPI tasklist_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
102 BOOL pushed;
103 LOGFONTA lf;
104 HFONT font, oldFont;
105 + int cxsmicon, cysmicon;
107 pushed = SendMessageW(dis->hwndItem, BM_GETSTATE, 0, 0) & BST_PUSHED;
109 + /* draw button frame */
110 DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH|(pushed?DFCS_PUSHED:0));
112 + /* calculate rect of face */
113 rc = dis->rcItem;
115 InflateRect(&rc, -3, -3);
116 if (pushed)
117 OffsetRect(&rc, 1, 1);
119 + /* draw icon */
120 + if (toplevels[id].icon)
122 + cxsmicon = GetSystemMetrics(SM_CXSMICON);
123 + cysmicon = GetSystemMetrics(SM_CYSMICON);
124 + DrawIconEx(dis->hDC, rc.left, rc.top, toplevels[id].icon, cxsmicon, cysmicon, 0, NULL, DI_NORMAL);
125 + rc.left += cxsmicon+2;
128 + /* draw caption */
129 ZeroMemory(&lf, sizeof(lf));
130 lf.lfHeight = -12;
131 lf.lfWeight = FW_NORMAL;
133 1.5.6.5