Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(79)

Side by Side Diff: ui/views/widget/native_widget_win.cc

Issue 10860054: Selectively revert parts of my earlier CL to green interactive tests. I will progressively re-enabl… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/views/widget/native_widget_win.h" 5 #include "ui/views/widget/native_widget_win.h"
6 6
7 #include <dwmapi.h> 7 #include <dwmapi.h>
8 #include <shellapi.h> 8 #include <shellapi.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 SetMsgHandled(FALSE); 1454 SetMsgHandled(FALSE);
1455 } 1455 }
1456 1456
1457 LRESULT NativeWidgetWin::OnImeMessages(UINT message, 1457 LRESULT NativeWidgetWin::OnImeMessages(UINT message,
1458 WPARAM w_param, 1458 WPARAM w_param,
1459 LPARAM l_param) { 1459 LPARAM l_param) {
1460 return message_handler_->OnImeMessages(message, w_param, l_param); 1460 return message_handler_->OnImeMessages(message, w_param, l_param);
1461 } 1461 }
1462 1462
1463 void NativeWidgetWin::OnInitMenu(HMENU menu) { 1463 void NativeWidgetWin::OnInitMenu(HMENU menu) {
1464 message_handler_->OnInitMenu(menu); 1464 bool is_fullscreen = IsFullscreen();
1465 bool is_minimized = IsMinimized();
1466 bool is_maximized = IsMaximized();
1467 bool is_restored = !is_fullscreen && !is_minimized && !is_maximized;
1468
1469 ScopedRedrawLock lock(this);
1470 EnableMenuItem(menu, SC_RESTORE, is_minimized || is_maximized);
1471 EnableMenuItem(menu, SC_MOVE, is_restored);
1472 EnableMenuItem(menu, SC_SIZE,
1473 GetWidget()->widget_delegate()->CanResize() && is_restored);
1474 EnableMenuItem(menu, SC_MAXIMIZE,
1475 GetWidget()->widget_delegate()->CanMaximize() &&
1476 !is_fullscreen && !is_maximized);
1477 EnableMenuItem(menu, SC_MINIMIZE,
1478 GetWidget()->widget_delegate()->CanMaximize() &&
1479 !is_minimized);
1465 } 1480 }
1466 1481
1467 void NativeWidgetWin::OnInitMenuPopup(HMENU menu, 1482 void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
1468 UINT position, 1483 UINT position,
1469 BOOL is_system_menu) { 1484 BOOL is_system_menu) {
1470 message_handler_->OnInitMenu(menu); 1485 SetMsgHandled(FALSE);
1471 } 1486 }
1472 1487
1473 void NativeWidgetWin::OnInputLangChange(DWORD character_set, 1488 void NativeWidgetWin::OnInputLangChange(DWORD character_set,
1474 HKL input_language_id) { 1489 HKL input_language_id) {
1475 message_handler_->OnInputLangChange(character_set, input_language_id); 1490 message_handler_->OnInputLangChange(character_set, input_language_id);
1476 } 1491 }
1477 1492
1478 LRESULT NativeWidgetWin::OnKeyEvent(UINT message, 1493 LRESULT NativeWidgetWin::OnKeyEvent(UINT message,
1479 WPARAM w_param, 1494 WPARAM w_param,
1480 LPARAM l_param) { 1495 LPARAM l_param) {
1481 return message_handler_->OnKeyEvent(message, w_param, l_param); 1496 MSG msg = { hwnd(), message, w_param, l_param };
1497 ui::KeyEvent key(msg, message == WM_CHAR);
1498 InputMethod* input_method = GetWidget()->GetInputMethodDirect();
1499 if (input_method)
1500 input_method->DispatchKeyEvent(key);
1501 else
1502 DispatchKeyEventPostIME(key);
1503 return 0;
1482 } 1504 }
1483 1505
1484 void NativeWidgetWin::OnKillFocus(HWND focused_window) { 1506 void NativeWidgetWin::OnKillFocus(HWND focused_window) {
1485 message_handler_->OnKillFocus(focused_window); 1507 delegate_->OnNativeBlur(focused_window);
1508 InputMethod* input_method = GetWidget()->GetInputMethodDirect();
1509 if (input_method)
1510 input_method->OnBlur();
1511 SetMsgHandled(FALSE);
1486 } 1512 }
1487 1513
1488 LRESULT NativeWidgetWin::OnMouseActivate(UINT message, 1514 LRESULT NativeWidgetWin::OnMouseActivate(UINT message,
1489 WPARAM w_param, 1515 WPARAM w_param,
1490 LPARAM l_param) { 1516 LPARAM l_param) {
1491 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent 1517 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent
1492 // line. 1518 // line.
1493 if (GetWidget()->non_client_view()) 1519 if (GetWidget()->non_client_view())
1494 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT; 1520 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT;
1495 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE) 1521 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1722 // window from the left edge look slightly less broken. 1748 // window from the left edge look slightly less broken.
1723 // We special case when left or top insets are 0, since these conditions 1749 // We special case when left or top insets are 0, since these conditions
1724 // actually require another repaint to correct the layout after glass gets 1750 // actually require another repaint to correct the layout after glass gets
1725 // turned on and off. 1751 // turned on and off.
1726 if (insets.left() == 0 || insets.top() == 0) 1752 if (insets.left() == 0 || insets.top() == 0)
1727 return 0; 1753 return 0;
1728 return mode ? WVR_REDRAW : 0; 1754 return mode ? WVR_REDRAW : 0;
1729 } 1755 }
1730 1756
1731 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) { 1757 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
1732 return message_handler_->OnNCHitTest(point); 1758 if (!GetWidget()->non_client_view()) {
1759 SetMsgHandled(FALSE);
1760 return 0;
1761 }
1762
1763 // If the DWM is rendering the window controls, we need to give the DWM's
1764 // default window procedure first chance to handle hit testing.
1765 if (!message_handler_->remove_standard_frame() &&
1766 GetWidget()->ShouldUseNativeFrame()) {
1767 LRESULT result;
1768 if (DwmDefWindowProc(GetNativeView(), WM_NCHITTEST, 0,
1769 MAKELPARAM(point.x, point.y), &result)) {
1770 return result;
1771 }
1772 }
1773
1774 // First, give the NonClientView a chance to test the point to see if it
1775 // provides any of the non-client area.
1776 POINT temp = point;
1777 MapWindowPoints(HWND_DESKTOP, GetNativeView(), &temp, 1);
1778 int component = delegate_->GetNonClientComponent(gfx::Point(temp));
1779 if (component != HTNOWHERE)
1780 return component;
1781
1782 // Otherwise, we let Windows do all the native frame non-client handling for
1783 // us.
1784 SetMsgHandled(FALSE);
1785 return 0;
1733 } 1786 }
1734 1787
1735 void NativeWidgetWin::OnNCPaint(HRGN rgn) { 1788 void NativeWidgetWin::OnNCPaint(HRGN rgn) {
1736 // We only do non-client painting if we're not using the native frame. 1789 // We only do non-client painting if we're not using the native frame.
1737 // It's required to avoid some native painting artifacts from appearing when 1790 // It's required to avoid some native painting artifacts from appearing when
1738 // the window is resized. 1791 // the window is resized.
1739 if (!GetWidget()->non_client_view() || GetWidget()->ShouldUseNativeFrame()) { 1792 if (!GetWidget()->non_client_view() || GetWidget()->ShouldUseNativeFrame()) {
1740 SetMsgHandled(FALSE); 1793 SetMsgHandled(FALSE);
1741 return; 1794 return;
1742 } 1795 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg, 1920 LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
1868 WPARAM w_param, 1921 WPARAM w_param,
1869 LPARAM l_param) { 1922 LPARAM l_param) {
1870 SetMsgHandled(FALSE); 1923 SetMsgHandled(FALSE);
1871 return 0; 1924 return 0;
1872 } 1925 }
1873 1926
1874 LRESULT NativeWidgetWin::OnSetCursor(UINT message, 1927 LRESULT NativeWidgetWin::OnSetCursor(UINT message,
1875 WPARAM w_param, 1928 WPARAM w_param,
1876 LPARAM l_param) { 1929 LPARAM l_param) {
1877 return message_handler_->OnSetCursor(message, w_param, l_param); 1930 // Using ScopedRedrawLock here frequently allows content behind this window to
1931 // paint in front of this window, causing glaring rendering artifacts.
1932 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via
1933 // DefWindowProc message handling, we'll need to find a better solution.
1934 SetMsgHandled(FALSE);
1935 return 0;
1878 } 1936 }
1879 1937
1880 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { 1938 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) {
1881 message_handler_->OnSetFocus(old_focused_window); 1939 delegate_->OnNativeFocus(old_focused_window);
1940 InputMethod* input_method = GetWidget()->GetInputMethodDirect();
1941 if (input_method)
1942 input_method->OnFocus();
1943 SetMsgHandled(FALSE);
1882 } 1944 }
1883 1945
1884 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { 1946 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
1885 return message_handler_->OnSetIcon(size_type, new_icon); 1947 // Use a ScopedRedrawLock to avoid weird non-client painting.
1948 return DefWindowProcWithRedrawLock(WM_SETICON, size_type,
1949 reinterpret_cast<LPARAM>(new_icon));
1886 } 1950 }
1887 1951
1888 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { 1952 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) {
1889 return message_handler_->OnSetText(text); 1953 // Use a ScopedRedrawLock to avoid weird non-client painting.
1954 return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL,
1955 reinterpret_cast<LPARAM>(text));
1890 } 1956 }
1891 1957
1892 void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { 1958 void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
1893 if (!GetParent() && (flags == SPI_SETWORKAREA) && 1959 if (!GetParent() && (flags == SPI_SETWORKAREA) &&
1894 !GetWidget()->widget_delegate()->WillProcessWorkAreaChange()) { 1960 !GetWidget()->widget_delegate()->WillProcessWorkAreaChange()) {
1895 // Fire a dummy SetWindowPos() call, so we'll trip the code in 1961 // Fire a dummy SetWindowPos() call, so we'll trip the code in
1896 // OnWindowPosChanging() below that notices work area changes. 1962 // OnWindowPosChanging() below that notices work area changes.
1897 ::SetWindowPos(GetNativeView(), 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | 1963 ::SetWindowPos(GetNativeView(), 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
1898 SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOOWNERZORDER); 1964 SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
1899 SetMsgHandled(TRUE); 1965 SetMsgHandled(TRUE);
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 // static 2768 // static
2703 bool NativeWidgetPrivate::IsTouchDown() { 2769 bool NativeWidgetPrivate::IsTouchDown() {
2704 // This currently isn't necessary because we're not generating touch events on 2770 // This currently isn't necessary because we're not generating touch events on
2705 // windows. When we do, this will need to be updated. 2771 // windows. When we do, this will need to be updated.
2706 return false; 2772 return false;
2707 } 2773 }
2708 2774
2709 } // namespace internal 2775 } // namespace internal
2710 2776
2711 } // namespace views 2777 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698