@@ -1456,6 +1456,26 @@ void TogglePillMenu() {
14561456 SetFocus (g_slider);
14571457}
14581458
1459+ void ResizeWindowFromPointerDelta (int dx, int dy) {
1460+ MONITORINFO monitor{sizeof (monitor)};
1461+ GetMonitorInfoW (MonitorFromWindow (g_window, MONITOR_DEFAULTTONEAREST ), &monitor);
1462+ const int maxWidth =
1463+ std::max (ScaleForDpi (g_window, 180 ), static_cast <int >(monitor.rcWork .right - monitor.rcWork .left ));
1464+ const int maxHeight =
1465+ std::max (ScaleForDpi (g_window, 90 ), static_cast <int >(monitor.rcWork .bottom - monitor.rcWork .top ));
1466+ SetWindowPos (g_window, nullptr , 0 , 0 ,
1467+ std::clamp (static_cast <int >(g_pointerWindow.right - g_pointerWindow.left ) + dx,
1468+ ScaleForDpi (g_window, 180 ), maxWidth),
1469+ std::clamp (static_cast <int >(g_pointerWindow.bottom - g_pointerWindow.top ) + dy,
1470+ ScaleForDpi (g_window, 90 ), maxHeight),
1471+ SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
1472+ }
1473+
1474+ void MoveWindowFromPointerDelta (int dx, int dy) {
1475+ SetWindowPos (g_window, nullptr , g_pointerWindow.left + dx, g_pointerWindow.top + dy, 0 , 0 ,
1476+ SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1477+ }
1478+
14591479LRESULT CALLBACK PointerProcedure (HWND window, UINT message, WPARAM wp, LPARAM lp, UINT_PTR id, DWORD_PTR ) {
14601480 if (message == BM_CLICK && id == kControlPill ) {
14611481 PostMessageW (g_window, WM_COMMAND , kControlPill , 0 );
@@ -1524,22 +1544,10 @@ LRESULT CALLBACK PointerProcedure(HWND window, UINT message, WPARAM wp, LPARAM l
15241544 g_pointerDragged = true ;
15251545 if (g_pointerDragged) {
15261546 CloseMenu ();
1527- if (id == kControlGrip ) {
1528- MONITORINFO monitor{sizeof (monitor)};
1529- GetMonitorInfoW (MonitorFromWindow (g_window, MONITOR_DEFAULTTONEAREST ), &monitor);
1530- const int maxWidth = std::max (ScaleForDpi (g_window, 180 ),
1531- static_cast <int >(monitor.rcWork .right - monitor.rcWork .left ));
1532- const int maxHeight = std::max (ScaleForDpi (g_window, 90 ),
1533- static_cast <int >(monitor.rcWork .bottom - monitor.rcWork .top ));
1534- SetWindowPos (g_window, nullptr , 0 , 0 ,
1535- std::clamp (static_cast <int >(g_pointerWindow.right - g_pointerWindow.left ) + dx,
1536- ScaleForDpi (g_window, 180 ), maxWidth),
1537- std::clamp (static_cast <int >(g_pointerWindow.bottom - g_pointerWindow.top ) + dy,
1538- ScaleForDpi (g_window, 90 ), maxHeight),
1539- SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
1540- } else
1541- SetWindowPos (g_window, nullptr , g_pointerWindow.left + dx, g_pointerWindow.top + dy, 0 , 0 ,
1542- SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
1547+ if (id == kControlGrip )
1548+ ResizeWindowFromPointerDelta (dx, dy);
1549+ else
1550+ MoveWindowFromPointerDelta (dx, dy);
15431551 }
15441552 }
15451553 return 0 ;
0 commit comments