diff options
Diffstat (limited to 'chrome/views')
-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 | ||||
-rw-r--r-- | chrome/views/window/non_client_view.cc | 2 | ||||
-rw-r--r-- | chrome/views/window/window_win.cc | 1 | ||||
-rw-r--r-- | chrome/views/window/window_win.h | 4 |
8 files changed, 42 insertions, 32 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); 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 { |