[systray 1] explorer: every adaptor window has its own class now
Kirill K. Smirnov
lich at math.spbu.ru
Tue Jan 2 15:41:57 CST 2007
This serie of patches is more complicated (and correct) solution for
transparent systray icons.
-------------- next part --------------
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c
index 7fc66fd..5a7d9bf 100644
--- a/programs/explorer/systray.c
+++ b/programs/explorer/systray.c
@@ -45,7 +45,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(systray);
#define IS_OPTION_FALSE(ch) \
((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
-static const WCHAR adaptor_classname[] = /* Adaptor */ {'A','d','a','p','t','o','r',0};
+static const WCHAR adaptor_classname_template[] = /* Adaptor%d */ {'A','d','a','p','t','o','r','%','d',0};
/* tray state */
struct tray
@@ -59,6 +59,7 @@ struct icon
{
struct list entry;
HICON image; /* the image to render */
+ WCHAR classname[100];
HWND owner; /* the HWND passed in to the Shell_NotifyIcon call */
HWND window; /* the adaptor window */
HWND tooltip; /* Icon tooltip */
@@ -112,7 +113,6 @@ static LRESULT WINAPI adaptor_wndproc(HW
EndPaint(window, &ps);
break;
}
-
case WM_MOUSEMOVE:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
@@ -200,6 +200,8 @@ static void modify_icon(NOTIFYICONDATAW
if (icon->image) DestroyIcon(icon->image);
icon->image = CopyIcon(nid->hIcon);
+ WINE_FIXME("updating icon\n");
+ SendMessageW(icon->window, WM_SETICON, ICON_BIG, (LPARAM)(icon->image));
RedrawWindow(icon->window, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_UPDATENOW);
}
@@ -219,6 +221,7 @@ static void add_icon(NOTIFYICONDATAW *ni
struct icon *icon;
static const WCHAR adaptor_windowname[] = /* Wine System Tray Adaptor */ {'W','i','n','e',' ','S','y','s','t','e','m',' ','T','r','a','y',' ','A','d','a','p','t','o','r',0};
static BOOL tooltps_initialized = FALSE;
+ WNDCLASSEX class;
WINE_TRACE("id=0x%x, hwnd=%p\n", nid->uID, nid->hWnd);
@@ -237,6 +240,24 @@ static void add_icon(NOTIFYICONDATAW *ni
icon->id = nid->uID;
icon->owner = nid->hWnd;
icon->image = NULL;
+ wsprintfW(icon->classname, adaptor_classname_template, nid->uID);
+
+ /* now register the adaptor window class */
+ ZeroMemory(&class, sizeof(class));
+ class.cbSize = sizeof(class);
+ class.lpfnWndProc = adaptor_wndproc;
+ class.hInstance = NULL;
+ class.hIcon = NULL;
+ class.hCursor = LoadCursor(0, IDC_ARROW);
+ class.hbrBackground = NULL;
+ class.lpszClassName = icon->classname;
+ class.style = CS_SAVEBITS | CS_DBLCLKS;
+
+ if (!RegisterClassEx(&class))
+ {
+ WINE_ERR("Could not register adaptor class\n");
+ return;
+ }
rect.left = 0;
rect.top = 0;
@@ -245,7 +266,7 @@ static void add_icon(NOTIFYICONDATAW *ni
AdjustWindowRect(&rect, WS_CLIPSIBLINGS | WS_CAPTION, FALSE);
/* create the adaptor window */
- icon->window = CreateWindowEx(WS_EX_TRAYWINDOW, adaptor_classname,
+ icon->window = CreateWindowEx(WS_EX_TRAYWINDOW, icon->classname,
adaptor_windowname,
WS_CLIPSIBLINGS | WS_CAPTION,
CW_USEDEFAULT, CW_USEDEFAULT,
@@ -295,6 +316,7 @@ static void delete_icon(const NOTIFYICON
DestroyWindow(icon->tooltip);
DestroyWindow(icon->window);
+ UnregisterClass(icon->classname, NULL);
}
static void handle_incoming(HWND hwndSource, COPYDATASTRUCT *cds)
@@ -426,23 +448,6 @@ void initialize_systray(void)
return;
}
- /* now register the adaptor window class */
- ZeroMemory(&class, sizeof(class));
- class.cbSize = sizeof(class);
- class.lpfnWndProc = adaptor_wndproc;
- class.hInstance = NULL;
- class.hIcon = LoadIcon(0, IDI_WINLOGO);
- class.hCursor = LoadCursor(0, IDC_ARROW);
- class.hbrBackground = (HBRUSH) COLOR_WINDOW;
- class.lpszClassName = adaptor_classname;
- class.style = CS_SAVEBITS | CS_DBLCLKS;
-
- if (!RegisterClassEx(&class))
- {
- WINE_ERR("Could not register adaptor class\n");
- return;
- }
-
tray.window = CreateWindow(classname, winname, WS_OVERLAPPED,
CW_USEDEFAULT, CW_USEDEFAULT,
0, 0, 0, 0, 0, 0);
More information about the wine-patches
mailing list