summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 19:40:09 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-29 19:40:09 +0000
commitc2ab7327dc1fa24ec753b098e1e902b1bab4d936 (patch)
tree2c93e57fbbed199632daf53f5136eecb1a20c6a8
parent4309aee5e93a20a7dbc438a762caf94ffb0aed11 (diff)
downloadchromium_src-c2ab7327dc1fa24ec753b098e1e902b1bab4d936.zip
chromium_src-c2ab7327dc1fa24ec753b098e1e902b1bab4d936.tar.gz
chromium_src-c2ab7327dc1fa24ec753b098e1e902b1bab4d936.tar.bz2
Two changes:
. Removes MoveToFront on Widget. . CHanges AsWindow to GetWindow. BUG=none TEST=none Review URL: http://codereview.chromium.org/99133 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14868 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/external_tab_container.cc3
-rw-r--r--chrome/browser/external_tab_container.h1
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc2
-rw-r--r--chrome/browser/views/tabs/tab_renderer.cc8
-rw-r--r--chrome/browser/views/tabs/tab_strip.cc2
-rw-r--r--chrome/browser/views/toolbar_view.cc6
-rw-r--r--chrome/views/widget/widget.h12
-rw-r--r--chrome/views/widget/widget_gtk.cc5
-rw-r--r--chrome/views/widget/widget_gtk.h1
-rw-r--r--chrome/views/widget/widget_win.cc38
-rw-r--r--chrome/views/widget/widget_win.h11
-rw-r--r--chrome/views/window/non_client_view.cc2
-rw-r--r--chrome/views/window/window_win.cc1
-rw-r--r--chrome/views/window/window_win.h4
14 files changed, 52 insertions, 44 deletions
diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc
index 8bcdead..5e4a78e 100644
--- a/chrome/browser/external_tab_container.cc
+++ b/chrome/browser/external_tab_container.cc
@@ -316,9 +316,6 @@ void ExternalTabContainer::GetBounds(gfx::Rect* out,
*out = gfx::Rect(crect);
}
-void ExternalTabContainer::MoveToFront(bool should_activate) {
-}
-
gfx::NativeView ExternalTabContainer::GetNativeView() const {
return m_hWnd;
}
diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h
index 2d0b9bd..395ae266 100644
--- a/chrome/browser/external_tab_container.h
+++ b/chrome/browser/external_tab_container.h
@@ -104,7 +104,6 @@ class ExternalTabContainer : public TabContentsDelegate,
// views::Widget
/////////////////////////////////////////////////////////////////////////////
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
- virtual void MoveToFront(bool should_activate);
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
virtual views::RootView* GetRootView();
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 7c75d2f..dd4a2e11 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -723,7 +723,7 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip,
tab->SetVisible(false);
// Move the corresponding window to the front.
- attached_tabstrip_->GetWidget()->MoveToFront(true);
+ attached_tabstrip_->GetWidget()->GetWindow()->Activate();
}
void DraggedTabController::Detach() {
diff --git a/chrome/browser/views/tabs/tab_renderer.cc b/chrome/browser/views/tabs/tab_renderer.cc
index 88033a4..047da51 100644
--- a/chrome/browser/views/tabs/tab_renderer.cc
+++ b/chrome/browser/views/tabs/tab_renderer.cc
@@ -507,8 +507,10 @@ void TabRenderer::OnMouseExited(const views::MouseEvent& e) {
}
void TabRenderer::ThemeChanged() {
- if (GetWidget() && GetWidget()->AsWindow())
- LoadTabImages(GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame());
+ if (GetWidget() && GetWidget()->GetWindow()) {
+ LoadTabImages(
+ GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame());
+ }
View::ThemeChanged();
}
@@ -543,7 +545,7 @@ void TabRenderer::PaintTabBackground(ChromeCanvas* canvas) {
animation = pulse_animation_.get();
if (animation->GetCurrentValue() > 0) {
PaintHoverTabBackground(canvas, animation->GetCurrentValue() *
- (GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame() ?
+ (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ?
kHoverOpacityVista : kHoverOpacity));
} else {
PaintInactiveTabBackground(canvas);
diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc
index 60c6268..51ff414 100644
--- a/chrome/browser/views/tabs/tab_strip.cc
+++ b/chrome/browser/views/tabs/tab_strip.cc
@@ -601,7 +601,7 @@ void TabStrip::PaintChildren(ChromeCanvas* canvas) {
}
}
- if (GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame()) {
+ if (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame()) {
// Make sure unselected tabs are somewhat transparent.
SkPaint paint;
paint.setColor(SkColorSetARGB(200, 255, 255, 255));
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 4757920..f4270aa 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -399,7 +399,7 @@ void BrowserToolbarView::Paint(ChromeCanvas* canvas) {
// For glass, we need to draw a black line below the location bar to separate
// it from the content area. For non-glass, the NonClientView draws the
// toolbar background below the location bar for us.
- if (GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame())
+ if (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame())
canvas->FillRectInt(SK_ColorBLACK, 0, height() - 1, width(), 1);
}
@@ -554,7 +554,7 @@ gfx::Size BrowserToolbarView::GetPreferredSize() {
}
int vertical_spacing = PopupTopSpacing() +
- (GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame() ?
+ (GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ?
kPopupBottomSpacingGlass : kPopupBottomSpacingNonGlass);
return gfx::Size(0, location_bar_->GetPreferredSize().height() +
vertical_spacing);
@@ -883,7 +883,7 @@ gfx::Rect BrowserToolbarView::GetPopupBounds() const {
// static
int BrowserToolbarView::PopupTopSpacing() {
- return GetWidget()->AsWindow()->GetNonClientView()->UseNativeFrame() ?
+ return GetWidget()->GetWindow()->GetNonClientView()->UseNativeFrame() ?
0 : kPopupTopSpacingNonGlass;
}
diff --git a/chrome/views/widget/widget.h b/chrome/views/widget/widget.h
index 40b153e..1b390bc 100644
--- a/chrome/views/widget/widget.h
+++ b/chrome/views/widget/widget.h
@@ -44,10 +44,6 @@ class Widget {
// including_frame is ignored.
virtual void GetBounds(gfx::Rect* out, bool including_frame) const = 0;
- // Moves this Widget to the front of the Z-Order If should_activate is TRUE,
- // the window should also become the active window.
- virtual void MoveToFront(bool should_activate) = 0;
-
// Returns the gfx::NativeView associated with this Widget.
virtual gfx::NativeView GetNativeView() const = 0;
@@ -74,10 +70,10 @@ class Widget {
virtual bool GetAccelerator(int cmd_id,
Accelerator* accelerator) = 0;
- // Returns the Widget as a Window, if such a conversion is possible, or NULL
- // if it is not.
- virtual Window* AsWindow() { return NULL; }
- virtual const Window* AsWindow() const { return NULL; }
+ // Returns the Window containing this Widget, or NULL if not contained in a
+ // window.
+ virtual Window* GetWindow() { return NULL; }
+ virtual const Window* GetWindow() const { return NULL; }
};
} // namespace views
diff --git a/chrome/views/widget/widget_gtk.cc b/chrome/views/widget/widget_gtk.cc
index 3e51d77..4fc51d9 100644
--- a/chrome/views/widget/widget_gtk.cc
+++ b/chrome/views/widget/widget_gtk.cc
@@ -122,11 +122,6 @@ void WidgetGtk::GetBounds(gfx::Rect* out, bool including_frame) const {
NOTIMPLEMENTED();
}
-void WidgetGtk::MoveToFront(bool should_activate) {
- // TODO(erg): I'm not sure about how to do z-ordering on GTK widgets...
- NOTIMPLEMENTED();
-}
-
gfx::NativeView WidgetGtk::GetNativeView() const {
return widget_;
}
diff --git a/chrome/views/widget/widget_gtk.h b/chrome/views/widget/widget_gtk.h
index aedac31..e29a869 100644
--- a/chrome/views/widget/widget_gtk.h
+++ b/chrome/views/widget/widget_gtk.h
@@ -37,7 +37,6 @@ class WidgetGtk : public Widget {
// Overridden from Widget:
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
- virtual void MoveToFront(bool should_activate);
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
virtual RootView* GetRootView();
diff --git a/chrome/views/widget/widget_win.cc b/chrome/views/widget/widget_win.cc
index bdd709f..3de8958 100644
--- a/chrome/views/widget/widget_win.cc
+++ b/chrome/views/widget/widget_win.cc
@@ -18,6 +18,7 @@
#include "chrome/views/widget/aero_tooltip_manager.h"
#include "chrome/views/widget/hwnd_notification_source.h"
#include "chrome/views/widget/root_view.h"
+#include "chrome/views/window/window_win.h"
namespace views {
@@ -145,6 +146,7 @@ WidgetWin::WidgetWin()
can_update_layered_window_(true),
last_mouse_event_was_move_(false),
is_mouse_down_(false),
+ is_window_(false),
class_style_(CS_DBLCLKS),
hwnd_(NULL) {
}
@@ -252,20 +254,6 @@ void WidgetWin::GetBounds(gfx::Rect* out, bool including_frame) const {
crect.Width(), crect.Height());
}
-void WidgetWin::MoveToFront(bool should_activate) {
- int flags = SWP_NOMOVE | SWP_NOSIZE;
- if (!should_activate) {
- flags |= SWP_NOACTIVATE;
- }
-
- // Keep the window topmost if it was already topmost.
- WINDOWINFO wi;
- wi.cbSize = sizeof WINDOWINFO;
- GetWindowInfo(GetNativeView(), &wi);
- SetWindowPos((wi.dwExStyle & WS_EX_TOPMOST) ? HWND_TOPMOST : HWND_NOTOPMOST,
- 0, 0, 0, 0, flags);
-}
-
gfx::NativeView WidgetWin::GetNativeView() const {
return hwnd_;
}
@@ -319,6 +307,13 @@ TooltipManager* WidgetWin::GetTooltipManager() {
return tooltip_manager_.get();
}
+Window* WidgetWin::GetWindow() {
+ return GetWindowImpl(hwnd_);
+}
+
+const Window* WidgetWin::GetWindow() const {
+ return GetWindowImpl(hwnd_);
+}
void WidgetWin::SetLayeredAlpha(BYTE layered_alpha) {
layered_alpha_ = layered_alpha;
@@ -850,6 +845,21 @@ RootView* WidgetWin::CreateRootView() {
///////////////////////////////////////////////////////////////////////////////
// WidgetWin, private:
+// static
+Window* WidgetWin::GetWindowImpl(HWND hwnd) {
+ // NOTE: we can't use GetAncestor here as constrained windows are a Window,
+ // but not a top level window.
+ HWND parent = hwnd;
+ while (parent) {
+ WidgetWin* widget =
+ reinterpret_cast<WidgetWin*>(win_util::GetWindowUserData(parent));
+ if (widget && widget->is_window_)
+ return static_cast<WindowWin*>(widget);
+ parent = ::GetParent(parent);
+ }
+ return NULL;
+}
+
void WidgetWin::SizeContents(const CRect& window_rect) {
contents_.reset(new ChromeCanvas(window_rect.Width(),
window_rect.Height(),
diff --git a/chrome/views/widget/widget_win.h b/chrome/views/widget/widget_win.h
index 110a0b4..00ecb93 100644
--- a/chrome/views/widget/widget_win.h
+++ b/chrome/views/widget/widget_win.h
@@ -24,6 +24,7 @@ namespace views {
class RootView;
class TooltipManager;
+class Window;
bool SetRootViewForHWND(HWND hwnd, RootView* root_view);
RootView* GetRootViewForHWND(HWND hwnd);
@@ -231,13 +232,14 @@ class WidgetWin : public Widget,
// Overridden from Widget:
virtual void GetBounds(gfx::Rect* out, bool including_frame) const;
- virtual void MoveToFront(bool should_activate);
virtual gfx::NativeView GetNativeView() const;
virtual void PaintNow(const gfx::Rect& update_rect);
virtual RootView* GetRootView();
virtual bool IsVisible() const;
virtual bool IsActive() const;
virtual TooltipManager* GetTooltipManager();
+ virtual Window* GetWindow();
+ virtual const Window* GetWindow() const;
// Overridden from MessageLoop::Observer:
void WillProcessMessage(const MSG& msg);
@@ -529,7 +531,14 @@ class WidgetWin : public Widget,
scoped_ptr<TooltipManager> tooltip_manager_;
+ // Are a subclass of WindowWin?
+ bool is_window_;
+
private:
+ // Implementation of GetWindow. Ascends the parents of |hwnd| returning the
+ // first ancestor that is a Window.
+ static Window* GetWindowImpl(HWND hwnd);
+
// Resize the bitmap used to contain the contents of the layered window. This
// recreates the entire bitmap.
void SizeContents(const CRect& window_rect);
diff --git a/chrome/views/window/non_client_view.cc b/chrome/views/window/non_client_view.cc
index 29daf06..9402adf 100644
--- a/chrome/views/window/non_client_view.cc
+++ b/chrome/views/window/non_client_view.cc
@@ -191,7 +191,7 @@ views::View* NonClientView::GetViewForPoint(const gfx::Point& point,
bool NonClientFrameView::HitTest(const gfx::Point& l) const {
// For the default case, we assume the non-client frame view never overlaps
// the client view.
- return !GetWidget()->AsWindow()->GetClientView()->bounds().Contains(l);
+ return !GetWidget()->GetWindow()->GetClientView()->bounds().Contains(l);
}
void NonClientFrameView::DidChangeBounds(const gfx::Rect& previous,
diff --git a/chrome/views/window/window_win.cc b/chrome/views/window/window_win.cc
index 8c03219..8a53e2f 100644
--- a/chrome/views/window/window_win.cc
+++ b/chrome/views/window/window_win.cc
@@ -467,6 +467,7 @@ WindowWin::WindowWin(WindowDelegate* window_delegate)
ignore_pos_changes_factory_(this),
force_hidden_count_(0),
last_monitor_(NULL) {
+ is_window_ = true;
InitClass();
DCHECK(window_delegate_);
window_delegate_->window_.reset(this);
diff --git a/chrome/views/window/window_win.h b/chrome/views/window/window_win.h
index 222ac52..239e17e 100644
--- a/chrome/views/window/window_win.h
+++ b/chrome/views/window/window_win.h
@@ -147,8 +147,8 @@ class WindowWin : public WidgetWin,
virtual void OnSize(UINT size_param, const CSize& new_size);
virtual void OnSysCommand(UINT notification_code, CPoint click);
virtual void OnWindowPosChanging(WINDOWPOS* window_pos);
- virtual Window* AsWindow() { return this; }
- virtual const Window* AsWindow() const { return this; }
+ virtual Window* GetWindow() { return this; }
+ virtual const Window* GetWindow() const { return this; }
// Accessor for disable_inactive_rendering_.
bool disable_inactive_rendering() const {