diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 19:40:09 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-29 19:40:09 +0000 |
commit | c2ab7327dc1fa24ec753b098e1e902b1bab4d936 (patch) | |
tree | 2c93e57fbbed199632daf53f5136eecb1a20c6a8 /chrome/views/widget | |
parent | 4309aee5e93a20a7dbc438a762caf94ffb0aed11 (diff) | |
download | chromium_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
Diffstat (limited to 'chrome/views/widget')
-rw-r--r-- | chrome/views/widget/widget.h | 12 | ||||
-rw-r--r-- | chrome/views/widget/widget_gtk.cc | 5 | ||||
-rw-r--r-- | chrome/views/widget/widget_gtk.h | 1 | ||||
-rw-r--r-- | chrome/views/widget/widget_win.cc | 38 | ||||
-rw-r--r-- | chrome/views/widget/widget_win.h | 11 |
5 files changed, 38 insertions, 29 deletions
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); |