mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 18:26:39 +02:00
Enable code analysis on Keyboard Manager projects (#4455)
* Enable code analysis and fix GetTickCount warning * Fix arithmetic casting warning
This commit is contained in:
@@ -24,7 +24,7 @@ KeyTimedEvent KeyDelay::NextEvent()
|
||||
return ev;
|
||||
}
|
||||
|
||||
bool KeyDelay::CheckIfMillisHaveElapsed(DWORD first, DWORD last, DWORD duration)
|
||||
bool KeyDelay::CheckIfMillisHaveElapsed(DWORD64 first, DWORD64 last, DWORD64 duration)
|
||||
{
|
||||
if (first < last && first <= first + duration)
|
||||
{
|
||||
@@ -32,8 +32,8 @@ bool KeyDelay::CheckIfMillisHaveElapsed(DWORD first, DWORD last, DWORD duration)
|
||||
}
|
||||
else
|
||||
{
|
||||
first += ULONG_MAX / 2;
|
||||
last += ULONG_MAX / 2;
|
||||
first += ULLONG_MAX / 2;
|
||||
last += ULLONG_MAX / 2;
|
||||
return first + duration < last;
|
||||
}
|
||||
}
|
||||
@@ -99,7 +99,7 @@ bool KeyDelay::HandleOnHold(std::unique_lock<std::mutex>& cvLock)
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckIfMillisHaveElapsed(_initialHoldKeyDown, GetTickCount(), LONG_PRESS_DELAY_MILLIS))
|
||||
if (CheckIfMillisHaveElapsed(_initialHoldKeyDown, GetTickCount64(), LONG_PRESS_DELAY_MILLIS))
|
||||
{
|
||||
if (_onLongPressDetected != nullptr)
|
||||
{
|
||||
|
||||
@@ -16,7 +16,7 @@ enum class KeyDelayState
|
||||
// Virtual key + timestamp (in millis since Windows startup)
|
||||
struct KeyTimedEvent
|
||||
{
|
||||
DWORD time;
|
||||
DWORD64 time;
|
||||
WPARAM message;
|
||||
};
|
||||
|
||||
@@ -61,7 +61,7 @@ private:
|
||||
|
||||
// Check if <duration> milliseconds passed since <first> millisecond.
|
||||
// Also checks for overflow conditions.
|
||||
bool CheckIfMillisHaveElapsed(DWORD first, DWORD last, DWORD duration);
|
||||
bool CheckIfMillisHaveElapsed(DWORD64 first, DWORD64 last, DWORD64 duration);
|
||||
|
||||
std::thread _delayThread;
|
||||
bool _quit;
|
||||
@@ -81,11 +81,11 @@ private:
|
||||
std::condition_variable _cv;
|
||||
|
||||
// Keeps track of the time at which the initial KEY_DOWN event happened.
|
||||
DWORD _initialHoldKeyDown;
|
||||
DWORD64 _initialHoldKeyDown;
|
||||
|
||||
// Virtual Key provided in the constructor. Passed to callback functions.
|
||||
DWORD _key;
|
||||
|
||||
static const DWORD LONG_PRESS_DELAY_MILLIS = 900;
|
||||
static const DWORD ON_HOLD_WAIT_TIMEOUT_MILLIS = 50;
|
||||
static const DWORD64 LONG_PRESS_DELAY_MILLIS = 900;
|
||||
static const DWORD64 ON_HOLD_WAIT_TIMEOUT_MILLIS = 50;
|
||||
};
|
||||
|
||||
@@ -49,11 +49,13 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace KeyboardManagerConstants
|
||||
inline const long RemapTableArrowColIndex = 1;
|
||||
inline const long RemapTableNewColIndex = 2;
|
||||
inline const long RemapTableRemoveColIndex = 3;
|
||||
inline const DWORD RemapTableDropDownWidth = 110;
|
||||
inline const DWORD64 RemapTableDropDownWidth = 110;
|
||||
|
||||
// Shortcut table constants
|
||||
inline const long ShortcutTableColCount = 4;
|
||||
@@ -66,17 +66,17 @@ namespace KeyboardManagerConstants
|
||||
inline const long ShortcutTableArrowColIndex = 1;
|
||||
inline const long ShortcutTableNewColIndex = 2;
|
||||
inline const long ShortcutTableRemoveColIndex = 3;
|
||||
inline const DWORD ShortcutTableDropDownWidth = 110;
|
||||
inline const DWORD ShortcutTableDropDownSpacing = 10;
|
||||
inline const DWORD64 ShortcutTableDropDownWidth = 110;
|
||||
inline const DWORD64 ShortcutTableDropDownSpacing = 10;
|
||||
|
||||
// Drop down height used for both Edit Keyboard and Edit Shortcuts
|
||||
inline const DWORD TableDropDownHeight = 200;
|
||||
inline const DWORD TableArrowColWidth = 20;
|
||||
inline const DWORD TableRemoveColWidth = 20;
|
||||
inline const DWORD TableWarningColWidth = 20;
|
||||
inline const DWORD64 TableDropDownHeight = 200;
|
||||
inline const DWORD64 TableArrowColWidth = 20;
|
||||
inline const DWORD64 TableRemoveColWidth = 20;
|
||||
inline const DWORD64 TableWarningColWidth = 20;
|
||||
|
||||
// Shared style constants for both Remap Table and Shortcut Table
|
||||
inline const double HeaderButtonWidth = 100;
|
||||
inline const DWORD64 HeaderButtonWidth = 100;
|
||||
|
||||
// Flags used for distinguishing key events sent by Keyboard Manager
|
||||
inline const ULONG_PTR KEYBOARDMANAGER_SINGLEKEY_FLAG = 0x11; // Single key remaps
|
||||
|
||||
@@ -51,11 +51,13 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\$(ProjectName)\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
||||
@@ -51,11 +51,13 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
||||
@@ -52,11 +52,13 @@
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\modules\KeyboardManager\</OutDir>
|
||||
<IntDir>$(Platform)\$(Configuration)\obj\$(ProjectName)\</IntDir>
|
||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
||||
Reference in New Issue
Block a user