| 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/win/hwnd_message_handler.h" | 5 #include "ui/views/win/hwnd_message_handler.h" |
| 6 | 6 |
| 7 #include <dwmapi.h> | 7 #include <dwmapi.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <wtsapi32.h> | 9 #include <wtsapi32.h> |
| 10 #pragma comment(lib, "wtsapi32.lib") | 10 #pragma comment(lib, "wtsapi32.lib") |
| (...skipping 1887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1898 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); | 1898 MapWindowPoints(HWND_DESKTOP, hwnd(), &temp, 1); |
| 1899 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); | 1899 int component = delegate_->GetNonClientComponent(gfx::Point(temp)); |
| 1900 if (component != HTNOWHERE) | 1900 if (component != HTNOWHERE) |
| 1901 return component; | 1901 return component; |
| 1902 | 1902 |
| 1903 // Otherwise, we let Windows do all the native frame non-client handling for | 1903 // Otherwise, we let Windows do all the native frame non-client handling for |
| 1904 // us. | 1904 // us. |
| 1905 #if defined(USE_AURA) | 1905 #if defined(USE_AURA) |
| 1906 LRESULT hit_test_code = DefWindowProc(hwnd(), WM_NCHITTEST, 0, | 1906 LRESULT hit_test_code = DefWindowProc(hwnd(), WM_NCHITTEST, 0, |
| 1907 MAKELPARAM(point.x, point.y)); | 1907 MAKELPARAM(point.x, point.y)); |
| 1908 // If we faked the WS_VSCROLL and WS_HSCROLL styles for this window, then | 1908 if (needs_scroll_styles_) { |
| 1909 // Windows returns the HTVSCROLL or HTHSCROLL hit test codes if we hover or | 1909 switch (hit_test_code) { |
| 1910 // click on the non client portions of the window where the OS scrollbars | 1910 // If we faked the WS_VSCROLL and WS_HSCROLL styles for this window, then |
| 1911 // would be drawn. These hittest codes are returned even when the scrollbars | 1911 // Windows returns the HTVSCROLL or HTHSCROLL hit test codes if we hover |
| 1912 // are hidden, which is the case in Aura. We fake the hittest code as | 1912 // or click on the non client portions of the window where the OS |
| 1913 // HTCLIENT in this case to ensure that we receive client mouse messages as | 1913 // scrollbars would be drawn. These hittest codes are returned even when |
| 1914 // opposed to non client mouse messages. | 1914 // the scrollbars are hidden, which is the case in Aura. We fake the |
| 1915 if (needs_scroll_styles_ && (hit_test_code == HTVSCROLL || | 1915 // hittest code as HTCLIENT in this case to ensure that we receive client |
| 1916 hit_test_code == HTHSCROLL)) | 1916 // mouse messages as opposed to non client mouse messages. |
| 1917 hit_test_code = HTCLIENT; | 1917 case HTVSCROLL: |
| 1918 case HTHSCROLL: |
| 1919 hit_test_code = HTCLIENT; |
| 1920 break; |
| 1921 |
| 1922 case HTBOTTOMRIGHT: { |
| 1923 // Normally the HTBOTTOMRIGHT hittest code is received when we hover |
| 1924 // near the bottom right of the window. However due to our fake scroll |
| 1925 // styles, we get this code even when we hover around the area where |
| 1926 // the vertical scrollar down arrow would be drawn. |
| 1927 // We check if the hittest coordinates lie in this region and if yes |
| 1928 // we return HTCLIENT. |
| 1929 int border_width = ::GetSystemMetrics(SM_CXSIZEFRAME); |
| 1930 int border_height = ::GetSystemMetrics(SM_CYSIZEFRAME); |
| 1931 int scroll_width = ::GetSystemMetrics(SM_CXVSCROLL); |
| 1932 int scroll_height = ::GetSystemMetrics(SM_CYVSCROLL); |
| 1933 RECT window_rect; |
| 1934 ::GetWindowRect(hwnd(), &window_rect); |
| 1935 window_rect.bottom -= border_height; |
| 1936 window_rect.right -= border_width; |
| 1937 window_rect.left = window_rect.right - scroll_width; |
| 1938 window_rect.top = window_rect.bottom - scroll_height; |
| 1939 POINT pt; |
| 1940 pt.x = point.x; |
| 1941 pt.y = point.y; |
| 1942 if (::PtInRect(&window_rect, pt)) |
| 1943 hit_test_code = HTCLIENT; |
| 1944 break; |
| 1945 } |
| 1946 |
| 1947 default: |
| 1948 break; |
| 1949 } |
| 1950 } |
| 1918 return hit_test_code; | 1951 return hit_test_code; |
| 1919 #else | 1952 #else |
| 1920 SetMsgHandled(FALSE); | 1953 SetMsgHandled(FALSE); |
| 1921 #endif | 1954 #endif |
| 1922 } | 1955 } |
| 1923 | 1956 |
| 1924 void HWNDMessageHandler::OnNCPaint(HRGN rgn) { | 1957 void HWNDMessageHandler::OnNCPaint(HRGN rgn) { |
| 1925 // We only do non-client painting if we're not using the native frame. | 1958 // We only do non-client painting if we're not using the native frame. |
| 1926 // It's required to avoid some native painting artifacts from appearing when | 1959 // It's required to avoid some native painting artifacts from appearing when |
| 1927 // the window is resized. | 1960 // the window is resized. |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2388 SetMsgHandled(FALSE); | 2421 SetMsgHandled(FALSE); |
| 2389 } | 2422 } |
| 2390 | 2423 |
| 2391 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { | 2424 void HWNDMessageHandler::HandleTouchEvents(const TouchEvents& touch_events) { |
| 2392 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); | 2425 base::WeakPtr<HWNDMessageHandler> ref(weak_factory_.GetWeakPtr()); |
| 2393 for (size_t i = 0; i < touch_events.size() && ref; ++i) | 2426 for (size_t i = 0; i < touch_events.size() && ref; ++i) |
| 2394 delegate_->HandleTouchEvent(touch_events[i]); | 2427 delegate_->HandleTouchEvent(touch_events[i]); |
| 2395 } | 2428 } |
| 2396 | 2429 |
| 2397 } // namespace views | 2430 } // namespace views |
| OLD | NEW |