OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/views/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
6 | 6 |
7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <oleacc.h> | 8 #include <oleacc.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 | 10 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
688 | 688 |
689 bool HWNDMessageHandler::RunMoveLoop(const gfx::Vector2d& drag_offset, | 689 bool HWNDMessageHandler::RunMoveLoop(const gfx::Vector2d& drag_offset, |
690 bool hide_on_escape) { | 690 bool hide_on_escape) { |
691 ReleaseCapture(); | 691 ReleaseCapture(); |
692 MoveLoopMouseWatcher watcher(this, hide_on_escape); | 692 MoveLoopMouseWatcher watcher(this, hide_on_escape); |
693 // In Aura, we handle touch events asynchronously. So we need to allow nested | 693 // In Aura, we handle touch events asynchronously. So we need to allow nested |
694 // tasks while in windows move loop. | 694 // tasks while in windows move loop. |
695 base::MessageLoop::ScopedNestableTaskAllower allow_nested( | 695 base::MessageLoop::ScopedNestableTaskAllower allow_nested( |
696 base::MessageLoop::current()); | 696 base::MessageLoop::current()); |
697 | 697 |
698 SendMessage(hwnd(), WM_SYSCOMMAND, SC_MOVE | 0x0002, GetMessagePos()); | 698 // SC_MOVE ignores the lParam cursor argument, so first ensure the point |
| 699 // |drag_offset| into the window lies under the cursor. Note that the offset |
| 700 // is in window coordinates, the cursor in screen coordinates, and the call to |
| 701 // SetWindowPos must be client area coordinates. |
| 702 DWORD message_pos = GetMessagePos(); |
| 703 POINTS cursor_pos = MAKEPOINTS(message_pos); |
| 704 POINT anchor_pos = { drag_offset.x(), drag_offset.y() }; |
| 705 //MapWindowPoints(hwnd(), HWND_DESKTOP, &anchor_pos, 1); |
| 706 ClientToScreen(hwnd(), &anchor_pos); |
| 707 RECT client_rect; |
| 708 GetClientRect(hwnd(), &client_rect); |
| 709 SetWindowPos(hwnd(), nullptr, |
| 710 client_rect.left + cursor_pos.x - anchor_pos.x, |
| 711 client_rect.top + cursor_pos.y - anchor_pos.y, |
| 712 0, 0, SWP_NOSIZE); |
| 713 |
| 714 SendMessage(hwnd(), WM_SYSCOMMAND, SC_MOVE | 0x0002, 0); |
699 // Windows doesn't appear to offer a way to determine whether the user | 715 // Windows doesn't appear to offer a way to determine whether the user |
700 // canceled the move or not. We assume if the user released the mouse it was | 716 // canceled the move or not. We assume if the user released the mouse it was |
701 // successful. | 717 // successful. |
702 return watcher.got_mouse_up(); | 718 return watcher.got_mouse_up(); |
703 } | 719 } |
704 | 720 |
705 void HWNDMessageHandler::EndMoveLoop() { | 721 void HWNDMessageHandler::EndMoveLoop() { |
706 SendMessage(hwnd(), WM_CANCELMODE, 0, 0); | 722 SendMessage(hwnd(), WM_CANCELMODE, 0, 0); |
707 } | 723 } |
708 | 724 |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2739 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); | 2755 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_HIDEWINDOW); |
2740 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); | 2756 SetWindowPos(hwnd(), NULL, 0, 0, 0, 0, flags | SWP_SHOWWINDOW); |
2741 } | 2757 } |
2742 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want | 2758 // WM_DWMCOMPOSITIONCHANGED is only sent to top level windows, however we want |
2743 // to notify our children too, since we can have MDI child windows who need to | 2759 // to notify our children too, since we can have MDI child windows who need to |
2744 // update their appearance. | 2760 // update their appearance. |
2745 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); | 2761 EnumChildWindows(hwnd(), &SendDwmCompositionChanged, NULL); |
2746 } | 2762 } |
2747 | 2763 |
2748 } // namespace views | 2764 } // namespace views |
OLD | NEW |