summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui
diff options
context:
space:
mode:
authorthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 03:46:59 +0000
committerthestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 03:46:59 +0000
commitd3bcf8114501d8d743a780e901f971af7a03d239 (patch)
tree681210ecffc664f59509b4479564b16f8b80470b /chrome/browser/ui
parenta6d1552a81236a5e213fab50549e13995c1ab33a (diff)
downloadchromium_src-d3bcf8114501d8d743a780e901f971af7a03d239.zip
chromium_src-d3bcf8114501d8d743a780e901f971af7a03d239.tar.gz
chromium_src-d3bcf8114501d8d743a780e901f971af7a03d239.tar.bz2
Revert 101446 - Implement minimize/restore/hover for panels on Linux.
- Minimize panel to 3 pixles when clicked on the titlebar. - Expose titlebar for all panels when hovering on or under a minimized panel. - Restore panel to normal when clicked while in minimized state or showing titlebar state. - Added platform independent unit tests. Platform specific hooks are only implemented for linux. So test only enable on linux currently. BUG=None TEST=PanelBrowserTest.MinimizeRestore Review URL: http://codereview.chromium.org/7879003 TBR=prasadt@chromium.org Review URL: http://codereview.chromium.org/7922005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui')
-rw-r--r--chrome/browser/ui/panels/native_panel.h3
-rw-r--r--chrome/browser/ui/panels/panel.cc6
-rw-r--r--chrome/browser/ui/panels/panel.h2
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.cc11
-rw-r--r--chrome/browser/ui/panels/panel_browser_frame_view.h3
-rw-r--r--chrome/browser/ui/panels/panel_browser_view.cc17
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_cocoa.mm13
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk.cc107
-rw-r--r--chrome/browser/ui/panels/panel_browser_window_gtk.h23
-rw-r--r--chrome/browser/ui/panels/panel_browsertest.cc169
-rw-r--r--chrome/browser/ui/panels/panel_manager.cc22
-rw-r--r--chrome/browser/ui/panels/panel_manager.h11
-rw-r--r--chrome/browser/ui/panels/panel_mouse_watcher.cc61
-rw-r--r--chrome/browser/ui/panels/panel_mouse_watcher.h100
-rw-r--r--chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc77
15 files changed, 52 insertions, 573 deletions
diff --git a/chrome/browser/ui/panels/native_panel.h b/chrome/browser/ui/panels/native_panel.h
index 41caeaa..8aa419d 100644
--- a/chrome/browser/ui/panels/native_panel.h
+++ b/chrome/browser/ui/panels/native_panel.h
@@ -92,9 +92,6 @@ class NativePanelTesting {
virtual void DragTitlebar(int delta_x, int delta_y) = 0;
virtual void CancelDragTitlebar() = 0;
virtual void FinishDragTitlebar() = 0;
- virtual void SetMousePositionForMinimizeRestore(const gfx::Point& point) = 0;
-
- virtual int TitleOnlyHeight() const = 0;
};
#endif // CHROME_BROWSER_UI_PANELS_NATIVE_PANEL_H_
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 3a3bb9d..e742df6 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -374,10 +374,8 @@ void Panel::UserChangedTheme() {
}
int Panel::GetExtraRenderViewHeight() const {
- // This is currently used only on Linux and that returns the height for
- // optional elements like bookmark bar, download bar etc. Not applicable to
- // panels.
- return 0;
+ NOTIMPLEMENTED();
+ return -1;
}
void Panel::TabContentsFocused(TabContents* tab_contents) {
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index cb843d3..3fae8f0 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -34,7 +34,7 @@ class Panel : public BrowserWindow, public NotificationObserver {
EXPANDED,
// The panel is shown with the title-bar only.
TITLE_ONLY,
- // The panel is shown with 3-pixel line.
+ // The panel is shown with 3-pxiel line.
MINIMIZED
};
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.cc b/chrome/browser/ui/panels/panel_browser_frame_view.cc
index 379b425..b27e96e 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.cc
@@ -52,6 +52,9 @@ const int kIconSize = 16;
// The spacing in pixels between buttons or the button and the adjacent control.
const int kButtonSpacing = 6;
+// The panel can be minimized to 3-pixel lines.
+const int kMinimizedPanelHeight = 3;
+
// Colors used in painting the titlebar for drawing attention.
const SkColor kBackgroundColorForAttention = 0xfffa983a;
const SkColor kTitleTextColorForAttention = SK_ColorWHITE;
@@ -465,6 +468,10 @@ int PanelBrowserFrameView::NonClientTopBorderHeight() const {
return kFrameBorderThickness + kTitlebarHeight + kClientEdgeThickness;
}
+int PanelBrowserFrameView::MinimizedPanelHeight() {
+ return kMinimizedPanelHeight;
+}
+
gfx::Size PanelBrowserFrameView::NonClientAreaSize() const {
return gfx::Size(NonClientBorderThickness() * 2,
NonClientTopBorderHeight() + NonClientBorderThickness());
@@ -526,7 +533,7 @@ void PanelBrowserFrameView::PaintFrameBorder(gfx::Canvas* canvas) {
canvas->TileImageInt(*theme_frame, 0, 0, width(), height());
// No need to paint other stuff if panel is minimized.
- if (height() <= PanelManager::minimized_panel_height())
+ if (height() <= kMinimizedPanelHeight)
return;
// Draw the top border.
@@ -572,7 +579,7 @@ void PanelBrowserFrameView::PaintClientEdge(gfx::Canvas* canvas) {
int client_area_top = client_view_bounds_.y();
// No need to paint other stuff if panel is minimized.
- if (height() <= PanelManager::minimized_panel_height())
+ if (height() <= kMinimizedPanelHeight)
return;
// Draw the top edge.
diff --git a/chrome/browser/ui/panels/panel_browser_frame_view.h b/chrome/browser/ui/panels/panel_browser_frame_view.h
index 00479f8..5cf4252 100644
--- a/chrome/browser/ui/panels/panel_browser_frame_view.h
+++ b/chrome/browser/ui/panels/panel_browser_frame_view.h
@@ -45,6 +45,9 @@ class PanelBrowserFrameView : public BrowserNonClientFrameView,
// frame, any title area, and any connected client edge.
int NonClientTopBorderHeight() const;
+ // Returns the height of the panel in minimized state.
+ static int MinimizedPanelHeight();
+
// Returns the size of the non-client area, that is, the window size minus
// the size of the client area.
gfx::Size NonClientAreaSize() const;
diff --git a/chrome/browser/ui/panels/panel_browser_view.cc b/chrome/browser/ui/panels/panel_browser_view.cc
index 2b1efd7..d0e9a2a 100644
--- a/chrome/browser/ui/panels/panel_browser_view.cc
+++ b/chrome/browser/ui/panels/panel_browser_view.cc
@@ -205,7 +205,7 @@ void PanelBrowserView::OnPanelExpansionStateChanged(
height = GetFrameView()->NonClientTopBorderHeight();
break;
case Panel::MINIMIZED:
- height = PanelManager::minimized_panel_height();
+ height = PanelBrowserFrameView::MinimizedPanelHeight();
// Start the mouse watcher so that we can bring up the minimized panels.
// TODO(jianli): Need to support mouse watching in ChromeOS.
@@ -305,7 +305,7 @@ void PanelBrowserView::StopDrawingAttention() {
// user clicks on it to mean to clear the attention.
attention_cleared_time_ = base::TimeTicks::Now();
- // Restore the panel.
+ // Bring up the titlebar.
if (panel_->expansion_state() == Panel::TITLE_ONLY)
panel_->SetExpansionState(Panel::EXPANDED);
@@ -424,9 +424,6 @@ class NativePanelTestingWin : public NativePanelTesting {
virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE;
virtual void CancelDragTitlebar() OVERRIDE;
virtual void FinishDragTitlebar() OVERRIDE;
- virtual void SetMousePositionForMinimizeRestore(
- const gfx::Point& point) OVERRIDE;
- virtual int TitleOnlyHeight() const OVERRIDE;
PanelBrowserView* panel_browser_view_;
};
@@ -467,13 +464,3 @@ void NativePanelTestingWin::CancelDragTitlebar() {
void NativePanelTestingWin::FinishDragTitlebar() {
panel_browser_view_->OnTitlebarMouseReleased();
}
-
-void NativePanelTestingWin::SetMousePositionForMinimizeRestore(
- const gfx::Point& hover_point) {
- NOTIMPLEMENTED();
-}
-
-int NativePanelTestingWin::TitleOnlyHeight() const {
- NOTIMPLEMENTED();
- return -1;
-}
diff --git a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
index 89a7d24..6cc00fa 100644
--- a/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
+++ b/chrome/browser/ui/panels/panel_browser_window_cocoa.mm
@@ -265,10 +265,6 @@ class NativePanelTestingCocoa : public NativePanelTesting {
virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE;
virtual void CancelDragTitlebar() OVERRIDE;
virtual void FinishDragTitlebar() OVERRIDE;
- virtual void SetMousePositionForMinimizeRestore(
- const gfx::Point& point) OVERRIDE;
- virtual int TitleOnlyHeight() const OVERRIDE;
-
private:
PanelTitlebarViewCocoa* titlebar();
// Weak, assumed always to outlive this test API object.
@@ -309,12 +305,3 @@ void NativePanelTestingCocoa::FinishDragTitlebar() {
[titlebar() finishDragTitlebar];
}
-void NativePanelTestingCocoa::SetMousePositionForMinimizeRestore(
- const gfx::Point& hover_point) {
- NOTIMPLEMENTED();
-}
-
-int NativePanelTestingCocoa::TitleOnlyHeight() const {
- NOTIMPLEMENTED();
- return -1;
-}
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.cc b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
index e1cdc9b..5cfaff1 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.cc
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.cc
@@ -6,7 +6,6 @@
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
-#include "chrome/browser/ui/panels/panel_mouse_watcher.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
#include "ui/base/dragdrop/gtk_dnd_util.h"
@@ -27,8 +26,7 @@ PanelBrowserWindowGtk::PanelBrowserWindowGtk(Browser* browser,
destroy_drag_widget_factory_(this),
drag_end_factory_(this),
panel_(panel),
- bounds_(bounds),
- restored_height_(bounds.height()) {
+ bounds_(bounds) {
}
PanelBrowserWindowGtk::~PanelBrowserWindowGtk() {
@@ -39,9 +37,6 @@ PanelBrowserWindowGtk::~PanelBrowserWindowGtk() {
gtk_grab_remove(drag_widget_);
DestroyDragWidget();
}
-
- if (PanelMouseWatcher::GetInstance()->IsSubscribed(this))
- PanelMouseWatcher::GetInstance()->RemoveSubscriber(this);
}
void PanelBrowserWindowGtk::Init() {
@@ -92,19 +87,14 @@ void PanelBrowserWindowGtk::SaveWindowPosition() {
}
void PanelBrowserWindowGtk::SetGeometryHints() {
- // Set minimum height the window can be set to.
- GdkGeometry hints;
- hints.min_height = PanelManager::minimized_panel_height();
- hints.min_width = panel_->min_size().width();
- gtk_window_set_geometry_hints(
- window(), GTK_WIDGET(window()), &hints, GDK_HINT_MIN_SIZE);
-
- SetBoundsImpl(bounds_, true);
+ SetBoundsImpl();
}
void PanelBrowserWindowGtk::SetBounds(const gfx::Rect& bounds) {
- // This should never be called.
- DLOG(WARNING) << "Unexpected call to PanelBrowserWindowGtk::SetBounds()";
+ if (bounds_ != bounds) {
+ bounds_ = bounds;
+ SetBoundsImpl();
+ }
}
bool PanelBrowserWindowGtk::UseCustomFrame() {
@@ -134,49 +124,18 @@ gfx::Rect PanelBrowserWindowGtk::GetPanelBounds() const {
}
void PanelBrowserWindowGtk::SetPanelBounds(const gfx::Rect& bounds) {
- if (bounds != bounds_)
- SetBoundsImpl(bounds, true);
+ SetBounds(bounds);
}
void PanelBrowserWindowGtk::OnPanelExpansionStateChanged(
Panel::ExpansionState expansion_state) {
- // TODO(prasadt): This is very similar to what we do for windows. Look into
- // sharing this implementation across platforms.
- int height;
- switch (expansion_state) {
- case Panel::EXPANDED:
- height = restored_height_;
- PanelMouseWatcher::GetInstance()->RemoveSubscriber(this);
- break;
- case Panel::TITLE_ONLY:
- height = TitleOnlyHeight();
- break;
- case Panel::MINIMIZED:
- height = PanelManager::minimized_panel_height();
- PanelMouseWatcher::GetInstance()->AddSubscriber(this);
- break;
- default:
- NOTREACHED();
- height = restored_height_;
- break;
- }
-
- gfx::Rect bounds = bounds_;
- int bottom = panel_->manager()->GetBottomPositionForExpansionState(
- expansion_state);
- bounds.set_y(bottom - height);
- bounds.set_height(height);
-
- // Do not move the window when expansion state changes. Just change the size.
- // Because of GDK_GRAVITY_SOUTH_EAST gravity, the window will stay docked to
- // the bottom.
- SetBoundsImpl(bounds, false);
+ NOTIMPLEMENTED();
}
bool PanelBrowserWindowGtk::ShouldBringUpPanelTitlebar(int mouse_x,
int mouse_y) const {
- return bounds_.x() <= mouse_x && mouse_x <= bounds_.right() &&
- mouse_y >= bounds_.y();
+ NOTIMPLEMENTED();
+ return false;
}
void PanelBrowserWindowGtk::ClosePanel() {
@@ -220,6 +179,7 @@ void PanelBrowserWindowGtk::DrawAttention() {
}
bool PanelBrowserWindowGtk::IsDrawingAttention() const {
+ NOTIMPLEMENTED();
return false;
}
@@ -256,11 +216,9 @@ void PanelBrowserWindowGtk::SetRestoredHeight(int height) {
NOTIMPLEMENTED();
}
-void PanelBrowserWindowGtk::SetBoundsImpl(const gfx::Rect& bounds, bool move) {
- bounds_ = bounds;
- if (move)
- gtk_window_move(window_, bounds.x(), bounds.y());
- gtk_window_resize(window(), bounds.width(), bounds.height());
+void PanelBrowserWindowGtk::SetBoundsImpl() {
+ gtk_window_move(window_, bounds_.x(), bounds_.y());
+ gtk_window_resize(window(), bounds_.width(), bounds_.height());
}
void PanelBrowserWindowGtk::WillProcessEvent(GdkEvent* event) {
@@ -287,7 +245,7 @@ void PanelBrowserWindowGtk::DidProcessEvent(GdkEvent* event) {
if (drag_widget_) {
panel_->manager()->Drag(new_x - old_x);
gdk_event_free(last_mouse_down_);
- last_mouse_down_ = gdk_event_copy(event);
+ last_mouse_down_ = gdk_event_copy(reinterpret_cast<GdkEvent*>(event));
} else if (gtk_drag_check_threshold(titlebar_widget(), old_x,
old_y, new_x, new_y)) {
CreateDragWidget();
@@ -357,23 +315,7 @@ gboolean PanelBrowserWindowGtk::OnTitlebarButtonPressEvent(
gboolean PanelBrowserWindowGtk::OnTitlebarButtonReleaseEvent(
GtkWidget* widget, GdkEventButton* event) {
- if (event->button != 1) {
- DCHECK(!last_mouse_down_);
- return TRUE;
- }
-
- DCHECK(last_mouse_down_);
CleanupDragDrop();
-
- Panel::ExpansionState new_expansion_state;
- if (panel_->expansion_state() == Panel::EXPANDED) {
- restored_height_ = bounds_.height();
- new_expansion_state = Panel::MINIMIZED;
- } else {
- new_expansion_state = Panel::EXPANDED;
- }
- panel_->SetExpansionState(new_expansion_state);
-
return TRUE;
}
@@ -421,9 +363,6 @@ class NativePanelTestingGtk : public NativePanelTesting {
virtual void DragTitlebar(int delta_x, int delta_y) OVERRIDE;
virtual void CancelDragTitlebar() OVERRIDE;
virtual void FinishDragTitlebar() OVERRIDE;
- virtual void SetMousePositionForMinimizeRestore(
- const gfx::Point& point) OVERRIDE;
- virtual int TitleOnlyHeight() const OVERRIDE;
PanelBrowserWindowGtk* panel_browser_window_gtk_;
};
@@ -453,11 +392,7 @@ void NativePanelTestingGtk::PressLeftMouseButtonTitlebar(
}
void NativePanelTestingGtk::ReleaseMouseButtonTitlebar() {
- GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS);
- event->button.button = 1;
- panel_browser_window_gtk_->OnTitlebarButtonReleaseEvent(
- panel_browser_window_gtk_->titlebar_widget(),
- reinterpret_cast<GdkEventButton*>(event));
+ panel_browser_window_gtk_->OnTitlebarButtonReleaseEvent(NULL, NULL);
MessageLoopForUI::current()->RunAllPending();
}
@@ -490,13 +425,3 @@ void NativePanelTestingGtk::FinishDragTitlebar() {
GTK_DRAG_RESULT_NO_TARGET);
MessageLoopForUI::current()->RunAllPending();
}
-
-void NativePanelTestingGtk::SetMousePositionForMinimizeRestore(
- const gfx::Point& hover_point) {
- PanelMouseWatcher::GetInstance()->HandleMouseMovement(hover_point);
- MessageLoopForUI::current()->RunAllPending();
-}
-
-int NativePanelTestingGtk::TitleOnlyHeight() const {
- return panel_browser_window_gtk_->TitleOnlyHeight();
-}
diff --git a/chrome/browser/ui/panels/panel_browser_window_gtk.h b/chrome/browser/ui/panels/panel_browser_window_gtk.h
index 95664f4..b981c82 100644
--- a/chrome/browser/ui/panels/panel_browser_window_gtk.h
+++ b/chrome/browser/ui/panels/panel_browser_window_gtk.h
@@ -74,20 +74,7 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
virtual void SetRestoredHeight(int height) OVERRIDE;
private:
- // Resize the window as specified by the bounds. Move the window to the
- // specified location only if "move" is true. We set the window gravity to be
- // GDK_GRAVITY_SOUTH_EAST which means the window is anchored to the bottom
- // right corner on resize, making it unnecessary to move the window if the
- // bottom right corner is unchanged, for example when we minimize to the
- // bottom. Moving can actually result in the wrong behavior.
- // - Say window is 100x100 with x,y=900,900 on a 1000x1000 screen.
- // - Say you minimize the window to 100x3 and move it to 900,997 to keep it
- // anchored to the bottom.
- // - resize is an async operation and the window manager will decide that
- // the move will take the window off screen and it won't honor the
- // request.
- // - When resize finally happens, you'll have a 100x3 window a x,y=900,900.
- void SetBoundsImpl(const gfx::Rect& bounds, bool move);
+ void SetBoundsImpl();
// MessageLoop::Observer implementation:
virtual void WillProcessEvent(GdkEvent* event) OVERRIDE;
@@ -98,10 +85,6 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
void EndDrag(bool canceled);
void CleanupDragDrop();
- int TitleOnlyHeight() const {
- return titlebar_widget()->allocation.height;
- }
-
CHROMEGTK_CALLBACK_1(PanelBrowserWindowGtk, gboolean,
OnTitlebarButtonPressEvent, GdkEventButton*);
CHROMEGTK_CALLBACK_1(PanelBrowserWindowGtk, gboolean,
@@ -150,10 +133,6 @@ class PanelBrowserWindowGtk : public BrowserWindowGtk,
scoped_ptr<PanelSettingsMenuModel> settings_menu_model_;
scoped_ptr<MenuGtk> settings_menu_;
- // Stores the original height of the panel so we can restore it after it's
- // been minimized.
- int restored_height_;
-
DISALLOW_COPY_AND_ASSIGN(PanelBrowserWindowGtk);
};
diff --git a/chrome/browser/ui/panels/panel_browsertest.cc b/chrome/browser/ui/panels/panel_browsertest.cc
index 42a32cd..ec4661a 100644
--- a/chrome/browser/ui/panels/panel_browsertest.cc
+++ b/chrome/browser/ui/panels/panel_browsertest.cc
@@ -12,7 +12,6 @@
#include "chrome/browser/ui/panels/native_panel.h"
#include "chrome/browser/ui/panels/panel.h"
#include "chrome/browser/ui/panels/panel_manager.h"
-#include "chrome/browser/ui/panels/panel_mouse_watcher.h"
#include "chrome/browser/ui/panels/panel_settings_menu_model.h"
#include "chrome/browser/web_applications/web_app.h"
#include "chrome/common/chrome_notification_types.h"
@@ -163,13 +162,6 @@ class PanelBrowserTest : public BasePanelBrowserTest {
}
}
- void CheckExpansionStates(
- std::vector<Panel::ExpansionState> expected_expansion_states) {
- std::vector<Panel*> panels = PanelManager::GetInstance()->panels();
- for (size_t i = 0; i < panels.size(); i++)
- EXPECT_EQ(expected_expansion_states[i], panels[i]->expansion_state());
- }
-
void TestDragging(int delta_x,
int delta_y,
size_t drag_index,
@@ -201,8 +193,10 @@ class PanelBrowserTest : public BasePanelBrowserTest {
if (drag_action & DRAG_ACTION_BEGIN) {
// Trigger the mouse-pressed event.
// All panels should remain in their original positions.
- panel_testing_to_drag->PressLeftMouseButtonTitlebar(
- panels[drag_index]->GetRestoredBounds().origin());
+ gfx::Point button_press_point(
+ panels[drag_index]->GetRestoredBounds().x(),
+ panels[drag_index]->GetRestoredBounds().y());
+ panel_testing_to_drag->PressLeftMouseButtonTitlebar(button_press_point);
CheckPanelBounds(panels, test_begin_bounds);
}
@@ -300,136 +294,6 @@ class PanelBrowserTest : public BasePanelBrowserTest {
panel->Close();
}
-
- void TestMinimizeRestore() {
- std::vector<Panel*> panels = PanelManager::GetInstance()->panels();
- std::vector<gfx::Rect> test_begin_bounds = GetAllPanelsBounds();
- std::vector<gfx::Rect> expected_bounds = test_begin_bounds;
- std::vector<Panel::ExpansionState> expected_expansion_states(
- panels.size(), Panel::EXPANDED);
- std::vector<NativePanelTesting*> native_panels_testing(panels.size());
- for (size_t i = 0; i < panels.size(); ++i) {
- native_panels_testing[i] =
- NativePanelTesting::Create(panels[i]->native_panel());
- }
-
- // Test minimize.
- for (size_t index = 0; index < panels.size(); ++index) {
- // Press left mouse button. Verify nothing changed.
- native_panels_testing[index]->PressLeftMouseButtonTitlebar(
- panels[index]->GetRestoredBounds().origin());
- CheckPanelBounds(panels, expected_bounds);
- CheckExpansionStates(expected_expansion_states);
-
- // Release mouse button. Verify minimized.
- native_panels_testing[index]->ReleaseMouseButtonTitlebar();
- expected_bounds[index].set_height(
- PanelManager::minimized_panel_height());
- expected_bounds[index].set_y(
- test_begin_bounds[index].y() +
- test_begin_bounds[index].height() -
- PanelManager::minimized_panel_height());
- expected_expansion_states[index] = Panel::MINIMIZED;
- CheckPanelBounds(panels, expected_bounds);
- CheckExpansionStates(expected_expansion_states);
- }
-
- // Setup bounds and expansion states for minimized and titlebar-only
- // states.
- std::vector<Panel::ExpansionState> titlebar_exposed_states(
- panels.size(), Panel::TITLE_ONLY);
- std::vector<gfx::Rect> minimized_bounds = expected_bounds;
- std::vector<Panel::ExpansionState> minimized_states(
- panels.size(), Panel::MINIMIZED);
- std::vector<gfx::Rect> titlebar_exposed_bounds = test_begin_bounds;
- for (size_t index = 0; index < panels.size(); ++index) {
- titlebar_exposed_bounds[index].set_height(
- native_panels_testing[index]->TitleOnlyHeight());
- titlebar_exposed_bounds[index].set_y(
- test_begin_bounds[index].y() +
- test_begin_bounds[index].height() -
- native_panels_testing[index]->TitleOnlyHeight());
- }
-
- // Test hover. All panels are currently in minimized state.
- CheckExpansionStates(minimized_states);
- for (size_t index = 0; index < panels.size(); ++index) {
- // Hover mouse on minimized panel.
- // Verify titlebar is exposed on all panels.
- gfx::Point hover_point(panels[index]->GetRestoredBounds().origin());
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- hover_point);
- CheckPanelBounds(panels, titlebar_exposed_bounds);
- CheckExpansionStates(titlebar_exposed_states);
-
- // Hover mouse above the panel. Verify all panels are minimized.
- hover_point.set_y(panels[index]->GetRestoredBounds().y() - 10);
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- hover_point);
- CheckPanelBounds(panels, minimized_bounds);
- CheckExpansionStates(minimized_states);
-
- // Hover mouse below minimized panel.
- // Verify titlebar is exposed on all panels.
- hover_point.set_y(panels[index]->GetRestoredBounds().y() +
- panels[index]->GetRestoredBounds().height() + 5);
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- hover_point);
- CheckPanelBounds(panels, titlebar_exposed_bounds);
- CheckExpansionStates(titlebar_exposed_states);
-
- // Hover below titlebar exposed panel. Verify nothing changed.
- hover_point.set_y(panels[index]->GetRestoredBounds().y() +
- panels[index]->GetRestoredBounds().height() + 6);
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- hover_point);
- CheckPanelBounds(panels, titlebar_exposed_bounds);
- CheckExpansionStates(titlebar_exposed_states);
-
- // Hover mouse above panel. Verify all panels are minimized.
- hover_point.set_y(panels[index]->GetRestoredBounds().y() - 10);
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- hover_point);
- CheckPanelBounds(panels, minimized_bounds);
- CheckExpansionStates(minimized_states);
- }
-
- // Test restore. All panels are currently in minimized state.
- for (size_t index = 0; index < panels.size(); ++index) {
- // Hover on the last panel. This is to test the case of clicking on the
- // panel when it's in titlebar exposed state.
- if (index == panels.size() - 1) {
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- minimized_bounds[index].origin());
- }
-
- // Click minimized or title bar exposed panel as the case may be.
- // Verify panel is restored to its original size.
- native_panels_testing[index]->PressLeftMouseButtonTitlebar(
- panels[index]->GetRestoredBounds().origin());
- native_panels_testing[index]->ReleaseMouseButtonTitlebar();
- expected_bounds[index].set_height(
- test_begin_bounds[index].height());
- expected_bounds[index].set_y(test_begin_bounds[index].y());
- expected_expansion_states[index] = Panel::EXPANDED;
- CheckPanelBounds(panels, expected_bounds);
- CheckExpansionStates(expected_expansion_states);
-
- // Hover again on the last panel which is now restored, to reset the
- // titlebar exposed state.
- if (index == panels.size() - 1) {
- native_panels_testing[index]->SetMousePositionForMinimizeRestore(
- minimized_bounds[index].origin());
- }
- }
-
- // The below could be separate tests, just adding a TODO here for tracking.
- // TODO(prasadt): Add test for dragging when in titlebar exposed state.
- // TODO(prasadt): Add test in presence of auto hiding task bar.
-
- for (size_t i = 0; i < panels.size(); ++i)
- delete native_panels_testing[i];
- }
};
IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreatePanel) {
@@ -759,31 +623,6 @@ IN_PROC_BROWSER_TEST_F(PanelBrowserTest, CreateSettingsMenu) {
"http://home", "options.html");
}
-#if defined(TOOLKIT_GTK)
-#define MAYBE_MinimizeRestore MinimizeRestore
-#else
-#define MAYBE_MinimizeRestore DISABLED_MinimizeRestore
-#endif
-
-IN_PROC_BROWSER_TEST_F(PanelBrowserTest, MAYBE_MinimizeRestore) {
- // Disable mouse watcher. We'll simulate mouse movements for test.
- PanelMouseWatcher::GetInstance()->EnableTestingMode();
-
- // Test with one panel.
- CreatePanelWithBounds("PanelTest1", gfx::Rect(0, 0, 100, 100));
- TestMinimizeRestore();
-
- // Test with two panels.
- CreatePanelWithBounds("PanelTest2", gfx::Rect(0, 0, 110, 110));
- TestMinimizeRestore();
-
- // Test with three panels.
- CreatePanelWithBounds("PanelTest3", gfx::Rect(0, 0, 120, 120));
- TestMinimizeRestore();
-
- PanelManager::GetInstance()->RemoveAll();
-}
-
class PanelDownloadTest : public PanelBrowserTest {
public:
PanelDownloadTest() : PanelBrowserTest() { }
diff --git a/chrome/browser/ui/panels/panel_manager.cc b/chrome/browser/ui/panels/panel_manager.cc
index 6a8443e..7a60030 100644
--- a/chrome/browser/ui/panels/panel_manager.cc
+++ b/chrome/browser/ui/panels/panel_manager.cc
@@ -16,9 +16,15 @@ namespace {
// Invalid panel index.
const size_t kInvalidPanelIndex = static_cast<size_t>(-1);
+// Minimum width and height of a panel.
+// Note: The minimum size of a widget (see widget.cc) is fixed to 100x100.
+// TODO(jianli): Need to fix this to support smaller panel.
+const int kPanelMinWidthPixels = 100;
+const int kPanelMinHeightPixels = 100;
+
// Default width and height of a panel.
-const int kPanelDefaultWidth = 240;
-const int kPanelDefaultHeight = 290;
+const int kPanelDefaultWidthPixels = 240;
+const int kPanelDefaultHeightPixels = 290;
// Maxmium width and height of a panel based on the factor of the working
// area.
@@ -100,20 +106,20 @@ Panel* PanelManager::CreatePanel(Browser* browser) {
int height = browser->override_bounds().height();
if (width == 0 && height == 0) {
- width = kPanelDefaultWidth;
- height = kPanelDefaultHeight;
+ width = kPanelDefaultWidthPixels;
+ height = kPanelDefaultHeightPixels;
}
int max_panel_width = GetMaxPanelWidth();
int max_panel_height = GetMaxPanelHeight();
- if (width < kPanelMinWidth)
- width = kPanelMinWidth;
+ if (width < kPanelMinWidthPixels)
+ width = kPanelMinWidthPixels;
else if (width > max_panel_width)
width = max_panel_width;
- if (height < kPanelMinHeight)
- height = kPanelMinHeight;
+ if (height < kPanelMinHeightPixels)
+ height = kPanelMinHeightPixels;
else if (height > max_panel_height)
height = max_panel_height;
diff --git a/chrome/browser/ui/panels/panel_manager.h b/chrome/browser/ui/panels/panel_manager.h
index 859766d..27d0f5f 100644
--- a/chrome/browser/ui/panels/panel_manager.h
+++ b/chrome/browser/ui/panels/panel_manager.h
@@ -28,8 +28,6 @@ class PanelManager : public AutoHidingDesktopBar::Observer,
// Returns a single instance.
static PanelManager* GetInstance();
- static int minimized_panel_height() { return kMinimizedPanelHeight; }
-
virtual ~PanelManager();
// Called when the display is changed, i.e. work area is updated.
@@ -188,15 +186,6 @@ class PanelManager : public AutoHidingDesktopBar::Observer,
static const int kPanelsHorizontalSpacing = 4;
- // Minimum width and height of a panel.
- // Note: The minimum size of a widget (see widget.cc) is fixed to 100x100.
- // TODO(jianli): Need to fix this to support smaller panel.
- static const int kPanelMinWidth = 100;
- static const int kPanelMinHeight = 100;
-
- // The panel can be minimized to 3-pixel lines.
- static const int kMinimizedPanelHeight = 3;
-
DISALLOW_COPY_AND_ASSIGN(PanelManager);
};
diff --git a/chrome/browser/ui/panels/panel_mouse_watcher.cc b/chrome/browser/ui/panels/panel_mouse_watcher.cc
deleted file mode 100644
index bf1f437..0000000
--- a/chrome/browser/ui/panels/panel_mouse_watcher.cc
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/panels/panel_mouse_watcher.h"
-
-#include "chrome/browser/ui/panels/panel_manager.h"
-
-PanelMouseWatcher::PanelMouseWatcher()
- : bring_up_titlebar_(false), is_testing_mode_enabled_(false) {
-}
-
-PanelMouseWatcher::~PanelMouseWatcher() {
-}
-
-void PanelMouseWatcher::AddSubscriber(NativePanel* native_panel) {
- if (is_testing_mode_enabled_)
- return;
-
- if (subscribers_.count(native_panel) == 0) {
- subscribers_.insert(native_panel);
- DCHECK_LE(subscribers_.size(),
- static_cast<size_t>(PanelManager::GetInstance()->num_panels()));
-
- if (subscribers_.size() == 1)
- Start();
- }
-}
-
-void PanelMouseWatcher::RemoveSubscriber(NativePanel* native_panel) {
- if (is_testing_mode_enabled_)
- return;
-
- DCHECK(subscribers_.count(native_panel) == 1);
- subscribers_.erase(native_panel);
-
- if (subscribers_.size() == 0)
- Stop();
-}
-
-bool PanelMouseWatcher::IsSubscribed(NativePanel* native_panel) const {
- return subscribers_.count(native_panel) != 0;
-}
-
-void PanelMouseWatcher::EnableTestingMode() {
- is_testing_mode_enabled_ = true;
- DCHECK(subscribers_.size() == 0);
-}
-
-void PanelMouseWatcher::HandleMouseMovement(
- const gfx::Point& mouse_position) {
- PanelManager* panel_manager = PanelManager::GetInstance();
-
- bool bring_up_titlebar =
- panel_manager->ShouldBringUpTitlebars(
- mouse_position.x(), mouse_position.y());
- if (bring_up_titlebar == bring_up_titlebar_)
- return;
- bring_up_titlebar_ = bring_up_titlebar;
- panel_manager->BringUpOrDownTitlebars(bring_up_titlebar);
-}
diff --git a/chrome/browser/ui/panels/panel_mouse_watcher.h b/chrome/browser/ui/panels/panel_mouse_watcher.h
deleted file mode 100644
index 14af47c..0000000
--- a/chrome/browser/ui/panels/panel_mouse_watcher.h
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
-#define CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
-
-#include "base/hash_tables.h"
-
-class NativePanel;
-
-namespace gfx {
-
-class Point;
-
-}
-
-#if defined(COMPILER_GCC)
-
-// Defines the hash function for type NativePanel* to be the pointer value.
-// Need this to make base::hash_set<NativePanel*> work. Borrowed the idea from
-// prerender_manager.h.
-namespace __gnu_cxx {
-template <>
-struct hash<NativePanel*> {
- std::size_t operator()(NativePanel* value) const {
- return reinterpret_cast<std::size_t>(value);
- }
-};
-}
-
-#endif
-
-// This is the base class for functionality to respond to mouse movements when
-// at least one panel is in the minimized state. On detecting the mouse
-// movement, it interacts with PanelManager to either show the titlebar or go
-// to minimized state. The specific implementation of this abstract class
-// differ in how they track mouse movements.
-class PanelMouseWatcher {
- public:
- // Returns an instance of the platform specific implementation.
- static PanelMouseWatcher* GetInstance();
-
- // clang gives an error asking for an out of line destructor.
- virtual ~PanelMouseWatcher();
-
- // Adds to set of subscribers. Starts the mouse watcher when the first
- // subscriber is registered.
- void AddSubscriber(NativePanel* native_panel);
-
- // Removes from set of subscribers. Stops the mouse watcher when the last
- // subscriber is unregistered.
- void RemoveSubscriber(NativePanel* native_panel);
-
- bool IsSubscribed(NativePanel* native_panel) const;
-
- // To be used by tests only. Allows unit testing to be done without the
- // timer running.
- void EnableTestingMode();
-
- // Helper function invoked when mouse movement is detected. Factoring out this
- // function allows for unit testing without actually tracking the mouse
- // movements.
- void HandleMouseMovement(const gfx::Point& mouse_position);
-
- protected:
- PanelMouseWatcher();
-
- // Starts tracking mouse movements.
- virtual void Start() = 0;
-
- // Stops tracking mouse movements.
- virtual void Stop() = 0;
-
- private:
- // Stores the action requested of PanelManager on the last timer callback.
- // Used to avoid sending redundant requests to PanelManager.
- bool bring_up_titlebar_;
-
- // The set of subscribers currently registered. The mouse watcher is started
- // when the first subscriber is registered and stopped when the last
- // subscriber is unregistered.
- base::hash_set<NativePanel*> subscribers_;
-
- // If set to true, ignore all Start/Stop requests. Used for unit testing.
- bool is_testing_mode_enabled_;
-};
-
-// TODO(jianli): Delete this when mouse watcher for windows starts using this
-// interface.
-#if defined(OS_WIN)
-
-// static
-inline PanelMouseWatcher* PanelMouseWatcher::GetInstance() {
- return NULL;
-}
-
-#endif // OS_WIN
-
-#endif // CHROME_BROWSER_UI_PANELS_PANEL_MOUSE_WATCHER_H_
diff --git a/chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc b/chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc
deleted file mode 100644
index 9ae6002..0000000
--- a/chrome/browser/ui/panels/panel_mouse_watcher_gtk.cc
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// #include "chrome/browser/ui/panels/panel_mouse_watcher_gtk.h"
-
-#include "base/memory/singleton.h"
-#include "base/time.h"
-#include "base/timer.h"
-#include "chrome/browser/ui/panels/panel_manager.h"
-#include "chrome/browser/ui/panels/panel_mouse_watcher.h"
-#include "ui/gfx/screen.h"
-
-// A timer based implementation of PanelMouseWatcher. Currently used on Gtk
-// but could be used on any platform.
-class PanelMouseWatcherGtk : public PanelMouseWatcher {
- public:
- // Returns the singleton instance.
- static PanelMouseWatcherGtk* GetInstance();
-
- virtual ~PanelMouseWatcherGtk();
-
- protected:
- virtual void Start();
- virtual void Stop();
-
- private:
- // Specifies the rate at which we want to sample the mouse position.
- static const int kMousePollingIntervalMs = 250;
-
- PanelMouseWatcherGtk();
- friend struct DefaultSingletonTraits<PanelMouseWatcherGtk>;
-
- // Timer callback function.
- void DoWork();
- friend class base::RepeatingTimer<PanelMouseWatcherGtk>;
-
- // Timer used to track mouse movements. Gtk does not provide an easy way of
- // tracking mouse movements across applications. So we use a timer to
- // accomplish the same. This could also be more efficient as you end up
- // getting a lot of notifications when tracking mouse movements.
- base::RepeatingTimer<PanelMouseWatcherGtk> timer_;
-
- DISALLOW_COPY_AND_ASSIGN(PanelMouseWatcherGtk);
-};
-
-// static
-PanelMouseWatcher* PanelMouseWatcher::GetInstance() {
- return PanelMouseWatcherGtk::GetInstance();
-}
-
-// static
-PanelMouseWatcherGtk* PanelMouseWatcherGtk::GetInstance() {
- return Singleton<PanelMouseWatcherGtk>::get();
-}
-
-PanelMouseWatcherGtk::PanelMouseWatcherGtk() : PanelMouseWatcher() {
-}
-
-PanelMouseWatcherGtk::~PanelMouseWatcherGtk() {
-}
-
-void PanelMouseWatcherGtk::Start() {
- DCHECK(!timer_.IsRunning());
- timer_.Start(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kMousePollingIntervalMs),
- this, &PanelMouseWatcherGtk::DoWork);
-}
-
-void PanelMouseWatcherGtk::Stop() {
- DCHECK(timer_.IsRunning());
- timer_.Stop();
-}
-
-void PanelMouseWatcherGtk::DoWork() {
- HandleMouseMovement(gfx::Screen::GetCursorScreenPoint());
-}