summaryrefslogtreecommitdiffstats
path: root/views/window
diff options
context:
space:
mode:
authorben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 22:15:09 +0000
committerben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-26 22:15:09 +0000
commitb3d7b1d8e2d35d13b19ae7294271fe470bbbb730 (patch)
tree7b9013bb48471eae817de7c50005a47992a2d362 /views/window
parent9b46eb22ef9a1cd601ed6972571e838ad75f5b18 (diff)
downloadchromium_src-b3d7b1d8e2d35d13b19ae7294271fe470bbbb730.zip
chromium_src-b3d7b1d8e2d35d13b19ae7294271fe470bbbb730.tar.gz
chromium_src-b3d7b1d8e2d35d13b19ae7294271fe470bbbb730.tar.bz2
Move a bunch of functions from Window onto Widget.
BUG=72040 TEST=none Review URL: http://codereview.chromium.org/7075019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86914 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views/window')
-rw-r--r--views/window/native_window.h12
-rw-r--r--views/window/native_window_gtk.cc88
-rw-r--r--views/window/native_window_gtk.h25
-rw-r--r--views/window/native_window_views.cc49
-rw-r--r--views/window/native_window_views.h12
-rw-r--r--views/window/native_window_win.cc70
-rw-r--r--views/window/native_window_win.h18
-rw-r--r--views/window/window.cc101
-rw-r--r--views/window/window.h54
9 files changed, 66 insertions, 363 deletions
diff --git a/views/window/native_window.h b/views/window/native_window.h
index 0e83f30..0ede59b 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -91,23 +91,11 @@ class NativeWindow {
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) = 0;
- virtual void HideWindow() = 0;
- virtual void Activate() = 0;
- virtual void Deactivate() = 0;
- virtual void Maximize() = 0;
- virtual void Minimize() = 0;
- virtual void Restore() = 0;
- virtual bool IsActive() const = 0;
- virtual bool IsVisible() const = 0;
- virtual bool IsMaximized() const = 0;
- virtual bool IsMinimized() const = 0;
virtual void SetFullscreen(bool fullscreen) = 0;
virtual bool IsFullscreen() const = 0;
- virtual void SetAlwaysOnTop(bool always_on_top) = 0;
virtual void SetUseDragFrame(bool use_drag_frame) = 0;
virtual NonClientFrameView* CreateFrameViewForWindow() = 0;
virtual void UpdateFrameAfterFrameChange() = 0;
- virtual gfx::NativeWindow GetNativeWindow() const = 0;
virtual bool ShouldUseNativeFrame() const = 0;
virtual void FrameTypeChanged() = 0;
};
diff --git a/views/window/native_window_gtk.cc b/views/window/native_window_gtk.cc
index 4e25fb4..d65d9c0 100644
--- a/views/window/native_window_gtk.cc
+++ b/views/window/native_window_gtk.cc
@@ -80,7 +80,6 @@ namespace views {
NativeWindowGtk::NativeWindowGtk(internal::NativeWindowDelegate* delegate)
: NativeWidgetGtk(delegate->AsNativeWidgetDelegate()),
delegate_(delegate),
- window_state_(GDK_WINDOW_STATE_WITHDRAWN),
window_closed_(false) {
is_window_ = true;
}
@@ -182,14 +181,6 @@ void NativeWindowGtk::OnSizeAllocate(GtkWidget* widget,
SaveWindowPosition();
}
-gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget,
- GdkEventWindowState* event) {
- window_state_ = event->new_window_state;
- if (!(window_state_ & GDK_WINDOW_STATE_WITHDRAWN))
- SaveWindowPosition();
- return FALSE;
-}
-
gboolean NativeWindowGtk::OnLeaveNotify(GtkWidget* widget,
GdkEventCrossing* event) {
gdk_window_set_cursor(widget->window, gfx::GetCursor(GDK_LEFT_PTR));
@@ -207,8 +198,6 @@ void NativeWindowGtk::InitNativeWidget(const Widget::InitParams& params) {
g_signal_connect(G_OBJECT(GetNativeWindow()), "configure-event",
G_CALLBACK(CallConfigureEvent), this);
- g_signal_connect(G_OBJECT(GetNativeWindow()), "window-state-event",
- G_CALLBACK(CallWindowStateEvent), this);
}
////////////////////////////////////////////////////////////////////////////////
@@ -302,51 +291,6 @@ void NativeWindowGtk::SetWindowBounds(const gfx::Rect& bounds,
NativeWidgetGtk::SetBounds(bounds);
}
-void NativeWindowGtk::HideWindow() {
- GetWindow()->Hide();
-}
-
-void NativeWindowGtk::Activate() {
- gtk_window_present(GTK_WINDOW(GetNativeView()));
-}
-
-void NativeWindowGtk::Deactivate() {
- gdk_window_lower(GTK_WIDGET(GetNativeView())->window);
-}
-
-void NativeWindowGtk::Maximize() {
- gtk_window_maximize(GetNativeWindow());
-}
-
-void NativeWindowGtk::Minimize() {
- gtk_window_iconify(GetNativeWindow());
-}
-
-void NativeWindowGtk::Restore() {
- if (IsMaximized())
- gtk_window_unmaximize(GetNativeWindow());
- else if (IsMinimized())
- gtk_window_deiconify(GetNativeWindow());
- else if (IsFullscreen())
- SetFullscreen(false);
-}
-
-bool NativeWindowGtk::IsActive() const {
- return NativeWidgetGtk::IsActive();
-}
-
-bool NativeWindowGtk::IsVisible() const {
- return GTK_WIDGET_VISIBLE(GetNativeView());
-}
-
-bool NativeWindowGtk::IsMaximized() const {
- return window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
-}
-
-bool NativeWindowGtk::IsMinimized() const {
- return window_state_ & GDK_WINDOW_STATE_ICONIFIED;
-}
-
void NativeWindowGtk::SetFullscreen(bool fullscreen) {
if (fullscreen)
gtk_window_fullscreen(GetNativeWindow());
@@ -366,20 +310,12 @@ NonClientFrameView* NativeWindowGtk::CreateFrameViewForWindow() {
return NULL;
}
-void NativeWindowGtk::SetAlwaysOnTop(bool always_on_top) {
- gtk_window_set_keep_above(GetNativeWindow(), always_on_top);
-}
-
void NativeWindowGtk::UpdateFrameAfterFrameChange() {
// We currently don't support different frame types on Gtk, so we don't
// need to implement this.
NOTIMPLEMENTED();
}
-gfx::NativeWindow NativeWindowGtk::GetNativeWindow() const {
- return GTK_WINDOW(GetNativeView());
-}
-
bool NativeWindowGtk::ShouldUseNativeFrame() const {
return false;
}
@@ -392,6 +328,23 @@ void NativeWindowGtk::FrameTypeChanged() {
}
////////////////////////////////////////////////////////////////////////////////
+// NativeWindowGtk, NativeWidgetGtk overrides:
+
+void NativeWindowGtk::Restore() {
+ if (IsFullscreen())
+ SetFullscreen(false);
+ else
+ NativeWidgetGtk::Restore();
+}
+
+gboolean NativeWindowGtk::OnWindowStateEvent(GtkWidget* widget,
+ GdkEventWindowState* event) {
+ if (!(event->new_window_state & GDK_WINDOW_STATE_WITHDRAWN))
+ SaveWindowPosition();
+ return NativeWidgetGtk::OnWindowStateEvent(widget, event);
+}
+
+////////////////////////////////////////////////////////////////////////////////
// NativeWindowGtk, private:
// static
@@ -401,13 +354,6 @@ gboolean NativeWindowGtk::CallConfigureEvent(GtkWidget* widget,
return window_gtk->OnConfigureEvent(widget, event);
}
-// static
-gboolean NativeWindowGtk::CallWindowStateEvent(GtkWidget* widget,
- GdkEventWindowState* event,
- NativeWindowGtk* window_gtk) {
- return window_gtk->OnWindowStateEvent(widget, event);
-}
-
void NativeWindowGtk::SaveWindowPosition() {
// The delegate may have gone away on us.
if (!GetWindow()->window_delegate())
diff --git a/views/window/native_window_gtk.h b/views/window/native_window_gtk.h
index f45380e..56e46da 100644
--- a/views/window/native_window_gtk.h
+++ b/views/window/native_window_gtk.h
@@ -39,8 +39,6 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
GdkEventConfigure* event);
virtual gboolean OnMotionNotify(GtkWidget* widget, GdkEventMotion* event);
virtual void OnSizeAllocate(GtkWidget* widget, GtkAllocation* allocation);
- virtual gboolean OnWindowStateEvent(GtkWidget* widget,
- GdkEventWindowState* event);
virtual gboolean OnLeaveNotify(GtkWidget* widget, GdkEventCrossing* event);
virtual void IsActiveChanged();
@@ -65,26 +63,19 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
- virtual void HideWindow() OVERRIDE;
- virtual void Activate() OVERRIDE;
- virtual void Deactivate() OVERRIDE;
- virtual void Maximize() OVERRIDE;
- virtual void Minimize() OVERRIDE;
- virtual void Restore() OVERRIDE;
- virtual bool IsActive() const OVERRIDE;
- virtual bool IsVisible() const OVERRIDE;
- virtual bool IsMaximized() const OVERRIDE;
- virtual bool IsMinimized() const OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
- virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
- virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
virtual bool ShouldUseNativeFrame() const OVERRIDE;
virtual void FrameTypeChanged() OVERRIDE;
+ // Overridden from NativeWidgetGtk:
+ virtual void Restore() OVERRIDE;
+ virtual gboolean OnWindowStateEvent(GtkWidget* widget,
+ GdkEventWindowState* event) OVERRIDE;
+
// For the constructor.
friend class Window;
@@ -94,9 +85,6 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
static gboolean CallConfigureEvent(GtkWidget* widget,
GdkEventConfigure* event,
NativeWindowGtk* window_gtk);
- static gboolean CallWindowStateEvent(GtkWidget* widget,
- GdkEventWindowState* event,
- NativeWindowGtk* window_gtk);
// Asks the delegate if any to save the window's location and size.
void SaveWindowPosition();
@@ -113,9 +101,6 @@ class NativeWindowGtk : public NativeWidgetGtk, public NativeWindow {
// 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_;
diff --git a/views/window/native_window_views.cc b/views/window/native_window_views.cc
index 156338b..de2e2ed 100644
--- a/views/window/native_window_views.cc
+++ b/views/window/native_window_views.cc
@@ -92,48 +92,6 @@ void NativeWindowViews::SetWindowBounds(const gfx::Rect& bounds,
GetView()->SetBoundsRect(bounds);
}
-void NativeWindowViews::HideWindow() {
- GetView()->SetVisible(false);
-}
-
-void NativeWindowViews::Activate() {
- NOTIMPLEMENTED();
-}
-
-void NativeWindowViews::Deactivate() {
- NOTIMPLEMENTED();
-}
-
-void NativeWindowViews::Maximize() {
- NOTIMPLEMENTED();
-}
-
-void NativeWindowViews::Minimize() {
- NOTIMPLEMENTED();
-}
-
-void NativeWindowViews::Restore() {
- NOTIMPLEMENTED();
-}
-
-bool NativeWindowViews::IsActive() const {
- return NativeWidgetViews::IsActive();
-}
-
-bool NativeWindowViews::IsVisible() const {
- return GetView()->IsVisible();
-}
-
-bool NativeWindowViews::IsMaximized() const {
- NOTIMPLEMENTED();
- return false;
-}
-
-bool NativeWindowViews::IsMinimized() const {
- NOTIMPLEMENTED();
- return false;
-}
-
void NativeWindowViews::SetFullscreen(bool fullscreen) {
}
@@ -142,9 +100,6 @@ bool NativeWindowViews::IsFullscreen() const {
return false;
}
-void NativeWindowViews::SetAlwaysOnTop(bool always_on_top) {
-}
-
void NativeWindowViews::SetUseDragFrame(bool use_drag_frame) {
}
@@ -155,10 +110,6 @@ NonClientFrameView* NativeWindowViews::CreateFrameViewForWindow() {
void NativeWindowViews::UpdateFrameAfterFrameChange() {
}
-gfx::NativeWindow NativeWindowViews::GetNativeWindow() const {
- return NULL;
-}
-
bool NativeWindowViews::ShouldUseNativeFrame() const {
NOTIMPLEMENTED();
return false;
diff --git a/views/window/native_window_views.h b/views/window/native_window_views.h
index 65a4310..83339be 100644
--- a/views/window/native_window_views.h
+++ b/views/window/native_window_views.h
@@ -44,23 +44,11 @@ class NativeWindowViews : public NativeWidgetViews,
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
- virtual void HideWindow() OVERRIDE;
- virtual void Activate() OVERRIDE;
- virtual void Deactivate() OVERRIDE;
- virtual void Maximize() OVERRIDE;
- virtual void Minimize() OVERRIDE;
- virtual void Restore() OVERRIDE;
- virtual bool IsActive() const OVERRIDE;
- virtual bool IsVisible() const OVERRIDE;
- virtual bool IsMaximized() const OVERRIDE;
- virtual bool IsMinimized() const OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
- virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
- virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
virtual bool ShouldUseNativeFrame() const OVERRIDE;
virtual void FrameTypeChanged() OVERRIDE;
diff --git a/views/window/native_window_win.cc b/views/window/native_window_win.cc
index fed8173..c72822a 100644
--- a/views/window/native_window_win.cc
+++ b/views/window/native_window_win.cc
@@ -1175,53 +1175,6 @@ void NativeWindowWin::SetWindowBounds(const gfx::Rect& bounds,
kMonitorEdgePadding, 0);
}
-void NativeWindowWin::HideWindow() {
- // We can just call the function implemented by the widget.
- Hide();
-}
-
-void NativeWindowWin::Activate() {
- if (IsMinimized())
- ::ShowWindow(GetNativeView(), SW_RESTORE);
- ::SetWindowPos(GetNativeView(), HWND_TOP, 0, 0, 0, 0,
- SWP_NOSIZE | SWP_NOMOVE);
- SetForegroundWindow(GetNativeView());
-}
-
-void NativeWindowWin::Deactivate() {
- HWND hwnd = ::GetNextWindow(GetNativeView(), GW_HWNDNEXT);
- if (hwnd)
- ::SetForegroundWindow(hwnd);
-}
-
-void NativeWindowWin::Maximize() {
- ExecuteSystemMenuCommand(SC_MAXIMIZE);
-}
-
-void NativeWindowWin::Minimize() {
- ExecuteSystemMenuCommand(SC_MINIMIZE);
-}
-
-void NativeWindowWin::Restore() {
- ExecuteSystemMenuCommand(SC_RESTORE);
-}
-
-bool NativeWindowWin::IsActive() const {
- return is_active_;
-}
-
-bool NativeWindowWin::IsVisible() const {
- return !!::IsWindowVisible(GetNativeView());
-}
-
-bool NativeWindowWin::IsMaximized() const {
- return !!::IsZoomed(GetNativeView());
-}
-
-bool NativeWindowWin::IsMinimized() const {
- return !!::IsIconic(GetNativeView());
-}
-
void NativeWindowWin::SetFullscreen(bool fullscreen) {
if (fullscreen_ == fullscreen)
return; // Nothing to do.
@@ -1283,11 +1236,6 @@ bool NativeWindowWin::IsFullscreen() const {
return fullscreen_;
}
-void NativeWindowWin::SetAlwaysOnTop(bool always_on_top) {
- ::SetWindowPos(GetNativeView(), always_on_top ? HWND_TOPMOST : HWND_NOTOPMOST,
- 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
-}
-
void NativeWindowWin::SetUseDragFrame(bool use_drag_frame) {
if (use_drag_frame) {
// Make the frame slightly transparent during the drag operation.
@@ -1316,10 +1264,6 @@ void NativeWindowWin::UpdateFrameAfterFrameChange() {
ResetWindowRegion(true);
}
-gfx::NativeWindow NativeWindowWin::GetNativeWindow() const {
- return GetNativeView();
-}
-
bool NativeWindowWin::ShouldUseNativeFrame() const {
return NativeWidgetWin::IsAeroGlassEnabled();
}
@@ -1354,6 +1298,15 @@ void NativeWindowWin::FrameTypeChanged() {
}
////////////////////////////////////////////////////////////////////////////////
+// NativeWindowWin, NativeWidgetWin overrides:
+
+bool NativeWindowWin::IsActive() const {
+ // TODO(beng): evaluate whether or not this is needed. NativeWidgetWin checks
+ // active-state with the OS using GetWindowInfo().
+ return is_active_;
+}
+
+////////////////////////////////////////////////////////////////////////////////
// NativeWindowWin, private:
void NativeWindowWin::RestoreEnabledIfNecessary() {
@@ -1456,11 +1409,6 @@ LRESULT NativeWindowWin::CallDefaultNCActivateHandler(BOOL active) {
return DefWindowProc(GetNativeView(), WM_NCACTIVATE, active, 0);
}
-void NativeWindowWin::ExecuteSystemMenuCommand(int command) {
- if (command)
- SendMessage(GetNativeView(), WM_SYSCOMMAND, command, 0);
-}
-
////////////////////////////////////////////////////////////////////////////////
// NativeWindow, public:
diff --git a/views/window/native_window_win.h b/views/window/native_window_win.h
index 7587832..71eac11 100644
--- a/views/window/native_window_win.h
+++ b/views/window/native_window_win.h
@@ -151,26 +151,17 @@ class NativeWindowWin : public NativeWidgetWin,
virtual void SetAccessibleState(ui::AccessibilityTypes::State state) OVERRIDE;
virtual void SetWindowBounds(const gfx::Rect& bounds,
gfx::NativeWindow other_window) OVERRIDE;
- virtual void HideWindow() OVERRIDE;
- virtual void Activate() OVERRIDE;
- virtual void Deactivate() OVERRIDE;
- virtual void Maximize() OVERRIDE;
- virtual void Minimize() OVERRIDE;
- virtual void Restore() OVERRIDE;
- virtual bool IsActive() const OVERRIDE;
- virtual bool IsVisible() const OVERRIDE;
- virtual bool IsMaximized() const OVERRIDE;
- virtual bool IsMinimized() const OVERRIDE;
virtual void SetFullscreen(bool fullscreen) OVERRIDE;
virtual bool IsFullscreen() const OVERRIDE;
- virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual void SetUseDragFrame(bool use_drag_frame) OVERRIDE;
virtual NonClientFrameView* CreateFrameViewForWindow() OVERRIDE;
virtual void UpdateFrameAfterFrameChange() OVERRIDE;
- virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
virtual bool ShouldUseNativeFrame() const OVERRIDE;
virtual void FrameTypeChanged() OVERRIDE;
+ // Overridden from NativeWidgetWin:
+ virtual bool IsActive() const OVERRIDE;
+
private:
// Information saved before going into fullscreen mode, used to restore the
// window afterwards.
@@ -212,9 +203,6 @@ class NativeWindowWin : public NativeWidgetWin,
// flicker.
LRESULT CallDefaultNCActivateHandler(BOOL active);
- // Executes the specified SC_command.
- void ExecuteSystemMenuCommand(int command);
-
// A delegate implementation that handles events received here.
internal::NativeWindowDelegate* delegate_;
diff --git a/views/window/window.cc b/views/window/window.cc
index f2d51ee..1886aa5 100644
--- a/views/window/window.cc
+++ b/views/window/window.cc
@@ -112,80 +112,15 @@ void Window::SetWindowBounds(const gfx::Rect& bounds,
native_window_->SetWindowBounds(bounds, other_window);
}
-void Window::Show() {
- native_window_->ShowNativeWindow(
- saved_maximized_state_ ? NativeWindow::SHOW_MAXIMIZED
- : NativeWindow::SHOW_RESTORED);
- // |saved_maximized_state_| only applies the first time the window is shown.
- // If we don't reset the value the window will be shown maximized every time
- // it is subsequently shown after being hidden.
- saved_maximized_state_ = false;
-}
-
void Window::ShowInactive() {
native_window_->ShowNativeWindow(NativeWindow::SHOW_INACTIVE);
}
-void Window::HideWindow() {
- native_window_->HideWindow();
-}
-
void Window::DisableInactiveRendering() {
disable_inactive_rendering_ = true;
non_client_view_->DisableInactiveRendering(disable_inactive_rendering_);
}
-void Window::Activate() {
- native_window_->Activate();
-}
-
-void Window::Deactivate() {
- native_window_->Deactivate();
-}
-
-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
- // invoking Close again.
- return;
- }
-
- if (non_client_view_->CanClose()) {
- SaveWindowPosition();
- Widget::Close();
- window_closed_ = true;
- }
-}
-
-void Window::Maximize() {
- native_window_->Maximize();
-}
-
-void Window::Minimize() {
- native_window_->Minimize();
-}
-
-void Window::Restore() {
- native_window_->Restore();
-}
-
-bool Window::IsActive() const {
- return native_window_->IsActive();
-}
-
-bool Window::IsVisible() const {
- return native_window_->IsVisible();
-}
-
-bool Window::IsMaximized() const {
- return native_window_->IsMaximized();
-}
-
-bool Window::IsMinimized() const {
- return native_window_->IsMinimized();
-}
-
void Window::SetFullscreen(bool fullscreen) {
native_window_->SetFullscreen(fullscreen);
}
@@ -225,10 +160,6 @@ void Window::UpdateWindowIcon() {
window_delegate_->GetWindowAppIcon());
}
-void Window::SetIsAlwaysOnTop(bool always_on_top) {
- native_window_->SetAlwaysOnTop(always_on_top);
-}
-
NonClientFrameView* Window::CreateFrameViewForWindow() {
NonClientFrameView* frame_view = native_window_->CreateFrameViewForWindow();
return frame_view ? frame_view : new CustomFrameView(this);
@@ -238,10 +169,6 @@ void Window::UpdateFrameAfterFrameChange() {
native_window_->UpdateFrameAfterFrameChange();
}
-gfx::NativeWindow Window::GetNativeWindow() const {
- return native_window_->GetNativeWindow();
-}
-
bool Window::ShouldUseNativeFrame() const {
if (frame_type_ != FRAME_TYPE_DEFAULT)
return frame_type_ == FRAME_TYPE_FORCE_NATIVE;
@@ -264,6 +191,34 @@ void Window::FrameTypeChanged() {
}
////////////////////////////////////////////////////////////////////////////////
+// Window, Widget overrides:
+
+void Window::Show() {
+ native_window_->ShowNativeWindow(
+ saved_maximized_state_ ? NativeWindow::SHOW_MAXIMIZED
+ : NativeWindow::SHOW_RESTORED);
+ // |saved_maximized_state_| only applies the first time the window is shown.
+ // If we don't reset the value the window will be shown maximized every time
+ // it is subsequently shown after being hidden.
+ saved_maximized_state_ = false;
+}
+
+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
+ // invoking Close again.
+ return;
+ }
+
+ if (non_client_view_->CanClose()) {
+ SaveWindowPosition();
+ Widget::Close();
+ window_closed_ = true;
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
// Window, internal::NativeWindowDelegate implementation:
bool Window::CanActivate() const {
diff --git a/views/window/window.h b/views/window/window.h
index eb8490a..669b23d 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -30,15 +30,6 @@ class WindowDelegate;
//
// Encapsulates window-like behavior. See WindowDelegate.
//
-// TODO(beng): Subclass Widget as part of V2.
-//
-// TODO(beng): Note that this class being non-abstract means that we have a
-// violation of Google style in that we are using multiple
-// inheritance. The intention is to split this into a separate
-// object associated with but not equal to a NativeWidget
-// implementation. Multiple inheritance is required for this
-// transitional step.
-//
class Window : public Widget,
public internal::NativeWindowDelegate {
public:
@@ -94,50 +85,15 @@ class Window : public Widget,
// monitor.
void SetWindowBounds(const gfx::Rect& bounds, gfx::NativeWindow other_window);
- // Makes the window visible.
- void Show();
-
// Like Show(), but does not activate the window.
void ShowInactive();
- // Hides the window. This does not delete the window, it just hides it. This
- // always hides the window, it is separate from the stack maintained by
- // Push/PopForceHidden.
- virtual void HideWindow();
-
// Prevents the window from being rendered as deactivated the next time it is.
// This state is reset automatically as soon as the window becomes activated
// again. There is no ability to control the state through this API as this
// leads to sync problems.
void DisableInactiveRendering();
- // Activates the window, assuming it already exists and is visible.
- void Activate();
-
- // Deactivates the window, making the next window in the Z order the active
- // window.
- void Deactivate();
-
- // 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.
- virtual void Close() OVERRIDE;
-
- // Maximizes/minimizes/restores the window.
- void Maximize();
- void Minimize();
- void Restore();
-
- // Whether or not the window is currently active.
- bool IsActive() const;
-
- // Whether or not the window is currently visible.
- bool IsVisible() const;
-
- // Whether or not the window is maximized or minimized.
- virtual bool IsMaximized() const;
- bool IsMinimized() const;
-
// Accessors for fullscreen state.
void SetFullscreen(bool fullscreen);
bool IsFullscreen() const;
@@ -156,18 +112,12 @@ class Window : public Widget,
// Tell the window to update its icon from the delegate.
void UpdateWindowIcon();
- // Sets whether or not the window is always-on-top.
- void SetIsAlwaysOnTop(bool always_on_top);
-
// Creates an appropriate NonClientFrameView for this window.
virtual NonClientFrameView* CreateFrameViewForWindow();
// Updates the frame after an event caused it to be changed.
virtual void UpdateFrameAfterFrameChange();
- // Retrieves the Window's native window handle.
- gfx::NativeWindow GetNativeWindow() const;
-
void set_frame_type(FrameType frame_type) { frame_type_ = frame_type; }
FrameType frame_type() const { return frame_type_; }
@@ -181,6 +131,10 @@ class Window : public Widget,
// Tell the window that something caused the frame type to change.
void FrameTypeChanged();
+ // Overridden from Widget:
+ virtual void Show() OVERRIDE;
+ virtual void Close() OVERRIDE;
+
WindowDelegate* window_delegate() {
return const_cast<WindowDelegate*>(
const_cast<const Window*>(this)->window_delegate());