The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

77 lines
2.5KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library - "Jules' Utility Class Extensions"
  4. Copyright 2004-9 by Raw Material Software Ltd.
  5. ------------------------------------------------------------------------------
  6. JUCE can be redistributed and/or modified under the terms of the GNU General
  7. Public License (Version 2), as published by the Free Software Foundation.
  8. A copy of the license is included in the JUCE distribution, or can be found
  9. online at www.gnu.org/licenses.
  10. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  13. ------------------------------------------------------------------------------
  14. To release a closed-source product which uses JUCE, commercial licenses are
  15. available: visit www.rawmaterialsoftware.com/juce for more information.
  16. ==============================================================================
  17. */
  18. #include "juce_IncludeCharacteristics.h"
  19. #include "../../../juce_amalgamated.h"
  20. #ifndef __JUCE_PLUGINHEADERS_JUCEHEADER__
  21. #define __JUCE_PLUGINHEADERS_JUCEHEADER__
  22. #if JUCE_MAC && JUCE_SUPPORT_CARBON
  23. // Helper class to workaround carbon windows not getting mouse-moves..
  24. class FakeMouseMoveGenerator : public Timer
  25. {
  26. public:
  27. FakeMouseMoveGenerator()
  28. {
  29. startTimer (1000 / 30);
  30. }
  31. void timerCallback()
  32. {
  33. // workaround for carbon windows not getting mouse-moves..
  34. const Point<int> screenPos (Desktop::getInstance().getMainMouseSource().getScreenPosition());
  35. if (screenPos != lastScreenPos)
  36. {
  37. lastScreenPos = screenPos;
  38. const ModifierKeys mods (ModifierKeys::getCurrentModifiers());
  39. if (! mods.isAnyMouseButtonDown())
  40. {
  41. Component* comp = Desktop::getInstance().findComponentAt (screenPos);
  42. if (comp != 0)
  43. {
  44. ComponentPeer* const peer = comp->getPeer();
  45. if (peer != 0 && ! peer->isFocused())
  46. peer->handleMouseEvent (0, screenPos - peer->getScreenPosition(), mods, Time::currentTimeMillis());
  47. }
  48. }
  49. }
  50. }
  51. private:
  52. Point<int> lastScreenPos;
  53. };
  54. #else
  55. struct FakeMouseMoveGenerator {};
  56. #endif
  57. #endif