Commit ec9024ca authored by Thomas Weidenmueller's avatar Thomas Weidenmueller Committed by Alexandre Julliard

Hook up "Hide on Minimize" & Add context menu to the tray icon.

parent 63308e5a
...@@ -129,10 +129,13 @@ END ...@@ -129,10 +129,13 @@ END
IDR_TRAY_POPUP MENU DISCARDABLE IDR_TRAY_POPUP MENU DISCARDABLE
BEGIN BEGIN
MENUITEM "&Restore", ID_RESTORE POPUP "DUMMY"
MENUITEM "&Close", ID_FILE_EXIT BEGIN
MENUITEM SEPARATOR MENUITEM "&Restore", ID_RESTORE
MENUITEM "&Always On Top", ID_OPTIONS_ALWAYSONTOP, CHECKED MENUITEM "&Close", ID_FILE_EXIT
MENUITEM SEPARATOR
MENUITEM "&Always On Top", ID_OPTIONS_ALWAYSONTOP
END
END END
IDR_PROCESS_PAGE_CONTEXT MENU DISCARDABLE IDR_PROCESS_PAGE_CONTEXT MENU DISCARDABLE
......
...@@ -37,8 +37,6 @@ ...@@ -37,8 +37,6 @@
#include "taskmgr.h" #include "taskmgr.h"
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void) void TaskManager_OnOptionsAlwaysOnTop(void)
{ {
HMENU hMenu; HMENU hMenu;
...@@ -51,7 +49,7 @@ void TaskManager_OnOptionsAlwaysOnTop(void) ...@@ -51,7 +49,7 @@ void TaskManager_OnOptionsAlwaysOnTop(void)
* Check or uncheck the always on top menu item * Check or uncheck the always on top menu item
* and update main window. * and update main window.
*/ */
if (GetMenuState(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND) & MF_CHECKED) if ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0)
{ {
CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED); CheckMenuItem(hOptionsMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND|MF_UNCHECKED);
TaskManagerSettings.AlwaysOnTop = FALSE; TaskManagerSettings.AlwaysOnTop = FALSE;
......
...@@ -144,6 +144,9 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -144,6 +144,9 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
case ID_OPTIONS_SHOW16BITTASKS: case ID_OPTIONS_SHOW16BITTASKS:
TaskManager_OnOptionsShow16BitTasks(); TaskManager_OnOptionsShow16BitTasks();
break; break;
case ID_RESTORE:
TaskManager_OnRestoreMainWindow();
break;
case ID_VIEW_LARGE: case ID_VIEW_LARGE:
ApplicationPage_OnViewLargeIcons(); ApplicationPage_OnViewLargeIcons();
break; break;
...@@ -249,6 +252,48 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) ...@@ -249,6 +252,48 @@ TaskManagerWndProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
} }
break; break;
case WM_ONTRAYICON:
switch(lParam)
{
case WM_RBUTTONDOWN:
{
POINT pt;
BOOL OnTop;
HMENU hMenu, hPopupMenu;
GetCursorPos(&pt);
OnTop = ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0);
hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_TRAY_POPUP));
hPopupMenu = GetSubMenu(hMenu, 0);
if(IsWindowVisible(hMainWnd))
{
DeleteMenu(hPopupMenu, ID_RESTORE, MF_BYCOMMAND);
}
else
{
SetMenuDefaultItem(hPopupMenu, ID_RESTORE, FALSE);
}
if(OnTop)
{
CheckMenuItem(hPopupMenu, ID_OPTIONS_ALWAYSONTOP, MF_BYCOMMAND | MF_CHECKED);
}
SetForegroundWindow(hMainWnd);
TrackPopupMenuEx(hPopupMenu, 0, pt.x, pt.y, hMainWnd, NULL);
DestroyMenu(hMenu);
break;
}
case WM_LBUTTONDBLCLK:
TaskManager_OnRestoreMainWindow();
break;
}
break;
case WM_NOTIFY: case WM_NOTIFY:
idctrl = (int)wParam; idctrl = (int)wParam;
pnmh = (LPNMHDR)lParam; pnmh = (LPNMHDR)lParam;
...@@ -613,7 +658,13 @@ void OnSize( UINT nType, int cx, int cy ) ...@@ -613,7 +658,13 @@ void OnSize( UINT nType, int cx, int cy )
RECT rc; RECT rc;
if (nType == SIZE_MINIMIZED) if (nType == SIZE_MINIMIZED)
{
if(TaskManagerSettings.HideWhenMinimized)
{
ShowWindow(hMainWnd, SW_HIDE);
}
return; return;
}
nXDifference = cx - nOldWidth; nXDifference = cx - nOldWidth;
nYDifference = cy - nOldHeight; nYDifference = cy - nOldHeight;
...@@ -778,6 +829,20 @@ void SaveSettings(void) ...@@ -778,6 +829,20 @@ void SaveSettings(void)
RegCloseKey(hKey); RegCloseKey(hKey);
} }
void TaskManager_OnRestoreMainWindow(void)
{
HMENU hMenu, hOptionsMenu;
BOOL OnTop;
hMenu = GetMenu(hMainWnd);
hOptionsMenu = GetSubMenu(hMenu, OPTIONS_MENU_INDEX);
OnTop = ((GetWindowLong(hMainWnd, GWL_EXSTYLE) & WS_EX_TOPMOST) != 0);
OpenIcon(hMainWnd);
SetForegroundWindow(hMainWnd);
SetWindowPos(hMainWnd, (OnTop ? HWND_TOPMOST : HWND_TOP), 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW);
}
void TaskManager_OnEnterMenuLoop(HWND hWnd) void TaskManager_OnEnterMenuLoop(HWND hWnd)
{ {
int nParts; int nParts;
......
...@@ -153,6 +153,7 @@ void Draw3dRect2(HDC hDC, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottom ...@@ -153,6 +153,7 @@ void Draw3dRect2(HDC hDC, LPRECT lpRect, COLORREF clrTopLeft, COLORREF clrBottom
void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y); void Font_DrawText(HDC hDC, LPCTSTR lpszText, int x, int y);
void LoadSettings(void); void LoadSettings(void);
void SaveSettings(void); void SaveSettings(void);
void TaskManager_OnRestoreMainWindow(void);
void TaskManager_OnEnterMenuLoop(HWND hWnd); void TaskManager_OnEnterMenuLoop(HWND hWnd);
void TaskManager_OnExitMenuLoop(HWND hWnd); void TaskManager_OnExitMenuLoop(HWND hWnd);
void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu); void TaskManager_OnMenuSelect(HWND hWnd, UINT nItemID, UINT nFlags, HMENU hSysMenu);
...@@ -162,6 +163,9 @@ void TaskManager_OnViewUpdateSpeedLow(void); ...@@ -162,6 +163,9 @@ void TaskManager_OnViewUpdateSpeedLow(void);
void TaskManager_OnViewUpdateSpeedPaused(void); void TaskManager_OnViewUpdateSpeedPaused(void);
void TaskManager_OnViewRefresh(void); void TaskManager_OnViewRefresh(void);
void TaskManager_OnTabWndSelChange(void); void TaskManager_OnTabWndSelChange(void);
#define OPTIONS_MENU_INDEX 1
void TaskManager_OnOptionsAlwaysOnTop(void); void TaskManager_OnOptionsAlwaysOnTop(void);
void TaskManager_OnOptionsMinimizeOnUse(void); void TaskManager_OnOptionsMinimizeOnUse(void);
void TaskManager_OnOptionsHideWhenMinimized(void); void TaskManager_OnOptionsHideWhenMinimized(void);
...@@ -186,6 +190,8 @@ void ProcessPage_OnSetPriorityBelowNormal(void); ...@@ -186,6 +190,8 @@ void ProcessPage_OnSetPriorityBelowNormal(void);
void ProcessPage_OnSetPriorityLow(void); void ProcessPage_OnSetPriorityLow(void);
void ProcessPage_OnDebugChannels(void); void ProcessPage_OnDebugChannels(void);
#define WM_ONTRAYICON WM_USER + 5
HICON TrayIcon_GetProcessorUsageIcon(void); HICON TrayIcon_GetProcessorUsageIcon(void);
BOOL TrayIcon_ShellAddTrayIcon(void); BOOL TrayIcon_ShellAddTrayIcon(void);
BOOL TrayIcon_ShellRemoveTrayIcon(void); BOOL TrayIcon_ShellRemoveTrayIcon(void);
......
...@@ -155,7 +155,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void) ...@@ -155,7 +155,7 @@ BOOL TrayIcon_ShellAddTrayIcon(void)
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */ nid.uCallbackMessage = WM_ONTRAYICON;
nid.hIcon = hIcon; nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage()); wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
...@@ -178,7 +178,7 @@ BOOL TrayIcon_ShellRemoveTrayIcon(void) ...@@ -178,7 +178,7 @@ BOOL TrayIcon_ShellRemoveTrayIcon(void)
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = 0; nid.uFlags = 0;
/* nid.uCallbackMessage = ??; */ nid.uCallbackMessage = WM_ONTRAYICON;
bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid); bRetVal = Shell_NotifyIcon(NIM_DELETE, &nid);
...@@ -199,7 +199,7 @@ BOOL TrayIcon_ShellUpdateTrayIcon(void) ...@@ -199,7 +199,7 @@ BOOL TrayIcon_ShellUpdateTrayIcon(void)
nid.hWnd = hMainWnd; nid.hWnd = hMainWnd;
nid.uID = 0; nid.uID = 0;
nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP; nid.uFlags = NIF_ICON | NIF_MESSAGE | NIF_TIP;
/* nid.uCallbackMessage = ??; */ nid.uCallbackMessage = WM_ONTRAYICON;
nid.hIcon = hIcon; nid.hIcon = hIcon;
wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage()); wsprintf(nid.szTip, _T("CPU Usage: %d%%"), PerfDataGetProcessorUsage());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment