/* * synergy -- mouse and keyboard sharing utility * Copyright (C) 2003 Chris Schoeneman * Copyright (C) 2006 Knut St. Osmundsen * * This package is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * found in the file COPYING that should have accompanied this file. * * This package is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #ifndef CARCHTASKBARWINDOWS_H #define CARCHTASKBARWINDOWS_H #define WIN32_LEAN_AND_MEAN #include "IArchTaskBar.h" #include "IArchMultithread.h" #include "stdmap.h" #include "stdvector.h" #define INCL_BASE #define INCL_PM #define INCL_ERRORS #include #define ARCH_TASKBAR CArchTaskBarOS2 //! Win32 implementation of IArchTaskBar class CArchTaskBarOS2 : public IArchTaskBar { public: CArchTaskBarOS2(void*); virtual ~CArchTaskBarOS2(); //! Add a dialog window /*! Tell the task bar event loop about a dialog. Win32 annoyingly requires messages destined for modeless dialog boxes to be dispatched differently than other messages. */ static void addDialog(HWND); //! Remove a dialog window /*! Remove a dialog window added via \c addDialog(). */ static void removeDialog(HWND); // IArchTaskBar overrides virtual void addReceiver(IArchTaskBarReceiver*); virtual void removeReceiver(IArchTaskBarReceiver*); virtual void updateReceiver(IArchTaskBarReceiver*); private: class CReceiverInfo { public: ULONG m_id; }; typedef std::map CReceiverToInfoMap; typedef std::map CIDToReceiverMap; typedef std::vector CIDStack; typedef std::map CDialogs; ULONG getNextID(); void recycleID(ULONG); void addIcon(ULONG); void removeIcon(ULONG); void updateIcon(ULONG); void addAllIcons(); void removeAllIcons(); void modifyIconNoLock(CReceiverToInfoMap::const_iterator, ULONG taskBarMessage); void removeIconNoLock(ULONG id); void handleIconMessage(IArchTaskBarReceiver*, MPARAM); bool processDialogs(PQMSG); MRESULT wndProc(HWND, ULONG, MPARAM, MPARAM); static MRESULT EXPENTRY staticWndProc(HWND, ULONG, MPARAM, MPARAM); void threadMainLoop(); static void* threadEntry(void*); private: static CArchTaskBarOS2* s_instance; // multithread data CArchMutex m_mutex; CArchCond m_condVar; bool m_ready; int m_result; CArchThread m_thread; // child thread data HWND m_hwnd; ULONG m_taskBarRestart; // shared data CReceiverToInfoMap m_receivers; CIDToReceiverMap m_idTable; CIDStack m_oldIDs; ULONG m_nextID; // dialogs CDialogs m_dialogs; CDialogs m_addedDialogs; }; #endif