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

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

Issue 10828398: Revert 152388 - Revert 152374 - Move more message handlers from NativeWidgetWin to HWNDMessageHandl… (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 | « ui/views/widget/native_widget_win.h ('k') | 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 bool is_fullscreen = IsFullscreen(); 1464 message_handler_->OnInitMenu(menu);
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);
1480 } 1465 }
1481 1466
1482 void NativeWidgetWin::OnInitMenuPopup(HMENU menu, 1467 void NativeWidgetWin::OnInitMenuPopup(HMENU menu,
1483 UINT position, 1468 UINT position,
1484 BOOL is_system_menu) { 1469 BOOL is_system_menu) {
1485 SetMsgHandled(FALSE); 1470 message_handler_->OnInitMenu(menu);
1486 } 1471 }
1487 1472
1488 void NativeWidgetWin::OnInputLangChange(DWORD character_set, 1473 void NativeWidgetWin::OnInputLangChange(DWORD character_set,
1489 HKL input_language_id) { 1474 HKL input_language_id) {
1490 message_handler_->OnInputLangChange(character_set, input_language_id); 1475 message_handler_->OnInputLangChange(character_set, input_language_id);
1491 } 1476 }
1492 1477
1493 LRESULT NativeWidgetWin::OnKeyEvent(UINT message, 1478 LRESULT NativeWidgetWin::OnKeyEvent(UINT message,
1494 WPARAM w_param, 1479 WPARAM w_param,
1495 LPARAM l_param) { 1480 LPARAM l_param) {
1496 MSG msg = { hwnd(), message, w_param, l_param }; 1481 return message_handler_->OnKeyEvent(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;
1504 } 1482 }
1505 1483
1506 void NativeWidgetWin::OnKillFocus(HWND focused_window) { 1484 void NativeWidgetWin::OnKillFocus(HWND focused_window) {
1507 delegate_->OnNativeBlur(focused_window); 1485 message_handler_->OnKillFocus(focused_window);
1508 InputMethod* input_method = GetWidget()->GetInputMethodDirect();
1509 if (input_method)
1510 input_method->OnBlur();
1511 SetMsgHandled(FALSE);
1512 } 1486 }
1513 1487
1514 LRESULT NativeWidgetWin::OnMouseActivate(UINT message, 1488 LRESULT NativeWidgetWin::OnMouseActivate(UINT message,
1515 WPARAM w_param, 1489 WPARAM w_param,
1516 LPARAM l_param) { 1490 LPARAM l_param) {
1517 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent 1491 // TODO(beng): resolve this with the GetWindowLong() check on the subsequent
1518 // line. 1492 // line.
1519 if (GetWidget()->non_client_view()) 1493 if (GetWidget()->non_client_view())
1520 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT; 1494 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT;
1521 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE) 1495 if (GetWindowLong(GWL_EXSTYLE) & WS_EX_NOACTIVATE)
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1748 // window from the left edge look slightly less broken. 1722 // window from the left edge look slightly less broken.
1749 // We special case when left or top insets are 0, since these conditions 1723 // We special case when left or top insets are 0, since these conditions
1750 // actually require another repaint to correct the layout after glass gets 1724 // actually require another repaint to correct the layout after glass gets
1751 // turned on and off. 1725 // turned on and off.
1752 if (insets.left() == 0 || insets.top() == 0) 1726 if (insets.left() == 0 || insets.top() == 0)
1753 return 0; 1727 return 0;
1754 return mode ? WVR_REDRAW : 0; 1728 return mode ? WVR_REDRAW : 0;
1755 } 1729 }
1756 1730
1757 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) { 1731 LRESULT NativeWidgetWin::OnNCHitTest(const CPoint& point) {
1758 if (!GetWidget()->non_client_view()) { 1732 return message_handler_->OnNCHitTest(point);
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;
1786 } 1733 }
1787 1734
1788 void NativeWidgetWin::OnNCPaint(HRGN rgn) { 1735 void NativeWidgetWin::OnNCPaint(HRGN rgn) {
1789 // We only do non-client painting if we're not using the native frame. 1736 // We only do non-client painting if we're not using the native frame.
1790 // It's required to avoid some native painting artifacts from appearing when 1737 // It's required to avoid some native painting artifacts from appearing when
1791 // the window is resized. 1738 // the window is resized.
1792 if (!GetWidget()->non_client_view() || GetWidget()->ShouldUseNativeFrame()) { 1739 if (!GetWidget()->non_client_view() || GetWidget()->ShouldUseNativeFrame()) {
1793 SetMsgHandled(FALSE); 1740 SetMsgHandled(FALSE);
1794 return; 1741 return;
1795 } 1742 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg, 1867 LRESULT NativeWidgetWin::OnReflectedMessage(UINT msg,
1921 WPARAM w_param, 1868 WPARAM w_param,
1922 LPARAM l_param) { 1869 LPARAM l_param) {
1923 SetMsgHandled(FALSE); 1870 SetMsgHandled(FALSE);
1924 return 0; 1871 return 0;
1925 } 1872 }
1926 1873
1927 LRESULT NativeWidgetWin::OnSetCursor(UINT message, 1874 LRESULT NativeWidgetWin::OnSetCursor(UINT message,
1928 WPARAM w_param, 1875 WPARAM w_param,
1929 LPARAM l_param) { 1876 LPARAM l_param) {
1930 // Using ScopedRedrawLock here frequently allows content behind this window to 1877 return message_handler_->OnSetCursor(message, w_param, l_param);
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;
1936 } 1878 }
1937 1879
1938 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { 1880 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) {
1939 delegate_->OnNativeFocus(old_focused_window); 1881 message_handler_->OnSetFocus(old_focused_window);
1940 InputMethod* input_method = GetWidget()->GetInputMethodDirect();
1941 if (input_method)
1942 input_method->OnFocus();
1943 SetMsgHandled(FALSE);
1944 } 1882 }
1945 1883
1946 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { 1884 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) {
1947 // Use a ScopedRedrawLock to avoid weird non-client painting. 1885 return message_handler_->OnSetIcon(size_type, new_icon);
1948 return DefWindowProcWithRedrawLock(WM_SETICON, size_type,
1949 reinterpret_cast<LPARAM>(new_icon));
1950 } 1886 }
1951 1887
1952 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { 1888 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) {
1953 // Use a ScopedRedrawLock to avoid weird non-client painting. 1889 return message_handler_->OnSetText(text);
1954 return DefWindowProcWithRedrawLock(WM_SETTEXT, NULL,
1955 reinterpret_cast<LPARAM>(text));
1956 } 1890 }
1957 1891
1958 void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) { 1892 void NativeWidgetWin::OnSettingChange(UINT flags, const wchar_t* section) {
1959 if (!GetParent() && (flags == SPI_SETWORKAREA) && 1893 if (!GetParent() && (flags == SPI_SETWORKAREA) &&
1960 !GetWidget()->widget_delegate()->WillProcessWorkAreaChange()) { 1894 !GetWidget()->widget_delegate()->WillProcessWorkAreaChange()) {
1961 // Fire a dummy SetWindowPos() call, so we'll trip the code in 1895 // Fire a dummy SetWindowPos() call, so we'll trip the code in
1962 // OnWindowPosChanging() below that notices work area changes. 1896 // OnWindowPosChanging() below that notices work area changes.
1963 ::SetWindowPos(GetNativeView(), 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | 1897 ::SetWindowPos(GetNativeView(), 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE |
1964 SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOOWNERZORDER); 1898 SWP_NOZORDER | SWP_NOREDRAW | SWP_NOACTIVATE | SWP_NOOWNERZORDER);
1965 SetMsgHandled(TRUE); 1899 SetMsgHandled(TRUE);
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
2251 // NativeWidgetWin, HWNDMessageHandlerDelegate implementation: 2185 // NativeWidgetWin, HWNDMessageHandlerDelegate implementation:
2252 2186
2253 bool NativeWidgetWin::IsWidgetWindow() const { 2187 bool NativeWidgetWin::IsWidgetWindow() const {
2254 return !!GetWidget()->non_client_view(); 2188 return !!GetWidget()->non_client_view();
2255 } 2189 }
2256 2190
2257 bool NativeWidgetWin::IsUsingCustomFrame() const { 2191 bool NativeWidgetWin::IsUsingCustomFrame() const {
2258 return GetWidget()->ShouldUseNativeFrame(); 2192 return GetWidget()->ShouldUseNativeFrame();
2259 } 2193 }
2260 2194
2195 bool NativeWidgetWin::CanResize() const {
2196 return GetWidget()->widget_delegate()->CanResize();
2197 }
2198
2199 bool NativeWidgetWin::CanMaximize() const {
2200 return GetWidget()->widget_delegate()->CanMaximize();
2201 }
2202
2203 bool NativeWidgetWin::CanActivate() const {
2204 return delegate_->CanActivate();
2205 }
2206
2207 int NativeWidgetWin::GetNonClientComponent(const gfx::Point& point) const {
2208 return delegate_->GetNonClientComponent(point);
2209 }
2210
2211 void NativeWidgetWin::GetWindowMask(const gfx::Size& size, gfx::Path* path) {
2212 GetWidget()->non_client_view()->GetWindowMask(size, path);
2213 }
2214
2261 InputMethod* NativeWidgetWin::GetInputMethod() { 2215 InputMethod* NativeWidgetWin::GetInputMethod() {
2262 return GetWidget()->GetInputMethodDirect(); 2216 return GetWidget()->GetInputMethodDirect();
2263 } 2217 }
2264 2218
2265 void NativeWidgetWin::HandleAppDeactivated() { 2219 void NativeWidgetWin::HandleAppDeactivated() {
2266 // Another application was activated, we should reset any state that 2220 // Another application was activated, we should reset any state that
2267 // disables inactive rendering now. 2221 // disables inactive rendering now.
2268 delegate_->EnableInactiveRendering(); 2222 delegate_->EnableInactiveRendering();
2269 } 2223 }
2270 2224
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
2314 } 2268 }
2315 2269
2316 void NativeWidgetWin::HandleEndWMSizeMove() { 2270 void NativeWidgetWin::HandleEndWMSizeMove() {
2317 delegate_->OnNativeWidgetEndUserBoundsChange(); 2271 delegate_->OnNativeWidgetEndUserBoundsChange();
2318 } 2272 }
2319 2273
2320 void NativeWidgetWin::HandleMove() { 2274 void NativeWidgetWin::HandleMove() {
2321 delegate_->OnNativeWidgetMove(); 2275 delegate_->OnNativeWidgetMove();
2322 } 2276 }
2323 2277
2278 void NativeWidgetWin::HandleNativeFocus(HWND last_focused_window) {
2279 delegate_->OnNativeFocus(last_focused_window);
2280 }
2281
2282 void NativeWidgetWin::HandleNativeBlur(HWND focused_window) {
2283 delegate_->OnNativeBlur(focused_window);
2284 }
2285
2324 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() { 2286 NativeWidgetWin* NativeWidgetWin::AsNativeWidgetWin() {
2325 return this; 2287 return this;
2326 } 2288 }
2327 2289
2328 //////////////////////////////////////////////////////////////////////////////// 2290 ////////////////////////////////////////////////////////////////////////////////
2329 // NativeWidgetWin, private: 2291 // NativeWidgetWin, private:
2330 2292
2331 // static 2293 // static
2332 void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget, 2294 void NativeWidgetWin::PostProcessActivateMessage(NativeWidgetWin* widget,
2333 int activation_state) { 2295 int activation_state) {
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
2740 // static 2702 // static
2741 bool NativeWidgetPrivate::IsTouchDown() { 2703 bool NativeWidgetPrivate::IsTouchDown() {
2742 // This currently isn't necessary because we're not generating touch events on 2704 // This currently isn't necessary because we're not generating touch events on
2743 // windows. When we do, this will need to be updated. 2705 // windows. When we do, this will need to be updated.
2744 return false; 2706 return false;
2745 } 2707 }
2746 2708
2747 } // namespace internal 2709 } // namespace internal
2748 2710
2749 } // namespace views 2711 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/native_widget_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698