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

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