| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/widget_win.h" | 5 #include "chrome/views/widget_win.h" |
| 6 | 6 |
| 7 #include "base/gfx/native_theme.h" | 7 #include "base/gfx/native_theme.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); | 526 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); |
| 527 SetMsgHandled(root_view_->ProcessKeyEvent(event)); | 527 SetMsgHandled(root_view_->ProcessKeyEvent(event)); |
| 528 } | 528 } |
| 529 | 529 |
| 530 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { | 530 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { |
| 531 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); | 531 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); |
| 532 SetMsgHandled(root_view_->ProcessKeyEvent(event)); | 532 SetMsgHandled(root_view_->ProcessKeyEvent(event)); |
| 533 } | 533 } |
| 534 | 534 |
| 535 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { | 535 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { |
| 536 ProcessMousePressed(point, flags | MK_LBUTTON, false, false); | 536 ProcessMousePressed(point, flags | MK_LBUTTON, false); |
| 537 } | 537 } |
| 538 | 538 |
| 539 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { | 539 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { |
| 540 ProcessMouseReleased(point, flags | MK_LBUTTON); | 540 ProcessMouseReleased(point, flags | MK_LBUTTON); |
| 541 } | 541 } |
| 542 | 542 |
| 543 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { | 543 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { |
| 544 ProcessMousePressed(point, flags | MK_LBUTTON, true, false); | 544 ProcessMousePressed(point, flags | MK_LBUTTON, true); |
| 545 } | 545 } |
| 546 | 546 |
| 547 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { | 547 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { |
| 548 ProcessMousePressed(point, flags | MK_MBUTTON, false, false); | 548 ProcessMousePressed(point, flags | MK_MBUTTON, false); |
| 549 } | 549 } |
| 550 | 550 |
| 551 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { | 551 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { |
| 552 ProcessMouseReleased(point, flags | MK_MBUTTON); | 552 ProcessMouseReleased(point, flags | MK_MBUTTON); |
| 553 } | 553 } |
| 554 | 554 |
| 555 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { | 555 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { |
| 556 ProcessMousePressed(point, flags | MK_MBUTTON, true, false); | 556 ProcessMousePressed(point, flags | MK_MBUTTON, true); |
| 557 } | 557 } |
| 558 | 558 |
| 559 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, | 559 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, |
| 560 UINT message) { | 560 UINT message) { |
| 561 SetMsgHandled(FALSE); | 561 SetMsgHandled(FALSE); |
| 562 return MA_ACTIVATE; | 562 return MA_ACTIVATE; |
| 563 } | 563 } |
| 564 | 564 |
| 565 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { | 565 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { |
| 566 ProcessMouseMoved(point, flags, false); | 566 ProcessMouseMoved(point, flags, false); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 581 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; | 581 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; |
| 582 } | 582 } |
| 583 | 583 |
| 584 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { | 584 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { |
| 585 tooltip_manager_->OnMouse(msg, w_param, l_param); | 585 tooltip_manager_->OnMouse(msg, w_param, l_param); |
| 586 SetMsgHandled(FALSE); | 586 SetMsgHandled(FALSE); |
| 587 return 0; | 587 return 0; |
| 588 } | 588 } |
| 589 | 589 |
| 590 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { | 590 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { |
| 591 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true)); | 591 SetMsgHandled(FALSE); |
| 592 } | 592 } |
| 593 | 593 |
| 594 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { | 594 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { |
| 595 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true)); | 595 SetMsgHandled(FALSE); |
| 596 } | 596 } |
| 597 | 597 |
| 598 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { | 598 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { |
| 599 SetMsgHandled(FALSE); | 599 SetMsgHandled(FALSE); |
| 600 } | 600 } |
| 601 | 601 |
| 602 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { | 602 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { |
| 603 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true)); | 603 SetMsgHandled(FALSE); |
| 604 } | 604 } |
| 605 | 605 |
| 606 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { | 606 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { |
| 607 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true)); | 607 SetMsgHandled(FALSE); |
| 608 } | 608 } |
| 609 | 609 |
| 610 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { | 610 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { |
| 611 SetMsgHandled(FALSE); | 611 SetMsgHandled(FALSE); |
| 612 } | 612 } |
| 613 | 613 |
| 614 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { | 614 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { |
| 615 ProcessMouseExited(); | 615 ProcessMouseExited(); |
| 616 return 0; | 616 return 0; |
| 617 } | 617 } |
| 618 | 618 |
| 619 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { | 619 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { |
| 620 // NC points are in screen coordinates. | 620 // NC points are in screen coordinates. |
| 621 CPoint temp = point; | 621 CPoint temp = point; |
| 622 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); | 622 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); |
| 623 ProcessMouseMoved(temp, 0, true); | 623 ProcessMouseMoved(temp, 0, true); |
| 624 | 624 |
| 625 // We need to process this message to stop Windows from drawing the window | 625 // We need to process this message to stop Windows from drawing the window |
| 626 // controls as the mouse moves over the title bar area when the window is | 626 // controls as the mouse moves over the title bar area when the window is |
| 627 // maximized. | 627 // maximized. |
| 628 return 0; | 628 return 0; |
| 629 } | 629 } |
| 630 | 630 |
| 631 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { | 631 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { |
| 632 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); | 632 SetMsgHandled(FALSE); |
| 633 } | 633 } |
| 634 | 634 |
| 635 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { | 635 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { |
| 636 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true)); | 636 SetMsgHandled(FALSE); |
| 637 } | 637 } |
| 638 | 638 |
| 639 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { | 639 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { |
| 640 SetMsgHandled(FALSE); | 640 SetMsgHandled(FALSE); |
| 641 } | 641 } |
| 642 | 642 |
| 643 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { | 643 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { |
| 644 // We can be sent this message before the tooltip manager is created, if a | 644 // We can be sent this message before the tooltip manager is created, if a |
| 645 // subclass overrides OnCreate and creates some kind of Windows control there | 645 // subclass overrides OnCreate and creates some kind of Windows control there |
| 646 // that sends WM_NOTIFY messages. | 646 // that sends WM_NOTIFY messages. |
| 647 if (tooltip_manager_.get()) { | 647 if (tooltip_manager_.get()) { |
| 648 bool handled; | 648 bool handled; |
| 649 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); | 649 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); |
| 650 SetMsgHandled(handled); | 650 SetMsgHandled(handled); |
| 651 return result; | 651 return result; |
| 652 } | 652 } |
| 653 SetMsgHandled(FALSE); | 653 SetMsgHandled(FALSE); |
| 654 return 0; | 654 return 0; |
| 655 } | 655 } |
| 656 | 656 |
| 657 void WidgetWin::OnPaint(HDC dc) { | 657 void WidgetWin::OnPaint(HDC dc) { |
| 658 root_view_->OnPaint(GetHWND()); | 658 root_view_->OnPaint(GetHWND()); |
| 659 } | 659 } |
| 660 | 660 |
| 661 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { | 661 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { |
| 662 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); | 662 ProcessMousePressed(point, flags | MK_RBUTTON, false); |
| 663 } | 663 } |
| 664 | 664 |
| 665 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { | 665 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { |
| 666 ProcessMouseReleased(point, flags | MK_RBUTTON); | 666 ProcessMouseReleased(point, flags | MK_RBUTTON); |
| 667 } | 667 } |
| 668 | 668 |
| 669 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { | 669 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { |
| 670 ProcessMousePressed(point, flags | MK_RBUTTON, true, false); | 670 ProcessMousePressed(point, flags | MK_RBUTTON, true); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { | 673 void WidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { |
| 674 if (toplevel_ && (flags == SPI_SETWORKAREA)) { | 674 if (toplevel_ && (flags == SPI_SETWORKAREA)) { |
| 675 AdjustWindowToFitScreenSize(); | 675 AdjustWindowToFitScreenSize(); |
| 676 SetMsgHandled(TRUE); | 676 SetMsgHandled(TRUE); |
| 677 } | 677 } |
| 678 } | 678 } |
| 679 | 679 |
| 680 void WidgetWin::OnSize(UINT param, const CSize& size) { | 680 void WidgetWin::OnSize(UINT param, const CSize& size) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 711 tme.dwFlags = mouse_tracking_flags; | 711 tme.dwFlags = mouse_tracking_flags; |
| 712 tme.hwndTrack = GetHWND(); | 712 tme.hwndTrack = GetHWND(); |
| 713 tme.dwHoverTime = 0; | 713 tme.dwHoverTime = 0; |
| 714 TrackMouseEvent(&tme); | 714 TrackMouseEvent(&tme); |
| 715 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 715 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
| 716 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 716 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
| 717 TrackMouseEvents(mouse_tracking_flags); | 717 TrackMouseEvents(mouse_tracking_flags); |
| 718 } | 718 } |
| 719 } | 719 } |
| 720 | 720 |
| 721 bool WidgetWin::ProcessMousePressed(const CPoint& point, | 721 bool WidgetWin::ProcessMousePressed(const CPoint& point, UINT flags, |
| 722 UINT flags, | 722 bool dbl_click) { |
| 723 bool dbl_click, | |
| 724 bool non_client) { | |
| 725 last_mouse_event_was_move_ = false; | 723 last_mouse_event_was_move_ = false; |
| 726 // Windows gives screen coordinates for nonclient events, while the RootView | 724 // Windows gives screen coordinates for nonclient events, while the RootView |
| 727 // expects window coordinates; convert if necessary. | 725 // expects window coordinates; convert if necessary. |
| 728 gfx::Point converted_point(point); | 726 gfx::Point converted_point(point); |
| 729 if (non_client) | |
| 730 View::ConvertPointToView(NULL, root_view_.get(), &converted_point); | |
| 731 MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, | 727 MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, |
| 732 converted_point.x(), | 728 converted_point.x(), |
| 733 converted_point.y(), | 729 converted_point.y(), |
| 734 (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | | 730 (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | |
| 735 (non_client ? MouseEvent::EF_IS_NON_CLIENT : 0) | | |
| 736 Event::ConvertWindowsFlags(flags)); | 731 Event::ConvertWindowsFlags(flags)); |
| 737 if (root_view_->OnMousePressed(mouse_pressed)) { | 732 if (root_view_->OnMousePressed(mouse_pressed)) { |
| 738 is_mouse_down_ = true; | 733 is_mouse_down_ = true; |
| 739 if (!has_capture_) { | 734 if (!has_capture_) { |
| 740 SetCapture(); | 735 SetCapture(); |
| 741 has_capture_ = true; | 736 has_capture_ = true; |
| 742 current_action_ = FA_FORWARDING; | 737 current_action_ = FA_FORWARDING; |
| 743 } | 738 } |
| 744 return true; | 739 return true; |
| 745 } | 740 } |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 if (message == WM_NCDESTROY) { | 949 if (message == WM_NCDESTROY) { |
| 955 TRACK_HWND_DESTRUCTION(window); | 950 TRACK_HWND_DESTRUCTION(window); |
| 956 widget->hwnd_ = NULL; | 951 widget->hwnd_ = NULL; |
| 957 widget->OnFinalMessage(window); | 952 widget->OnFinalMessage(window); |
| 958 } | 953 } |
| 959 return result; | 954 return result; |
| 960 } | 955 } |
| 961 | 956 |
| 962 } // namespace views | 957 } // namespace views |
| 963 | 958 |
| OLD | NEW |