diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 15:17:16 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-02 15:17:16 +0000 |
commit | a7859412517983e37dee8fabf398ca27701c5ad0 (patch) | |
tree | 40dfc13819789b8daa3729219022e45babbab704 | |
parent | f67131a62cfde0397fe4f442fdf7aa4925986c73 (diff) | |
download | chromium_src-a7859412517983e37dee8fabf398ca27701c5ad0.zip chromium_src-a7859412517983e37dee8fabf398ca27701c5ad0.tar.gz chromium_src-a7859412517983e37dee8fabf398ca27701c5ad0.tar.bz2 |
Fixes a couple of bugs encountered in getting info bubbles to work:
. Initial bounds of windows weren't being set.
. Widgets were created initially shown. This was bad for windows as
the window would end up showing prematurely.
. WindowGtk::window_state_ wasn't being initialized.
. And then actual InfoBubble stuff: properly init the bubble, show it
and position it on the monitor.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/118102
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17401 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 18 | ||||
-rw-r--r-- | views/widget/widget_gtk.cc | 5 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 1 | ||||
-rw-r--r-- | views/window/window_gtk.h | 3 |
4 files changed, 15 insertions, 12 deletions
diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 2f7091f..908aa54 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -9,6 +9,7 @@ #include "app/resource_bundle.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/views/frame/browser_view.h" +#include "chrome/browser/window_sizer.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "grit/theme_resources.h" @@ -16,7 +17,6 @@ #include "views/window/window.h" #if defined(OS_WIN) -#include "app/win_util.h" #include "base/win_util.h" #endif @@ -83,7 +83,7 @@ InfoBubble* InfoBubble::Show(views::Window* parent, #if defined(OS_WIN) window->ShowWindow(SW_SHOW); #else - NOTREACHED(); + static_cast<WidgetGtk*>(window)->Show(); #endif return window; } @@ -134,6 +134,8 @@ void InfoBubble::Init(views::Window* parent, #if defined(OS_WIN) WidgetWin::Init(parent->GetNativeWindow(), bounds, true); +#else + WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), bounds, true); #endif SetContentsView(content_view_); // The preferred size may differ when parented. Ask for the bounds again @@ -148,8 +150,6 @@ void InfoBubble::Init(views::Window* parent, SWP_NOACTIVATE | SWP_NOREDRAW | SWP_NOZORDER); // Invoke ChangeSize, otherwise layered window isn't updated correctly. ChangeSize(0, CSize(parented_bounds.width(), parented_bounds.height())); -#else - NOTIMPLEMENTED(); #endif } @@ -254,12 +254,10 @@ InfoBubble::ContentView::ContentView(views::View* content, InfoBubble* host) gfx::Rect InfoBubble::ContentView::CalculateWindowBoundsAndAjust( const gfx::Rect& position_relative_to) { -#if defined(OS_WIN) - gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect( - position_relative_to); -#else - gfx::Rect monitor_bounds; -#endif + scoped_ptr<WindowSizer::MonitorInfoProvider> monitor_provider( + WindowSizer::CreateDefaultMonitorInfoProvider()); + gfx::Rect monitor_bounds( + monitor_provider->GetMonitorWorkAreaMatching(position_relative_to)); // Calculate the bounds using TOP_LEFT (the default). gfx::Rect window_bounds = CalculateWindowBounds(position_relative_to); if (monitor_bounds.IsEmpty() || monitor_bounds.Contains(window_bounds)) diff --git a/views/widget/widget_gtk.cc b/views/widget/widget_gtk.cc index 01b6b87..f79601e 100644 --- a/views/widget/widget_gtk.cc +++ b/views/widget/widget_gtk.cc @@ -163,6 +163,10 @@ void WidgetGtk::Init(GtkWidget* parent, parent_widget->AddChild(widget_); parent_widget->PositionChild(widget_, bounds.x(), bounds.y(), bounds.width(), bounds.height()); + } else { + if (bounds.width() > 0 && bounds.height() > 0) + gtk_window_resize(GTK_WINDOW(widget_), bounds.width(), bounds.height()); + gtk_window_move(GTK_WINDOW(widget_), bounds.x(), bounds.y()); } } @@ -364,7 +368,6 @@ void WidgetGtk::CreateGtkWidget() { SetViewForNative(child_widget_parent_, this); } - gtk_widget_show(widget_); } void WidgetGtk::OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation) { diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 3979831..c5b2208 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -189,6 +189,7 @@ WindowGtk::WindowGtk(WindowDelegate* window_delegate) is_modal_(false), window_delegate_(window_delegate), non_client_view_(new NonClientView(this)), + window_state_(GDK_WINDOW_STATE_WITHDRAWN), window_closed_(false) { is_window_ = true; window_delegate_->window_.reset(this); diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index 80ed1dd..a670536 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -96,8 +96,9 @@ class WindowGtk : public WidgetGtk, public Window { // desired implementation before calling |Init|. NonClientView* non_client_view_; - + // State of the window, such as fullscreen, hidden... GdkWindowState window_state_; + // Set to true if the window is in the process of closing. bool window_closed_; |