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

Side by Side Diff: ui/gfx/win/hwnd_util.cc

Issue 1581473002: Remove base/win/metro.{cc|h} and some associated code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 4 years, 11 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/gfx/win/hwnd_util.h" 5 #include "ui/gfx/win/hwnd_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/win/metro.h"
10 #include "base/win/win_util.h" 9 #include "base/win/win_util.h"
11 #include "ui/gfx/geometry/point.h" 10 #include "ui/gfx/geometry/point.h"
12 #include "ui/gfx/geometry/rect.h" 11 #include "ui/gfx/geometry/rect.h"
13 #include "ui/gfx/geometry/size.h" 12 #include "ui/gfx/geometry/size.h"
14 13
15 namespace gfx { 14 namespace gfx {
16 15
17 namespace { 16 namespace {
18 17
19 // Adjust the window to fit. 18 // Adjust the window to fit.
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 RECT rect; 207 RECT rect;
209 GetWindowRect(window, &rect); 208 GetWindowRect(window, &rect);
210 Point point = Point(base::i18n::IsRTL() ? rect.right : rect.left, rect.top); 209 Point point = Point(base::i18n::IsRTL() ? rect.right : rect.left, rect.top);
211 static const int kSystemMenuOffset = 10; 210 static const int kSystemMenuOffset = 10;
212 point.Offset(base::i18n::IsRTL() ? -kSystemMenuOffset : kSystemMenuOffset, 211 point.Offset(base::i18n::IsRTL() ? -kSystemMenuOffset : kSystemMenuOffset,
213 kSystemMenuOffset); 212 kSystemMenuOffset);
214 ShowSystemMenuAtPoint(window, point); 213 ShowSystemMenuAtPoint(window, point);
215 } 214 }
216 215
217 void ShowSystemMenuAtPoint(HWND window, const Point& point) { 216 void ShowSystemMenuAtPoint(HWND window, const Point& point) {
218 // In the Metro process, we never want to show the system menu.
219 if (base::win::IsMetroProcess())
220 return;
221 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD; 217 UINT flags = TPM_LEFTBUTTON | TPM_RIGHTBUTTON | TPM_RETURNCMD;
222 if (base::i18n::IsRTL()) 218 if (base::i18n::IsRTL())
223 flags |= TPM_RIGHTALIGN; 219 flags |= TPM_RIGHTALIGN;
224 HMENU menu = GetSystemMenu(window, FALSE); 220 HMENU menu = GetSystemMenu(window, FALSE);
225 221
226 const int command = 222 const int command =
227 TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL); 223 TrackPopupMenu(menu, flags, point.x(), point.y(), 0, window, NULL);
228 224
229 if (command) 225 if (command)
230 SendMessage(window, WM_SYSCOMMAND, command, 0); 226 SendMessage(window, WM_SYSCOMMAND, command, 0);
231 } 227 }
232 228
233 extern "C" { 229 extern "C" {
234 typedef HWND (*RootWindow)(); 230 typedef HWND (*RootWindow)();
235 } 231 }
236 232
237 HWND GetWindowToParentTo(bool get_real_hwnd) { 233 HWND GetWindowToParentTo(bool get_real_hwnd) {
238 HMODULE metro = base::win::GetMetroModule(); 234 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP;
239 if (!metro)
240 return get_real_hwnd ? ::GetDesktopWindow() : HWND_DESKTOP;
241 // In windows 8 metro-mode the root window is not the desktop.
242 RootWindow root_window =
243 reinterpret_cast<RootWindow>(::GetProcAddress(metro, "GetRootWindow"));
244 return root_window();
245 } 235 }
246 236
247 } // namespace gfx 237 } // namespace gfx
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698