Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 659883002: Enable hidpi on Linux, refactor a bit on Windows to share Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: constants Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ui/base/dragdrop/drag_utils.h" 11 #include "ui/base/dragdrop/drag_utils.h"
12 #include "ui/base/dragdrop/os_exchange_data.h" 12 #include "ui/base/dragdrop/os_exchange_data.h"
13 #include "ui/events/event.h" 13 #include "ui/events/event.h"
14 #include "ui/events/event_utils.h" 14 #include "ui/events/event_utils.h"
15 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
16 #include "ui/gfx/dpi.h"
16 #include "ui/gfx/native_widget_types.h" 17 #include "ui/gfx/native_widget_types.h"
17 #include "ui/gfx/point.h" 18 #include "ui/gfx/point.h"
18 #include "ui/gfx/screen.h" 19 #include "ui/gfx/screen.h"
19 #include "ui/gfx/vector2d.h" 20 #include "ui/gfx/vector2d.h"
20 #include "ui/native_theme/native_theme.h" 21 #include "ui/native_theme/native_theme.h"
21 #include "ui/views/controls/button/menu_button.h" 22 #include "ui/views/controls/button/menu_button.h"
22 #include "ui/views/controls/menu/menu_config.h" 23 #include "ui/views/controls/menu/menu_config.h"
23 #include "ui/views/controls/menu/menu_controller_delegate.h" 24 #include "ui/views/controls/menu/menu_controller_delegate.h"
24 #include "ui/views/controls/menu/menu_host_root_view.h" 25 #include "ui/views/controls/menu/menu_host_root_view.h"
25 #include "ui/views/controls/menu/menu_item_view.h" 26 #include "ui/views/controls/menu/menu_item_view.h"
26 #include "ui/views/controls/menu/menu_message_loop.h" 27 #include "ui/views/controls/menu/menu_message_loop.h"
27 #include "ui/views/controls/menu/menu_scroll_view_container.h" 28 #include "ui/views/controls/menu/menu_scroll_view_container.h"
28 #include "ui/views/controls/menu/submenu_view.h" 29 #include "ui/views/controls/menu/submenu_view.h"
29 #include "ui/views/drag_utils.h" 30 #include "ui/views/drag_utils.h"
30 #include "ui/views/focus/view_storage.h" 31 #include "ui/views/focus/view_storage.h"
31 #include "ui/views/mouse_constants.h" 32 #include "ui/views/mouse_constants.h"
32 #include "ui/views/view.h" 33 #include "ui/views/view.h"
33 #include "ui/views/view_constants.h" 34 #include "ui/views/view_constants.h"
34 #include "ui/views/views_delegate.h" 35 #include "ui/views/views_delegate.h"
35 #include "ui/views/widget/root_view.h" 36 #include "ui/views/widget/root_view.h"
36 #include "ui/views/widget/tooltip_manager.h" 37 #include "ui/views/widget/tooltip_manager.h"
37 #include "ui/views/widget/widget.h" 38 #include "ui/views/widget/widget.h"
38 39
39 #if defined(OS_WIN) 40 #if defined(OS_WIN)
40 #include "ui/base/win/internal_constants.h" 41 #include "ui/base/win/internal_constants.h"
41 #include "ui/gfx/win/dpi.h"
42 #include "ui/views/win/hwnd_util.h" 42 #include "ui/views/win/hwnd_util.h"
43 #endif 43 #endif
44 44
45 using base::Time; 45 using base::Time;
46 using base::TimeDelta; 46 using base::TimeDelta;
47 using ui::OSExchangeData; 47 using ui::OSExchangeData;
48 48
49 // Period of the scroll timer (in milliseconds). 49 // Period of the scroll timer (in milliseconds).
50 static const int kScrollTimerMS = 30; 50 static const int kScrollTimerMS = 30;
51 51
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc); 2067 gfx::NativeWindow window = screen->GetWindowAtScreenPoint(screen_loc);
2068 2068
2069 #if defined(OS_WIN) 2069 #if defined(OS_WIN)
2070 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint, 2070 // Convert screen_loc to pixels for the Win32 API's like WindowFromPoint,
2071 // PostMessage/SendMessage to work correctly. These API's expect the 2071 // PostMessage/SendMessage to work correctly. These API's expect the
2072 // coordinates to be in pixels. 2072 // coordinates to be in pixels.
2073 // PostMessage() to metro windows isn't allowed (access will be denied). Don't 2073 // PostMessage() to metro windows isn't allowed (access will be denied). Don't
2074 // try to repost with Win32 if the window under the mouse press is in metro. 2074 // try to repost with Win32 if the window under the mouse press is in metro.
2075 if (!ViewsDelegate::views_delegate || 2075 if (!ViewsDelegate::views_delegate ||
2076 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) { 2076 !ViewsDelegate::views_delegate->IsWindowInMetro(window)) {
2077 gfx::Point screen_loc_pixels = gfx::win::DIPToScreenPoint(screen_loc); 2077 gfx::Point screen_loc_pixels = gfx::DIPToScreenPoint(screen_loc);
2078 HWND target_window = window ? HWNDForNativeWindow(window) : 2078 HWND target_window = window ? HWNDForNativeWindow(window) :
2079 WindowFromPoint(screen_loc_pixels.ToPOINT()); 2079 WindowFromPoint(screen_loc_pixels.ToPOINT());
2080 HWND source_window = HWNDForNativeView(native_view); 2080 HWND source_window = HWNDForNativeView(native_view);
2081 if (!target_window || !source_window || 2081 if (!target_window || !source_window ||
2082 GetWindowThreadProcessId(source_window, NULL) != 2082 GetWindowThreadProcessId(source_window, NULL) !=
2083 GetWindowThreadProcessId(target_window, NULL)) { 2083 GetWindowThreadProcessId(target_window, NULL)) {
2084 // Even though we have mouse capture, windows generates a mouse event if 2084 // Even though we have mouse capture, windows generates a mouse event if
2085 // the other window is in a separate thread. Only repost an event if 2085 // the other window is in a separate thread. Only repost an event if
2086 // |target_window| and |source_window| were created on the same thread, 2086 // |target_window| and |source_window| were created on the same thread,
2087 // else double events can occur and lead to bad behavior. 2087 // else double events can occur and lead to bad behavior.
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
2306 } 2306 }
2307 } 2307 }
2308 2308
2309 gfx::Screen* MenuController::GetScreen() { 2309 gfx::Screen* MenuController::GetScreen() {
2310 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL; 2310 Widget* root = owner_ ? owner_->GetTopLevelWidget() : NULL;
2311 return root ? gfx::Screen::GetScreenFor(root->GetNativeView()) 2311 return root ? gfx::Screen::GetScreenFor(root->GetNativeView())
2312 : gfx::Screen::GetNativeScreen(); 2312 : gfx::Screen::GetNativeScreen();
2313 } 2313 }
2314 2314
2315 } // namespace views 2315 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698