mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed to register for WM_INPUT only when needed
This commit is contained in:
parent
ed9f27ba38
commit
0c89989d5a
@ -83,6 +83,8 @@ CMeterWindow::CMeterWindow(const std::wstring& folderPath, const std::wstring& f
|
|||||||
m_BackgroundSize(),
|
m_BackgroundSize(),
|
||||||
m_Window(),
|
m_Window(),
|
||||||
m_MouseOver(false),
|
m_MouseOver(false),
|
||||||
|
m_MouseInputRegistered(false),
|
||||||
|
m_HasMouseScrollAction(false),
|
||||||
m_BackgroundMargins(),
|
m_BackgroundMargins(),
|
||||||
m_DragMargins(),
|
m_DragMargins(),
|
||||||
m_WindowX(1, L'0'),
|
m_WindowX(1, L'0'),
|
||||||
@ -185,6 +187,8 @@ CMeterWindow::~CMeterWindow()
|
|||||||
KillTimer(m_Window, TIMER_FADE);
|
KillTimer(m_Window, TIMER_FADE);
|
||||||
KillTimer(m_Window, TIMER_TRANSITION);
|
KillTimer(m_Window, TIMER_TRANSITION);
|
||||||
|
|
||||||
|
UnregisterMouseInput();
|
||||||
|
|
||||||
// Destroy the meters
|
// Destroy the meters
|
||||||
std::vector<CMeter*>::iterator j = m_Meters.begin();
|
std::vector<CMeter*>::iterator j = m_Meters.begin();
|
||||||
for ( ; j != m_Meters.end(); ++j)
|
for ( ; j != m_Meters.end(); ++j)
|
||||||
@ -272,16 +276,6 @@ void CMeterWindow::Initialize()
|
|||||||
FadeWindow(0, m_AlphaValue);
|
FadeWindow(0, m_AlphaValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RAWINPUTDEVICE raw[1];
|
|
||||||
raw[0].usUsagePage = 0x01;
|
|
||||||
raw[0].usUsage = 0x02;
|
|
||||||
raw[0].dwFlags = RIDEV_INPUTSINK;
|
|
||||||
raw[0].hwndTarget = m_Window;
|
|
||||||
if (!RegisterRawInputDevices(raw, 1, sizeof(raw[0])))
|
|
||||||
{
|
|
||||||
Log(LOG_WARNING, L"Error registering raw input mouse device.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -297,6 +291,40 @@ void CMeterWindow::IgnoreAeroPeek()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Registers to receive WM_INPUT for the mouse events.
|
||||||
|
**
|
||||||
|
*/
|
||||||
|
void CMeterWindow::RegisterMouseInput()
|
||||||
|
{
|
||||||
|
if (!m_MouseInputRegistered && m_HasMouseScrollAction)
|
||||||
|
{
|
||||||
|
RAWINPUTDEVICE rid;
|
||||||
|
rid.usUsagePage = 0x01;
|
||||||
|
rid.usUsage = 0x02; // HID mouse
|
||||||
|
rid.dwFlags = RIDEV_INPUTSINK;
|
||||||
|
rid.hwndTarget = m_Window;
|
||||||
|
if (RegisterRawInputDevices(&rid, 1, sizeof(rid)))
|
||||||
|
{
|
||||||
|
m_MouseInputRegistered = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeterWindow::UnregisterMouseInput()
|
||||||
|
{
|
||||||
|
if (m_MouseInputRegistered)
|
||||||
|
{
|
||||||
|
RAWINPUTDEVICE rid;
|
||||||
|
rid.usUsagePage = 0x01;
|
||||||
|
rid.usUsage = 0x02; // HID mouse
|
||||||
|
rid.dwFlags = RIDEV_REMOVE;
|
||||||
|
rid.hwndTarget = m_Window;
|
||||||
|
RegisterRawInputDevices(&rid, 1, sizeof(rid));
|
||||||
|
m_MouseInputRegistered = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CMeterWindow::AddWindowExStyle(LONG_PTR flag)
|
void CMeterWindow::AddWindowExStyle(LONG_PTR flag)
|
||||||
{
|
{
|
||||||
LONG_PTR style = GetWindowLongPtr(m_Window, GWL_EXSTYLE);
|
LONG_PTR style = GetWindowLongPtr(m_Window, GWL_EXSTYLE);
|
||||||
@ -4309,6 +4337,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
|
|||||||
//LogWithArgs(LOG_DEBUG, L"@Enter: %s", m_FolderPath.c_str());
|
//LogWithArgs(LOG_DEBUG, L"@Enter: %s", m_FolderPath.c_str());
|
||||||
m_MouseOver = true;
|
m_MouseOver = true;
|
||||||
SetMouseLeaveEvent(false);
|
SetMouseLeaveEvent(false);
|
||||||
|
RegisterMouseInput();
|
||||||
|
|
||||||
if (!m_Mouse.GetOverAction().empty())
|
if (!m_Mouse.GetOverAction().empty())
|
||||||
{
|
{
|
||||||
@ -4392,6 +4421,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
|
|||||||
//LogWithArgs(LOG_DEBUG, L"Enter: %s", m_FolderPath.c_str());
|
//LogWithArgs(LOG_DEBUG, L"Enter: %s", m_FolderPath.c_str());
|
||||||
m_MouseOver = true;
|
m_MouseOver = true;
|
||||||
SetMouseLeaveEvent(false);
|
SetMouseLeaveEvent(false);
|
||||||
|
RegisterMouseInput();
|
||||||
|
|
||||||
if (!m_Mouse.GetOverAction().empty())
|
if (!m_Mouse.GetOverAction().empty())
|
||||||
{
|
{
|
||||||
@ -4412,6 +4442,7 @@ bool CMeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
|
|||||||
//LogWithArgs(LOG_DEBUG, L"Leave: %s", m_FolderPath.c_str());
|
//LogWithArgs(LOG_DEBUG, L"Leave: %s", m_FolderPath.c_str());
|
||||||
m_MouseOver = false;
|
m_MouseOver = false;
|
||||||
SetMouseLeaveEvent(true);
|
SetMouseLeaveEvent(true);
|
||||||
|
UnregisterMouseInput();
|
||||||
|
|
||||||
if (!m_Mouse.GetLeaveAction().empty())
|
if (!m_Mouse.GetLeaveAction().empty())
|
||||||
{
|
{
|
||||||
|
@ -179,6 +179,7 @@ public:
|
|||||||
void SetOption(const std::wstring& section, const std::wstring& option, const std::wstring& value, bool group);
|
void SetOption(const std::wstring& section, const std::wstring& option, const std::wstring& value, bool group);
|
||||||
|
|
||||||
void SetMouseLeaveEvent(bool cancel);
|
void SetMouseLeaveEvent(bool cancel);
|
||||||
|
void SetHasMouseScrollAction() { m_HasMouseScrollAction = true; }
|
||||||
|
|
||||||
void MoveWindow(int x, int y);
|
void MoveWindow(int x, int y);
|
||||||
void ChangeZPos(ZPOSITION zPos, bool all = false);
|
void ChangeZPos(ZPOSITION zPos, bool all = false);
|
||||||
@ -334,6 +335,8 @@ private:
|
|||||||
bool DoMoveAction(int x, int y, MOUSEACTION action);
|
bool DoMoveAction(int x, int y, MOUSEACTION action);
|
||||||
bool ResizeWindow(bool reset);
|
bool ResizeWindow(bool reset);
|
||||||
void IgnoreAeroPeek();
|
void IgnoreAeroPeek();
|
||||||
|
void RegisterMouseInput();
|
||||||
|
void UnregisterMouseInput();
|
||||||
void AddWindowExStyle(LONG_PTR flag);
|
void AddWindowExStyle(LONG_PTR flag);
|
||||||
void RemoveWindowExStyle(LONG_PTR flag);
|
void RemoveWindowExStyle(LONG_PTR flag);
|
||||||
void BlurBehindWindow(BOOL fEnable);
|
void BlurBehindWindow(BOOL fEnable);
|
||||||
@ -360,6 +363,8 @@ private:
|
|||||||
|
|
||||||
CMouse m_Mouse;
|
CMouse m_Mouse;
|
||||||
bool m_MouseOver;
|
bool m_MouseOver;
|
||||||
|
bool m_MouseInputRegistered;
|
||||||
|
bool m_HasMouseScrollAction;
|
||||||
|
|
||||||
std::wstring m_OnRefreshAction;
|
std::wstring m_OnRefreshAction;
|
||||||
std::wstring m_OnCloseAction;
|
std::wstring m_OnCloseAction;
|
||||||
|
@ -51,6 +51,11 @@ void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWind
|
|||||||
m_LeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
m_LeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false);
|
||||||
m_MouseScrollDownAction = parser.ReadString(section, L"MouseScrollDownAction", L"", false);
|
m_MouseScrollDownAction = parser.ReadString(section, L"MouseScrollDownAction", L"", false);
|
||||||
m_MouseScrollUpAction = parser.ReadString(section, L"MouseScrollUpAction", L"", false);
|
m_MouseScrollUpAction = parser.ReadString(section, L"MouseScrollUpAction", L"", false);
|
||||||
|
if (!m_MouseScrollDownAction.empty() || !m_MouseScrollUpAction.empty())
|
||||||
|
{
|
||||||
|
meterWindow->SetHasMouseScrollAction();
|
||||||
|
}
|
||||||
|
|
||||||
m_MouseScrollLeftAction = parser.ReadString(section, L"MouseScrollLeftAction", L"", false);
|
m_MouseScrollLeftAction = parser.ReadString(section, L"MouseScrollLeftAction", L"", false);
|
||||||
m_MouseScrollRightAction = parser.ReadString(section, L"MouseScrollRightAction", L"", false);
|
m_MouseScrollRightAction = parser.ReadString(section, L"MouseScrollRightAction", L"", false);
|
||||||
m_X1DownAction = parser.ReadString(section, L"X1MouseDownAction", L"", false);
|
m_X1DownAction = parser.ReadString(section, L"X1MouseDownAction", L"", false);
|
||||||
|
Loading…
Reference in New Issue
Block a user