Skip to content

Commit 3ee39a5

Browse files
committed
[Windows] Prevent right button drag
1 parent 432f19f commit 3ee39a5

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎webview/platforms/win32.py‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
_SWP_NOSIZE = 0x0001
1515
_SWP_NOZORDER = 0x0004
1616
_SWP_NOACTIVATE = 0x0010
17+
_VK_LBUTTON = 0x01
1718

1819

1920
class _MSLLHOOKSTRUCT(ctypes.Structure):
@@ -74,6 +75,8 @@ class _MSLLHOOKSTRUCT(ctypes.Structure):
7475
ctypes.c_int,
7576
wintypes.UINT,
7677
]
78+
_user32.GetKeyState.restype = wintypes.SHORT
79+
_user32.GetKeyState.argtypes = [ctypes.c_int]
7780

7881
_LowLevelMouseProcType = ctypes.WINFUNCTYPE(
7982
ctypes.c_ssize_t, ctypes.c_int, wintypes.WPARAM, ctypes.c_void_p
@@ -211,6 +214,10 @@ def start_drag(hwnd: int) -> None:
211214
if _user32.IsZoomed(hwnd):
212215
return
213216

217+
# Only start drag if left mouse button is pressed
218+
if not (_user32.GetKeyState(_VK_LBUTTON) & 0x8000):
219+
return
220+
214221
drag = _drag_states.get(hwnd)
215222
if drag is not None:
216223
rect = wintypes.RECT()

0 commit comments

Comments
 (0)