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.

SDisplayCoreWMHooks.cxx 2.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. // -=- SDisplayCoreWMHooks.cxx
  19. #ifdef HAVE_CONFIG_H
  20. #include <config.h>
  21. #endif
  22. #include <rfb_win32/SDisplayCoreWMHooks.h>
  23. #include <rfb/LogWriter.h>
  24. using namespace rfb;
  25. using namespace rfb::win32;
  26. static LogWriter vlog("SDisplayCoreWMHooks");
  27. const unsigned int SDisplayCoreWMHooks::cursorTimerId = 2;
  28. const unsigned int SDisplayCoreWMHooks::consolePollTimerId = 3;
  29. SDisplayCoreWMHooks::SDisplayCoreWMHooks(SDisplay* d, UpdateTracker* ut)
  30. : SDisplayCorePolling(d, ut, 5000),
  31. cursorTimer(getHandle(), cursorTimerId),
  32. consolePollTimer(getHandle(), consolePollTimerId),
  33. pollConsoles(false) {
  34. if (!hooks.setEvent(display->getUpdateEvent()))
  35. throw rdr::Exception("hook subsystem failed to initialise");
  36. poller.setUpdateTracker(updateTracker);
  37. cursorTimer.start(20);
  38. consolePollTimer.start(200);
  39. }
  40. SDisplayCoreWMHooks::~SDisplayCoreWMHooks() {
  41. }
  42. LRESULT SDisplayCoreWMHooks::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
  43. if (msg == WM_TIMER) {
  44. if (wParam == cursorTimerId) {
  45. SetEvent(display->getUpdateEvent());
  46. return 0;
  47. } else if (wParam == consolePollTimerId) {
  48. pollConsoles = true;
  49. SetEvent(display->getUpdateEvent());
  50. return 0;
  51. }
  52. }
  53. return SDisplayCorePolling::processMessage(msg, wParam, lParam);
  54. }
  55. void SDisplayCoreWMHooks::flushUpdates() {
  56. // Poll any visible console windows
  57. if (pollConsoles) {
  58. pollConsoles = false;
  59. poller.processEvent();
  60. }
  61. // Check for updates from the hooks
  62. hooks.getUpdates(updateTracker);
  63. // Check for updates from the polling Core
  64. SDisplayCorePolling::flushUpdates();
  65. }