1 From 9c17f3db9f6c30d2beb29d0c85abac55b409e794 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
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 2efcf70..dd08fda 100644
12 --- a/programs/explorer/tasklist.c
13 +++ b/programs/explorer/tasklist.c
14 @@ -35,6 +35,7 @@ struct toplevel_window
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)
43 + index = get_toplevel(hwnd);
48 + set_icon(index, (HICON)result);
51 +static void update_window(int index)
57 HeapFree(GetProcessHeap(), 0, toplevels[index].caption);
59 @@ -97,6 +123,16 @@ static void update_window_caption(int index)
62 toplevels[index].caption = caption;
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);
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,10 +156,11 @@ 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 - update_window_caption(result);
84 + toplevels[result].icon = NULL;
86 + update_window(result);
90 @@ -221,7 +258,7 @@ static BOOL CALLBACK handle_enumwindow(HWND hwnd, LPARAM lparam)
94 - update_window_caption(window);
95 + update_window(window);
98 toplevels[window].still_alive = TRUE;
99 @@ -318,17 +355,30 @@ static LRESULT WINAPI tasklist_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARA
103 + int cxsmicon, cysmicon;
105 pushed = SendMessageW(dis->hwndItem, BM_GETSTATE, 0, 0) & BST_PUSHED;
107 + /* draw button frame */
108 DrawFrameControl(dis->hDC, &dis->rcItem, DFC_BUTTON, DFCS_BUTTONPUSH|(pushed?DFCS_PUSHED:0));
110 + /* calculate rect of face */
113 InflateRect(&rc, -3, -3);
115 OffsetRect(&rc, 1, 1);
118 + if (toplevels[id].icon)
120 + cxsmicon = GetSystemMetrics(SM_CXSMICON);
121 + cysmicon = GetSystemMetrics(SM_CYSMICON);
122 + DrawIconEx(dis->hDC, rc.left, rc.top, toplevels[id].icon, cxsmicon, cysmicon, 0, NULL, DI_NORMAL);
123 + rc.left += cxsmicon+2;
127 ZeroMemory(&lf, sizeof(lf));
129 lf.lfWeight = FW_NORMAL;