Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/event_utils.h" | 5 #include "ui/views/event_utils.h" |
| 6 | 6 |
| 7 #include <windowsx.h> | 7 #include <windowsx.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ui/events/event.h" | 10 #include "ui/events/event.h" |
| 11 #include "ui/events/event_constants.h" | 11 #include "ui/events/event_constants.h" |
| 12 #include "ui/gfx/point.h" | 12 #include "ui/gfx/point.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 bool RepostLocatedEvent(gfx::NativeWindow window, | 16 #if defined(USE_AURA) |
| 17 bool RepostLocatedEventWin(HWND window, | |
|
sky
2013/12/03 17:16:45
Can't you go with this signature always? Meaning n
| |
| 18 const ui::LocatedEvent& event) { | |
| 19 #else | |
| 20 bool RepostLocatedEvent(gfx::NativeWindow window | |
| 17 const ui::LocatedEvent& event) { | 21 const ui::LocatedEvent& event) { |
| 22 #endif | |
| 18 if (!window) | 23 if (!window) |
| 19 return false; | 24 return false; |
| 20 | 25 |
| 21 // Determine whether the click was in the client area or not. | 26 // Determine whether the click was in the client area or not. |
| 22 // NOTE: WM_NCHITTEST coordinates are relative to the screen. | 27 // NOTE: WM_NCHITTEST coordinates are relative to the screen. |
| 23 const gfx::Point screen_loc = event.location(); | 28 const gfx::Point screen_loc = event.location(); |
| 24 LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0, | 29 LRESULT nc_hit_result = SendMessage(window, WM_NCHITTEST, 0, |
| 25 MAKELPARAM(screen_loc.x(), | 30 MAKELPARAM(screen_loc.x(), |
| 26 screen_loc.y())); | 31 screen_loc.y())); |
| 27 const bool in_client_area = nc_hit_result == HTCLIENT; | 32 const bool in_client_area = nc_hit_result == HTCLIENT; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 50 window_x -= window_bounds.left; | 55 window_x -= window_bounds.left; |
| 51 window_y -= window_bounds.top; | 56 window_y -= window_bounds.top; |
| 52 } | 57 } |
| 53 | 58 |
| 54 WPARAM target = in_client_area ? event.native_event().wParam : nc_hit_result; | 59 WPARAM target = in_client_area ? event.native_event().wParam : nc_hit_result; |
| 55 PostMessage(window, event_type, target, MAKELPARAM(window_x, window_y)); | 60 PostMessage(window, event_type, target, MAKELPARAM(window_x, window_y)); |
| 56 return true; | 61 return true; |
| 57 } | 62 } |
| 58 | 63 |
| 59 } // namespace views | 64 } // namespace views |
| OLD | NEW |