| Index: chrome/browser/ui/views/extensions/shell_frame_win.cc
|
| diff --git a/chrome/browser/ui/views/extensions/shell_frame_win.cc b/chrome/browser/ui/views/extensions/shell_frame_win.cc
|
| new file mode 100755
|
| index 0000000000000000000000000000000000000000..05a6329b7cf6d563a4f6b7fc2676da2ffce4301a
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/views/extensions/shell_frame_win.cc
|
| @@ -0,0 +1,82 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include <dwmapi.h>
|
| +
|
| +#include "chrome/browser/ui/views/extensions/shell_frame_win.h"
|
| +
|
| +ShellFrameWin::ShellFrameWin(views::Widget* delegate)
|
| + : views::NativeWidgetWin(delegate) {
|
| +}
|
| +
|
| +views::NativeWidget* ShellFrameWin::AsNativeWidget() {
|
| + return this;
|
| +}
|
| +const views::NativeWidget* ShellFrameWin::AsNativeWidget() const {
|
| + return this;
|
| +}
|
| +
|
| +gfx::Insets ShellFrameWin::GetClientAreaInsets() const {
|
| + return gfx::Insets(0,0,0,0);
|
| +}
|
| +
|
| +LRESULT ShellFrameWin::OnNCCalcSize(BOOL w_param, LPARAM l_param) {
|
| + if (w_param) {
|
| + SetMsgHandled(TRUE);
|
| + MARGINS margins = {10,10,10,10};
|
| + DwmExtendFrameIntoClientArea(GetNativeView(), &margins);
|
| + return 0;
|
| + }
|
| + return views::NativeWidgetWin::OnNCCalcSize(w_param, l_param);
|
| +}
|
| +
|
| +LRESULT ShellFrameWin::OnCreate(CREATESTRUCT* create_struct) {
|
| + RECT rc;
|
| + GetWindowRect(&rc);
|
| + SetWindowPos(NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
|
| + SWP_FRAMECHANGED);
|
| + return views::NativeWidgetWin::OnCreate(create_struct);
|
| +}
|
| +
|
| +LRESULT ShellFrameWin::OnNCHitTest(const CPoint& point) {
|
| + SetMsgHandled(true);
|
| + RECT rc;
|
| + GetWindowRect(&rc);
|
| + int x = point.x - rc.left;
|
| + int y = point.y - rc.top;
|
| + int width = rc.right - rc.left;
|
| + int height = rc.bottom - rc.top;
|
| + if (x <= 5) {
|
| + if (y <= 5) {
|
| + return HTTOPLEFT;
|
| + } else if (y >= height - 5) {
|
| + return HTBOTTOMLEFT;
|
| + } else {
|
| + return HTLEFT;
|
| + }
|
| + } else if (x >= width - 5) {
|
| + if (y <= 5) {
|
| + return HTTOPRIGHT;
|
| + } else if (y >= height - 5) {
|
| + return HTBOTTOMRIGHT;
|
| + } else {
|
| + return HTRIGHT;
|
| + }
|
| + } else {
|
| + if (y <= 5) {
|
| + return HTTOP;
|
| + } else if (y >= height - 5) {
|
| + return HTBOTTOM;
|
| + } else {
|
| + return HTCAPTION;
|
| + }
|
| + }
|
| + NOTREACHED();
|
| +}
|
| +
|
| +// static
|
| +NativeShellFrame* NativeShellFrame::CreateNativeShellFrame(
|
| + views::Widget* container) {
|
| + return new ShellFrameWin(container);
|
| +}
|
|
|