Chromium Code Reviews| Index: chrome/browser/ui/panels/panel_browser_view.cc |
| diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc |
| index bc154189aa452b03c6cb5d315201d559f1849d79..6a973c209856fb2659fc831c06c60aae89872dc9 100644 |
| --- a/chrome/browser/ui/panels/panel_browser_view.cc |
| +++ b/chrome/browser/ui/panels/panel_browser_view.cc |
| @@ -19,14 +19,11 @@ |
| #include "content/public/browser/notification_service.h" |
| #include "grit/chromium_strings.h" |
| #include "ui/base/l10n/l10n_util.h" |
| +#include "ui/views/events/event.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/label.h" |
| #include "ui/views/widget/widget.h" |
| -#if defined(OS_WIN) && !defined(USE_AURA) |
| -#include "base/win/win_util.h" // for IsCtrlPressed() |
| -#endif |
| - |
| using content::WebContents; |
| NativePanel* Panel::CreateNativePanel(Browser* browser, Panel* panel, |
| @@ -440,19 +437,27 @@ PanelBrowserFrameView* PanelBrowserView::GetFrameView() const { |
| return static_cast<PanelBrowserFrameView*>(frame()->GetFrameView()); |
| } |
| -bool PanelBrowserView::OnTitlebarMousePressed( |
| - const gfx::Point& mouse_location) { |
| +bool PanelBrowserView::OnTitlebarMousePressed(const views::MouseEvent& event) { |
| + // |event.location| is in the view's coordinate system. Convert it to the |
| + // screen coordinate system. |
| + gfx::Point mouse_location = event.location(); |
| + views::View::ConvertPointToScreen(this, &mouse_location); |
|
jianli
2012/04/27 22:32:10
|event| is for PanelBrowserFrameView, not PanelBro
jennb
2012/04/27 23:27:54
Changed to pass modifier around rather than event.
|
| + |
| mouse_pressed_ = true; |
| mouse_dragging_state_ = NO_DRAGGING; |
| last_mouse_location_ = mouse_location; |
| return true; |
| } |
| -bool PanelBrowserView::OnTitlebarMouseDragged( |
| - const gfx::Point& mouse_location) { |
| +bool PanelBrowserView::OnTitlebarMouseDragged(const views::MouseEvent& event) { |
| if (!mouse_pressed_) |
| return false; |
| + // |event.location| is in the view's coordinate system. Convert it to the |
| + // screen coordinate system. |
| + gfx::Point mouse_location = event.location(); |
| + views::View::ConvertPointToScreen(this, &mouse_location); |
| + |
| int delta_x = mouse_location.x() - last_mouse_location_.x(); |
| int delta_y = mouse_location.y() - last_mouse_location_.y(); |
| if (mouse_dragging_state_ == NO_DRAGGING && |
| @@ -475,7 +480,7 @@ bool PanelBrowserView::OnTitlebarMouseDragged( |
| return true; |
| } |
| -bool PanelBrowserView::OnTitlebarMouseReleased() { |
| +bool PanelBrowserView::OnTitlebarMouseReleased(const views::MouseEvent& event) { |
| if (mouse_dragging_state_ != NO_DRAGGING) { |
| // Ensure dragging a minimized panel does not leave it activated. |
| // Windows activates a panel on mouse-down, regardless of our attempts |
| @@ -500,16 +505,8 @@ bool PanelBrowserView::OnTitlebarMouseReleased() { |
| return true; |
| } |
| - panel::ClickModifier click_modifier = panel::NO_MODIFIER; |
| -#if defined(OS_WIN) && !defined(USE_AURA) |
| - if (base::win::IsCtrlPressed()) { |
| - click_modifier = panel::APPLY_TO_ALL; |
| - } |
| -#else |
| - // Proceed without modifier. |
| -#endif |
| - |
| - panel_->OnTitlebarClicked(click_modifier); |
| + panel_->OnTitlebarClicked( |
| + event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| return true; |
| } |
| @@ -530,6 +527,16 @@ bool PanelBrowserView::EndDragging(bool cancelled) { |
| return true; |
| } |
| +void PanelBrowserView::MinimizeButtonPressed(const views::Event& event) { |
| + panel_->OnMinimizeButtonClicked( |
| + event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| +} |
| + |
| +void PanelBrowserView::RestoreButtonPressed(const views::Event& event) { |
| + panel_->OnRestoreButtonClicked( |
| + event.IsControlDown() ? panel::APPLY_TO_ALL : panel::NO_MODIFIER); |
| +} |
| + |
| void PanelBrowserView::SetPanelAppIconVisibility(bool visible) { |
| #if defined(OS_WIN) && !defined(USE_AURA) |
| gfx::NativeWindow native_window = GetNativeHandle(); |
| @@ -615,48 +622,35 @@ NativePanelTestingWin::NativePanelTestingWin( |
| void NativePanelTestingWin::PressLeftMouseButtonTitlebar( |
| const gfx::Point& mouse_location, panel::ClickModifier modifier) { |
| -#if defined(OS_WIN) && !defined(USE_AURA) |
| - if (modifier == panel::APPLY_TO_ALL) { |
| - BYTE keyState[256]; |
| - ::GetKeyboardState(keyState); |
| - BYTE newKeyState[256]; |
| - memcpy(newKeyState, keyState, sizeof(keyState)); |
| - newKeyState[VK_CONTROL] = 0x80; |
| - ::SetKeyboardState(newKeyState); |
| - panel_browser_view_->OnTitlebarMousePressed(mouse_location); |
| - ::SetKeyboardState(keyState); // restore to original |
| - return; |
| - } |
| -#else |
| - // Cannot test with modifier. Proceed without it. |
| -#endif |
| - |
| - panel_browser_view_->OnTitlebarMousePressed(mouse_location); |
| + int flags = ui::EF_LEFT_MOUSE_BUTTON; |
| + if (modifier == panel::APPLY_TO_ALL) |
| + flags |= ui::EF_CONTROL_DOWN; |
| + views::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| + mouse_location.x(), |
| + mouse_location.y(), |
| + flags); |
| + panel_browser_view_->OnTitlebarMousePressed(event); |
| } |
| void NativePanelTestingWin::ReleaseMouseButtonTitlebar( |
| panel::ClickModifier modifier) { |
| -#if defined(OS_WIN) && !defined(USE_AURA) |
| - if (modifier == panel::APPLY_TO_ALL) { |
| - BYTE keyState[256]; |
| - ::GetKeyboardState(keyState); |
| - BYTE newKeyState[256]; |
| - memcpy(newKeyState, keyState, sizeof(keyState)); |
| - newKeyState[VK_CONTROL] = 0x80; |
| - ::SetKeyboardState(newKeyState); |
| - panel_browser_view_->OnTitlebarMouseReleased(); |
| - ::SetKeyboardState(keyState); // restore to original |
| - return; |
| - } |
| -#else |
| - // Cannot test with modifier. Proceed without it. |
| -#endif |
| - |
| - panel_browser_view_->OnTitlebarMouseReleased(); |
| + int flags = ui::EF_RIGHT_MOUSE_BUTTON; |
| + if (modifier == panel::APPLY_TO_ALL) |
| + flags |= ui::EF_CONTROL_DOWN; |
| + // Mouse location does not matter on button release. |
| + views::MouseEvent event(ui::ET_MOUSE_RELEASED, |
| + 0, |
| + 0, |
| + flags); |
| + panel_browser_view_->OnTitlebarMouseReleased(event); |
| } |
| void NativePanelTestingWin::DragTitlebar(const gfx::Point& mouse_location) { |
| - panel_browser_view_->OnTitlebarMouseDragged(mouse_location); |
| + views::MouseEvent event(ui::ET_MOUSE_PRESSED, |
| + mouse_location.x(), |
| + mouse_location.y(), |
| + ui::EF_LEFT_MOUSE_BUTTON); |
| + panel_browser_view_->OnTitlebarMouseDragged(event); |
| } |
| void NativePanelTestingWin::CancelDragTitlebar() { |
| @@ -664,7 +658,7 @@ void NativePanelTestingWin::CancelDragTitlebar() { |
| } |
| void NativePanelTestingWin::FinishDragTitlebar() { |
| - panel_browser_view_->OnTitlebarMouseReleased(); |
| + ReleaseMouseButtonTitlebar(panel::NO_MODIFIER); |
| } |
| bool NativePanelTestingWin::VerifyDrawingAttention() const { |