[FancyZones] Secondary mouse buttons click to toggle zones activation (#3989)

* Changed option name in settings, changed behaviour of zones activation by mouse to switch
* Removed IsDragEnabled from ZoneWindow
This commit is contained in:
Yevhenii Holovachov
2020-06-05 17:53:08 +03:00
committed by GitHub
parent e6408a0c37
commit 8410d7b08e
12 changed files with 134 additions and 67 deletions

View File

@@ -17,6 +17,7 @@
#include "MonitorWorkAreaHandler.h"
#include <interface/win_hook_event_data.h>
#include <lib/SecondaryMouseButtonsHook.h>
enum class DisplayChangeType
{
@@ -32,7 +33,8 @@ public:
FancyZones(HINSTANCE hinstance, const winrt::com_ptr<IFancyZonesSettings>& settings) noexcept :
m_hinstance(hinstance),
m_settings(settings),
m_windowMoveHandler(settings)
m_mouseHook(std::bind(&FancyZones::OnMouseDown, this)),
m_windowMoveHandler(settings, &m_mouseHook)
{
m_settings->SetCallback(this);
}
@@ -43,6 +45,14 @@ public:
IFACEMETHODIMP_(void)
Destroy() noexcept;
void OnMouseDown() noexcept
{
std::unique_lock writeLock(m_lock);
m_windowMoveHandler.OnMouseDown();
PostMessageW(m_window, WM_PRIV_LOCATIONCHANGE, NULL, NULL);
}
void MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen) noexcept
{
std::unique_lock writeLock(m_lock);
@@ -60,6 +70,7 @@ public:
std::unique_lock writeLock(m_lock);
m_windowMoveHandler.MoveSizeEnd(window, ptScreen, m_workAreaHandler.GetWorkAreasByDesktopId(m_currentDesktopId));
}
IFACEMETHODIMP_(void)
HandleWinHookEvent(const WinHookEvent* data) noexcept
{
@@ -213,6 +224,7 @@ private:
HWND m_window{};
WindowMoveHandler m_windowMoveHandler;
MonitorWorkAreaHandler m_workAreaHandler;
SecondaryMouseButtonsHook m_mouseHook;
winrt::com_ptr<IFancyZonesSettings> m_settings{};
GUID m_previousDesktopId{}; // UUID of previously active virtual desktop.