summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-14 01:18:00 +0000
committerderat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-14 01:18:00 +0000
commitb8595e9c25fc47e4e0e91683b38f4772b4789f1b (patch)
tree9cc63c58e432b835a3af85ac89d4cd9df0d33aa9 /chrome/browser/views
parent5da4928116a7168b456415f9af412f93138b6dcb (diff)
downloadchromium_src-b8595e9c25fc47e4e0e91683b38f4772b4789f1b.zip
chromium_src-b8595e9c25fc47e4e0e91683b38f4772b4789f1b.tar.gz
chromium_src-b8595e9c25fc47e4e0e91683b38f4772b4789f1b.tar.bz2
gtk: Hide the status bubble when the mouse nears it.
This isn't as slick as other platforms, in that the bubble just slides down and gets cropped instead of sliding down out of the browser window -- doing the latter will probably require reparenting the bubble into its own window when we want to move it. BUG=18311 TEST=ran "nc -l -p 8080", went to localhost:8080, and made sure that the bubble ran away with both LTR and RTL languages Review URL: http://codereview.chromium.org/392007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31984 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/status_bubble_views.cc35
-rw-r--r--chrome/browser/views/status_bubble_views.h7
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_gtk.cc10
-rw-r--r--chrome/browser/views/tab_contents/tab_contents_view_win.cc10
4 files changed, 36 insertions, 26 deletions
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 9642294..fbf8153 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -11,6 +11,7 @@
#include "app/l10n_util.h"
#include "app/animation.h"
#include "app/resource_bundle.h"
+#include "base/gfx/point.h"
#include "base/message_loop.h"
#include "base/string_util.h"
#include "chrome/browser/browser_theme_provider.h"
@@ -572,14 +573,18 @@ void StatusBubbleViews::Hide() {
view_->Hide();
}
-void StatusBubbleViews::MouseMoved() {
+void StatusBubbleViews::MouseMoved(const gfx::Point& location,
+ bool left_content) {
+ if (left_content)
+ return;
+
if (view_) {
view_->ResetTimer();
if (view_->GetState() != StatusView::BUBBLE_HIDDEN &&
view_->GetState() != StatusView::BUBBLE_HIDING_FADE &&
view_->GetState() != StatusView::BUBBLE_HIDING_TIMER) {
- AvoidMouse();
+ AvoidMouse(location);
}
}
}
@@ -588,42 +593,40 @@ void StatusBubbleViews::UpdateDownloadShelfVisibility(bool visible) {
download_shelf_is_visible_ = visible;
}
-void StatusBubbleViews::AvoidMouse() {
+void StatusBubbleViews::AvoidMouse(const gfx::Point& location) {
// Get the position of the frame.
gfx::Point top_left;
views::RootView* root = frame_->GetRootView();
views::View::ConvertPointToScreen(root, &top_left);
int window_width = root->GetLocalBounds(true).width(); // border included.
- // Our status bubble is located in screen coordinates, so we should get
- // those rather than attempting to reverse decode the web contents
- // coordinates.
- gfx::Point cursor_location = views::Screen::GetCursorScreenPoint();
-
// Get the cursor position relative to the popup.
+ gfx::Point relative_location = location;
if (view_->UILayoutIsRightToLeft()) {
int top_right_x = top_left.x() + window_width;
- cursor_location.set_x(top_right_x - cursor_location.x());
+ relative_location.set_x(top_right_x - relative_location.x());
} else {
- cursor_location.set_x(cursor_location.x() - (top_left.x() + position_.x()));
+ relative_location.set_x(
+ relative_location.x() - (top_left.x() + position_.x()));
}
- cursor_location.set_y(cursor_location.y() - (top_left.y() + position_.y()));
+ relative_location.set_y(
+ relative_location.y() - (top_left.y() + position_.y()));
// If the mouse is in a position where we think it would move the
// status bubble, figure out where and how the bubble should be moved.
- if (cursor_location.y() > -kMousePadding &&
- cursor_location.x() < size_.width() + kMousePadding) {
- int offset = kMousePadding + cursor_location.y();
+ if (relative_location.y() > -kMousePadding &&
+ relative_location.x() < size_.width() + kMousePadding) {
+ int offset = kMousePadding + relative_location.y();
// Make the movement non-linear.
offset = offset * offset / kMousePadding;
// When the mouse is entering from the right, we want the offset to be
// scaled by how horizontally far away the cursor is from the bubble.
- if (cursor_location.x() > size_.width()) {
+ if (relative_location.x() > size_.width()) {
offset = static_cast<int>(static_cast<float>(offset) * (
static_cast<float>(kMousePadding -
- (cursor_location.x() - size_.width())) /
+ (relative_location.x() - size_.width())) /
static_cast<float>(kMousePadding)));
}
diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h
index 06bf6bd..78d3265 100644
--- a/chrome/browser/views/status_bubble_views.h
+++ b/chrome/browser/views/status_bubble_views.h
@@ -11,6 +11,9 @@
#include "chrome/browser/status_bubble.h"
class GURL;
+namespace gfx {
+class Point;
+}
namespace views {
class Widget;
}
@@ -44,7 +47,7 @@ class StatusBubbleViews : public StatusBubble {
virtual void SetStatus(const std::wstring& status);
virtual void SetURL(const GURL& url, const std::wstring& languages);
virtual void Hide();
- virtual void MouseMoved();
+ virtual void MouseMoved(const gfx::Point& location, bool left_content);
virtual void UpdateDownloadShelfVisibility(bool visible);
private:
@@ -55,7 +58,7 @@ class StatusBubbleViews : public StatusBubble {
// Attempt to move the status bubble out of the way of the cursor, allowing
// users to see links in the region normally occupied by the status bubble.
- void AvoidMouse();
+ void AvoidMouse(const gfx::Point& location);
// Returns true if the frame_ is visible and not minimized.
bool IsFrameVisible();
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
index fce6c9c..7db5ad4 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_gtk.cc
@@ -26,8 +26,9 @@
#include "chrome/browser/views/blocked_popup_container_view_views.h"
#include "chrome/browser/views/sad_tab_view.h"
#include "chrome/browser/views/tab_contents/render_view_context_menu_win.h"
-#include "views/focus/view_storage.h"
#include "views/controls/native/native_view_host.h"
+#include "views/focus/view_storage.h"
+#include "views/screen.h"
#include "views/widget/root_view.h"
using WebKit::WebDragOperation;
@@ -62,7 +63,8 @@ gboolean OnFocus(GtkWidget* widget, GtkDirectionType focus,
gboolean OnLeaveNotify2(GtkWidget* widget, GdkEventCrossing* event,
TabContents* tab_contents) {
if (tab_contents->delegate())
- tab_contents->delegate()->ContentsMouseEvent(tab_contents, false);
+ tab_contents->delegate()->ContentsMouseEvent(
+ tab_contents, views::Screen::GetCursorScreenPoint(), false);
return FALSE;
}
@@ -70,7 +72,8 @@ gboolean OnLeaveNotify2(GtkWidget* widget, GdkEventCrossing* event,
gboolean OnMouseMove(GtkWidget* widget, GdkEventMotion* event,
TabContents* tab_contents) {
if (tab_contents->delegate())
- tab_contents->delegate()->ContentsMouseEvent(tab_contents, true);
+ tab_contents->delegate()->ContentsMouseEvent(
+ tab_contents, views::Screen::GetCursorScreenPoint(), true);
return FALSE;
}
@@ -423,4 +426,3 @@ void TabContentsViewGtk::SetFloatingPosition(const gfx::Size& size) {
PositionChild(widget, child_x, 0, requisition.width, requisition.height);
}
}
-
diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
index a0a0beb..9c79650 100644
--- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc
+++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc
@@ -31,6 +31,7 @@
#include "chrome/common/url_constants.h"
#include "net/base/net_util.h"
#include "views/focus/view_storage.h"
+#include "views/screen.h"
#include "views/widget/root_view.h"
#include "webkit/glue/webdropdata.h"
@@ -474,7 +475,8 @@ void TabContentsViewWin::OnMouseLeave() {
// Let our delegate know that the mouse moved (useful for resetting status
// bubble state).
if (tab_contents()->delegate())
- tab_contents()->delegate()->ContentsMouseEvent(tab_contents(), false);
+ tab_contents()->delegate()->ContentsMouseEvent(
+ tab_contents(), views::Screen::GetCursorScreenPoint(), false);
SetMsgHandled(FALSE);
}
@@ -496,9 +498,9 @@ LRESULT TabContentsViewWin::OnMouseRange(UINT msg,
case WM_MOUSEMOVE:
// Let our delegate know that the mouse moved (useful for resetting status
// bubble state).
- if (tab_contents()->delegate()) {
- tab_contents()->delegate()->ContentsMouseEvent(tab_contents(), true);
- }
+ if (tab_contents()->delegate())
+ tab_contents()->delegate()->ContentsMouseEvent(
+ tab_contents(), views::Screen::GetCursorScreenPoint(), true);
break;
default:
break;