Merge pull request #4615 from bombizombi/master
[vuplus_xbmc] / xbmc / input / MouseStat.cpp
index cc72b34..77ace26 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *      Copyright (C) 2005-2013 Team XBMC
- *      http://www.xbmc.org
+ *      http://xbmc.org
  *
  *  This Program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -20,8 +20,9 @@
 
 #include "MouseStat.h"
 #include "guilib/Key.h"
-#include "windowing/WindowingFactory.h"
+#include "settings/lib/Setting.h"
 #include "utils/TimeUtils.h"
+#include "windowing/WindowingFactory.h"
 
 CMouseStat::CMouseStat()
 {
@@ -37,6 +38,16 @@ CMouseStat::~CMouseStat()
 {
 }
 
+void CMouseStat::OnSettingChanged(const CSetting *setting)
+{
+  if (setting == NULL)
+    return;
+
+  const std::string &settingId = setting->GetId();
+  if (settingId == "input.enablemouse")
+    SetEnabled(((CSettingBool*)setting)->GetValue());
+}
+
 void CMouseStat::Initialize()
 {
   // Set the default resolution (PAL)
@@ -149,21 +160,22 @@ void CMouseStat::HandleEvent(XBMC_Event& newEvent)
   else if (m_mouseState.dz < 0)
     m_Action = ACTION_MOUSE_WHEEL_DOWN;
 
-  // Finally check for a mouse move (that isn't a drag)
-  else if (newEvent.type == XBMC_MOUSEMOTION)
+  // Check for a mouse move that isn't a drag, ignoring messages with no movement at all
+  else if (newEvent.type == XBMC_MOUSEMOTION && (m_mouseState.dx || m_mouseState.dy))
     m_Action = ACTION_MOUSE_MOVE;
 
   // ignore any other mouse messages
   else
     m_Action = ACTION_NOOP;
 
-  // Activate the mouse pointer
-  if (MovedPastThreshold() || m_mouseState.dz)
+  // activate the mouse pointer if we have an action or the mouse has moved far enough
+  if ((MovedPastThreshold() && m_Action == ACTION_MOUSE_MOVE) ||
+      (m_Action != ACTION_NOOP && m_Action != ACTION_MOUSE_MOVE))
     SetActive();
-  else if (bNothingDown)
+
+  // reset the mouse state if nothing is held down
+  if (bNothingDown)
     SetState(MOUSE_STATE_NORMAL);
-  else
-    SetActive();
 }
 
 void CMouseStat::SetResolution(int maxX, int maxY, float speedX, float speedY)