From 0fa710246c6a780bb6840f89573ddb50ca48354e Mon Sep 17 00:00:00 2001 From: Martin Fuchs Date: Sat, 27 Mar 2004 14:02:28 +0000 Subject: [PATCH] rollback changes when cancelling notify icon configuration dialog svn path=/trunk/; revision=8888 --- reactos/subsys/system/explorer/Jamfile | 3 +- reactos/subsys/system/explorer/Makefile.MinGW | 4 +- .../system/explorer/notifyhook/notifyhook.dsp | 8 +-- .../system/explorer/taskbar/traynotify.cpp | 61 +++++++++++++------ .../system/explorer/taskbar/traynotify.h | 10 ++- .../subsys/system/explorer/utility/utility.h | 2 +- 6 files changed, 61 insertions(+), 27 deletions(-) diff --git a/reactos/subsys/system/explorer/Jamfile b/reactos/subsys/system/explorer/Jamfile index 2c1c84316d8..9be72f6b573 100644 --- a/reactos/subsys/system/explorer/Jamfile +++ b/reactos/subsys/system/explorer/Jamfile @@ -51,7 +51,8 @@ exe explorer : uuid wsock32 oleaut32 - libexpat +# expat notifyhook.dll + libexpat.dll ; diff --git a/reactos/subsys/system/explorer/Makefile.MinGW b/reactos/subsys/system/explorer/Makefile.MinGW index 8a0ac4bdc84..4eb220c29d3 100644 --- a/reactos/subsys/system/explorer/Makefile.MinGW +++ b/reactos/subsys/system/explorer/Makefile.MinGW @@ -73,12 +73,12 @@ OBJECTS = \ i386-stub-win32.o \ xmlstorage.o -LIBS = gdi32 comctl32 ole32 uuid libexpat +LIBS = gdi32 comctl32 ole32 uuid DELAYIMPORTS = oleaut32 wsock32 all: $(TARGET) -$(TARGET): $(OBJECTS) $(PROGRAM)$(RES_SUFFIX) notifyhook.dll +$(TARGET): $(OBJECTS) $(PROGRAM)$(RES_SUFFIX) notifyhook.dll libexpat.dll $(LINK) $(LFLAGS) -o $@ $^ $(addprefix -l,$(LIBS)) $(addprefix -l,$(DELAYIMPORTS)) explorer$(RES_SUFFIX): $(PROGRAM)_intres.rc res/*.bmp res/*.ico diff --git a/reactos/subsys/system/explorer/notifyhook/notifyhook.dsp b/reactos/subsys/system/explorer/notifyhook/notifyhook.dsp index 0eaac0450de..84260c998f6 100644 --- a/reactos/subsys/system/explorer/notifyhook/notifyhook.dsp +++ b/reactos/subsys/system/explorer/notifyhook/notifyhook.dsp @@ -88,14 +88,14 @@ LINK32=link.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "notifyhook___Win32_Win32" -# PROP BASE Intermediate_Dir "notifyhook___Win32_Win32" +# PROP BASE Output_Dir "Win32" +# PROP BASE Intermediate_Dir "Win32" # PROP BASE Ignore_Export_Lib 0 # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 -# PROP Output_Dir "notifyhook___Win32_Win32" -# PROP Intermediate_Dir "notifyhook___Win32_Win32" +# PROP Output_Dir "Win32" +# PROP Intermediate_Dir "Win32" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_NOTIFYHOOK_IMPL" /FR /FD /GZ /c diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.cpp b/reactos/subsys/system/explorer/taskbar/traynotify.cpp index 6c14807a1dd..a298dafbd8d 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.cpp +++ b/reactos/subsys/system/explorer/taskbar/traynotify.cpp @@ -322,7 +322,7 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) break; case WM_TIMER: { - TimerTick(); + Refresh(); ClockWindow* clock_window = GET_WINDOW(ClockWindow, _hwndClock); @@ -331,7 +331,7 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) break;} case PM_REFRESH: - TimerTick(); + Refresh(true); break; case WM_SIZE: { @@ -414,7 +414,7 @@ LRESULT NotifyArea::WndProc(UINT nmsg, WPARAM wparam, LPARAM lparam) } } else if (_icon_map.erase(entry)) // delete icons without valid owner window - Refresh(); + UpdateIcons(); } } @@ -429,7 +429,7 @@ int NotifyArea::Command(int id, int code) switch(id) { case ID_SHOW_HIDDEN_ICONS: _show_hidden = !_show_hidden; - Refresh(); + UpdateIcons(); break; case ID_CONFIG_NOTIFYAREA: @@ -492,7 +492,7 @@ LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pni entry._dwState |= NIS_HIDDEN; #endif - Refresh(); ///@todo call only if really changes occurred + UpdateIcons(); ///@todo call only if really changes occurred return TRUE; } @@ -505,7 +505,7 @@ LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pni if (found->second._hIcon) DestroyIcon(found->second._hIcon); _icon_map.erase(found); - Refresh(); + UpdateIcons(); return TRUE; } break;} @@ -529,7 +529,7 @@ LRESULT NotifyArea::ProcessTrayNotification(int notify_code, NOTIFYICONDATA* pni return FALSE; } -void NotifyArea::Refresh() +void NotifyArea::UpdateIcons() { _sorted_icons.clear(); @@ -590,10 +590,8 @@ void NotifyArea::Paint() } } -void NotifyArea::TimerTick() +void NotifyArea::Refresh(bool update) { - bool do_refresh = false; - // Look for task icons without valid owner window. // This is an extended feature missing in MS Windows. for(NotifyIconSet::const_iterator it=_sorted_icons.begin(); it!=_sorted_icons.end(); ++it) { @@ -601,7 +599,7 @@ void NotifyArea::TimerTick() if (!IsWindow(entry._hWnd)) if (_icon_map.erase(entry)) // delete icons without valid owner window - ++do_refresh; + ++update; } DWORD now = GetTickCount(); @@ -616,14 +614,14 @@ void NotifyArea::TimerTick() case NIM_HIDE: if (!(entry._dwState & NIS_HIDDEN)) { entry._dwState |= NIS_HIDDEN; - ++do_refresh; + ++update; } break; case NIM_SHOW: if (entry._dwState&NIS_HIDDEN) { entry._dwState &= ~NIS_HIDDEN; - ++do_refresh; + ++update; } break; @@ -632,14 +630,14 @@ void NotifyArea::TimerTick() if (!(entry._dwState & NIS_HIDDEN)) if (now-entry._lastChange > ICON_AUTOHIDE_SECONDS*1000) { entry._dwState |= NIS_HIDDEN; - ++do_refresh; + ++update; } break; } } - if (do_refresh) - Refresh(); + if (update) + UpdateIcons(); } /// search for a icon at a given client coordinate position @@ -740,6 +738,14 @@ TrayNotifyDlg::TrayNotifyDlg(HWND hwnd) { _selectedItem = 0; + if (_pNotifyArea) { + // save original icon states and configuration data + for(NotifyIconMap::const_iterator it=_pNotifyArea->_icon_map.begin(); it!=_pNotifyArea->_icon_map.end(); ++it) + _icon_states_org[it->first] = IconStatePair(it->second._mode, it->second._dwState); + + _cfg_org = _pNotifyArea->_cfg; + } + SetWindowIcon(hwnd, IDI_REACTOS/*IDI_SEARCH*/); _haccel = LoadAccelerators(g_Globals._hInstance, MAKEINTRESOURCE(IDA_TRAYNOTIFY)); @@ -870,6 +876,8 @@ void TrayNotifyDlg::Refresh() TreeView_Expand(_tree_ctrl, _hitemCurrent_hidden, TVE_EXPAND); TreeView_Expand(_tree_ctrl, _hitemCurrent, TVE_EXPAND); TreeView_Expand(_tree_ctrl, _hitemConfig, TVE_EXPAND); + + TreeView_EnsureVisible(_tree_ctrl, _hitemCurrent_visible); } void TrayNotifyDlg::InsertItem(HTREEITEM hparent, HTREEITEM after, const NotifyInfo& entry, HDC hdc) @@ -947,7 +955,25 @@ int TrayNotifyDlg::Command(int id, int code) break; case IDOK: + EndDialog(_hwnd, id); + break; + case IDCANCEL: + // rollback changes + if (_pNotifyArea) { + // restore original icon states and configuration data + _pNotifyArea->_cfg = _cfg_org; + + for(IconStateMap::const_iterator it=_icon_states_org.begin(); it!=_icon_states_org.end(); ++it) { + NotifyInfo& info = _pNotifyArea->_icon_map[it->first]; + + info._mode = it->second.first; + info._dwState = it->second.second; + } + + SendMessage(*_pNotifyArea, PM_REFRESH, 0, 0); + } + EndDialog(_hwnd, id); break; } @@ -1022,7 +1048,8 @@ void TrayNotifyDlg::SetIconMode(NOTIFYICONMODE mode) entry._mode = mode; // trigger refresh in notify area and this dialog - SendMessage(*_pNotifyArea, PM_REFRESH, 0, 0); + if (_pNotifyArea) + SendMessage(*_pNotifyArea, PM_REFRESH, 0, 0); } if (_pNotifyArea) { diff --git a/reactos/subsys/system/explorer/taskbar/traynotify.h b/reactos/subsys/system/explorer/taskbar/traynotify.h index 4f42b30167d..acfcf76a31f 100644 --- a/reactos/subsys/system/explorer/taskbar/traynotify.h +++ b/reactos/subsys/system/explorer/taskbar/traynotify.h @@ -149,9 +149,9 @@ protected: int Command(int id, int code); int Notify(int id, NMHDR* pnmh); - void Refresh(); + void UpdateIcons(); void Paint(); - void TimerTick(); + void Refresh(bool do_refresh=false); void CancelModes(); NotifyIconSet::iterator IconHitTest(const POINT& pos); @@ -186,6 +186,12 @@ protected: HIMAGELIST _himl; NotifyArea* _pNotifyArea; + typedef pair IconStatePair; + typedef map IconStateMap; + + NotifyIconCfgList _cfg_org; + IconStateMap _icon_states_org; + HTREEITEM _hitemCurrent; HTREEITEM _hitemCurrent_visible; HTREEITEM _hitemCurrent_hidden; diff --git a/reactos/subsys/system/explorer/utility/utility.h b/reactos/subsys/system/explorer/utility/utility.h index 7fb8d68a459..45c858c6593 100644 --- a/reactos/subsys/system/explorer/utility/utility.h +++ b/reactos/subsys/system/explorer/utility/utility.h @@ -719,7 +719,7 @@ protected: }; - /// string class for convenience + /// string class for TCHAR strings struct String #ifdef UNICODE : public wstring