Constantin Kaplinsky | 7f8d774 | 2006-05-11 05:29:14 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2002-2005 RealVNC Ltd. All Rights Reserved. |
| 2 | * |
Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame] | 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 | #ifndef WINVNCCONF_INPUTS |
| 19 | #define WINVNCCONF_INPUTS |
| 20 | |
| 21 | #ifndef SPI_GETBLOCKSENDINPUTRESETS |
| 22 | #define SPI_GETBLOCKSENDINPUTRESETS 0x1026 |
| 23 | #define SPI_SETBLOCKSENDINPUTRESETS 0x1027 |
| 24 | #endif |
| 25 | |
| 26 | #include <rfb_win32/Registry.h> |
| 27 | #include <rfb_win32/Dialog.h> |
Constantin Kaplinsky | 7f8d774 | 2006-05-11 05:29:14 +0000 | [diff] [blame] | 28 | #include <rfb_win32/OSVersion.h> |
Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame] | 29 | #include <rfb/ServerCore.h> |
| 30 | |
| 31 | namespace rfb { |
Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame] | 32 | namespace win32 { |
| 33 | |
| 34 | class InputsPage : public PropSheetPage { |
| 35 | public: |
| 36 | InputsPage(const RegKey& rk) |
| 37 | : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_INPUTS)), |
| 38 | regKey(rk), enableAffectSSaver(true) {} |
| 39 | void initDialog() { |
| 40 | setItemChecked(IDC_ACCEPT_KEYS, rfb::Server::acceptKeyEvents); |
| 41 | setItemChecked(IDC_ACCEPT_PTR, rfb::Server::acceptPointerEvents); |
| 42 | setItemChecked(IDC_ACCEPT_CUTTEXT, rfb::Server::acceptCutText); |
| 43 | setItemChecked(IDC_SEND_CUTTEXT, rfb::Server::sendCutText); |
| 44 | setItemChecked(IDC_DISABLE_LOCAL_INPUTS, SDisplay::disableLocalInputs); |
Constantin Kaplinsky | 7f8d774 | 2006-05-11 05:29:14 +0000 | [diff] [blame] | 45 | enableItem(IDC_DISABLE_LOCAL_INPUTS, !osVersion.isPlatformWindows); |
Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame] | 46 | BOOL blocked = FALSE; |
| 47 | if (SystemParametersInfo(SPI_GETBLOCKSENDINPUTRESETS, 0, &blocked, 0)) |
| 48 | setItemChecked(IDC_AFFECT_SCREENSAVER, !blocked); |
| 49 | else |
| 50 | enableAffectSSaver = false; |
| 51 | enableItem(IDC_AFFECT_SCREENSAVER, enableAffectSSaver); |
| 52 | } |
| 53 | bool onCommand(int id, int cmd) { |
| 54 | BOOL inputResetsBlocked; |
| 55 | SystemParametersInfo(SPI_GETBLOCKSENDINPUTRESETS, 0, &inputResetsBlocked, 0); |
| 56 | setChanged((rfb::Server::acceptKeyEvents != isItemChecked(IDC_ACCEPT_KEYS)) || |
| 57 | (rfb::Server::acceptPointerEvents != isItemChecked(IDC_ACCEPT_PTR)) || |
| 58 | (rfb::Server::acceptCutText != isItemChecked(IDC_ACCEPT_CUTTEXT)) || |
| 59 | (rfb::Server::sendCutText != isItemChecked(IDC_SEND_CUTTEXT)) || |
| 60 | (SDisplay::disableLocalInputs != isItemChecked(IDC_DISABLE_LOCAL_INPUTS)) || |
| 61 | (enableAffectSSaver && (!inputResetsBlocked != isItemChecked(IDC_AFFECT_SCREENSAVER)))); |
| 62 | return false; |
| 63 | } |
| 64 | bool onOk() { |
| 65 | regKey.setBool(_T("AcceptKeyEvents"), isItemChecked(IDC_ACCEPT_KEYS)); |
| 66 | regKey.setBool(_T("AcceptPointerEvents"), isItemChecked(IDC_ACCEPT_PTR)); |
| 67 | regKey.setBool(_T("AcceptCutText"), isItemChecked(IDC_ACCEPT_CUTTEXT)); |
| 68 | regKey.setBool(_T("SendCutText"), isItemChecked(IDC_SEND_CUTTEXT)); |
| 69 | regKey.setBool(_T("DisableLocalInputs"), isItemChecked(IDC_DISABLE_LOCAL_INPUTS)); |
| 70 | if (enableAffectSSaver) { |
| 71 | BOOL blocked = !isItemChecked(IDC_AFFECT_SCREENSAVER); |
| 72 | SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE); |
| 73 | } |
| 74 | return true; |
| 75 | } |
| 76 | protected: |
| 77 | RegKey regKey; |
| 78 | bool enableAffectSSaver; |
| 79 | }; |
| 80 | |
| 81 | }; |
Constantin Kaplinsky | 47ed8d3 | 2004-10-08 09:43:57 +0000 | [diff] [blame] | 82 | }; |
| 83 | |
Constantin Kaplinsky | 7f8d774 | 2006-05-11 05:29:14 +0000 | [diff] [blame] | 84 | #endif |