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 "chrome/browser/ui/views/panels/panel_frame_view.h" | 5 #include "chrome/browser/ui/views/panels/panel_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/ui/panels/panel.h" | 7 #include "chrome/browser/ui/panels/panel.h" |
8 #include "chrome/browser/ui/panels/panel_constants.h" | 8 #include "chrome/browser/ui/panels/panel_constants.h" |
9 #include "chrome/browser/ui/views/panels/panel_view.h" | 9 #include "chrome/browser/ui/views/panels/panel_view.h" |
10 #include "chrome/browser/ui/views/tab_icon_view.h" | 10 #include "chrome/browser/ui/views/tab_icon_view.h" |
11 #include "content/public/browser/web_contents.h" | 11 #include "content/public/browser/web_contents.h" |
12 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
13 #include "grit/theme_resources.h" | 13 #include "grit/theme_resources.h" |
14 #include "grit/ui_resources.h" | 14 #include "grit/ui_resources.h" |
15 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
16 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 #include "ui/gfx/canvas.h" | 18 #include "ui/gfx/canvas.h" |
19 #include "ui/gfx/font_list.h" | 19 #include "ui/gfx/font_list.h" |
20 #include "ui/gfx/path.h" | 20 #include "ui/gfx/path.h" |
| 21 #include "ui/gfx/screen.h" |
21 #include "ui/views/controls/button/image_button.h" | 22 #include "ui/views/controls/button/image_button.h" |
22 #include "ui/views/controls/label.h" | 23 #include "ui/views/controls/label.h" |
23 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
24 #include "ui/views/widget/widget_delegate.h" | 25 #include "ui/views/widget/widget_delegate.h" |
25 | 26 |
26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
27 #include "base/win/scoped_gdi_object.h" | 28 #include "base/win/scoped_gdi_object.h" |
28 #include "ui/base/win/shell.h" | 29 #include "ui/base/win/shell.h" |
29 #include "ui/gfx/path_win.h" | 30 #include "ui/gfx/path_win.h" |
30 #include "ui/views/win/hwnd_util.h" | 31 #include "ui/views/win/hwnd_util.h" |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // If the mouse location falls within the resizing area of the titlebar, | 572 // If the mouse location falls within the resizing area of the titlebar, |
572 // do not handle the event so that the system resizing logic could kick in. | 573 // do not handle the event so that the system resizing logic could kick in. |
573 if (!panel_view_->IsWithinResizingArea(mouse_location) && | 574 if (!panel_view_->IsWithinResizingArea(mouse_location) && |
574 panel_view_->OnTitlebarMousePressed(mouse_location)) | 575 panel_view_->OnTitlebarMousePressed(mouse_location)) |
575 return true; | 576 return true; |
576 } | 577 } |
577 return NonClientFrameView::OnMousePressed(event); | 578 return NonClientFrameView::OnMousePressed(event); |
578 } | 579 } |
579 | 580 |
580 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { | 581 bool PanelFrameView::OnMouseDragged(const ui::MouseEvent& event) { |
| 582 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 583 // Converting the mouse location to screen coordinates returns an incorrect |
| 584 // location while the panel is moving. See crbug.com/353393 for more details. |
| 585 // TODO(pkotwicz): Fix conversion to screen coordinates |
| 586 gfx::Screen* screen = gfx::Screen::GetNativeScreen(); |
| 587 gfx::Point mouse_location = screen->GetCursorScreenPoint(); |
| 588 #else |
581 // |event.location| is in the view's coordinate system. Convert it to the | 589 // |event.location| is in the view's coordinate system. Convert it to the |
582 // screen coordinate system. | 590 // screen coordinate system. |
583 gfx::Point mouse_location = event.location(); | 591 gfx::Point mouse_location = event.location(); |
584 views::View::ConvertPointToScreen(this, &mouse_location); | 592 views::View::ConvertPointToScreen(this, &mouse_location); |
| 593 #endif |
585 | 594 |
586 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) | 595 if (panel_view_->OnTitlebarMouseDragged(mouse_location)) |
587 return true; | 596 return true; |
588 return NonClientFrameView::OnMouseDragged(event); | 597 return NonClientFrameView::OnMouseDragged(event); |
589 } | 598 } |
590 | 599 |
591 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { | 600 void PanelFrameView::OnMouseReleased(const ui::MouseEvent& event) { |
592 if (panel_view_->OnTitlebarMouseReleased( | 601 if (panel_view_->OnTitlebarMouseReleased( |
593 event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER)) | 602 event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER)) |
594 return; | 603 return; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 | 764 |
756 // Draw the left border. | 765 // Draw the left border. |
757 canvas->TileImageInt(left_image, | 766 canvas->TileImageInt(left_image, |
758 0, | 767 0, |
759 top_left_image.height(), | 768 top_left_image.height(), |
760 left_image.width(), | 769 left_image.width(), |
761 height() - top_left_image.height() - | 770 height() - top_left_image.height() - |
762 bottom_left_image.height()); | 771 bottom_left_image.height()); |
763 #endif | 772 #endif |
764 } | 773 } |
OLD | NEW |