diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:54:40 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-08-20 22:54:40 +0000 |
commit | 9c471cf225f9e5487f3eff466792119f8370dc04 (patch) | |
tree | bbf4fb23abccca784e5546383046d5a7adcbd206 /ui | |
parent | 750ae6bd57722802e10484b108a66f8565fedc72 (diff) | |
download | chromium_src-9c471cf225f9e5487f3eff466792119f8370dc04.zip chromium_src-9c471cf225f9e5487f3eff466792119f8370dc04.tar.gz chromium_src-9c471cf225f9e5487f3eff466792119f8370dc04.tar.bz2 |
Selectively revert parts of my earlier CL to green interactive tests. I will progressively re-enable bits of this until I figure out what is the cause.
http://crbug.com/142962
TBR=sky@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10860054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152419 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/views/widget/native_widget_win.cc | 84 |
1 files changed, 75 insertions, 9 deletions
diff --git a/ui/views/widget/native_widget_win.cc b/ui/views/widget/native_widget_win.cc index 957b35e..83a5d23 100644 --- a/ui/views/widget/native_widget_win.cc +++ b/ui/views/widget/native_widget_win.cc @@ -1461,13 +1461,28 @@ LRESULT NativeWidgetWin::OnImeMessages(UINT message, } void NativeWidgetWin::OnInitMenu(HMENU menu) { - message_handler_->OnInitMenu(menu); + bool is_fullscreen = IsFullscreen(); + bool is_minimized = IsMinimized(); + bool is_maximized = IsMaximized(); + bool is_restored = !is_fullscreen && !is_minimized && !is_maximized; + + ScopedRedrawLock lock(this); + EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized); + EnableMenuItem(menu, SC_MOVE, is_restored); + EnableMenuItem(menu, SC_SIZE, + GetWidget()->widget_delegate()->CanResize() && is_restored); + EnableMenuItem(menu, SC_MAXIMIZE, + GetWidget()->widget_delegate()->CanMaximize() && + !is_fullscreen && !is_maximized); + EnableMenuItem(menu, SC_MINIMIZE, + GetWidget()->widget_delegate()->CanMaximize() && + !is_minimized); } void NativeWidgetWin::OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) { - message_handler_->OnInitMenu(menu); + SetMsgHandled(FALSE); } void NativeWidgetWin::OnInputLangChange(DWORD character_set, @@ -1478,11 +1493,22 @@ void NativeWidgetWin::OnInputLangChange(DWORD character_set, LRESULT NativeWidgetWin::OnKeyEvent(UINT message, WPARAM w_param, LPARAM l_param) { - return message_handler_->OnKeyEvent(message, w_param, l_param); + MSG msg = { hwnd(), message, w_param, l_param }; + ui::KeyEvent key(msg, message == WM_CHAR); + InputMethod* input_method = GetWidget()->GetInputMethodDirect(); + if (input_method) + input_method->DispatchKeyEvent(key); + else + DispatchKeyEventPostIME(key); + return 0; } void NativeWidgetWin::OnKillFocus(HWND focused_window) { - message_handler_->OnKillFocus(focused_window); + delegate_->OnNativeBlur(focused_window); + InputMethod* input_method = GetWidget()->GetInputMethodDirect(); + if (input_method) + input_method->OnBlur(); + SetMsgHandled(FALSE); } LRESULT NativeWidgetWin::OnMouseActivate(UINT message, @@ -1729,7 +1755,34 @@ LRESULT NativeWidgetWin::OnNCCalcSize(BOOL mode, LPARAM l_param) { } LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) { - return message_handler_->OnNCHitTest(point); + if (!GetWidget()->non_client_view()) { + SetMsgHandled(FALSE); + return 0; + } + + // 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 (!message_handler_->remove_standard_frame() && + GetWidget()->ShouldUseNativeFrame()) { + LRESULT result; + if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0, + MAKELPARAM(point.x, point.y), &result)) { + return result; + } + } + + // First, give the NonClientView a chance to test the point to see if it + // provides any of the non-client area. + POINT temp = point; + MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1); + int component = delegate_->GetNonClientComponent(gfx::Point(temp)); + if (component != HTNOWHERE) + return component; + + // Otherwise, we let Windows do all the native frame non-client handling for + // us. + SetMsgHandled(FALSE); + return 0; } void NativeWidgetWin::OnNCPaint(HRGN rgn) { @@ -1874,19 +1927,32 @@ LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg, LRESULT NativeWidgetWin::OnSetCursor(UINT message, WPARAM w_param, LPARAM l_param) { - return message_handler_->OnSetCursor(message, w_param, l_param); + // Using ScopedRedrawLock here frequently allows content behind this window to + // paint in front of this window, causing glaring rendering artifacts. + // If omitting ScopedRedrawLock here triggers caption rendering artifacts via + // DefWindowProc message handling, we'll need to find a better solution. + SetMsgHandled(FALSE); + return 0; } void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { - message_handler_->OnSetFocus(old_focused_window); + delegate_->OnNativeFocus(old_focused_window); + InputMethod* input_method = GetWidget()->GetInputMethodDirect(); + if (input_method) + input_method->OnFocus(); + SetMsgHandled(FALSE); } LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { - return message_handler_->OnSetIcon(size_type, new_icon); + // Use a ScopedRedrawLock to avoid weird non-client painting. + return DefWindowProcWithRedrawLock(WM_SETICON, size_type, + reinterpret_cast<LPARAM>(new_icon)); } LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { - return message_handler_->OnSetText(text); + // Use a ScopedRedrawLock to avoid weird non-client painting. + return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL, + reinterpret_cast<LPARAM>(text)); } void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { |