mirror of
https://github.com/reactos/reactos.git
synced 2024-11-20 14:30:57 +00:00
check for valid task icon owener windows
svn path=/trunk/; revision=5758
This commit is contained in:
parent
c92a9be46a
commit
ef6eb3eb50
10 changed files with 78 additions and 40 deletions
|
@ -67,9 +67,9 @@ static void draw_desktop_background(HWND hwnd, HDC hdc)
|
|||
// This next part could be improved by working out how much
|
||||
// space the text actually needs...
|
||||
|
||||
#define TASKBAR_HEIGHT 30
|
||||
#define DESKTOPBARBAR_HEIGHT 30
|
||||
rect.left = rect.right - 280;
|
||||
rect.top = rect.bottom - 56 - TASKBAR_HEIGHT;
|
||||
rect.top = rect.bottom - 56 - DESKTOPBARBAR_HEIGHT;
|
||||
rect.right = rect.left + 250;
|
||||
rect.bottom = rect.top + 40;
|
||||
|
||||
|
@ -208,14 +208,6 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
explorer_show_frame(_hwnd, SW_SHOWNORMAL);
|
||||
break;
|
||||
|
||||
case WM_SETFOCUS:
|
||||
// close startup menu and other popup menus like that of tray notification icons
|
||||
if (wparam)
|
||||
PostMessage((HWND)wparam, WM_CANCELMODE, 0, 0);
|
||||
else
|
||||
PostMessage(HWND_BROADCAST, WM_CANCELMODE, 0, 0);
|
||||
goto def;
|
||||
|
||||
case WM_GETISHELLBROWSER:
|
||||
return (LRESULT)static_cast<IShellBrowser*>(this);
|
||||
|
||||
|
@ -230,7 +222,7 @@ LRESULT DesktopWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
case WM_CLOSE:
|
||||
break; // Over-ride close. We need to close desktop some other way.
|
||||
|
||||
default: def:
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,9 +34,6 @@
|
|||
#include "../externals.h"
|
||||
|
||||
|
||||
#define WINMSG_DESKTOP_GOT_FOCUS _T("DesktopWindowGotFocus")
|
||||
|
||||
|
||||
struct BackgroundWindow : public SubclassedWindow
|
||||
{
|
||||
typedef SubclassedWindow super;
|
||||
|
|
|
@ -323,7 +323,7 @@ LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
}
|
||||
|
||||
SetFocus(_focus_pane? _right_hwnd: _left_hwnd);
|
||||
break;}
|
||||
goto def;}
|
||||
|
||||
case PM_DISPATCH_COMMAND: {
|
||||
Pane* pane = GetFocus()==_left_hwnd? _left: _right;
|
||||
|
@ -355,7 +355,7 @@ LRESULT FileChildWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
|
||||
return TRUE;}
|
||||
|
||||
default:
|
||||
default: def:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ LRESULT Pane::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
child->switch_focus_pane();
|
||||
}
|
||||
break;}
|
||||
}
|
||||
}
|
||||
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
|
|
@ -47,10 +47,10 @@ HWND InitializeExplorerBar(HINSTANCE hInstance)
|
|||
#ifdef TASKBAR_AT_TOP
|
||||
rect.top = -2; // hide top border
|
||||
#else
|
||||
rect.top = GetSystemMetrics(SM_CYSCREEN) - TASKBAR_HEIGHT;
|
||||
rect.top = GetSystemMetrics(SM_CYSCREEN) - DESKTOPBARBAR_HEIGHT;
|
||||
#endif
|
||||
rect.right = GetSystemMetrics(SM_CXSCREEN) + 2;
|
||||
rect.bottom = rect.top + TASKBAR_HEIGHT + 2;
|
||||
rect.bottom = rect.top + DESKTOPBARBAR_HEIGHT + 2;
|
||||
|
||||
return Window::Create(WINDOW_CREATOR(DesktopBar), WS_EX_PALETTEWINDOW,
|
||||
BtnWindowClass(CLASSNAME_EXPLORERBAR), TITLE_EXPLORERBAR,
|
||||
|
@ -78,7 +78,7 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
|||
return 1;
|
||||
|
||||
// create start button
|
||||
new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, TASKBAR_HEIGHT-8, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW),
|
||||
new PictureButton(Button(_hwnd, ResString(IDS_START), 2, 2, STARTBUTTON_WIDTH, DESKTOPBARBAR_HEIGHT-8, IDC_START, WS_VISIBLE|WS_CHILD|BS_OWNERDRAW),
|
||||
SmallIcon(IDI_STARTMENU));
|
||||
|
||||
ClientRect clnt(_hwnd);
|
||||
|
@ -86,9 +86,9 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
|||
// create task bar
|
||||
_hwndTaskBar = Window::Create(WINDOW_CREATOR(TaskBar), 0,
|
||||
BtnWindowClass(CLASSNAME_TASKBAR), TITLE_TASKBAR, WS_CHILD|WS_VISIBLE,
|
||||
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH+1), TASKBAR_HEIGHT, _hwnd);
|
||||
TASKBAR_LEFT, 0, clnt.right-TASKBAR_LEFT-(NOTIFYAREA_WIDTH+1), DESKTOPBARBAR_HEIGHT, _hwnd);
|
||||
|
||||
TaskBar* taskbar = static_cast<TaskBar*>(Window::get_window(_hwndTaskBar));
|
||||
TaskBar* taskbar = static_cast<TaskBar*>(get_window(_hwndTaskBar));
|
||||
taskbar->_desktop_bar = this;
|
||||
|
||||
// create tray notification area
|
||||
|
@ -96,7 +96,7 @@ LRESULT DesktopBar::Init(LPCREATESTRUCT pcs)
|
|||
BtnWindowClass(CLASSNAME_TRAYNOTIFY,CS_DBLCLKS), TITLE_TRAYNOTIFY, WS_CHILD|WS_VISIBLE,
|
||||
clnt.right-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, clnt.bottom-2, _hwnd);
|
||||
|
||||
// NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
// NotifyArea* notify_area = static_cast<NotifyArea*>(get_window(_hwndNotify));
|
||||
// notify_area->_desktop_bar = this;
|
||||
|
||||
RegisterHotkeys();
|
||||
|
@ -171,8 +171,7 @@ LRESULT DesktopBar::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
MoveWindow(_hwndNotify, cx-(NOTIFYAREA_WIDTH+1), 1, NOTIFYAREA_WIDTH, cy-2, TRUE);
|
||||
|
||||
WindowRect rect(_hwnd);
|
||||
int height = rect.bottom-rect.top;
|
||||
RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)-(height-1)};
|
||||
RECT work_area = {0, 0, GetSystemMetrics(SM_CXSCREEN), rect.top};
|
||||
SystemParametersInfo(SPI_SETWORKAREA, 0, &work_area, 0);
|
||||
PostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, SPI_SETWORKAREA, 0);
|
||||
break;}
|
||||
|
@ -252,7 +251,7 @@ LRESULT DesktopBar::ProcessCopyData(COPYDATASTRUCT* pcd)
|
|||
|
||||
//TODO: process the differnt versions of the NOTIFYICONDATA structure (look at cbSize to decide which one)
|
||||
|
||||
NotifyArea* notify_area = static_cast<NotifyArea*>(Window::get_window(_hwndNotify));
|
||||
NotifyArea* notify_area = static_cast<NotifyArea*>(get_window(_hwndNotify));
|
||||
|
||||
if (notify_area)
|
||||
return notify_area->ProcessTrayNotification(ptr->notify_code, &ptr->nicon_data);
|
||||
|
|
|
@ -36,6 +36,9 @@
|
|||
#define WINMSG_TASKBARCREATED _T("TaskbarCreated")
|
||||
|
||||
|
||||
#define DESKTOPBARBAR_HEIGHT 29
|
||||
|
||||
|
||||
#define IDC_START 0x1000
|
||||
#define IDC_LOGOFF 0x1001
|
||||
#define IDC_SHUTDOWN 0x1002
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
|
||||
#define IDC_FIRST_APP 0x2000
|
||||
|
||||
#define TASKBAR_HEIGHT 30
|
||||
#define STARTBUTTON_WIDTH 60
|
||||
#define TASKBAR_LEFT 70
|
||||
//#define TASKBAR_AT_TOP
|
||||
|
|
|
@ -98,9 +98,16 @@ LRESULT NotifyArea::Init(LPCREATESTRUCT pcs)
|
|||
BtnWindowClass(CLASSNAME_CLOCKWINDOW,CS_DBLCLKS), NULL, WS_CHILD|WS_VISIBLE,
|
||||
clnt.right-(CLOCKWINDOW_WIDTH+1), 1, CLOCKWINDOW_WIDTH, clnt.bottom-2, _hwnd);
|
||||
|
||||
SetTimer(_hwnd, 0, 1000, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
NotifyArea::~NotifyArea()
|
||||
{
|
||||
KillTimer(_hwnd, 0);
|
||||
}
|
||||
|
||||
LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
switch(nmsg) {
|
||||
|
@ -108,6 +115,15 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
Paint();
|
||||
break;
|
||||
|
||||
case WM_TIMER: {
|
||||
Tick();
|
||||
|
||||
ClockWindow* clock_window = static_cast<ClockWindow*>(get_window(_hwndClock));
|
||||
|
||||
if (clock_window)
|
||||
clock_window->Tick();
|
||||
break;}
|
||||
|
||||
default:
|
||||
if (nmsg>=WM_MOUSEFIRST && nmsg<=WM_MOUSELAST) {
|
||||
NotifyIconSet::iterator found = IconHitTest(Point(lparam));
|
||||
|
@ -116,13 +132,10 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
NotifyInfo& entry = const_cast<NotifyInfo&>(*found); // Why does GCC 3.3 need this additional const_cast ?!
|
||||
|
||||
// Notify the message the the owner if it's still alive
|
||||
if (IsWindow(entry._hWnd)) //TODO: We could check this regularly for all icons by using WM_TIMER to prevent for hanging icons
|
||||
if (IsWindow(entry._hWnd))
|
||||
PostMessage(entry._hWnd, entry._uCallbackMessage, entry._uID, nmsg);
|
||||
else {
|
||||
// delete icons without owner window
|
||||
if (_icon_map.erase(entry))
|
||||
Refresh();
|
||||
}
|
||||
else if (_icon_map.erase(entry)) // delete icons without valid owner window
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +212,29 @@ void NotifyArea::Paint()
|
|||
}
|
||||
}
|
||||
|
||||
void NotifyArea::Tick()
|
||||
{
|
||||
bool do_refresh = false;
|
||||
|
||||
// Look for task icons without valid owner window.
|
||||
// This is an advanced feature, which is missing in MS Windows.
|
||||
for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it)
|
||||
{
|
||||
const NotifyInfo& entry = *it;
|
||||
|
||||
#ifdef NIF_STATE // currently (as of 21.08.2003) missing in MinGW headers
|
||||
if (!(entry._dwState & NIS_HIDDEN))
|
||||
#endif
|
||||
{
|
||||
if (!IsWindow(entry._hWnd))
|
||||
if (_icon_map.erase(entry)) // delete icons without valid owner window
|
||||
++do_refresh;
|
||||
}
|
||||
}
|
||||
|
||||
if (do_refresh)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// search for a icon at a given client coordinate position
|
||||
NotifyIconSet::iterator NotifyArea::IconHitTest(const POINT& pos)
|
||||
|
@ -234,8 +270,6 @@ ClockWindow::ClockWindow(HWND hwnd)
|
|||
{
|
||||
*_time = _T('\0');
|
||||
FormatTime();
|
||||
|
||||
SetTimer(hwnd, 0, 1000, NULL);
|
||||
}
|
||||
|
||||
LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
|
@ -245,11 +279,6 @@ LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
Paint();
|
||||
break;
|
||||
|
||||
case WM_TIMER: {
|
||||
if (FormatTime())
|
||||
InvalidateRect(_hwnd, NULL, TRUE);
|
||||
break;}
|
||||
|
||||
default:
|
||||
return super::WndProc(nmsg, wparam, lparam);
|
||||
}
|
||||
|
@ -257,6 +286,12 @@ LRESULT ClockWindow::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void ClockWindow::Tick()
|
||||
{
|
||||
if (FormatTime())
|
||||
InvalidateRect(_hwnd, NULL, TRUE); // refresh displayed time
|
||||
}
|
||||
|
||||
bool ClockWindow::FormatTime()
|
||||
{
|
||||
SYSTEMTIME systime;
|
||||
|
|
|
@ -76,6 +76,7 @@ struct NotifyArea : public Window
|
|||
typedef Window super;
|
||||
|
||||
NotifyArea(HWND hwnd);
|
||||
~NotifyArea();
|
||||
|
||||
// DesktopBar* _desktop_bar;
|
||||
|
||||
|
@ -93,6 +94,7 @@ protected:
|
|||
|
||||
void Refresh();
|
||||
void Paint();
|
||||
void Tick();
|
||||
|
||||
NotifyIconSet::iterator IconHitTest(const POINT& pos);
|
||||
};
|
||||
|
@ -105,6 +107,8 @@ struct ClockWindow : public Window
|
|||
|
||||
ClockWindow(HWND hwnd);
|
||||
|
||||
void Tick();
|
||||
|
||||
protected:
|
||||
LRESULT WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam);
|
||||
|
||||
|
|
|
@ -186,6 +186,15 @@ LRESULT CALLBACK Window::WindowWndProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPAR
|
|||
|
||||
LRESULT Window::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam)
|
||||
{
|
||||
if (nmsg == WM_SETFOCUS) {
|
||||
// close startup menu and other popup menus
|
||||
// This functionality is for tray notification icons missing in MS Windows.
|
||||
if (wparam)
|
||||
PostMessage((HWND)wparam, WM_CANCELMODE, 0, 0);
|
||||
else
|
||||
PostMessage(HWND_BROADCAST, WM_CANCELMODE, 0, 0);
|
||||
}
|
||||
|
||||
return DefWindowProc(_hwnd, nmsg, wparam, lparam);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue