Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Unified Diff: ui/views/win/hwnd_message_handler.cc

Issue 1272223005: WIP: Tab-Drag-Slippage Various experiments Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/win/hwnd_message_handler.cc
diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
index bd2072b47ee7d0b71d538d9f065151da85262315..23f09dcf08871f9814b8d2184d100e5de0568f3e 100644
--- a/ui/views/win/hwnd_message_handler.cc
+++ b/ui/views/win/hwnd_message_handler.cc
@@ -695,7 +695,23 @@ bool HWNDMessageHandler::RunMoveLoop(const gfx::Vector2d& drag_offset,
base::MessageLoop::ScopedNestableTaskAllower allow_nested(
base::MessageLoop::current());
- SendMessage(hwnd(), WM_SYSCOMMAND, SC_MOVE | 0x0002, GetMessagePos());
+ // SC_MOVE ignores the lParam cursor argument, so first ensure the point
+ // |drag_offset| into the window lies under the cursor. Note that the offset
+ // is in window coordinates, the cursor in screen coordinates, and the call to
+ // SetWindowPos must be client area coordinates.
+ DWORD message_pos = GetMessagePos();
+ POINTS cursor_pos = MAKEPOINTS(message_pos);
+ POINT anchor_pos = { drag_offset.x(), drag_offset.y() };
+ //MapWindowPoints(hwnd(), HWND_DESKTOP, &anchor_pos, 1);
+ ClientToScreen(hwnd(), &anchor_pos);
+ RECT client_rect;
+ GetClientRect(hwnd(), &client_rect);
+ SetWindowPos(hwnd(), nullptr,
+ client_rect.left + cursor_pos.x - anchor_pos.x,
+ client_rect.top + cursor_pos.y - anchor_pos.y,
+ 0, 0, SWP_NOSIZE);
+
+ SendMessage(hwnd(), WM_SYSCOMMAND, SC_MOVE | 0x0002, 0);
// Windows doesn't appear to offer a way to determine whether the user
// canceled the move or not. We assume if the user released the mouse it was
// successful.
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698