Mercurial > pidgin.yaz
view pidgin/win32/MinimizeToTray.c @ 23325:8c315f969600
Patch from Andrew Gaul that fixes another leak:
==24860== 61,150 (15,900 direct, 45,250 indirect) bytes in 124 blocks are definitely lost in loss record 294 of 317
==24860== at 0x4A07A7E: malloc (vg_replace_malloc.c:207)
==24860== by 0x331303F8A2: g_malloc (in /lib64/libglib-2.0.so.0.1600.3)
==24860== by 0x3313055397: g_slice_alloc (in /lib64/libglib-2.0.so.0.1600.3)
==24860== by 0x3BC001B0D9: gdk_color_copy (in /usr/lib64/libgdk-x11-2.0.so.0.1200.9)
==24860== by 0x3313408E2B: (within /lib64/libgobject-2.0.so.0.1600.3)
==24860== by 0x331340FC95: g_object_get_valist (in /lib64/libgobject-2.0.so.0.1600.3)
==24860== by 0x331340FF03: g_object_get (in /lib64/libgobject-2.0.so.0.1600.3)
==24860== by 0x47C1A1: tag_to_html_start (gtkimhtml.c:5023)
==24860== by 0x47C5EF: text_tag_data_new (gtkimhtml.c:5114)
==24860== by 0x47CA50: gtk_imhtml_get_markup_range (gtkimhtml.c:5198)
==24860== by 0x47CEF8: gtk_imhtml_get_markup (gtkimhtml.c:5314)
==24860== by 0x44BC3B: send_cb (gtkconv.c:548)
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sun, 08 Jun 2008 22:18:14 +0000 |
parents | 5fe8042783c1 |
children |
line wrap: on
line source
/* MinimizeToTray * * A couple of routines to show how to make it produce a custom caption * animation to make it look like we are minimizing to and maximizing * from the system tray * * These routines are public domain, but it would be nice if you dropped * me a line if you use them! * * 1.0 29.06.2000 Initial version * 1.1 01.07.2000 The window retains it's place in the Z-order of windows * when minimized/hidden. This means that when restored/shown, it doesn't * always appear as the foreground window unless we call SetForegroundWindow * * Copyright 2000 Matthew Ellis <m.t.ellis@bigfoot.com> */ #define _WIN32_WINNT 0x0500 #include <windows.h> #include "MinimizeToTray.h" #define DEFAULT_RECT_WIDTH 150 #define DEFAULT_RECT_HEIGHT 30 static void GetTrayWndRect(LPRECT lpTrayRect) { APPBARDATA appBarData; HWND hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL); if(hShellTrayWnd) { HWND hTrayNotifyWnd = FindWindowEx(hShellTrayWnd, NULL, TEXT("TrayNotifyWnd"), NULL); if(hTrayNotifyWnd) { GetWindowRect(hTrayNotifyWnd,lpTrayRect); return; } } appBarData.cbSize = sizeof(appBarData); if(SHAppBarMessage(ABM_GETTASKBARPOS, &appBarData)) { switch(appBarData.uEdge) { case ABE_LEFT: case ABE_RIGHT: lpTrayRect->top = appBarData.rc.bottom - 100; lpTrayRect->bottom = appBarData.rc.bottom - 16; lpTrayRect->left = appBarData.rc.left; lpTrayRect->right = appBarData.rc.right; break; case ABE_TOP: case ABE_BOTTOM: lpTrayRect->top = appBarData.rc.top; lpTrayRect->bottom = appBarData.rc.bottom; lpTrayRect->left = appBarData.rc.right - 100; lpTrayRect->right = appBarData.rc.right - 16; break; } return; } hShellTrayWnd = FindWindowEx(NULL, NULL, TEXT("Shell_TrayWnd"), NULL); if(hShellTrayWnd) { GetWindowRect(hShellTrayWnd, lpTrayRect); if(lpTrayRect->right-lpTrayRect->left > DEFAULT_RECT_WIDTH) lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; if(lpTrayRect->bottom-lpTrayRect->top > DEFAULT_RECT_HEIGHT) lpTrayRect->top=lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; return; } SystemParametersInfo(SPI_GETWORKAREA, 0, lpTrayRect, 0); lpTrayRect->left = lpTrayRect->right - DEFAULT_RECT_WIDTH; lpTrayRect->top = lpTrayRect->bottom - DEFAULT_RECT_HEIGHT; } static BOOL GetDoAnimateMinimize(void) { ANIMATIONINFO ai; ai.cbSize = sizeof(ai); SystemParametersInfo(SPI_GETANIMATION, sizeof(ai), &ai, 0); return ai.iMinAnimate ? TRUE : FALSE; } void MinimizeWndToTray(HWND hWnd) { if(!IsWindowVisible(hWnd)) return; if(GetDoAnimateMinimize()) { RECT rcFrom, rcTo; GetWindowRect(hWnd, &rcFrom); GetTrayWndRect(&rcTo); DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); } ShowWindow(hWnd, SW_HIDE); } void RestoreWndFromTray(HWND hWnd) { if(IsWindowVisible(hWnd)) return; if(GetDoAnimateMinimize()) { RECT rcFrom, rcTo; GetTrayWndRect(&rcFrom); GetWindowRect(hWnd, &rcTo); DrawAnimatedRects(hWnd, IDANI_CAPTION, &rcFrom, &rcTo); } ShowWindow(hWnd, SW_SHOW); SetActiveWindow(hWnd); SetForegroundWindow(hWnd); }