summaryrefslogtreecommitdiffstats
path: root/views/window
diff options
context:
space:
mode:
Diffstat (limited to 'views/window')
-rw-r--r--views/window/custom_frame_view.cc2
-rw-r--r--views/window/dialog_client_view.cc2
-rw-r--r--views/window/native_frame_view.cc12
-rw-r--r--views/window/native_frame_view.h6
-rw-r--r--views/window/native_window.h7
-rw-r--r--views/window/native_window_delegate.h10
-rw-r--r--views/window/window.cc63
-rw-r--r--views/window/window.h32
-rw-r--r--views/window/window_gtk.cc69
-rw-r--r--views/window/window_gtk.h10
-rw-r--r--views/window/window_win.cc93
-rw-r--r--views/window/window_win.h12
12 files changed, 188 insertions, 130 deletions
diff --git a/views/window/custom_frame_view.cc b/views/window/custom_frame_view.cc
index 305eae1..e86cd10 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_->Close();
+ frame_->CloseWindow();
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 b3b5c9a..e2cc5ef 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()->Close();
+ window()->CloseWindow();
GetDialogDelegate()->OnClose();
}
diff --git a/views/window/native_frame_view.cc b/views/window/native_frame_view.cc
index c78d6d1..397b6f3 100644
--- a/views/window/native_frame_view.cc
+++ b/views/window/native_frame_view.cc
@@ -4,16 +4,14 @@
#include "views/window/native_frame_view.h"
-#include "views/widget/widget_win.h"
-#include "views/window/native_window.h"
-#include "views/window/window.h"
+#include "views/window/window_win.h"
namespace views {
////////////////////////////////////////////////////////////////////////////////
// NativeFrameView, public:
-NativeFrameView::NativeFrameView(Window* frame)
+NativeFrameView::NativeFrameView(WindowWin* frame)
: NonClientFrameView(),
frame_(frame) {
}
@@ -31,10 +29,8 @@ gfx::Rect NativeFrameView::GetBoundsForClientView() const {
gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
RECT rect = client_bounds.ToRECT();
- WidgetWin* widget_win =
- static_cast<WidgetWin*>(frame_->native_window()->AsNativeWidget());
- AdjustWindowRectEx(&rect, widget_win->window_style(), FALSE,
- widget_win->window_ex_style());
+ AdjustWindowRectEx(&rect, frame_->window_style(), FALSE,
+ frame_->window_ex_style());
return gfx::Rect(rect);
}
diff --git a/views/window/native_frame_view.h b/views/window/native_frame_view.h
index 9bc943f..ac68ddf 100644
--- a/views/window/native_frame_view.h
+++ b/views/window/native_frame_view.h
@@ -10,11 +10,11 @@
namespace views {
-class Window;
+class WindowWin;
class NativeFrameView : public NonClientFrameView {
public:
- explicit NativeFrameView(Window* frame);
+ explicit NativeFrameView(WindowWin* frame);
virtual ~NativeFrameView();
// NonClientFrameView overrides:
@@ -33,7 +33,7 @@ class NativeFrameView : public NonClientFrameView {
private:
// Our containing frame.
- Window* frame_;
+ WindowWin* frame_;
DISALLOW_COPY_AND_ASSIGN(NativeFrameView);
};
diff --git a/views/window/native_window.h b/views/window/native_window.h
index 0e83f30..63da12a 100644
--- a/views/window/native_window.h
+++ b/views/window/native_window.h
@@ -37,13 +37,9 @@ class NativeWindow {
virtual ~NativeWindow() {}
- // Creates an appropriate default NativeWindow implementation for the current
- // OS/circumstance.
- static NativeWindow* CreateNativeWindow(
- internal::NativeWindowDelegate* delegate);
+ static Window* CreateNativeWindow();
virtual Window* GetWindow() = 0;
- virtual const Window* GetWindow() const = 0;
virtual NativeWidget* AsNativeWidget() = 0;
virtual const NativeWidget* AsNativeWidget() const = 0;
@@ -104,6 +100,7 @@ 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 c88924b..23705a5 100644
--- a/views/window/native_window_delegate.h
+++ b/views/window/native_window_delegate.h
@@ -6,10 +6,6 @@
#define VIEWS_WIDGET_NATIVE_WINDOW_DELEGATE_H_
#pragma once
-namespace ui {
-class ThemeProvider;
-}
-
namespace views {
namespace internal {
@@ -68,12 +64,6 @@ 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 efc9f15..13f2515 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 = new Window;
+ Window* window = NativeWindow::CreateNativeWindow();
Window::InitParams params(window_delegate);
params.parent_window = parent;
params.widget_init_params.bounds = bounds;
@@ -74,24 +74,34 @@ 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());
- 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);
+ AsWidget()->Init(params.widget_init_params);
+ OnNativeWindowCreated(params.widget_init_params.bounds);
}
gfx::Rect Window::GetBounds() const {
@@ -139,7 +149,7 @@ void Window::Deactivate() {
native_window_->Deactivate();
}
-void Window::Close() {
+void Window::CloseWindow() {
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
@@ -149,7 +159,9 @@ void Window::Close() {
if (non_client_view_->CanClose()) {
SaveWindowPosition();
- Widget::Close();
+ // TODO(beng): This can be simplified to Widget::Close() once Window
+ // subclasses Widget.
+ native_window_->AsNativeWidget()->GetWidget()->Close();
window_closed_ = true;
}
}
@@ -194,6 +206,10 @@ 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);
@@ -245,6 +261,21 @@ 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:
@@ -333,14 +364,6 @@ 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 191aba4..76fdb76 100644
--- a/views/window/window.h
+++ b/views/window/window.h
@@ -39,8 +39,7 @@ class WindowDelegate;
// implementation. Multiple inheritance is required for this
// transitional step.
//
-class Window : public Widget,
- public internal::NativeWindowDelegate {
+class Window : public internal::NativeWindowDelegate {
public:
struct InitParams {
// |window_delegate| cannot be NULL.
@@ -72,6 +71,16 @@ class Window : public Widget,
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);
@@ -115,7 +124,7 @@ class Window : public Widget,
// 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;
+ void CloseWindow();
// Maximizes/minimizes/restores the window.
void Maximize();
@@ -129,7 +138,7 @@ class Window : public Widget,
bool IsVisible() const;
// Whether or not the window is maximized or minimized.
- virtual bool IsMaximized() const;
+ bool IsMaximized() const;
bool IsMinimized() const;
// Accessors for fullscreen state.
@@ -140,6 +149,11 @@ class Window : public Widget,
// 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);
@@ -168,6 +182,10 @@ class Window : public Widget,
// 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());
@@ -195,6 +213,10 @@ class Window : public Widget,
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;
@@ -212,8 +234,6 @@ class Window : public Widget,
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 5d72ed8..0e7a6f2 100644
--- a/views/window/window_gtk.cc
+++ b/views/window/window_gtk.cc
@@ -79,17 +79,37 @@ GdkCursorType HitTestCodeToGdkCursorType(int hittest_code) {
namespace views {
-WindowGtk::WindowGtk(internal::NativeWindowDelegate* delegate)
- : WidgetGtk(delegate->AsNativeWidgetDelegate()),
- delegate_(delegate),
+WindowGtk::WindowGtk()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(delegate_(this)),
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:
@@ -109,7 +129,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(GetWindow()->GetRootView(), &screen_point);
+ View::ConvertPointToScreen(GetRootView(), &screen_point);
gtk_window_begin_move_drag(GetNativeWindow(), event->button,
screen_point.x(), screen_point.y(),
event->time);
@@ -127,7 +147,7 @@ gboolean WindowGtk::OnButtonPress(GtkWidget* widget, GdkEventButton* event) {
case HTTOPLEFT:
case HTTOPRIGHT: {
gfx::Point screen_point(event->x, event->y);
- View::ConvertPointToScreen(GetWindow()->GetRootView(), &screen_point);
+ View::ConvertPointToScreen(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(),
@@ -201,6 +221,9 @@ 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",
@@ -287,11 +310,7 @@ void WindowGtk::SetAccessibleState(ui::AccessibilityTypes::State state) {
}
Window* WindowGtk::GetWindow() {
- return delegate_->AsWindow();
-}
-
-const Window* WindowGtk::GetWindow() const {
- return delegate_->AsWindow();
+ return this;
}
void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
@@ -301,7 +320,7 @@ void WindowGtk::SetWindowBounds(const gfx::Rect& bounds,
}
void WindowGtk::HideWindow() {
- GetWindow()->Hide();
+ Hide();
}
void WindowGtk::Activate() {
@@ -360,14 +379,20 @@ void WindowGtk::SetUseDragFrame(bool use_drag_frame) {
NOTIMPLEMENTED();
}
-NonClientFrameView* WindowGtk::CreateFrameViewForWindow() {
- return new CustomFrameView(delegate_->AsWindow());
-}
-
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() {
+ // 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::UpdateFrameAfterFrameChange() {
// We currently don't support different frame types on Gtk, so we don't
// need to implement this.
@@ -385,8 +410,8 @@ bool WindowGtk::ShouldUseNativeFrame() const {
void WindowGtk::FrameTypeChanged() {
// This is called when the Theme has changed, so forward the event to the root
// widget.
- GetWidget()->ThemeChanged();
- GetWidget()->GetRootView()->SchedulePaint();
+ ThemeChanged();
+ GetRootView()->SchedulePaint();
}
////////////////////////////////////////////////////////////////////////////////
@@ -412,9 +437,7 @@ void WindowGtk::SaveWindowPosition() {
return;
bool maximized = window_state_ & GDK_WINDOW_STATE_MAXIMIZED;
- GetWindow()->window_delegate()->SaveWindowPlacement(
- GetWidget()->GetWindowScreenBounds(),
- maximized);
+ GetWindow()->window_delegate()->SaveWindowPlacement(GetBounds(), maximized);
}
void WindowGtk::OnDestroy(GtkWidget* widget) {
@@ -427,10 +450,8 @@ void WindowGtk::OnDestroy(GtkWidget* widget) {
// NativeWindow, public:
// static
-NativeWindow* NativeWindow::CreateNativeWindow(
- internal::NativeWindowDelegate* delegate) {
- return new WindowGtk(delegate);
+Window* NativeWindow::CreateNativeWindow() {
+ return new WindowGtk;
}
} // namespace views
-
diff --git a/views/window/window_gtk.h b/views/window/window_gtk.h
index b235349..e659e4a 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 {
+class WindowGtk : public WidgetGtk, public NativeWindow, public Window {
public:
- explicit WindowGtk(internal::NativeWindowDelegate* delegate);
+ WindowGtk();
virtual ~WindowGtk();
- virtual Window* GetWindow() OVERRIDE;
- virtual const Window* GetWindow() const OVERRIDE;
+ virtual Window* AsWindow();
+ virtual const Window* AsWindow() const;
// Overridden from WidgetGtk:
virtual gboolean OnButtonPress(GtkWidget* widget, GdkEventButton* event);
@@ -63,6 +63,7 @@ class WindowGtk : public WidgetGtk, public NativeWindow {
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;
@@ -78,6 +79,7 @@ class WindowGtk : public WidgetGtk, public NativeWindow {
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 621af5a..d421647 100644
--- a/views/window/window_win.cc
+++ b/views/window/window_win.cc
@@ -233,30 +233,6 @@ 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() {
}
@@ -307,6 +283,28 @@ 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.
@@ -373,7 +371,7 @@ LRESULT WindowWin::OnAppCommand(HWND window, short app_command, WORD device,
}
void WindowWin::OnClose() {
- GetWindow()->Close();
+ GetWindow()->CloseWindow();
}
void WindowWin::OnCommand(UINT notification_code, int command_id, HWND window) {
@@ -414,7 +412,7 @@ void WindowWin::OnExitSizeMove() {
WidgetWin::OnExitSizeMove();
delegate_->OnNativeWindowEndUserBoundsChange();
- if (!ShouldUseNativeFrame()) {
+ if (!GetThemeProvider()->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()).
@@ -775,8 +773,7 @@ void WindowWin::OnSysCommand(UINT notification_code, CPoint click) {
!!(GetKeyState(VK_SHIFT) & 0x8000),
!!(GetKeyState(VK_CONTROL) & 0x8000),
false);
- AsNativeWidget()->GetWidget()->GetFocusManager()->
- ProcessAccelerator(accelerator);
+ GetFocusManager()->ProcessAccelerator(accelerator);
return;
}
@@ -895,14 +892,6 @@ 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;
}
@@ -1174,6 +1163,10 @@ 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.
@@ -1194,8 +1187,8 @@ void WindowWin::SetUseDragFrame(bool use_drag_frame) {
NonClientFrameView* WindowWin::CreateFrameViewForWindow() {
if (ShouldUseNativeFrame())
- return new NativeFrameView(GetWindow());
- return new CustomFrameView(GetWindow());
+ return new NativeFrameView(this);
+ return new CustomFrameView(this);
}
void WindowWin::UpdateFrameAfterFrameChange() {
@@ -1208,7 +1201,10 @@ gfx::NativeWindow WindowWin::GetNativeWindow() const {
}
bool WindowWin::ShouldUseNativeFrame() const {
- return WidgetWin::IsAeroGlassEnabled();
+ ui::ThemeProvider* tp = GetThemeProvider();
+ if (!tp)
+ return WidgetWin::IsAeroGlassEnabled();
+ return tp->ShouldUseNativeFrame();
}
void WindowWin::FrameTypeChanged() {
@@ -1348,13 +1344,26 @@ 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
-NativeWindow* NativeWindow::CreateNativeWindow(
- internal::NativeWindowDelegate* delegate) {
- return new WindowWin(delegate);
+Window* NativeWindow::CreateNativeWindow() {
+ return new WindowWin;
}
} // namespace views
diff --git a/views/window/window_win.h b/views/window/window_win.h
index 71f2273..5ade949 100644
--- a/views/window/window_win.h
+++ b/views/window/window_win.h
@@ -41,9 +41,10 @@ class WindowDelegate;
//
///////////////////////////////////////////////////////////////////////////////
class WindowWin : public WidgetWin,
- public NativeWindow {
+ public NativeWindow,
+ public Window {
public:
- explicit WindowWin(internal::NativeWindowDelegate* delegate);
+ WindowWin();
virtual ~WindowWin();
// Show the window with the specified show command.
@@ -66,10 +67,6 @@ 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;
@@ -126,6 +123,8 @@ 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;
@@ -160,6 +159,7 @@ 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;