-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FancyZones] Shift + StickyKeys behavior fix (#6039)
- Loading branch information
1 parent
f64df97
commit 845bb46
Showing
8 changed files
with
94 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#pragma once | ||
|
||
#include "GenericKeyHook.h" | ||
|
||
template<int... keys> | ||
class KeyState | ||
{ | ||
public: | ||
KeyState(const std::function<void()>& callback) : | ||
m_state(false), | ||
m_hook(std::bind(&KeyState::onChangeState, this, std::placeholders::_1)), | ||
m_updateCallback(callback) | ||
{ | ||
|
||
} | ||
|
||
inline bool state() const noexcept { return m_state; } | ||
|
||
inline void enable() | ||
{ | ||
m_hook.enable(); | ||
m_state = (((GetAsyncKeyState(keys) & 0x8000) || ...)); | ||
} | ||
|
||
inline void disable() | ||
{ | ||
m_hook.disable(); | ||
} | ||
|
||
inline void setState(bool state) noexcept | ||
{ | ||
if (m_state != state) | ||
{ | ||
m_state = state; | ||
if (m_updateCallback) | ||
{ | ||
m_updateCallback(); | ||
} | ||
} | ||
} | ||
|
||
private: | ||
inline void onChangeState(bool state) noexcept | ||
{ | ||
setState(state); | ||
} | ||
|
||
private: | ||
std::atomic<bool> m_state; | ||
GenericKeyHook<keys...> m_hook; | ||
std::function<void()> m_updateCallback; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters