summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 21:30:41 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-21 21:30:41 +0000
commitcbd7dcc7c93c7e73443abd6ddc6c140e2e7e98fd (patch)
treea5621b3aea39636f2e10399223097577b71f5bb5 /chrome/browser/views
parentdd6ef5991cf5f4b2b822db46832e0d78874efc24 (diff)
downloadchromium_src-cbd7dcc7c93c7e73443abd6ddc6c140e2e7e98fd.zip
chromium_src-cbd7dcc7c93c7e73443abd6ddc6c140e2e7e98fd.tar.gz
chromium_src-cbd7dcc7c93c7e73443abd6ddc6c140e2e7e98fd.tar.bz2
Gets status bubbles on views/gtk to correctly track when the parent
window is hidden/minimized/moved. This is made tricky by the fact that gtk doesn't have the notion of owned windows that automatically hidden along with the parent as windows does. BUG=none TEST=none directly, although covered by ui tests. Review URL: http://codereview.chromium.org/304008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29710 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.cc19
-rw-r--r--chrome/browser/views/frame/browser_frame_gtk.h6
-rw-r--r--chrome/browser/views/status_bubble_views.cc24
-rw-r--r--chrome/browser/views/status_bubble_views.h3
4 files changed, 50 insertions, 2 deletions
diff --git a/chrome/browser/views/frame/browser_frame_gtk.cc b/chrome/browser/views/frame/browser_frame_gtk.cc
index 4b011b0..13b0ce1 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.cc
+++ b/chrome/browser/views/frame/browser_frame_gtk.cc
@@ -6,6 +6,7 @@
#include "base/logging.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/status_bubble.h"
#include "chrome/browser/views/frame/browser_root_view.h"
#include "chrome/browser/views/frame/browser_view.h"
#include "chrome/browser/views/frame/opaque_browser_frame_view.h"
@@ -96,3 +97,21 @@ bool BrowserFrameGtk::GetAccelerator(int cmd_id,
views::Accelerator* accelerator) {
return browser_view_->GetAccelerator(cmd_id, accelerator);
}
+
+gboolean BrowserFrameGtk::OnWindowStateEvent(GtkWidget* widget,
+ GdkEventWindowState* event) {
+ gboolean result = views::WindowGtk::OnWindowStateEvent(widget, event);
+ if ((!IsVisible() || IsMinimized()) && browser_view_->GetStatusBubble()) {
+ // The window is effectively hidden. We have to hide the status bubble as
+ // unlike windows gtk has no notion of child windows that are hidden along
+ // with the parent.
+ browser_view_->GetStatusBubble()->Hide();
+ }
+ return result;
+}
+
+gboolean BrowserFrameGtk::OnConfigureEvent(GtkWidget* widget,
+ GdkEventConfigure* event) {
+ browser_view_->WindowMoved();
+ return views::WindowGtk::OnConfigureEvent(widget, event);
+}
diff --git a/chrome/browser/views/frame/browser_frame_gtk.h b/chrome/browser/views/frame/browser_frame_gtk.h
index 297b3bd..32d7162 100644
--- a/chrome/browser/views/frame/browser_frame_gtk.h
+++ b/chrome/browser/views/frame/browser_frame_gtk.h
@@ -44,6 +44,12 @@ class BrowserFrameGtk : public BrowserFrame,
virtual views::RootView* CreateRootView();
virtual bool GetAccelerator(int cmd_id, views::Accelerator* accelerator);
+ // Overriden from views::WindowGtk:
+ virtual gboolean OnWindowStateEvent(GtkWidget* widget,
+ GdkEventWindowState* event);
+ virtual gboolean OnConfigureEvent(GtkWidget* widget,
+ GdkEventConfigure* event);
+
private:
// The BrowserView is our ClientView. This is a pointer to it.
BrowserView* browser_view_;
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index cd77c45..4ade4e6 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -506,9 +506,15 @@ void StatusBubbleViews::SetBounds(int x, int y, int w, int h) {
}
void StatusBubbleViews::SetStatus(const std::wstring& status_text) {
+ if (size_.IsEmpty())
+ return; // We have no bounds, don't attempt to show the popup.
+
if (status_text_ == status_text)
return;
+ if (!IsFrameVisible())
+ return; // Don't show anything if the parent isn't visible.
+
Init();
status_text_ = status_text;
if (!status_text_.empty()) {
@@ -522,13 +528,17 @@ void StatusBubbleViews::SetStatus(const std::wstring& status_text) {
}
void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) {
+ if (size_.IsEmpty())
+ return; // We have no bounds, don't attempt to show the popup.
+
Init();
// If we want to clear a displayed URL but there is a status still to
// display, display that status instead.
if (url.is_empty() && !status_text_.empty()) {
url_text_ = std::wstring();
- view_->SetText(status_text_);
+ if (IsFrameVisible())
+ view_->SetText(status_text_);
return;
}
@@ -546,7 +556,9 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) {
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT &&
!url_text_.empty())
l10n_util::WrapStringWithLTRFormatting(&url_text_);
- view_->SetText(url_text_);
+
+ if (IsFrameVisible())
+ view_->SetText(url_text_);
}
void StatusBubbleViews::Hide() {
@@ -659,3 +671,11 @@ void StatusBubbleViews::AvoidMouse() {
size_.width(), size_.height()));
}
}
+
+bool StatusBubbleViews::IsFrameVisible() {
+ if (!frame_->IsVisible())
+ return false;
+
+ views::Window* window = frame_->GetWindow();
+ return !window || !window->IsMinimized();
+}
diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h
index 5adb3e0..06bf6bd 100644
--- a/chrome/browser/views/status_bubble_views.h
+++ b/chrome/browser/views/status_bubble_views.h
@@ -57,6 +57,9 @@ class StatusBubbleViews : public StatusBubble {
// users to see links in the region normally occupied by the status bubble.
void AvoidMouse();
+ // Returns true if the frame_ is visible and not minimized.
+ bool IsFrameVisible();
+
// The status text we want to display when there are no URLs to display.
std::wstring status_text_;