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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); | 510 KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); |
511 root_view_->ProcessKeyEvent(event); | 511 root_view_->ProcessKeyEvent(event); |
512 } | 512 } |
513 | 513 |
514 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { | 514 void WidgetWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { |
515 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); | 515 KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); |
516 root_view_->ProcessKeyEvent(event); | 516 root_view_->ProcessKeyEvent(event); |
517 } | 517 } |
518 | 518 |
519 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { | 519 void WidgetWin::OnLButtonDown(UINT flags, const CPoint& point) { |
520 ProcessMousePressed(point, flags | MK_LBUTTON, false); | 520 ProcessMousePressed(point, flags | MK_LBUTTON, false, false); |
521 } | 521 } |
522 | 522 |
523 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { | 523 void WidgetWin::OnLButtonUp(UINT flags, const CPoint& point) { |
524 ProcessMouseReleased(point, flags | MK_LBUTTON); | 524 ProcessMouseReleased(point, flags | MK_LBUTTON); |
525 } | 525 } |
526 | 526 |
527 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { | 527 void WidgetWin::OnLButtonDblClk(UINT flags, const CPoint& point) { |
528 ProcessMousePressed(point, flags | MK_LBUTTON, true); | 528 ProcessMousePressed(point, flags | MK_LBUTTON, true, false); |
529 } | 529 } |
530 | 530 |
531 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { | 531 void WidgetWin::OnMButtonDown(UINT flags, const CPoint& point) { |
532 ProcessMousePressed(point, flags | MK_MBUTTON, false); | 532 ProcessMousePressed(point, flags | MK_MBUTTON, false, false); |
533 } | 533 } |
534 | 534 |
535 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { | 535 void WidgetWin::OnMButtonUp(UINT flags, const CPoint& point) { |
536 ProcessMouseReleased(point, flags | MK_MBUTTON); | 536 ProcessMouseReleased(point, flags | MK_MBUTTON); |
537 } | 537 } |
538 | 538 |
539 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { | 539 void WidgetWin::OnMButtonDblClk(UINT flags, const CPoint& point) { |
540 ProcessMousePressed(point, flags | MK_MBUTTON, true); | 540 ProcessMousePressed(point, flags | MK_MBUTTON, true, false); |
541 } | 541 } |
542 | 542 |
543 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, | 543 LRESULT WidgetWin::OnMouseActivate(HWND window, UINT hittest_code, |
544 UINT message) { | 544 UINT message) { |
545 SetMsgHandled(FALSE); | 545 SetMsgHandled(FALSE); |
546 return MA_ACTIVATE; | 546 return MA_ACTIVATE; |
547 } | 547 } |
548 | 548 |
549 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { | 549 void WidgetWin::OnMouseMove(UINT flags, const CPoint& point) { |
550 ProcessMouseMoved(point, flags, false); | 550 ProcessMouseMoved(point, flags, false); |
(...skipping 14 matching lines...) Expand all Loading... |
565 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; | 565 return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; |
566 } | 566 } |
567 | 567 |
568 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { | 568 LRESULT WidgetWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { |
569 tooltip_manager_->OnMouse(msg, w_param, l_param); | 569 tooltip_manager_->OnMouse(msg, w_param, l_param); |
570 SetMsgHandled(FALSE); | 570 SetMsgHandled(FALSE); |
571 return 0; | 571 return 0; |
572 } | 572 } |
573 | 573 |
574 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { | 574 void WidgetWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { |
575 SetMsgHandled(FALSE); | 575 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, true, true)); |
576 } | 576 } |
577 | 577 |
578 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { | 578 void WidgetWin::OnNCLButtonDown(UINT flags, const CPoint& point) { |
579 SetMsgHandled(FALSE); | 579 SetMsgHandled(ProcessMousePressed(point, flags | MK_LBUTTON, false, true)); |
580 } | 580 } |
581 | 581 |
582 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { | 582 void WidgetWin::OnNCLButtonUp(UINT flags, const CPoint& point) { |
583 SetMsgHandled(FALSE); | 583 SetMsgHandled(FALSE); |
584 } | 584 } |
585 | 585 |
586 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { | 586 void WidgetWin::OnNCMButtonDblClk(UINT flags, const CPoint& point) { |
587 SetMsgHandled(FALSE); | 587 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, true, true)); |
588 } | 588 } |
589 | 589 |
590 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { | 590 void WidgetWin::OnNCMButtonDown(UINT flags, const CPoint& point) { |
591 SetMsgHandled(FALSE); | 591 SetMsgHandled(ProcessMousePressed(point, flags | MK_MBUTTON, false, true)); |
592 } | 592 } |
593 | 593 |
594 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { | 594 void WidgetWin::OnNCMButtonUp(UINT flags, const CPoint& point) { |
595 SetMsgHandled(FALSE); | 595 SetMsgHandled(FALSE); |
596 } | 596 } |
597 | 597 |
598 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { | 598 LRESULT WidgetWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { |
599 ProcessMouseExited(); | 599 ProcessMouseExited(); |
600 return 0; | 600 return 0; |
601 } | 601 } |
602 | 602 |
603 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { | 603 LRESULT WidgetWin::OnNCMouseMove(UINT flags, const CPoint& point) { |
604 // NC points are in screen coordinates. | 604 // NC points are in screen coordinates. |
605 CPoint temp = point; | 605 CPoint temp = point; |
606 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); | 606 MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); |
607 ProcessMouseMoved(temp, 0, true); | 607 ProcessMouseMoved(temp, 0, true); |
608 | 608 |
609 // We need to process this message to stop Windows from drawing the window | 609 // We need to process this message to stop Windows from drawing the window |
610 // controls as the mouse moves over the title bar area when the window is | 610 // controls as the mouse moves over the title bar area when the window is |
611 // maximized. | 611 // maximized. |
612 return 0; | 612 return 0; |
613 } | 613 } |
614 | 614 |
615 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { | 615 void WidgetWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { |
616 SetMsgHandled(FALSE); | 616 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, true, true)); |
617 } | 617 } |
618 | 618 |
619 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { | 619 void WidgetWin::OnNCRButtonDown(UINT flags, const CPoint& point) { |
620 SetMsgHandled(FALSE); | 620 SetMsgHandled(ProcessMousePressed(point, flags | MK_RBUTTON, false, true)); |
621 } | 621 } |
622 | 622 |
623 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { | 623 void WidgetWin::OnNCRButtonUp(UINT flags, const CPoint& point) { |
624 SetMsgHandled(FALSE); | 624 SetMsgHandled(FALSE); |
625 } | 625 } |
626 | 626 |
627 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { | 627 LRESULT WidgetWin::OnNotify(int w_param, NMHDR* l_param) { |
628 // We can be sent this message before the tooltip manager is created, if a | 628 // We can be sent this message before the tooltip manager is created, if a |
629 // subclass overrides OnCreate and creates some kind of Windows control there | 629 // subclass overrides OnCreate and creates some kind of Windows control there |
630 // that sends WM_NOTIFY messages. | 630 // that sends WM_NOTIFY messages. |
631 if (tooltip_manager_.get()) { | 631 if (tooltip_manager_.get()) { |
632 bool handled; | 632 bool handled; |
633 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); | 633 LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); |
634 SetMsgHandled(handled); | 634 SetMsgHandled(handled); |
635 return result; | 635 return result; |
636 } | 636 } |
637 SetMsgHandled(FALSE); | 637 SetMsgHandled(FALSE); |
638 return 0; | 638 return 0; |
639 } | 639 } |
640 | 640 |
641 void WidgetWin::OnPaint(HDC dc) { | 641 void WidgetWin::OnPaint(HDC dc) { |
642 root_view_->OnPaint(GetHWND()); | 642 root_view_->OnPaint(GetHWND()); |
643 } | 643 } |
644 | 644 |
645 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { | 645 void WidgetWin::OnRButtonDown(UINT flags, const CPoint& point) { |
646 ProcessMousePressed(point, flags | MK_RBUTTON, false); | 646 ProcessMousePressed(point, flags | MK_RBUTTON, false, false); |
647 } | 647 } |
648 | 648 |
649 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { | 649 void WidgetWin::OnRButtonUp(UINT flags, const CPoint& point) { |
650 ProcessMouseReleased(point, flags | MK_RBUTTON); | 650 ProcessMouseReleased(point, flags | MK_RBUTTON); |
651 } | 651 } |
652 | 652 |
653 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { | 653 void WidgetWin::OnRButtonDblClk(UINT flags, const CPoint& point) { |
654 ProcessMousePressed(point, flags | MK_RBUTTON, true); | 654 ProcessMousePressed(point, flags | MK_RBUTTON, true, false); |
655 } | 655 } |
656 | 656 |
657 LRESULT WidgetWin::OnSettingChange(UINT msg, WPARAM w_param, LPARAM l_param) { | 657 LRESULT WidgetWin::OnSettingChange(UINT msg, WPARAM w_param, LPARAM l_param) { |
658 if (toplevel_) { | 658 if (toplevel_) { |
659 SetMsgHandled(FALSE); | 659 SetMsgHandled(FALSE); |
660 if (w_param != SPI_SETWORKAREA) | 660 if (w_param != SPI_SETWORKAREA) |
661 return 0; // Return value is effectively ignored in atlwin.h. | 661 return 0; // Return value is effectively ignored in atlwin.h. |
662 | 662 |
663 AdjustWindowToFitScreenSize(); | 663 AdjustWindowToFitScreenSize(); |
664 SetMsgHandled(TRUE); | 664 SetMsgHandled(TRUE); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 tme.dwFlags = mouse_tracking_flags; | 701 tme.dwFlags = mouse_tracking_flags; |
702 tme.hwndTrack = GetHWND(); | 702 tme.hwndTrack = GetHWND(); |
703 tme.dwHoverTime = 0; | 703 tme.dwHoverTime = 0; |
704 TrackMouseEvent(&tme); | 704 TrackMouseEvent(&tme); |
705 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { | 705 } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { |
706 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); | 706 TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); |
707 TrackMouseEvents(mouse_tracking_flags); | 707 TrackMouseEvents(mouse_tracking_flags); |
708 } | 708 } |
709 } | 709 } |
710 | 710 |
711 bool WidgetWin::ProcessMousePressed(const CPoint& point, UINT flags, | 711 bool WidgetWin::ProcessMousePressed(const CPoint& point, |
712 bool dbl_click) { | 712 UINT flags, |
| 713 bool dbl_click, |
| 714 bool non_client) { |
713 last_mouse_event_was_move_ = false; | 715 last_mouse_event_was_move_ = false; |
714 MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, | 716 MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, |
715 point.x, | 717 point.x, |
716 point.y, | 718 point.y, |
717 (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | | 719 (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | |
| 720 (non_client ? MouseEvent::EF_IS_NON_CLIENT : 0) | |
718 Event::ConvertWindowsFlags(flags)); | 721 Event::ConvertWindowsFlags(flags)); |
719 if (root_view_->OnMousePressed(mouse_pressed)) { | 722 if (root_view_->OnMousePressed(mouse_pressed)) { |
720 is_mouse_down_ = true; | 723 is_mouse_down_ = true; |
721 if (!has_capture_) { | 724 if (!has_capture_) { |
722 SetCapture(); | 725 SetCapture(); |
723 has_capture_ = true; | 726 has_capture_ = true; |
724 current_action_ = FA_FORWARDING; | 727 current_action_ = FA_FORWARDING; |
725 } | 728 } |
726 return true; | 729 return true; |
727 } | 730 } |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
936 if (message == WM_NCDESTROY) { | 939 if (message == WM_NCDESTROY) { |
937 TRACK_HWND_DESTRUCTION(window); | 940 TRACK_HWND_DESTRUCTION(window); |
938 widget->hwnd_ = NULL; | 941 widget->hwnd_ = NULL; |
939 widget->OnFinalMessage(window); | 942 widget->OnFinalMessage(window); |
940 } | 943 } |
941 return result; | 944 return result; |
942 } | 945 } |
943 | 946 |
944 } // namespace views | 947 } // namespace views |
945 | 948 |
OLD | NEW |