diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 19:03:31 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 19:03:31 +0000 |
commit | 9a56a0d8a1304ce392580319a066c0c1857a210e (patch) | |
tree | 188158d67d2446f7969f2dff588a6cfa02968974 /views/window | |
parent | 1357ae79b9d474da177632a85227efb676c6d98e (diff) | |
download | chromium_src-9a56a0d8a1304ce392580319a066c0c1857a210e.zip chromium_src-9a56a0d8a1304ce392580319a066c0c1857a210e.tar.gz chromium_src-9a56a0d8a1304ce392580319a066c0c1857a210e.tar.bz2 |
Re-land:
Split the hierarchy.
Now with AutocompletePopup implementing SupportsWeakPtr as before. This fixes the Windows XP crashes in browser_tests.
BUG=72040
TEST=none
Review URL: http://codereview.chromium.org/7015051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r-- | views/window/custom_frame_view.cc | 2 | ||||
-rw-r--r-- | views/window/dialog_client_view.cc | 2 | ||||
-rw-r--r-- | views/window/native_frame_view.cc | 12 | ||||
-rw-r--r-- | views/window/native_frame_view.h | 6 | ||||
-rw-r--r-- | views/window/native_window.h | 7 | ||||
-rw-r--r-- | views/window/native_window_delegate.h | 10 | ||||
-rw-r--r-- | views/window/window.cc | 63 | ||||
-rw-r--r-- | views/window/window.h | 32 | ||||
-rw-r--r-- | views/window/window_gtk.cc | 69 | ||||
-rw-r--r-- | views/window/window_gtk.h | 10 | ||||
-rw-r--r-- | views/window/window_win.cc | 93 | ||||
-rw-r--r-- | views/window/window_win.h | 12 |
12 files changed, 130 insertions, 188 deletions
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc index e86cd10..305eae1 100644 --- a/views/window/custom_frame_view.cc +++ b/views/window/custom_frame_view.cc @@ -236,7 +236,7 @@ gfx::Size CustomFrameView::GetPreferredSize() { void CustomFrameView::ButtonPressed(Button* sender, const views::Event& event) { if (sender == close_button_) - frame_->CloseWindow(); + frame_->Close(); else if (sender == minimize_button_) frame_->Minimize(); else if (sender == maximize_button_) diff --git a/views/window/dialog_client_view.cc b/views/window/dialog_client_view.cc index e2cc5ef..b3b5c9a 100644 --- a/views/window/dialog_client_view.cc +++ b/views/window/dialog_client_view.cc @@ -541,7 +541,7 @@ DialogDelegate* DialogClientView::GetDialogDelegate() const { } void DialogClientView::Close() { - window()->CloseWindow(); + window()->Close(); GetDialogDelegate()->OnClose(); } diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc index 397b6f3..c78d6d1 100644 --- a/views/window/native_frame_view.cc +++ b/views/window/native_frame_view.cc @@ -4,14 +4,16 @@ #include "views/window/native_frame_view.h" -#include "views/window/window_win.h" +#include "views/widget/widget_win.h" +#include "views/window/native_window.h" +#include "views/window/window.h" namespace views { //////////////////////////////////////////////////////////////////////////////// // NativeFrameView, public: -NativeFrameView::NativeFrameView(WindowWin* frame) +NativeFrameView::NativeFrameView(Window* frame) : NonClientFrameView(), frame_(frame) { } @@ -29,8 +31,10 @@ gfx::Rect NativeFrameView::GetBoundsForClientView() const { gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( const gfx::Rect& client_bounds) const { RECT rect = client_bounds.ToRECT(); - AdjustWindowRectEx(&rect, frame_->window_style(), FALSE, - frame_->window_ex_style()); + WidgetWin* widget_win = + static_cast<WidgetWin*>(frame_->native_window()->AsNativeWidget()); + AdjustWindowRectEx(&rect, widget_win->window_style(), FALSE, + widget_win->window_ex_style()); return gfx::Rect(rect); } diff --git a/views/window/native_frame_view.h b/views/window/native_frame_view.h index ac68ddf..9bc943f 100644 --- a/views/window/native_frame_view.h +++ b/views/window/native_frame_view.h @@ -10,11 +10,11 @@ namespace views { -class WindowWin; +class Window; class NativeFrameView : public NonClientFrameView { public: - explicit NativeFrameView(WindowWin* frame); + explicit NativeFrameView(Window* frame); virtual ~NativeFrameView(); // NonClientFrameView overrides: @@ -33,7 +33,7 @@ class NativeFrameView : public NonClientFrameView { private: // Our containing frame. - WindowWin* frame_; + Window* frame_; DISALLOW_COPY_AND_ASSIGN(NativeFrameView); }; diff --git a/views/window/native_window.h b/views/window/native_window.h index 63da12a..0e83f30 100644 --- a/views/window/native_window.h +++ b/views/window/native_window.h @@ -37,9 +37,13 @@ class NativeWindow { virtual ~NativeWindow() {} - static Window* CreateNativeWindow(); + // Creates an appropriate default NativeWindow implementation for the current + // OS/circumstance. + static NativeWindow* CreateNativeWindow( + internal::NativeWindowDelegate* delegate); virtual Window* GetWindow() = 0; + virtual const Window* GetWindow() const = 0; virtual NativeWidget* AsNativeWidget() = 0; virtual const NativeWidget* AsNativeWidget() const = 0; @@ -100,7 +104,6 @@ class NativeWindow { virtual void SetFullscreen(bool fullscreen) = 0; virtual bool IsFullscreen() const = 0; virtual void SetAlwaysOnTop(bool always_on_top) = 0; - virtual bool IsAppWindow() const = 0; virtual void SetUseDragFrame(bool use_drag_frame) = 0; virtual NonClientFrameView* CreateFrameViewForWindow() = 0; virtual void UpdateFrameAfterFrameChange() = 0; diff --git a/views/window/native_window_delegate.h b/views/window/native_window_delegate.h index 23705a5..c88924b 100644 --- a/views/window/native_window_delegate.h +++ b/views/window/native_window_delegate.h @@ -6,6 +6,10 @@ #define VIEWS_WIDGET_NATIVE_WINDOW_DELEGATE_H_ #pragma once +namespace ui { +class ThemeProvider; +} + namespace views { namespace internal { @@ -64,6 +68,12 @@ class NativeWindowDelegate { // Called when the native window's position or size has changed. virtual void OnNativeWindowBoundsChanged() = 0; + + // + virtual Window* AsWindow() = 0; + + // + virtual NativeWidgetDelegate* AsNativeWidgetDelegate() = 0; }; } // namespace internal diff --git a/views/window/window.cc b/views/window/window.cc index 13f2515..efc9f15 100644 --- a/views/window/window.cc +++ b/views/window/window.cc @@ -47,7 +47,7 @@ Window::~Window() { Window* Window::CreateChromeWindow(gfx::NativeWindow parent, const gfx::Rect& bounds, WindowDelegate* window_delegate) { - Window* window = NativeWindow::CreateNativeWindow(); + Window* window = new Window; Window::InitParams params(window_delegate); params.parent_window = parent; params.widget_init_params.bounds = bounds; @@ -74,34 +74,24 @@ gfx::Size Window::GetLocalizedContentsSize(int col_resource_id, GetLocalizedContentsHeight(row_resource_id)); } -// static -void Window::CloseSecondaryWidget(Widget* widget) { - if (!widget) - return; - - // Close widget if it's identified as a secondary window. - Window* window = widget->GetWindow(); - if (window) { - if (!window->IsAppWindow()) - window->CloseWindow(); - } else { - // If it's not a Window, then close it anyway since it probably is - // secondary. - widget->Close(); - } -} - void Window::InitWindow(const InitParams& params) { window_delegate_ = params.window_delegate; AsWidget()->set_widget_delegate(window_delegate_); DCHECK(window_delegate_); DCHECK(!window_delegate_->window_); window_delegate_->window_ = this; + set_widget_delegate(window_delegate_); + native_window_ = + params.native_window ? params.native_window + : NativeWindow::CreateNativeWindow(this); // If frame_view was set already, don't replace it with default one. if (!non_client_view()->frame_view()) non_client_view()->SetFrameView(CreateFrameViewForWindow()); - AsWidget()->Init(params.widget_init_params); - OnNativeWindowCreated(params.widget_init_params.bounds); + InitParams modified_params = params; + modified_params.widget_init_params.native_widget = + native_window_->AsNativeWidget(); + Init(modified_params.widget_init_params); + OnNativeWindowCreated(modified_params.widget_init_params.bounds); } gfx::Rect Window::GetBounds() const { @@ -149,7 +139,7 @@ void Window::Deactivate() { native_window_->Deactivate(); } -void Window::CloseWindow() { +void Window::Close() { if (window_closed_) { // It appears we can hit this code path if you close a modal dialog then // close the last browser before the destructor is hit, which triggers @@ -159,9 +149,7 @@ void Window::CloseWindow() { if (non_client_view_->CanClose()) { SaveWindowPosition(); - // TODO(beng): This can be simplified to Widget::Close() once Window - // subclasses Widget. - native_window_->AsNativeWidget()->GetWidget()->Close(); + Widget::Close(); window_closed_ = true; } } @@ -206,10 +194,6 @@ void Window::SetUseDragFrame(bool use_drag_frame) { native_window_->SetUseDragFrame(use_drag_frame); } -bool Window::IsAppWindow() const { - return native_window_->IsAppWindow(); -} - void Window::EnableClose(bool enable) { non_client_view_->EnableClose(enable); native_window_->EnableClose(enable); @@ -261,21 +245,6 @@ void Window::FrameTypeChanged() { native_window_->FrameTypeChanged(); } -Widget* Window::AsWidget() { - return const_cast<Widget*>(const_cast<const Window*>(this)->AsWidget()); -} - -const Widget* Window::AsWidget() const { - return native_window_->AsNativeWidget()->GetWidget(); -} - -//////////////////////////////////////////////////////////////////////////////// -// Window, protected: - -void Window::SetNativeWindow(NativeWindow* native_window) { - native_window_ = native_window; -} - //////////////////////////////////////////////////////////////////////////////// // Window, internal::NativeWindowDelegate implementation: @@ -364,6 +333,14 @@ void Window::OnNativeWindowBoundsChanged() { SaveWindowPosition(); } +Window* Window::AsWindow() { + return this; +} + +internal::NativeWidgetDelegate* Window::AsNativeWidgetDelegate() { + return this; +} + //////////////////////////////////////////////////////////////////////////////// // Window, private: diff --git a/views/window/window.h b/views/window/window.h index 76fdb76..191aba4 100644 --- a/views/window/window.h +++ b/views/window/window.h @@ -39,7 +39,8 @@ class WindowDelegate; // implementation. Multiple inheritance is required for this // transitional step. // -class Window : public internal::NativeWindowDelegate { +class Window : public Widget, + public internal::NativeWindowDelegate { public: struct InitParams { // |window_delegate| cannot be NULL. @@ -71,16 +72,6 @@ class Window : public internal::NativeWindowDelegate { static gfx::Size GetLocalizedContentsSize(int col_resource_id, int row_resource_id); - // Closes all windows that aren't identified as "app windows" via - // IsAppWindow. Called during application shutdown when the last "app window" - // is closed. - static void CloseAllSecondaryWindows(); - - // Used by |CloseAllSecondaryWindows|. If |widget|'s window is a secondary - // window, the window is closed. If |widget| has no window, it is closed. - // Does nothing if |widget| is null. - static void CloseSecondaryWidget(Widget* widget); - // Initializes the window. Must be called before any post-configuration // operations are performed. void InitWindow(const InitParams& params); @@ -124,7 +115,7 @@ class Window : public internal::NativeWindowDelegate { // Closes the window, ultimately destroying it. The window hides immediately, // and is destroyed after a return to the message loop. Close() can be called // multiple times. - void CloseWindow(); + virtual void Close() OVERRIDE; // Maximizes/minimizes/restores the window. void Maximize(); @@ -138,7 +129,7 @@ class Window : public internal::NativeWindowDelegate { bool IsVisible() const; // Whether or not the window is maximized or minimized. - bool IsMaximized() const; + virtual bool IsMaximized() const; bool IsMinimized() const; // Accessors for fullscreen state. @@ -149,11 +140,6 @@ class Window : public internal::NativeWindowDelegate { // frame" - slightly transparent and without the standard window controls. void SetUseDragFrame(bool use_drag_frame); - // Returns true if the Window is considered to be an "app window" - i.e. - // any window which when it is the last of its type closed causes the - // application to exit. - virtual bool IsAppWindow() const; - // Toggles the enable state for the Close button (and the Close menu item in // the system menu). void EnableClose(bool enable); @@ -182,10 +168,6 @@ class Window : public internal::NativeWindowDelegate { // Tell the window that something caused the frame type to change. void FrameTypeChanged(); - // TODO(beng): remove once Window subclasses Widget. - Widget* AsWidget(); - const Widget* AsWidget() const; - WindowDelegate* window_delegate() { return const_cast<WindowDelegate*>( const_cast<const Window*>(this)->window_delegate()); @@ -213,10 +195,6 @@ class Window : public internal::NativeWindowDelegate { NativeWindow* native_window() { return native_window_; } protected: - // TODO(beng): Temporarily provided as a way to associate the subclass' - // implementation of NativeWidget with this. - void SetNativeWindow(NativeWindow* native_window); - // Overridden from NativeWindowDelegate: virtual bool CanActivate() const OVERRIDE; virtual bool IsInactiveRenderingDisabled() const OVERRIDE; @@ -234,6 +212,8 @@ class Window : public internal::NativeWindowDelegate { virtual void OnNativeWindowDestroying() OVERRIDE; virtual void OnNativeWindowDestroyed() OVERRIDE; virtual void OnNativeWindowBoundsChanged() OVERRIDE; + virtual Window* AsWindow() OVERRIDE; + virtual internal::NativeWidgetDelegate* AsNativeWidgetDelegate() OVERRIDE; private: // Sizes and positions the window just after it is created. diff --git a/views/window/window_gtk.cc b/views/window/window_gtk.cc index 0e7a6f2..5d72ed8 100644 --- a/views/window/window_gtk.cc +++ b/views/window/window_gtk.cc @@ -79,37 +79,17 @@ GdkCursorType HitTestCodeToGdkCursorType(int hittest_code) { namespace views { -WindowGtk::WindowGtk() - : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), +WindowGtk::WindowGtk(internal::NativeWindowDelegate* delegate) + : WidgetGtk(delegate->AsNativeWidgetDelegate()), + delegate_(delegate), window_state_(GDK_WINDOW_STATE_WITHDRAWN), window_closed_(false) { - SetNativeWindow(this); is_window_ = true; } WindowGtk::~WindowGtk() { } -// static -void Window::CloseAllSecondaryWindows() { - GList* windows = gtk_window_list_toplevels(); - for (GList* window = windows; window; - window = g_list_next(window)) { - Window::CloseSecondaryWidget( - NativeWidget::GetNativeWidgetForNativeView( - GTK_WIDGET(window->data))->GetWidget()); - } - g_list_free(windows); -} - -Window* WindowGtk::AsWindow() { - return this; -} - -const Window* WindowGtk::AsWindow() const { - return this; -} - //////////////////////////////////////////////////////////////////////////////// // WindowGtk, WidgetGtk overrides: @@ -129,7 +109,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { if (event->type == GDK_BUTTON_PRESS && !mouse_event.IsOnlyRightMouseButton()) { gfx::Point screen_point(event->x, event->y); - View::ConvertPointToScreen(GetRootView(), &screen_point); + View::ConvertPointToScreen(GetWindow()->GetRootView(), &screen_point); gtk_window_begin_move_drag(GetNativeWindow(), event->button, screen_point.x(), screen_point.y(), event->time); @@ -147,7 +127,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) { case HTTOPLEFT: case HTTOPRIGHT: { gfx::Point screen_point(event->x, event->y); - View::ConvertPointToScreen(GetRootView(), &screen_point); + View::ConvertPointToScreen(GetWindow()->GetRootView(), &screen_point); // TODO(beng): figure out how to get a good minimum size. gtk_widget_set_size_request(GetNativeView(), 100, 100); gtk_window_begin_resize_drag(GetNativeWindow(), @@ -221,9 +201,6 @@ void WindowGtk::IsActiveChanged() { } void WindowGtk::InitNativeWidget(const Widget::InitParams& params) { - if (params.parent) - make_transient_to_parent(); - WidgetGtk::InitNativeWidget(params); g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event", @@ -310,7 +287,11 @@ void WindowGtk::SetAccessibleState(ui::AccessibilityTypes::State state) { } Window* WindowGtk::GetWindow() { - return this; + return delegate_->AsWindow(); +} + +const Window* WindowGtk::GetWindow() const { + return delegate_->AsWindow(); } void WindowGtk::SetWindowBounds(const gfx::Rect& bounds, @@ -320,7 +301,7 @@ void WindowGtk::SetWindowBounds(const gfx::Rect& bounds, } void WindowGtk::HideWindow() { - Hide(); + GetWindow()->Hide(); } void WindowGtk::Activate() { @@ -379,18 +360,12 @@ void WindowGtk::SetUseDragFrame(bool use_drag_frame) { NOTIMPLEMENTED(); } -void WindowGtk::SetAlwaysOnTop(bool always_on_top) { - gtk_window_set_keep_above(GetNativeWindow(), always_on_top); -} - -bool WindowGtk::IsAppWindow() const { - return false; +NonClientFrameView* WindowGtk::CreateFrameViewForWindow() { + return new CustomFrameView(delegate_->AsWindow()); } -NonClientFrameView* WindowGtk::CreateFrameViewForWindow() { - // TODO(erg): Always use a custom frame view? Are there cases where we let - // the window manager deal with the X11 equivalent of the "non-client" area? - return new CustomFrameView(this); +void WindowGtk::SetAlwaysOnTop(bool always_on_top) { + gtk_window_set_keep_above(GetNativeWindow(), always_on_top); } void WindowGtk::UpdateFrameAfterFrameChange() { @@ -410,8 +385,8 @@ bool WindowGtk::ShouldUseNativeFrame() const { void WindowGtk::FrameTypeChanged() { // This is called when the Theme has changed, so forward the event to the root // widget. - ThemeChanged(); - GetRootView()->SchedulePaint(); + GetWidget()->ThemeChanged(); + GetWidget()->GetRootView()->SchedulePaint(); } //////////////////////////////////////////////////////////////////////////////// @@ -437,7 +412,9 @@ void WindowGtk::SaveWindowPosition() { return; bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED; - GetWindow()->window_delegate()->SaveWindowPlacement(GetBounds(), maximized); + GetWindow()->window_delegate()->SaveWindowPlacement( + GetWidget()->GetWindowScreenBounds(), + maximized); } void WindowGtk::OnDestroy(GtkWidget* widget) { @@ -450,8 +427,10 @@ void WindowGtk::OnDestroy(GtkWidget* widget) { // NativeWindow, public: // static -Window* NativeWindow::CreateNativeWindow() { - return new WindowGtk; +NativeWindow* NativeWindow::CreateNativeWindow( + internal::NativeWindowDelegate* delegate) { + return new WindowGtk(delegate); } } // namespace views + diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h index e659e4a..b235349 100644 --- a/views/window/window_gtk.h +++ b/views/window/window_gtk.h @@ -25,13 +25,13 @@ class Client; class WindowDelegate; // Window implementation for GTK. -class WindowGtk : public WidgetGtk, public NativeWindow, public Window { +class WindowGtk : public WidgetGtk, public NativeWindow { public: - WindowGtk(); + explicit WindowGtk(internal::NativeWindowDelegate* delegate); virtual ~WindowGtk(); - virtual Window* AsWindow(); - virtual const Window* AsWindow() const; + virtual Window* GetWindow() OVERRIDE; + virtual const Window* GetWindow() const OVERRIDE; // Overridden from WidgetGtk: virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event); @@ -63,7 +63,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window { virtual void SetAccessibleName(const std::wstring& name) OVERRIDE; virtual void SetAccessibleRole(ui::AccessibilityTypes::Role role) OVERRIDE; virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE; - virtual Window* GetWindow() OVERRIDE; virtual void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window) OVERRIDE; virtual void HideWindow() OVERRIDE; @@ -79,7 +78,6 @@ class WindowGtk : public WidgetGtk, public NativeWindow, public Window { virtual void SetFullscreen(bool fullscreen) OVERRIDE; virtual bool IsFullscreen() const OVERRIDE; virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; - virtual bool IsAppWindow() const OVERRIDE; virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; virtual void UpdateFrameAfterFrameChange() OVERRIDE; diff --git a/views/window/window_win.cc b/views/window/window_win.cc index d421647..621af5a 100644 --- a/views/window/window_win.cc +++ b/views/window/window_win.cc @@ -233,6 +233,30 @@ class WindowWin::ScopedRedrawLock { //////////////////////////////////////////////////////////////////////////////// // WindowWin, public: +WindowWin::WindowWin(internal::NativeWindowDelegate* delegate) + : WidgetWin(delegate->AsNativeWidgetDelegate()), + delegate_(delegate), + focus_on_creation_(true), + restored_enabled_(false), + fullscreen_(false), + is_active_(false), + lock_updates_(false), + saved_window_style_(0), + ignore_window_pos_changes_(false), + ignore_pos_changes_factory_(this), + force_hidden_count_(0), + is_right_mouse_pressed_on_caption_(false), + last_monitor_(NULL), + is_in_size_move_(false) { + is_window_ = true; + // Initialize these values to 0 so that subclasses can override the default + // behavior before calling Init. + set_window_style(0); + set_window_ex_style(0); +} + + + WindowWin::~WindowWin() { } @@ -283,28 +307,6 @@ gfx::Font WindowWin::GetWindowTitleFont() { /////////////////////////////////////////////////////////////////////////////// // WindowWin, protected: -WindowWin::WindowWin() - : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)), - focus_on_creation_(true), - restored_enabled_(false), - fullscreen_(false), - is_active_(false), - lock_updates_(false), - saved_window_style_(0), - ignore_window_pos_changes_(false), - ignore_pos_changes_factory_(this), - force_hidden_count_(0), - is_right_mouse_pressed_on_caption_(false), - last_monitor_(NULL), - is_in_size_move_(false) { - SetNativeWindow(this); - is_window_ = true; - // Initialize these values to 0 so that subclasses can override the default - // behavior before calling Init. - set_window_style(0); - set_window_ex_style(0); -} - gfx::Insets WindowWin::GetClientAreaInsets() const { // Returning an empty Insets object causes the default handling in // WidgetWin::OnNCCalcSize() to be invoked. @@ -371,7 +373,7 @@ LRESULT WindowWin::OnAppCommand(HWND window, short app_command, WORD device, } void WindowWin::OnClose() { - GetWindow()->CloseWindow(); + GetWindow()->Close(); } void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) { @@ -412,7 +414,7 @@ void WindowWin::OnExitSizeMove() { WidgetWin::OnExitSizeMove(); delegate_->OnNativeWindowEndUserBoundsChange(); - if (!GetThemeProvider()->ShouldUseNativeFrame()) { + if (!ShouldUseNativeFrame()) { // Sending SWP_FRAMECHANGED forces a non-client repaint, which fixes the // glitch in rendering the bottom pixel of the window caused by us // offsetting the client rect there (See comment in GetClientAreaInsets()). @@ -773,7 +775,8 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) { !!(GetKeyState(VK_SHIFT) & 0x8000), !!(GetKeyState(VK_CONTROL) & 0x8000), false); - GetFocusManager()->ProcessAccelerator(accelerator); + AsNativeWidget()->GetWidget()->GetFocusManager()-> + ProcessAccelerator(accelerator); return; } @@ -892,6 +895,14 @@ void WindowWin::SetInitialFocus() { //////////////////////////////////////////////////////////////////////////////// // WindowWin, NativeWindow implementation: +Window* WindowWin::GetWindow() { + return delegate_->AsWindow(); +} + +const Window* WindowWin::GetWindow() const { + return delegate_->AsWindow(); +} + NativeWidget* WindowWin::AsNativeWidget() { return this; } @@ -1163,10 +1174,6 @@ void WindowWin::SetAlwaysOnTop(bool always_on_top) { 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } -bool WindowWin::IsAppWindow() const { - return false; -} - void WindowWin::SetUseDragFrame(bool use_drag_frame) { if (use_drag_frame) { // Make the frame slightly transparent during the drag operation. @@ -1187,8 +1194,8 @@ void WindowWin::SetUseDragFrame(bool use_drag_frame) { NonClientFrameView* WindowWin::CreateFrameViewForWindow() { if (ShouldUseNativeFrame()) - return new NativeFrameView(this); - return new CustomFrameView(this); + return new NativeFrameView(GetWindow()); + return new CustomFrameView(GetWindow()); } void WindowWin::UpdateFrameAfterFrameChange() { @@ -1201,10 +1208,7 @@ gfx::NativeWindow WindowWin::GetNativeWindow() const { } bool WindowWin::ShouldUseNativeFrame() const { - ui::ThemeProvider* tp = GetThemeProvider(); - if (!tp) - return WidgetWin::IsAeroGlassEnabled(); - return tp->ShouldUseNativeFrame(); + return WidgetWin::IsAeroGlassEnabled(); } void WindowWin::FrameTypeChanged() { @@ -1344,26 +1348,13 @@ void WindowWin::ExecuteSystemMenuCommand(int command) { SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0); } -namespace { -BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam) { - NativeWidget* native_widget = - NativeWidget::GetNativeWidgetForNativeView(hwnd); - if (native_widget) - Window::CloseSecondaryWidget(native_widget->GetWidget()); - return TRUE; -} -} // namespace - -void Window::CloseAllSecondaryWindows() { - EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, 0); -} - //////////////////////////////////////////////////////////////////////////////// // NativeWindow, public: // static -Window* NativeWindow::CreateNativeWindow() { - return new WindowWin; +NativeWindow* NativeWindow::CreateNativeWindow( + internal::NativeWindowDelegate* delegate) { + return new WindowWin(delegate); } } // namespace views diff --git a/views/window/window_win.h b/views/window/window_win.h index 5ade949..71f2273 100644 --- a/views/window/window_win.h +++ b/views/window/window_win.h @@ -41,10 +41,9 @@ class WindowDelegate; // /////////////////////////////////////////////////////////////////////////////// class WindowWin : public WidgetWin, - public NativeWindow, - public Window { + public NativeWindow { public: - WindowWin(); + explicit WindowWin(internal::NativeWindowDelegate* delegate); virtual ~WindowWin(); // Show the window with the specified show command. @@ -67,6 +66,10 @@ class WindowWin : public WidgetWin, // Returns the system set window title font. static gfx::Font GetWindowTitleFont(); + // Overridden from NativeWindow: + virtual Window* GetWindow() OVERRIDE; + virtual const Window* GetWindow() const OVERRIDE; + protected: friend Window; @@ -123,8 +126,6 @@ class WindowWin : public WidgetWin, virtual void OnSize(UINT size_param, const CSize& new_size) OVERRIDE; virtual void OnSysCommand(UINT notification_code, CPoint click) OVERRIDE; virtual void OnWindowPosChanging(WINDOWPOS* window_pos) OVERRIDE; - virtual Window* GetWindow() OVERRIDE { return this; } - virtual const Window* GetWindow() const OVERRIDE { return this; } virtual void Close() OVERRIDE; virtual void SetInitialFocus() OVERRIDE; @@ -159,7 +160,6 @@ class WindowWin : public WidgetWin, virtual void SetFullscreen(bool fullscreen) OVERRIDE; virtual bool IsFullscreen() const OVERRIDE; virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE; - virtual bool IsAppWindow() const OVERRIDE; virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE; virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE; virtual void UpdateFrameAfterFrameChange() OVERRIDE; |