Fix ColorPicker detecting grid (#24413)

* Fix ColorPicker sampling colour from the grid

Addresses #13831. The sampled pixel is now completely avoided by the grid.
Also, this should address the timing issue from the sampling being done
every 10ms, which overlaps strangely with monitor refresh rates at 16.6ms,
13.3ms, etc.

* Forgot extra library

* Revert rounding in GetPixelColor

* Ensure EnumDisplaySettingsW returns true

Assigning refreshRate only if EnumDisplaySettingsW returns true,
otherwise defaulting to 60.0Hz.

* Run spellchecker

* Spellcheck again

---------

Co-authored-by: Stefan Markovic <stefan@janeasystems.com>
This commit is contained in:
Tudor Croitoru
2023-03-17 21:25:03 +00:00
committed by GitHub
parent dbe52d3d52
commit 41997eb599
6 changed files with 99 additions and 139 deletions

View File

@@ -77,10 +77,10 @@
^\.gitmodules$ ^\.gitmodules$
^\Q.github/workflows/spelling2.yml\E$ ^\Q.github/workflows/spelling2.yml\E$
^\Q.pipelines/ESRPSigning_core.json\E$ ^\Q.pipelines/ESRPSigning_core.json\E$
^\Qinstaller/PowerToysSetup/Settings.wxs\E$
^\Qsrc/common/ManagedCommon/ColorFormatHelper.cs\E$
^\Qsrc/modules/colorPicker/ColorPickerUI/Shaders/GridShader.cso\E$ ^\Qsrc/modules/colorPicker/ColorPickerUI/Shaders/GridShader.cso\E$
^\Qsrc/modules/MouseUtils/MouseJumpUI/MainForm.resx\E$ ^\Qsrc/modules/MouseUtils/MouseJumpUI/MainForm.resx\E$
^\Qsrc/common/ManagedCommon/ColorFormatHelper.cs\E$
^\Qinstaller/PowerToysSetup/Settings.wxs\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/CorruptJson/Microsoft/PowerToys/settings.json\E$ ^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/CorruptJson/Microsoft/PowerToys/settings.json\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$ ^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.18.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$
^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$ ^\Qsrc/settings-ui/Settings.UI.UnitTests/BackwardsCompatibility/TestFiles/v0.19.2/Microsoft/PowerToys/PowerRename/power-rename-ui-flags\E$

View File

@@ -29,8 +29,6 @@ AFFINETRANSFORM
AFX AFX
AGGREGATABLE AGGREGATABLE
AHybrid AHybrid
Akrotiri
Aktobe
ALarger ALarger
alekhyareddy alekhyareddy
ALLAPPS ALLAPPS
@@ -43,13 +41,12 @@ amd
AModifier AModifier
AMPROPERTY AMPROPERTY
AMPROPSETID AMPROPSETID
Andreanof ANDSCANS
anges anges
angularsen angularsen
Animatable Animatable
ansicolor ansicolor
ANull ANull
ANDSCANS
AOC AOC
aocfnapldcnfbofgmbbllojgocaelgdd aocfnapldcnfbofgmbbllojgocaelgdd
APARTMENTTHREADED APARTMENTTHREADED
@@ -72,10 +69,8 @@ appref
apps apps
appwindow appwindow
appwiz appwiz
appxpackage
APSTUDIO APSTUDIO
AQS AQS
Aqtobe
ARCHITEW ARCHITEW
arcosh arcosh
ARemapped ARemapped
@@ -94,7 +89,6 @@ ASingle
ASSOCCHANGED ASSOCCHANGED
ASYNCWINDOWPLACEMENT ASYNCWINDOWPLACEMENT
ASYNCWINDOWPOS ASYNCWINDOWPOS
Atikokan
atl atl
atlbase atlbase
atlcom atlcom
@@ -102,7 +96,6 @@ atleast
atlfile atlfile
atlstr atlstr
Attribs Attribs
Atyrau
aumid aumid
Aut Aut
Authenticode Authenticode
@@ -113,18 +106,14 @@ AUTOMATIONPROPERTIES
Autorun Autorun
AUTOUPDATE AUTOUPDATE
AValid AValid
Avanc
awakeness awakeness
awakeversion awakeversion
AYUV AYUV
azman azman
backtracer backtracer
bak bak
Bashkortostan
Bayan
bbwe bbwe
bck bck
Belarus
betadele betadele
betsegaw betsegaw
BGR BGR
@@ -142,8 +131,8 @@ BITSPIXEL
bla bla
BLACKONWHITE BLACKONWHITE
Blockquotes Blockquotes
Blt
blogs blogs
Blt
BLUEGRAY BLUEGRAY
Bluetooth Bluetooth
BLURBEHIND BLURBEHIND
@@ -164,7 +153,6 @@ bricelam
BRIGHTGREEN BRIGHTGREEN
Browsable Browsable
bsd bsd
Bson
bstr bstr
bthprops bthprops
bti bti
@@ -176,14 +164,10 @@ bugreport
BUILDNUMBER BUILDNUMBER
buildtask buildtask
buildtransitive buildtransitive
Burkina
Buryatia
BUTTONUP BUTTONUP
BValue BValue
BYPOSITION BYPOSITION
bytearray bytearray
Cabo
Caiguna
CALG CALG
callbackptr callbackptr
Cangjie Cangjie
@@ -192,6 +176,10 @@ CAPTUREBLT
CAPTURECHANGED CAPTURECHANGED
CAtl CAtl
cch cch
CCHDEVICENAME
CCHDEVICENAME
CCHFORMNAME
CCHFORMNAME
CCom CCom
CContext CContext
cdecl cdecl
@@ -208,28 +196,24 @@ Changemove
chdir chdir
CHILDACTIVATE CHILDACTIVATE
CHILDWINDOW CHILDWINDOW
Choibalsan
chrdavis chrdavis
Chrzan Chrzan
cht cht
Chukotka
Chuuk
CIELAB CIELAB
CIEXYZ CIEXYZ
cim cim
CImage CImage
cla cla
clangformat clangformat
clayton
CLASSDC CLASSDC
CLASSNOTAVAILABLE CLASSNOTAVAILABLE
clayton
clickable clickable
clickonce clickonce
CLIENTEDGE CLIENTEDGE
clientid clientid
clientside clientside
CLIPCHILDREN CLIPCHILDREN
Clipperton
CLIPSIBLINGS CLIPSIBLINGS
Cloneable Cloneable
clrcall clrcall
@@ -249,7 +233,6 @@ cmpgt
cmyk cmyk
cne cne
cnt cnt
Cocklebiddy
coclass coclass
CODENAME CODENAME
codeofconduct codeofconduct
@@ -274,7 +257,6 @@ cominterop
commandline commandline
COMMANDTITLE COMMANDTITLE
commctrl commctrl
Comoros
compmgmt compmgmt
COMPOSITIONFULL COMPOSITIONFULL
comsupp comsupp
@@ -296,7 +278,6 @@ CONTROLL
CONTROLPARENT CONTROLPARENT
Controlz Controlz
copiedcolorrepresentation copiedcolorrepresentation
corewebview
cortana cortana
cotaskmem cotaskmem
COULDNOT COULDNOT
@@ -310,7 +291,6 @@ CProj
CREATESCHEDULEDTASK CREATESCHEDULEDTASK
CREATESTRUCT CREATESTRUCT
CREATEWINDOWFAILED CREATEWINDOWFAILED
createcompatibledc
critsec critsec
Crossdevice Crossdevice
CRSEL CRSEL
@@ -327,7 +307,6 @@ CTRLALTDEL
Ctrls Ctrls
Ctx Ctx
CUI CUI
Cunha
currentculture currentculture
CURRENTDIR CURRENTDIR
CURSORINFO CURSORINFO
@@ -351,12 +330,10 @@ cziplib
Dac Dac
dacl dacl
damienleroy damienleroy
Danmarkshavn
DARKPURPLE DARKPURPLE
DARKTEAL DARKTEAL
DARKYELLOW DARKYELLOW
datareader datareader
datatemplate
Datavalue Datavalue
dataversion dataversion
DATAW DATAW
@@ -414,6 +391,8 @@ devblogs
devdocs devdocs
devenum devenum
devmgmt devmgmt
DEVMODEW
DEVMODEW
DEVMON DEVMON
devpkey devpkey
DEVSOURCE DEVSOURCE
@@ -436,7 +415,6 @@ dllmain
DNLEN DNLEN
Dns Dns
DONOTROUND DONOTROUND
DONTRESOLVEDLLREFERENCES
DONTVALIDATEPATH DONTVALIDATEPATH
dotnet dotnet
DPICHANGED DPICHANGED
@@ -500,7 +478,6 @@ endpointvolume
endregion endregion
ENTERSIZEMOVE ENTERSIZEMOVE
enu enu
enumerationoptions
EOAC EOAC
epicgames epicgames
epu epu
@@ -514,10 +491,8 @@ ESettings
esize esize
esn esn
esrp esrp
Eswatini
etl etl
etw etw
Eucla
EUQ EUQ
eurochange eurochange
eventlog eventlog
@@ -554,7 +529,6 @@ fancyzones
FANCYZONESDRAWLAYOUTTEST FANCYZONESDRAWLAYOUTTEST
FANCYZONESEDITOR FANCYZONESEDITOR
Farbraum Farbraum
Faroe
FARPROC FARPROC
fdw fdw
feimage feimage
@@ -594,7 +568,6 @@ FSCTL
fsmgmt fsmgmt
FTYPE FTYPE
Functiondiscoverykeys Functiondiscoverykeys
Futuna
fwlink fwlink
FZE FZE
gabime gabime
@@ -612,8 +585,6 @@ gcode
gdi gdi
gdiplus gdiplus
GDISCALED GDISCALED
getancestor
getasynckeystate
GETDESKWALLPAPER GETDESKWALLPAPER
GETDLGCODE GETDLGCODE
GETDPISCALEDSIZE GETDPISCALEDSIZE
@@ -623,7 +594,6 @@ GETSTATE
GETTEXT GETTEXT
GETTEXTLENGTH GETTEXTLENGTH
GHND GHND
globalassemblycache
Globbing Globbing
GMEM GMEM
GNumber GNumber
@@ -642,7 +612,6 @@ gwl
GWLP GWLP
HACCEL HACCEL
handlekeyboardhookevent handlekeyboardhookevent
handlerroutine
hangeul hangeul
Hankaku Hankaku
hanselman hanselman
@@ -672,7 +641,6 @@ HEB
Heiko Heiko
Helpline Helpline
helptext helptext
Heure
HGFE HGFE
hglobal hglobal
hhk hhk
@@ -711,7 +679,6 @@ hotkeycontrol
hotkeys hotkeys
hotlight hotlight
hotspot hotspot
Hovd
HPAINTBUFFER HPAINTBUFFER
HPALETTE HPALETTE
HRAWINPUT HRAWINPUT
@@ -793,7 +760,6 @@ Inlines
inorder inorder
INPC INPC
inproc inproc
inputdev
INPUTHARDWARE INPUTHARDWARE
INPUTKEYBOARD INPUTKEYBOARD
INPUTLANGCHANGED INPUTLANGCHANGED
@@ -822,7 +788,6 @@ ipcmanager
IPlugin IPlugin
IPower IPower
IPREVIEW IPREVIEW
ipreviewhandler
ipreviewhandlervisualssetfont ipreviewhandlervisualssetfont
IProperty IProperty
IPublic IPublic
@@ -837,11 +802,8 @@ iss
ITask ITask
ith ith
ITHUMBNAIL ITHUMBNAIL
Ittoqqortoormiit
IUI IUI
IUnknown IUnknown
ivirtualdesktopmanager
Ivoire
IWbem IWbem
IWIC IWIC
iwr iwr
@@ -876,20 +838,11 @@ keynum
keyremaps keyremaps
Keytool Keytool
keyup keyup
Khakassia
Khanty
Khovd
KILLFOCUS KILLFOCUS
killrunner killrunner
Kitts
Knownfolders Knownfolders
Krai
KSPROPERTY KSPROPERTY
Kwango
Kwilu
Kybd Kybd
Kyrgyzstan
Kyzylorda
LAlt LAlt
Lambson Lambson
langword langword
@@ -909,8 +862,8 @@ LCtrl
Ldone Ldone
ldx ldx
LEFTDOWN LEFTDOWN
LEFTUP
LEFTSCROLLBAR LEFTSCROLLBAR
LEFTUP
lego lego
len len
LError LError
@@ -935,7 +888,6 @@ LMEM
LMENU LMENU
lnk lnk
LOADFROMFILE LOADFROMFILE
LOADLIBRARYASDATAFILE
LOBYTE LOBYTE
LOCALAPPDATA LOCALAPPDATA
LOCALDISPLAY LOCALDISPLAY
@@ -988,16 +940,12 @@ lstrcmpi
lstrlen lstrlen
LTRB LTRB
LTRREADING LTRREADING
Luhansk
luid luid
lusrmgr lusrmgr
LWA LWA
lwin lwin
LZero LZero
lzw lzw
Maarten
Macquarie
Magadan
Mainwindow Mainwindow
majortype majortype
MAJORVERSION MAJORVERSION
@@ -1005,10 +953,7 @@ makecab
MAKEINTRESOURCE MAKEINTRESOURCE
MAKEINTRESOURCEW MAKEINTRESOURCEW
makepri makepri
Mangere
Mangystau
manifestdependency manifestdependency
Mansi
MAPPEDTOSAMEKEY MAPPEDTOSAMEKEY
MAPTOSAMESHORTCUT MAPTOSAMESHORTCUT
MAPVK MAPVK
@@ -1016,10 +961,8 @@ Markdig
markdownpreviewhandler markdownpreviewhandler
MARKDOWNPREVIEWHANDLERCPP MARKDOWNPREVIEWHANDLERCPP
Markovic Markovic
Marquesas
martinchrzan martinchrzan
martinmoene martinmoene
Mato
Maximizable Maximizable
MAXIMIZEBOX MAXIMIZEBOX
MAXSHORTCUTSIZE MAXSHORTCUTSIZE
@@ -1031,8 +974,6 @@ MBUTTON
MBUTTONDBLCLK MBUTTONDBLCLK
MBUTTONDOWN MBUTTONDOWN
MBUTTONUP MBUTTONUP
MCDT
MCST
MDICHILD MDICHILD
MDL MDL
mdtext mdtext
@@ -1043,7 +984,6 @@ mediatype
Melman Melman
MENUITEMINFO MENUITEMINFO
MENUITEMINFOW MENUITEMINFOW
menurc
MERGECOPY MERGECOPY
MERGEPAINT MERGEPAINT
Metadatas Metadatas
@@ -1059,9 +999,9 @@ mftransform
Mgmt Mgmt
mic mic
microsoft microsoft
Midl
MIDDLEDOWN MIDDLEDOWN
MIDDLEUP MIDDLEUP
Midl
mii mii
MIIM MIIM
millis millis
@@ -1075,7 +1015,6 @@ miniz
minlevel minlevel
MINORVERSION MINORVERSION
Miracast Miracast
Mishkeegogamang
mjpg mjpg
mkd mkd
mkdn mkdn
@@ -1091,8 +1030,6 @@ mockapi
MODECHANGE MODECHANGE
modernwpf modernwpf
MODESPRUNED MODESPRUNED
Moldova
Mongala
MONITORINFO MONITORINFO
MONITORINFOEX MONITORINFOEX
MONITORINFOEXW MONITORINFOEXW
@@ -1137,15 +1074,11 @@ MTND
Mul Mul
MULTIPLEUSE MULTIPLEUSE
multizone multizone
Mundrabilla
mvvm mvvm
myfile myfile
MYICON MYICON
MYTZ
NAMECHANGE NAMECHANGE
nameof nameof
Navassa
navigatetostring
NCACTIVATE NCACTIVATE
ncc ncc
NCCALCSIZE NCCALCSIZE
@@ -1167,7 +1100,6 @@ NCRBUTTONDBLCLK
NCRBUTTONDOWN NCRBUTTONDOWN
NCRBUTTONUP NCRBUTTONUP
NCRENDERING NCRENDERING
Ndombe
ndp ndp
NEEDDISPATCH NEEDDISPATCH
Nemeth Nemeth
@@ -1211,7 +1143,6 @@ nonclient
NONCONVERT NONCONVERT
NONELEVATED NONELEVATED
NONINFRINGEMENT NONINFRINGEMENT
nonpackaged
nonstd nonstd
NOOWNERZORDER NOOWNERZORDER
NOPARENTNOTIFY NOPARENTNOTIFY
@@ -1224,7 +1155,6 @@ NOREPOSITION
norestart norestart
NORMALDISPLAY NORMALDISPLAY
NORMALUSER NORMALUSER
Noronha
NOSEARCH NOSEARCH
NOSENDCHANGING NOSENDCHANGING
NOSIZE NOSIZE
@@ -1251,8 +1181,6 @@ nullonfailure
numberbox numberbox
NUMLOCK NUMLOCK
NUMPAD NUMPAD
Nunavut
Nusa
nwc nwc
Objbase Objbase
OBJID OBJID
@@ -1273,8 +1201,6 @@ oldtheme
oleaut oleaut
OLECHAR OLECHAR
OLEDB OLEDB
oledbcommand
oledbconnection
OLIVEGREEN OLIVEGREEN
onebranch onebranch
onenote onenote
@@ -1339,6 +1265,8 @@ pdtobj
pdw pdw
PDWORD PDWORD
pedrolamas pedrolamas
Pels
Pels
PERCEIVEDFLAG PERCEIVEDFLAG
perfmon perfmon
pesi pesi
@@ -1362,7 +1290,6 @@ PINDIR
pinfo pinfo
pinvoke pinvoke
pipename pipename
Pitcairn
PKBDLLHOOKSTRUCT PKBDLLHOOKSTRUCT
PKEY PKEY
plib plib
@@ -1374,7 +1301,6 @@ plugins
pluginsmodel pluginsmodel
PMSIHANDLE PMSIHANDLE
Pnp Pnp
Pohnpei
Popups Popups
POPUPWINDOW POPUPWINDOW
posix posix
@@ -1415,7 +1341,6 @@ PREVIOUSVERSIONSINSTALLED
prevpane prevpane
prgms prgms
pri pri
Primorsky
PRINTCLIENT PRINTCLIENT
printmanagement printmanagement
prm prm
@@ -1464,7 +1389,6 @@ QITAB
QITABENT QITABENT
qps qps
QUERYENDSESSION QUERYENDSESSION
queryfocus
QUERYOPEN QUERYOPEN
QUEUESYNC QUEUESYNC
Quickime Quickime
@@ -1509,7 +1433,6 @@ regfile
REGFILTER REGFILTER
REGFILTERPINS REGFILTERPINS
REGISTERCLASSFAILED REGISTERCLASSFAILED
registerhotkey
registrypath registrypath
regkey regkey
REGPINTYPES REGPINTYPES
@@ -1536,7 +1459,6 @@ resizers
RESIZETOFIT RESIZETOFIT
resmimetype resmimetype
RESOURCEID RESOURCEID
resourcemanager
RESTORETOMAXIMIZED RESTORETOMAXIMIZED
restrictedcapabilities restrictedcapabilities
restrictederrorinfo restrictederrorinfo
@@ -1553,21 +1475,19 @@ rhs
ricardosantos ricardosantos
RIDEV RIDEV
RIGHTDOWN RIGHTDOWN
RIGHTUP
RIGHTSCROLLBAR RIGHTSCROLLBAR
RIGHTUP
riid riid
RKey RKey
RLO RLO
RMENU RMENU
RNumber RNumber
roadmap roadmap
Roamable
robmensching robmensching
Roboto Roboto
rooler rooler
rop rop
roslyn roslyn
Rothera
roundf roundf
ROUNDSMALL ROUNDSMALL
Rpc Rpc
@@ -1606,7 +1526,6 @@ SAMESHORTCUTPREVIOUSLYMAPPED
SAVEFAILED SAVEFAILED
scancode scancode
scanled scanled
Schd
schedtasks schedtasks
Scip Scip
scipbe scipbe
@@ -1618,10 +1537,8 @@ sddl
SDKDDK SDKDDK
sdns sdns
searchterm searchterm
secauthz
secpol secpol
Secur Secur
securityoverview
Segoe Segoe
Sekan Sekan
SENDCHANGE SENDCHANGE
@@ -1657,7 +1574,6 @@ shellex
SHELLEXECUTEINFO SHELLEXECUTEINFO
SHELLEXECUTEINFOW SHELLEXECUTEINFOW
shellscalingapi shellscalingapi
shemptyrecyclebina
SHFILEINFO SHFILEINFO
SHGFI SHGFI
Shl Shl
@@ -1722,13 +1638,12 @@ Soref
SOURCECLIENTAREAONLY SOURCECLIENTAREAONLY
SOURCEHEADER SOURCEHEADER
sourcesdirectory sourcesdirectory
SPACEBAR
spam spam
spdisp spdisp
spdlog spdlog
spdo spdo
specialfolder
spec'ing spec'ing
specialfolder
spesi spesi
splitwstring splitwstring
spsi spsi
@@ -1742,7 +1657,6 @@ Srch
SRCINVERT SRCINVERT
SRCPAINT SRCPAINT
sre sre
Srednekolymsk
SResize SResize
srme srme
srre srre
@@ -1794,9 +1708,7 @@ subkey
SUBLANG SUBLANG
subquery subquery
subresource subresource
Sul
Superbar Superbar
Suri
sut sut
SVE SVE
SVGIn SVGIn
@@ -1816,7 +1728,6 @@ SYSCOMMAND
SYSDEADCHAR SYSDEADCHAR
sysdm sysdm
SYSICONINDEX SYSICONINDEX
sysinfo
SYSKEY SYSKEY
syskeydown syskeydown
SYSKEYUP SYSKEYUP
@@ -1826,7 +1737,6 @@ systemroot
SYSTEMTIME SYSTEMTIME
sysvol sysvol
Tadele Tadele
Tajikistan
talynone talynone
TApp TApp
TApplication TApplication
@@ -1854,7 +1764,6 @@ telem
telephon telephon
Templated Templated
templatenamespace templatenamespace
Tenggara
testapp testapp
testcase testcase
testhost testhost
@@ -1874,7 +1783,6 @@ timedate
timediff timediff
timeunion timeunion
timeutil timeutil
timezones
Titlecase Titlecase
TKey TKey
TLayout TLayout
@@ -1887,7 +1795,6 @@ toolkitconverters
Toolset Toolset
toolwindow toolwindow
TOPDOWNDIB TOPDOWNDIB
tostring
TOUCHEVENTF TOUCHEVENTF
TOUCHINPUT TOUCHINPUT
touchpad touchpad
@@ -1895,15 +1802,12 @@ Towindow
tracelogging tracelogging
traies traies
transicc transicc
Transnistria
TRAYMOUSEMESSAGE TRAYMOUSEMESSAGE
triaging triaging
TRK TRK
trl trl
TServer TServer
Tshuapa
TStr TStr
Tuva
TValue TValue
TWF TWF
tymed tymed
@@ -1917,23 +1821,18 @@ TYPESHORTCUT
UAC UAC
UAL UAL
uap uap
uapmanifestschema
udit udit
Udk Udk
Udmurtia
Udp Udp
uefi uefi
UHash UHash
UIA UIA
uiauto
uid uid
UIEx UIEx
uipi uipi
UIs UIs
Ulaanbaatar
ULARGE ULARGE
ULONGLONG ULONGLONG
UMsg
unassign unassign
uncompilable uncompilable
UNCPRIORITY UNCPRIORITY
@@ -1954,13 +1853,11 @@ unmute
UNORM UNORM
unregistering unregistering
unremapped unremapped
Unstub
unsubscribe unsubscribe
unvirtualized unvirtualized
Updatelayout Updatelayout
UPGRADINGPRODUCTCODE UPGRADINGPRODUCTCODE
Uptool Uptool
Urville
Usb Usb
USEDEFAULT USEDEFAULT
USEFILEATTRIBUTES USEFILEATTRIBUTES
@@ -1973,7 +1870,6 @@ USRDLL
Utc Utc
utf utf
uuidof uuidof
Uvs
uwp uwp
uxtheme uxtheme
UYVY UYVY
@@ -2014,7 +1910,6 @@ viewbox
viewmodel viewmodel
vih vih
VIRTUALDESK VIRTUALDESK
virtualkey
visiblecolorformats visiblecolorformats
Visibletrue Visibletrue
VKey VKey
@@ -2070,7 +1965,6 @@ wikipedia
wildcards wildcards
winapi winapi
winappdriver winappdriver
winauto
wincodec wincodec
Wincodecsdk Wincodecsdk
wincolor wincolor
@@ -2097,7 +1991,6 @@ winevt
winexe winexe
winforms winforms
winfx winfx
wingdi
winget winget
wingetcreate wingetcreate
Winhook Winhook
@@ -2105,7 +1998,6 @@ winkey
WINL WINL
winmd winmd
winmm winmm
winmsg
WINNT WINNT
winres winres
winrt winrt
@@ -2116,7 +2008,6 @@ winternl
WINTHRESHOLD WINTHRESHOLD
winui winui
winuiex winuiex
winuser
winxamlmanager winxamlmanager
wistd wistd
withinrafael withinrafael
@@ -2170,11 +2061,9 @@ wtoi
WTS WTS
wtsapi wtsapi
WTSAT WTSAT
wtypes
Wubi Wubi
wuceffectsi wuceffectsi
WVC WVC
WVk
Wwan Wwan
Wwanpp Wwanpp
XAttribute XAttribute
@@ -2184,11 +2073,9 @@ XBUTTON
XBUTTONDBLCLK XBUTTONDBLCLK
XBUTTONDOWN XBUTTONDOWN
XBUTTONUP XBUTTONUP
XControl
xcopy xcopy
XDocument XDocument
XDOWN XDOWN
XUP
XElement XElement
XFile XFile
XIncrement XIncrement
@@ -2199,14 +2086,16 @@ XPixel
XResource XResource
xsi xsi
XStr XStr
XUP
XVIRTUALSCREEN XVIRTUALSCREEN
Yamalia
YAxis YAxis
YIncrement YIncrement
yinle yinle
yinwang yinwang
yinyue yinyue
YOffset YOffset
YResolution
YResolution
YStr YStr
YUY YUY
yuyoyuppe yuyoyuppe
@@ -2214,7 +2103,6 @@ YUYV
YVIRTUALSCREEN YVIRTUALSCREEN
YVU YVU
YVYU YVYU
Zabaykalsky
ZEROINIT ZEROINIT
ZIndex ZIndex
zipfile zipfile
@@ -2222,6 +2110,5 @@ zipfolder
zonable zonable
zoneset zoneset
Zoneszonabletester Zoneszonabletester
Zonev
Zykova Zykova
zzz zzz

View File

@@ -18,7 +18,7 @@ namespace ColorPicker.Mouse
[PartCreationPolicy(CreationPolicy.Shared)] [PartCreationPolicy(CreationPolicy.Shared)]
public class MouseInfoProvider : IMouseInfoProvider public class MouseInfoProvider : IMouseInfoProvider
{ {
private const int MousePullInfoIntervalInMs = 10; private readonly double _mousePullInfoIntervalInMs;
private readonly DispatcherTimer _timer = new DispatcherTimer(); private readonly DispatcherTimer _timer = new DispatcherTimer();
private readonly MouseHook _mouseHook; private readonly MouseHook _mouseHook;
private readonly IUserSettings _userSettings; private readonly IUserSettings _userSettings;
@@ -29,7 +29,8 @@ namespace ColorPicker.Mouse
[ImportingConstructor] [ImportingConstructor]
public MouseInfoProvider(AppStateHandler appStateMonitor, IUserSettings userSettings) public MouseInfoProvider(AppStateHandler appStateMonitor, IUserSettings userSettings)
{ {
_timer.Interval = TimeSpan.FromMilliseconds(MousePullInfoIntervalInMs); _mousePullInfoIntervalInMs = 1000.0 / GetMainDisplayRefreshRate();
_timer.Interval = TimeSpan.FromMilliseconds(_mousePullInfoIntervalInMs);
_timer.Tick += Timer_Tick; _timer.Tick += Timer_Tick;
if (appStateMonitor != null) if (appStateMonitor != null)
@@ -111,6 +112,22 @@ namespace ColorPicker.Mouse
return (System.Windows.Point)lpPoint; return (System.Windows.Point)lpPoint;
} }
private static double GetMainDisplayRefreshRate()
{
double refreshRate = 60.0;
foreach (var monitor in MonitorResolutionHelper.AllMonitors)
{
if (monitor.IsPrimary && EnumDisplaySettingsW(monitor.Name, ENUM_CURRENT_SETTINGS, out DEVMODEW lpDevMode))
{
refreshRate = (double)lpDevMode.dmDisplayFrequency;
break;
}
}
return refreshRate;
}
private void AppStateMonitor_AppClosed(object sender, EventArgs e) private void AppStateMonitor_AppClosed(object sender, EventArgs e)
{ {
DisposeHook(); DisposeHook();

View File

@@ -22,6 +22,9 @@ namespace ColorPicker
public const int KfAltdown = 0x2000; public const int KfAltdown = 0x2000;
public const int LlkhfAltdown = KfAltdown >> 8; public const int LlkhfAltdown = KfAltdown >> 8;
public const int MonitorinfofPrimary = 0x00000001; public const int MonitorinfofPrimary = 0x00000001;
public const int CCHDEVICENAME = 32;
public const int CCHFORMNAME = 32;
public const uint ENUM_CURRENT_SETTINGS = 4294967295;
public const int VK_SHIFT = 0x10; public const int VK_SHIFT = 0x10;
public const int VK_CONTROL = 0x11; public const int VK_CONTROL = 0x11;
public const int VK_MENU = 0x12; public const int VK_MENU = 0x12;
@@ -57,6 +60,13 @@ namespace ColorPicker
internal static extern bool EnumDisplayMonitors( internal static extern bool EnumDisplayMonitors(
HandleRef hdc, IntPtr rcClip, MonitorEnumProc lpfnEnum, IntPtr dwData); HandleRef hdc, IntPtr rcClip, MonitorEnumProc lpfnEnum, IntPtr dwData);
[DllImport("user32.dll", SetLastError = false, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
internal static extern bool EnumDisplaySettingsW(
string lpszDeviceName,
uint iModeNum,
out DEVMODEW lpDevMode);
[DllImport("user32.dll")] [DllImport("user32.dll")]
internal static extern bool GetCursorPos(out PointInter lpPoint); internal static extern bool GetCursorPos(out PointInter lpPoint);
@@ -131,6 +141,50 @@ namespace ColorPicker
public char[] szDevice = new char[32]; public char[] szDevice = new char[32];
} }
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct DEVMODEW
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHDEVICENAME)]
public string dmDeviceName;
public ushort dmSpecVersion;
public ushort dmDriverVersion;
public ushort dmSize;
public ushort dmDriverExtra;
public uint dmFields;
public int dmPositionX;
public int dmPositionY;
public uint dmDisplayOrientation;
public uint dmDisplayFixedOutput;
public short dmColor;
public short dmDuplex;
public short dmYResolution;
public short dmTTOption;
public short dmCollate;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = CCHFORMNAME)]
public string dmFormName;
public short dmLogPixels;
public uint dmBitsPerPel;
public uint dmPelsWidth;
public uint dmPelsHeight;
public uint dmDisplayFlags;
public uint dmDisplayFrequency;
public uint dmICMMethod;
public uint dmICMIntent;
public uint dmMediaType;
public uint dmDitherType;
public uint dmReserved1;
public uint dmReserved2;
public uint dmPanningWidth;
public uint dmPanningHeight;
}
[StructLayout(LayoutKind.Sequential)] [StructLayout(LayoutKind.Sequential)]
internal struct LowLevelKeyboardInputEvent internal struct LowLevelKeyboardInputEvent
{ {

View File

@@ -1,11 +1,13 @@
float2 mousePosition : register(C1); float2 mousePosition : register(C1);
float radius : register(C2); float radius : register(C2);
float squareSize : register(c3); float squareSize : register(c3);
float textureSize : register(c4); float textureSize : register(c4);
sampler2D inputSampler : register(S0); sampler2D inputSampler : register(S0);
float4 main(float2 uv : TEXCOORD) : COLOR float4 main(float2 uv
: TEXCOORD) :
COLOR
{ {
// do not draw grid where the mouse is // do not draw grid where the mouse is
if (uv.x == mousePosition.y && uv.y == mousePosition.y) if (uv.x == mousePosition.y && uv.y == mousePosition.y)
@@ -42,8 +44,8 @@ float4 main(float2 uv : TEXCOORD) : COLOR
int2 topLeftRectangle = int2(mousePositionX - (mousePositionX % squareSize) - 1, mousePositionY - (mousePositionY % squareSize) - 1); int2 topLeftRectangle = int2(mousePositionX - (mousePositionX % squareSize) - 1, mousePositionY - (mousePositionY % squareSize) - 1);
// do not draw grid inside square even when grid (avoid drawing grid in that area later // do not draw grid inside square even when grid (avoid drawing grid in that area later
if (((pixelPositionX >= topLeftRectangle.x + 1 && pixelPositionX <= topLeftRectangle.x + squareSize) && (pixelPositionY == topLeftRectangle.y + 1 || pixelPositionY == topLeftRectangle.y + squareSize)) || if (((pixelPositionX >= topLeftRectangle.x + 1 && pixelPositionX <= topLeftRectangle.x + squareSize + 1) && (pixelPositionY == topLeftRectangle.y + 1 || pixelPositionY == topLeftRectangle.y + squareSize + 1)) ||
((pixelPositionY >= topLeftRectangle.y + 1 && pixelPositionY <= topLeftRectangle.y + squareSize) && (pixelPositionX == topLeftRectangle.x + 1 || pixelPositionX == topLeftRectangle.x + squareSize))) ((pixelPositionY >= topLeftRectangle.y + 1 && pixelPositionY <= topLeftRectangle.y + squareSize + 1) && (pixelPositionX == topLeftRectangle.x + 1 || pixelPositionX == topLeftRectangle.x + squareSize + 1)))
{ {
return originalColor; return originalColor;
} }