OLD | NEW |
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 Loading... |
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_->OnInitMenuPopup(); |
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 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1929 LPARAM l_param) { | 1903 LPARAM l_param) { |
1930 // Using ScopedRedrawLock here frequently allows content behind this window to | 1904 // Using ScopedRedrawLock here frequently allows content behind this window to |
1931 // paint in front of this window, causing glaring rendering artifacts. | 1905 // paint in front of this window, causing glaring rendering artifacts. |
1932 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via | 1906 // If omitting ScopedRedrawLock here triggers caption rendering artifacts via |
1933 // DefWindowProc message handling, we'll need to find a better solution. | 1907 // DefWindowProc message handling, we'll need to find a better solution. |
1934 SetMsgHandled(FALSE); | 1908 SetMsgHandled(FALSE); |
1935 return 0; | 1909 return 0; |
1936 } | 1910 } |
1937 | 1911 |
1938 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { | 1912 void NativeWidgetWin::OnSetFocus(HWND old_focused_window) { |
1939 delegate_->OnNativeFocus(old_focused_window); | 1913 message_handler_->OnSetFocus(old_focused_window); |
1940 InputMethod* input_method = GetWidget()->GetInputMethodDirect(); | |
1941 if (input_method) | |
1942 input_method->OnFocus(); | |
1943 SetMsgHandled(FALSE); | |
1944 } | 1914 } |
1945 | 1915 |
1946 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { | 1916 LRESULT NativeWidgetWin::OnSetIcon(UINT size_type, HICON new_icon) { |
1947 // Use a ScopedRedrawLock to avoid weird non-client painting. | 1917 // Use a ScopedRedrawLock to avoid weird non-client painting. |
1948 return DefWindowProcWithRedrawLock(WM_SETICON, size_type, | 1918 return DefWindowProcWithRedrawLock(WM_SETICON, size_type, |
1949 reinterpret_cast<LPARAM>(new_icon)); | 1919 reinterpret_cast<LPARAM>(new_icon)); |
1950 } | 1920 } |
1951 | 1921 |
1952 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { | 1922 LRESULT NativeWidgetWin::OnSetText(const wchar_t* text) { |
1953 // Use a ScopedRedrawLock to avoid weird non-client painting. | 1923 // Use a ScopedRedrawLock to avoid weird non-client painting. |
(...skipping 814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2768 // static | 2738 // static |
2769 bool NativeWidgetPrivate::IsTouchDown() { | 2739 bool NativeWidgetPrivate::IsTouchDown() { |
2770 // This currently isn't necessary because we're not generating touch events on | 2740 // This currently isn't necessary because we're not generating touch events on |
2771 // windows. When we do, this will need to be updated. | 2741 // windows. When we do, this will need to be updated. |
2772 return false; | 2742 return false; |
2773 } | 2743 } |
2774 | 2744 |
2775 } // namespace internal | 2745 } // namespace internal |
2776 | 2746 |
2777 } // namespace views | 2747 } // namespace views |
OLD | NEW |