summaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 05:33:21 +0000
committerjeremya@chromium.org <jeremya@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-10 05:33:21 +0000
commit3e1caee2e8b3d11690b2e9ce4a1a2e556bcf38a6 (patch)
tree5b8d55834535600ad4f78de74f1b7619c6a974ed /ui
parent3dcf0407ae4fb947301ffbb61760c79e3239eb97 (diff)
downloadchromium_src-3e1caee2e8b3d11690b2e9ce4a1a2e556bcf38a6.zip
chromium_src-3e1caee2e8b3d11690b2e9ce4a1a2e556bcf38a6.tar.gz
chromium_src-3e1caee2e8b3d11690b2e9ce4a1a2e556bcf38a6.tar.bz2
Custom frame UI for platform apps on Windows.
Review URL: http://codereview.chromium.org/9254046 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@121408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r--ui/views/widget/native_widget_win.cc19
-rw-r--r--ui/views/widget/native_widget_win.h6
-rw-r--r--ui/views/widget/widget.cc2
-rw-r--r--ui/views/widget/widget.h4
4 files changed, 28 insertions, 3 deletions
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc
index e6fa310..f483364 100644
--- a/ui/views/widget/native_widget_win.cc
+++ b/ui/views/widget/native_widget_win.cc
@@ -1292,6 +1292,9 @@ LRESULT NativeWidgetWin::OnCreate(CREATESTRUCT* create_struct) {
// We should attach IMEs only when we need to input CJK strings.
ImmAssociateContextEx(hwnd(), NULL, 0);
+ if (remove_standard_frame_)
+ SendFrameChanged(GetNativeView());
+
// We need to allow the delegate to size its contents since the window may not
// receive a size notification when its initial bounds are specified at window
// creation time.
@@ -1641,9 +1644,11 @@ LRESULT NativeWidgetWin::OnNCActivate(BOOL active) {
LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) {
// We only override the default handling if we need to specify a custom
// non-client edge width. Note that in most cases "no insets" means no
- // custom width, but in fullscreen mode we want a custom width of 0.
+ // custom width, but in fullscreen mode or when the NonClientFrameView
+ // requests it, we want a custom width of 0.
gfx::Insets insets = GetClientAreaInsets();
- if (insets.empty() && !IsFullscreen()) {
+ if (insets.empty() && !IsFullscreen() &&
+ !(mode && remove_standard_frame_)) {
SetMsgHandled(FALSE);
return 0;
}
@@ -1728,7 +1733,7 @@ LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
// If the DWM is rendering the window controls, we need to give the DWM's
// default window procedure first chance to handle hit testing.
- if (GetWidget()->ShouldUseNativeFrame()) {
+ if (!remove_standard_frame_ && GetWidget()->ShouldUseNativeFrame()) {
LRESULT result;
if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
MAKELPARAM(point.x, point.y), &result)) {
@@ -2094,6 +2099,8 @@ void NativeWidgetWin::OnWindowPosChanging(WINDOWPOS* window_pos) {
void NativeWidgetWin::OnWindowPosChanged(WINDOWPOS* window_pos) {
if (DidClientAreaSizeChange(window_pos))
ClientAreaSizeChanged();
+ if (remove_standard_frame_ && window_pos->flags & SWP_FRAMECHANGED)
+ UpdateDWMFrame();
if (window_pos->flags & SWP_SHOWWINDOW)
delegate_->OnNativeWidgetVisibilityChanged(true);
else if (window_pos->flags & SWP_HIDEWINDOW)
@@ -2303,6 +2310,7 @@ void NativeWidgetWin::SetInitParams(const Widget::InitParams& params) {
set_window_ex_style(window_ex_style() | ex_style);
has_non_client_view_ = Widget::RequiresNonClientView(params.type);
+ remove_standard_frame_ = params.remove_standard_frame;
}
void NativeWidgetWin::RedrawInvalidRect() {
@@ -2376,6 +2384,11 @@ void NativeWidgetWin::ClientAreaSizeChanged() {
layered_window_contents_.reset(new gfx::CanvasSkia(s, false));
}
+void NativeWidgetWin::UpdateDWMFrame() {
+ MARGINS m = {10, 10, 10, 10};
+ DwmExtendFrameIntoClientArea(GetNativeView(), &m);
+}
+
void NativeWidgetWin::ResetWindowRegion(bool force) {
// A native frame uses the native window region, and we don't want to mess
// with it.
diff --git a/ui/views/widget/native_widget_win.h b/ui/views/widget/native_widget_win.h
index 3094cec..af67ba1 100644
--- a/ui/views/widget/native_widget_win.h
+++ b/ui/views/widget/native_widget_win.h
@@ -503,6 +503,10 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
// frame windows.
void ResetWindowRegion(bool force);
+ // When removing the standard frame, tells the DWM how much glass we want on
+ // the edges. Currently hardcoded to 10px on all sides.
+ void UpdateDWMFrame();
+
// Calls DefWindowProc, safely wrapping the call in a ScopedRedrawLock to
// prevent frame flicker. DefWindowProc handling can otherwise render the
// classic-look window title bar directly.
@@ -653,6 +657,8 @@ class VIEWS_EXPORT NativeWidgetWin : public ui::WindowImpl,
// Init time, before the Widget has created the NonClientView.
bool has_non_client_view_;
+ bool remove_standard_frame_;
+
DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin);
};
diff --git a/ui/views/widget/widget.cc b/ui/views/widget/widget.cc
index 05951e8..57434c0 100644
--- a/ui/views/widget/widget.cc
+++ b/ui/views/widget/widget.cc
@@ -120,6 +120,7 @@ Widget::InitParams::InitParams()
ownership(NATIVE_WIDGET_OWNS_WIDGET),
mirror_origin_in_rtl(false),
has_dropshadow(false),
+ remove_standard_frame(false),
show_state(ui::SHOW_STATE_DEFAULT),
double_buffer(false),
parent(NULL),
@@ -142,6 +143,7 @@ Widget::InitParams::InitParams(Type type)
ownership(NATIVE_WIDGET_OWNS_WIDGET),
mirror_origin_in_rtl(false),
has_dropshadow(false),
+ remove_standard_frame(false),
show_state(ui::SHOW_STATE_DEFAULT),
double_buffer(false),
parent(NULL),
diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h
index 9932ae9..d1144ac 100644
--- a/ui/views/widget/widget.h
+++ b/ui/views/widget/widget.h
@@ -163,6 +163,10 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
Ownership ownership;
bool mirror_origin_in_rtl;
bool has_dropshadow;
+ // Only used by NativeWidgetWin. Specifies that the system default caption
+ // and icon should not be rendered, and that the client area should be
+ // equivalent to the window area.
+ bool remove_standard_frame;
// Whether the widget should be maximized or minimized.
ui::WindowShowState show_state;
// Should the widget be double buffered? Default is false.