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 1992 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2044 gfx::Point screen_loc(event.location()); | 2045 gfx::Point screen_loc(event.location()); |
2045 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); | 2046 View::ConvertPointToScreen(source->GetScrollViewContainer(), &screen_loc); |
2046 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); | 2047 gfx::NativeView native_view = source->GetWidget()->GetNativeView(); |
2047 if (!native_view) | 2048 if (!native_view) |
2048 return; | 2049 return; |
2049 | 2050 |
2050 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); | 2051 gfx::Screen* screen = gfx::Screen::GetScreenFor(native_view); |
2051 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); | 2052 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); |
2052 | 2053 |
2053 #if defined(OS_WIN) | 2054 #if defined(OS_WIN) |
2055 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint, | |
2056 // PostMessage/SendMessage to work correctly. These API's expect the | |
2057 // coordinates to be in pixels. | |
2058 screen_loc = gfx::win::DIPToScreenPoint(screen_loc); | |
sky
2014/06/19 00:55:12
Don't reuse screen_loc here, it's too easy to get
ananta
2014/06/19 01:44:18
Done.
| |
2054 // PostMessage() to metro windows isn't allowed (access will be denied). Don't | 2059 // PostMessage() to metro windows isn't allowed (access will be denied). Don't |
2055 // try to repost with Win32 if the window under the mouse press is in metro. | 2060 // try to repost with Win32 if the window under the mouse press is in metro. |
2056 if (!ViewsDelegate::views_delegate || | 2061 if (!ViewsDelegate::views_delegate || |
2057 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) { | 2062 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) { |
2058 HWND target_window = window ? HWNDForNativeWindow(window) : | 2063 HWND target_window = window ? HWNDForNativeWindow(window) : |
2059 WindowFromPoint(screen_loc.ToPOINT()); | 2064 WindowFromPoint(screen_loc.ToPOINT()); |
2060 HWND source_window = HWNDForNativeView(native_view); | 2065 HWND source_window = HWNDForNativeView(native_view); |
2061 if (!target_window || !source_window || | 2066 if (!target_window || !source_window || |
2062 GetWindowThreadProcessId(source_window, NULL) != | 2067 GetWindowThreadProcessId(source_window, NULL) != |
2063 GetWindowThreadProcessId(target_window, NULL)) { | 2068 GetWindowThreadProcessId(target_window, NULL)) { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2286 } | 2291 } |
2287 } | 2292 } |
2288 | 2293 |
2289 gfx::Screen* MenuController::GetScreen() { | 2294 gfx::Screen* MenuController::GetScreen() { |
2290 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; | 2295 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; |
2291 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) | 2296 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) |
2292 : gfx::Screen::GetNativeScreen(); | 2297 : gfx::Screen::GetNativeScreen(); |
2293 } | 2298 } |
2294 | 2299 |
2295 } // namespace views | 2300 } // namespace views |
OLD | NEW |