Browse Source

Make sure HTCAPTION is only returned if mouse is currently pressed.

pull/187/head
weisj 5 years ago
parent
commit
1e3693b3a2
  1. 18
      windows/src/main/cpp/Decorations.cpp
  2. 1
      windows/src/main/cpp/Decorations.h
  3. 1
      windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

18
windows/src/main/cpp/Decorations.cpp

@ -40,6 +40,15 @@ bool Maximized(HWND hwnd) {
return placement.showCmd == SW_MAXIMIZE;
}
bool IsLeftMousePressed(WindowWrapper *wrapper) {
if (wrapper->left_pressed) return true;
if (GetSystemMetrics(SM_SWAPBUTTON)) {
return GetAsyncKeyState(VK_RBUTTON) < 0;
} else {
return GetAsyncKeyState(VK_LBUTTON) < 0;
}
}
LRESULT HandleHitTest(WindowWrapper *wrapper, int x, int y) {
if (wrapper->popup_menu) return HTCLIENT;
@ -100,7 +109,8 @@ LRESULT HandleHitTest(WindowWrapper *wrapper, int x, int y) {
LRESULT hit = hitTests[uRow][uCol];
if (hit == HTNOWHERE || !wrapper->resizable) {
//Handle window drag.
if (ptMouse.y < rcWindow.top + wrapper->title_height
if (IsLeftMousePressed(wrapper)
&& ptMouse.y < rcWindow.top + wrapper->title_height
&& ptMouse.x >= rcWindow.left + wrapper->left
&& ptMouse.x <= rcWindow.right - wrapper->right) {
return HTCAPTION;
@ -299,6 +309,12 @@ LRESULT CALLBACK WindowWrapper::WindowProc(_In_ HWND hwnd, _In_ UINT uMsg, _In_
auto wrapper = wrapper_map[handle];
switch (uMsg) {
case WM_LBUTTONDOWN:
wrapper->left_pressed = true;
break;
case WM_LBUTTONUP:
wrapper->left_pressed = false;
break;
case WM_NCACTIVATE:
// Prevents window flickering when being blocked by dialogs or when activating.
return TRUE;

1
windows/src/main/cpp/Decorations.h

@ -39,6 +39,7 @@ class WindowWrapper {
bool move_mode = false;
bool maximized = false;
bool skipEraseBg = true;
bool left_pressed = false;
// The original window procedure.
WNDPROC prev_proc;

1
windows/src/main/java/com/github/weisj/darklaf/platform/windows/ui/WindowsTitlePane.java

@ -774,7 +774,6 @@ public class WindowsTitlePane extends CustomTitlePane {
right = tmp;
}
right += 2; // Make sure mouse exit event is produced for left most button.
updateDragArea(getGraphicsConfiguration());
}

Loading…
Cancel
Save