You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Inputs.h 3.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef WINVNCCONF_INPUTS
  19. #define WINVNCCONF_INPUTS
  20. #ifndef SPI_GETBLOCKSENDINPUTRESETS
  21. #define SPI_GETBLOCKSENDINPUTRESETS 0x1026
  22. #define SPI_SETBLOCKSENDINPUTRESETS 0x1027
  23. #endif
  24. #include <rfb_win32/Registry.h>
  25. #include <rfb_win32/Dialog.h>
  26. #include <rfb/ServerCore.h>
  27. namespace rfb {
  28. namespace win32 {
  29. class InputsPage : public PropSheetPage {
  30. public:
  31. InputsPage(const RegKey& rk)
  32. : PropSheetPage(GetModuleHandle(0), MAKEINTRESOURCE(IDD_INPUTS)),
  33. regKey(rk), enableAffectSSaver(true) {}
  34. void initDialog() {
  35. setItemChecked(IDC_ACCEPT_KEYS, rfb::Server::acceptKeyEvents);
  36. setItemChecked(IDC_RAW_KEYBOARD, SKeyboard::rawKeyboard);
  37. setItemChecked(IDC_ACCEPT_PTR, rfb::Server::acceptPointerEvents);
  38. setItemChecked(IDC_ACCEPT_CUTTEXT, rfb::Server::acceptCutText);
  39. setItemChecked(IDC_SEND_CUTTEXT, rfb::Server::sendCutText);
  40. setItemChecked(IDC_DISABLE_LOCAL_INPUTS, SDisplay::disableLocalInputs);
  41. BOOL blocked = FALSE;
  42. if (SystemParametersInfo(SPI_GETBLOCKSENDINPUTRESETS, 0, &blocked, 0))
  43. setItemChecked(IDC_AFFECT_SCREENSAVER, !blocked);
  44. else
  45. enableAffectSSaver = false;
  46. enableItem(IDC_AFFECT_SCREENSAVER, enableAffectSSaver);
  47. }
  48. bool onCommand(int /*id*/, int /*cmd*/) {
  49. BOOL inputResetsBlocked;
  50. SystemParametersInfo(SPI_GETBLOCKSENDINPUTRESETS, 0, &inputResetsBlocked, 0);
  51. setChanged((rfb::Server::acceptKeyEvents != isItemChecked(IDC_ACCEPT_KEYS)) ||
  52. (SKeyboard::rawKeyboard != isItemChecked(IDC_RAW_KEYBOARD)) ||
  53. (rfb::Server::acceptPointerEvents != isItemChecked(IDC_ACCEPT_PTR)) ||
  54. (rfb::Server::acceptCutText != isItemChecked(IDC_ACCEPT_CUTTEXT)) ||
  55. (rfb::Server::sendCutText != isItemChecked(IDC_SEND_CUTTEXT)) ||
  56. (SDisplay::disableLocalInputs != isItemChecked(IDC_DISABLE_LOCAL_INPUTS)) ||
  57. (enableAffectSSaver && (!inputResetsBlocked != isItemChecked(IDC_AFFECT_SCREENSAVER))));
  58. return false;
  59. }
  60. bool onOk() {
  61. regKey.setBool(_T("AcceptKeyEvents"), isItemChecked(IDC_ACCEPT_KEYS));
  62. regKey.setBool(_T("RawKeyboard"), isItemChecked(IDC_RAW_KEYBOARD));
  63. regKey.setBool(_T("AcceptPointerEvents"), isItemChecked(IDC_ACCEPT_PTR));
  64. regKey.setBool(_T("AcceptCutText"), isItemChecked(IDC_ACCEPT_CUTTEXT));
  65. regKey.setBool(_T("SendCutText"), isItemChecked(IDC_SEND_CUTTEXT));
  66. regKey.setBool(_T("DisableLocalInputs"), isItemChecked(IDC_DISABLE_LOCAL_INPUTS));
  67. if (enableAffectSSaver) {
  68. BOOL blocked = !isItemChecked(IDC_AFFECT_SCREENSAVER);
  69. SystemParametersInfo(SPI_SETBLOCKSENDINPUTRESETS, blocked, 0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
  70. }
  71. return true;
  72. }
  73. protected:
  74. RegKey regKey;
  75. bool enableAffectSSaver;
  76. };
  77. };
  78. };
  79. #endif