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 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 | 288 |
289 #endif | 289 #endif |
290 | 290 |
291 // A custom MSAA object id used to determine if a screen reader is actively | 291 // A custom MSAA object id used to determine if a screen reader is actively |
292 // listening for MSAA events. | 292 // listening for MSAA events. |
293 const int kCustomObjectID = 1; | 293 const int kCustomObjectID = 1; |
294 | 294 |
295 // The thickness of an auto-hide taskbar in pixels. | 295 // The thickness of an auto-hide taskbar in pixels. |
296 const int kAutoHideTaskbarThicknessPx = 2; | 296 const int kAutoHideTaskbarThicknessPx = 2; |
297 | 297 |
| 298 // The touch id to be used for touch events coming in from Windows Aura |
| 299 // Desktop. |
| 300 const int kDesktopChromeAuraTouchId = 9; |
| 301 |
298 } // namespace | 302 } // namespace |
299 | 303 |
300 // A scoping class that prevents a window from being able to redraw in response | 304 // A scoping class that prevents a window from being able to redraw in response |
301 // to invalidations that may occur within it for the lifetime of the object. | 305 // to invalidations that may occur within it for the lifetime of the object. |
302 // | 306 // |
303 // Why would we want such a thing? Well, it turns out Windows has some | 307 // Why would we want such a thing? Well, it turns out Windows has some |
304 // "unorthodox" behavior when it comes to painting its non-client areas. | 308 // "unorthodox" behavior when it comes to painting its non-client areas. |
305 // Occasionally, Windows will paint portions of the default non-client area | 309 // Occasionally, Windows will paint portions of the default non-client area |
306 // right over the top of the custom frame. This is not simply fixed by handling | 310 // right over the top of the custom frame. This is not simply fixed by handling |
307 // WM_NCPAINT/WM_PAINT, with some investigation it turns out that this | 311 // WM_NCPAINT/WM_PAINT, with some investigation it turns out that this |
(...skipping 1148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT; | 1460 return delegate_->CanActivate() ? MA_ACTIVATE : MA_NOACTIVATEANDEAT; |
1457 if (GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE) | 1461 if (GetWindowLong(hwnd(), GWL_EXSTYLE) & WS_EX_NOACTIVATE) |
1458 return MA_NOACTIVATE; | 1462 return MA_NOACTIVATE; |
1459 SetMsgHandled(FALSE); | 1463 SetMsgHandled(FALSE); |
1460 return MA_ACTIVATE; | 1464 return MA_ACTIVATE; |
1461 } | 1465 } |
1462 | 1466 |
1463 LRESULT HWNDMessageHandler::OnMouseRange(UINT message, | 1467 LRESULT HWNDMessageHandler::OnMouseRange(UINT message, |
1464 WPARAM w_param, | 1468 WPARAM w_param, |
1465 LPARAM l_param) { | 1469 LPARAM l_param) { |
| 1470 #if defined(USE_AURA) |
| 1471 // We handle touch events on Windows Aura. Ignore synthesized mouse messages |
| 1472 // from Windows. |
| 1473 if (!touch_ids_.empty() || ui::IsMouseEventFromTouch(message)) |
| 1474 return 0; |
| 1475 #endif |
1466 if (message == WM_RBUTTONUP && is_right_mouse_pressed_on_caption_) { | 1476 if (message == WM_RBUTTONUP && is_right_mouse_pressed_on_caption_) { |
1467 is_right_mouse_pressed_on_caption_ = false; | 1477 is_right_mouse_pressed_on_caption_ = false; |
1468 ReleaseCapture(); | 1478 ReleaseCapture(); |
1469 // |point| is in window coordinates, but WM_NCHITTEST and TrackPopupMenu() | 1479 // |point| is in window coordinates, but WM_NCHITTEST and TrackPopupMenu() |
1470 // expect screen coordinates. | 1480 // expect screen coordinates. |
1471 CPoint screen_point(l_param); | 1481 CPoint screen_point(l_param); |
1472 MapWindowPoints(hwnd(), HWND_DESKTOP, &screen_point, 1); | 1482 MapWindowPoints(hwnd(), HWND_DESKTOP, &screen_point, 1); |
1473 w_param = SendMessage(hwnd(), WM_NCHITTEST, 0, | 1483 w_param = SendMessage(hwnd(), WM_NCHITTEST, 0, |
1474 MAKELPARAM(screen_point.x, screen_point.y)); | 1484 MAKELPARAM(screen_point.x, screen_point.y)); |
1475 if (w_param == HTCAPTION || w_param == HTSYSMENU) { | 1485 if (w_param == HTCAPTION || w_param == HTSYSMENU) { |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1967 } | 1977 } |
1968 | 1978 |
1969 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, | 1979 LRESULT HWNDMessageHandler::OnTouchEvent(UINT message, |
1970 WPARAM w_param, | 1980 WPARAM w_param, |
1971 LPARAM l_param) { | 1981 LPARAM l_param) { |
1972 int num_points = LOWORD(w_param); | 1982 int num_points = LOWORD(w_param); |
1973 scoped_array<TOUCHINPUT> input(new TOUCHINPUT[num_points]); | 1983 scoped_array<TOUCHINPUT> input(new TOUCHINPUT[num_points]); |
1974 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(l_param), | 1984 if (GetTouchInputInfo(reinterpret_cast<HTOUCHINPUT>(l_param), |
1975 num_points, input.get(), sizeof(TOUCHINPUT))) { | 1985 num_points, input.get(), sizeof(TOUCHINPUT))) { |
1976 for (int i = 0; i < num_points; ++i) { | 1986 for (int i = 0; i < num_points; ++i) { |
1977 if (input[i].dwFlags & TOUCHEVENTF_DOWN) | 1987 ui::EventType touch_event_type = ui::ET_UNKNOWN; |
| 1988 |
| 1989 if (input[i].dwFlags & TOUCHEVENTF_DOWN) { |
1978 touch_ids_.insert(input[i].dwID); | 1990 touch_ids_.insert(input[i].dwID); |
1979 if (input[i].dwFlags & TOUCHEVENTF_UP) | 1991 touch_event_type = ui::ET_TOUCH_PRESSED; |
| 1992 } else if (input[i].dwFlags & TOUCHEVENTF_UP) { |
1980 touch_ids_.erase(input[i].dwID); | 1993 touch_ids_.erase(input[i].dwID); |
| 1994 touch_event_type = ui::ET_TOUCH_RELEASED; |
| 1995 } else if (input[i].dwFlags & TOUCHEVENTF_MOVE) { |
| 1996 touch_event_type = ui::ET_TOUCH_MOVED; |
| 1997 } |
| 1998 // Handle touch events only on Aura for now. |
| 1999 #if defined(USE_AURA) |
| 2000 if (touch_event_type != ui::ET_UNKNOWN) { |
| 2001 POINT point; |
| 2002 point.x = TOUCH_COORD_TO_PIXEL(input[i].x); |
| 2003 point.y = TOUCH_COORD_TO_PIXEL(input[i].y); |
| 2004 |
| 2005 ScreenToClient(hwnd(), &point); |
| 2006 |
| 2007 ui::TouchEvent event( |
| 2008 touch_event_type, |
| 2009 gfx::Point(point.x, point.y), |
| 2010 kDesktopChromeAuraTouchId, |
| 2011 base::TimeDelta::FromMilliseconds(input[i].dwTime)); |
| 2012 delegate_->HandleTouchEvent(event); |
| 2013 } |
| 2014 #endif |
1981 } | 2015 } |
1982 } | 2016 } |
1983 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); | 2017 CloseTouchInputHandle(reinterpret_cast<HTOUCHINPUT>(l_param)); |
1984 SetMsgHandled(FALSE); | 2018 SetMsgHandled(FALSE); |
1985 return 0; | 2019 return 0; |
1986 } | 2020 } |
1987 | 2021 |
1988 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { | 2022 void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) { |
1989 if (ignore_window_pos_changes_) { | 2023 if (ignore_window_pos_changes_) { |
1990 // If somebody's trying to toggle our visibility, change the nonclient area, | 2024 // If somebody's trying to toggle our visibility, change the nonclient area, |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2070 DwmExtendFrameIntoClientArea(hwnd(), &m); | 2104 DwmExtendFrameIntoClientArea(hwnd(), &m); |
2071 } | 2105 } |
2072 if (window_pos->flags & SWP_SHOWWINDOW) | 2106 if (window_pos->flags & SWP_SHOWWINDOW) |
2073 delegate_->HandleVisibilityChanged(true); | 2107 delegate_->HandleVisibilityChanged(true); |
2074 else if (window_pos->flags & SWP_HIDEWINDOW) | 2108 else if (window_pos->flags & SWP_HIDEWINDOW) |
2075 delegate_->HandleVisibilityChanged(false); | 2109 delegate_->HandleVisibilityChanged(false); |
2076 SetMsgHandled(FALSE); | 2110 SetMsgHandled(FALSE); |
2077 } | 2111 } |
2078 | 2112 |
2079 } // namespace views | 2113 } // namespace views |
OLD | NEW |