Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | */ |
| 18 | |
| 19 | // -=- WMHooks.h |
| 20 | |
| 21 | #ifndef __RFB_WIN32_WM_HOOKS_H__ |
| 22 | #define __RFB_WIN32_WM_HOOKS_H__ |
| 23 | |
| 24 | #include <windows.h> |
| 25 | #include <rfb/UpdateTracker.h> |
| 26 | #include <rdr/Exception.h> |
| 27 | #include <rfb_win32/Win32Util.h> |
| 28 | |
| 29 | namespace rfb { |
| 30 | |
| 31 | namespace win32 { |
| 32 | |
| 33 | // -=- WMHooks |
| 34 | // Uses the wm_hooks DLL to intercept window messages, to get _hints_ as |
| 35 | // to what may have changed on-screen. Updates are notified via a Win32 |
| 36 | // event, and retrieved using the getUpdates method, which is thread-safe. |
| 37 | class WMHooks { |
| 38 | public: |
| 39 | WMHooks(); |
| 40 | ~WMHooks(); |
| 41 | |
| 42 | // Specify the event object to notify. Starts the hook subsystem if it is |
| 43 | // not already active, and returns false if the hooks fail to start. |
| 44 | bool setEvent(HANDLE updateEvent); |
| 45 | |
| 46 | // Copies any new updates to the UpdateTracker. Returns true if new updates |
| 47 | // were added, false otherwise. |
| 48 | bool getUpdates(UpdateTracker* ut); |
| 49 | |
Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame] | 50 | #ifdef _DEBUG |
| 51 | // Get notifications of any messages in the given range, to any hooked window |
| 52 | void setDiagnosticRange(UINT min, UINT max); |
| 53 | #endif |
| 54 | |
| 55 | // * INTERNAL NOTIFICATION FUNCTION * |
| 56 | void NotifyHooksRegion(const Region& r); |
| 57 | protected: |
| 58 | HANDLE updateEvent; |
| 59 | bool updatesReady; |
| 60 | SimpleUpdateTracker updates; |
| 61 | }; |
| 62 | |
| 63 | // -=- Support for filtering out local input events while remote connections are |
| 64 | // active. Implemented using SetWindowsHookEx for portability. |
| 65 | class WMBlockInput { |
| 66 | public: |
| 67 | WMBlockInput(); |
| 68 | ~WMBlockInput(); |
| 69 | bool blockInputs(bool block); |
| 70 | protected: |
| 71 | bool active; |
| 72 | }; |
| 73 | |
Constantin Kaplinsky | 729598c | 2006-05-25 05:12:25 +0000 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | }; |
| 77 | |
| 78 | #endif // __RFB_WIN32_WM_HOOKS_H__ |