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/controls/menu/menu_controller.h" | 5 #include "ui/views/controls/menu/menu_controller.h" |
6 | 6 |
7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
8 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 #include "ui/views/mouse_constants.h" | 32 #include "ui/views/mouse_constants.h" |
33 #include "ui/views/view.h" | 33 #include "ui/views/view.h" |
34 #include "ui/views/view_constants.h" | 34 #include "ui/views/view_constants.h" |
35 #include "ui/views/views_delegate.h" | 35 #include "ui/views/views_delegate.h" |
36 #include "ui/views/widget/root_view.h" | 36 #include "ui/views/widget/root_view.h" |
37 #include "ui/views/widget/tooltip_manager.h" | 37 #include "ui/views/widget/tooltip_manager.h" |
38 #include "ui/views/widget/widget.h" | 38 #include "ui/views/widget/widget.h" |
39 | 39 |
40 #if defined(OS_WIN) | 40 #if defined(OS_WIN) |
41 #include "ui/base/win/internal_constants.h" | 41 #include "ui/base/win/internal_constants.h" |
42 #include "ui/gfx/win/dpi.h" | |
42 #include "ui/views/win/hwnd_util.h" | 43 #include "ui/views/win/hwnd_util.h" |
43 #endif | 44 #endif |
44 | 45 |
45 using base::Time; | 46 using base::Time; |
46 using base::TimeDelta; | 47 using base::TimeDelta; |
47 using ui::OSExchangeData; | 48 using ui::OSExchangeData; |
48 | 49 |
49 // Period of the scroll timer (in milliseconds). | 50 // Period of the scroll timer (in milliseconds). |
50 static const int kScrollTimerMS = 30; | 51 static const int kScrollTimerMS = 30; |
51 | 52 |
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2042 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture(); | 2043 state_.item->GetRootMenuItem()->GetSubmenu()->ReleaseCapture(); |
2043 #endif | 2044 #endif |
2044 | 2045 |
2045 gfx::Point screen_loc(event.location()); | 2046 gfx::Point screen_loc(event.location()); |
2046 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); | 2047 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
2047 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); | 2048 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); |
2048 if (!native_view) | 2049 if (!native_view) |
2049 return; | 2050 return; |
2050 | 2051 |
2051 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 2052 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
2052 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); | 2053 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); |
sky
2014/06/18 13:15:59
Move this so that we only call GetWindowAtScreenPo
ananta
2014/06/18 18:53:40
Added a function PlatformGetWindowAtLocation in th
| |
2053 | 2054 |
2054 #if defined(OS_WIN) | 2055 #if defined(OS_WIN) |
2056 // While posting messages natively on Windows we need to convert the | |
2057 // coordinates to pixel to ensure that they get posted to the correct window. | |
2058 screen_loc = gfx::win::DIPToScreenPoint(screen_loc); | |
2059 window = screen->GetWindowAtScreenPoint(screen_loc); | |
2055 // PostMessage() to metro windows isn't allowed (access will be denied). Don't | 2060 // PostMessage() to metro windows isn't allowed (access will be denied). Don't |
2056 // try to repost with Win32 if the window under the mouse press is in metro. | 2061 // try to repost with Win32 if the window under the mouse press is in metro. |
2057 if (!ViewsDelegate::views_delegate || | 2062 if (!ViewsDelegate::views_delegate || |
2058 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) { | 2063 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) { |
2059 HWND target_window = window ? HWNDForNativeWindow(window) : | 2064 HWND target_window = window ? HWNDForNativeWindow(window) : |
2060 WindowFromPoint(screen_loc.ToPOINT()); | 2065 WindowFromPoint(screen_loc.ToPOINT()); |
2061 HWND source_window = HWNDForNativeView(native_view); | 2066 HWND source_window = HWNDForNativeView(native_view); |
2062 if (!target_window || !source_window || | 2067 if (!target_window || !source_window || |
2063 GetWindowThreadProcessId(source_window, NULL) != | 2068 GetWindowThreadProcessId(source_window, NULL) != |
2064 GetWindowThreadProcessId(target_window, NULL)) { | 2069 GetWindowThreadProcessId(target_window, NULL)) { |
2065 // Even though we have mouse capture, windows generates a mouse event if | 2070 // Even though we have mouse capture, windows generates a mouse event if |
2066 // the other window is in a separate thread. Only repost an event if | 2071 // the other window is in a separate thread. Only repost an event if |
2067 // |target_window| and |source_window| were created on the same thread, | 2072 // |target_window| and |source_window| were created on the same thread, |
2068 // else double events can occur and lead to bad behavior. | 2073 // else double events can occur and lead to bad behavior. |
2069 return; | 2074 return; |
2070 } | 2075 } |
2071 | |
2072 // Determine whether the click was in the client area or not. | 2076 // Determine whether the click was in the client area or not. |
2073 // NOTE: WM_NCHITTEST coordinates are relative to the screen. | 2077 // NOTE: WM_NCHITTEST coordinates are relative to the screen. |
2074 LPARAM coords = MAKELPARAM(screen_loc.x(), screen_loc.y()); | 2078 LPARAM coords = MAKELPARAM(screen_loc.x(), screen_loc.y()); |
2075 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords); | 2079 LRESULT nc_hit_result = SendMessage(target_window, WM_NCHITTEST, 0, coords); |
2076 const bool client_area = nc_hit_result == HTCLIENT; | 2080 const bool client_area = nc_hit_result == HTCLIENT; |
2077 | 2081 |
2078 // TODO(sky): this isn't right. The event to generate should correspond with | 2082 // TODO(sky): this isn't right. The event to generate should correspond with |
2079 // the event we just got. MouseEvent only tells us what is down, which may | 2083 // the event we just got. MouseEvent only tells us what is down, which may |
2080 // differ. Need to add ability to get changed button from MouseEvent. | 2084 // differ. Need to add ability to get changed button from MouseEvent. |
2081 int event_type; | 2085 int event_type; |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2287 } | 2291 } |
2288 } | 2292 } |
2289 | 2293 |
2290 gfx::Screen* MenuController::GetScreen() { | 2294 gfx::Screen* MenuController::GetScreen() { |
2291 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2295 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
2292 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2296 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
2293 : gfx::Screen::GetNativeScreen(); | 2297 : gfx::Screen::GetNativeScreen(); |
2294 } | 2298 } |
2295 | 2299 |
2296 } // namespace views | 2300 } // namespace views |
OLD | NEW |