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

Side by Side Diff: chrome/browser/ui/views/frame/minimize_button_metrics_win.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 "chrome/browser/ui/views/frame/minimize_button_metrics_win.h" 5 #include "chrome/browser/ui/views/frame/minimize_button_metrics_win.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "ui/base/win/shell.h" 9 #include "ui/base/win/shell.h"
10 #include "ui/gfx/win/dpi.h" 10 #include "ui/gfx/dpi.h"
11 11
12 namespace { 12 namespace {
13 13
14 int GetMinimizeButtonOffsetForWindow(HWND hwnd) { 14 int GetMinimizeButtonOffsetForWindow(HWND hwnd) {
15 // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible. By 15 // The WM_GETTITLEBARINFOEX message can fail if we are not active/visible. By
16 // fail we get a location of 0; the return status code is always the same and 16 // fail we get a location of 0; the return status code is always the same and
17 // similarly the state never seems to change (titlebar_info.rgstate). 17 // similarly the state never seems to change (titlebar_info.rgstate).
18 TITLEBARINFOEX titlebar_info = {0}; 18 TITLEBARINFOEX titlebar_info = {0};
19 titlebar_info.cbSize = sizeof(TITLEBARINFOEX); 19 titlebar_info.cbSize = sizeof(TITLEBARINFOEX);
20 SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0, 20 SendMessage(hwnd, WM_GETTITLEBARINFOEX, 0,
21 reinterpret_cast<WPARAM>(&titlebar_info)); 21 reinterpret_cast<WPARAM>(&titlebar_info));
22 22
23 if (titlebar_info.rgrect[2].left == titlebar_info.rgrect[2].right || 23 if (titlebar_info.rgrect[2].left == titlebar_info.rgrect[2].right ||
24 (titlebar_info.rgstate[2] & (STATE_SYSTEM_INVISIBLE | 24 (titlebar_info.rgstate[2] & (STATE_SYSTEM_INVISIBLE |
25 STATE_SYSTEM_OFFSCREEN | 25 STATE_SYSTEM_OFFSCREEN |
26 STATE_SYSTEM_UNAVAILABLE))) { 26 STATE_SYSTEM_UNAVAILABLE))) {
27 return 0; 27 return 0;
28 } 28 }
29 29
30 // WM_GETTITLEBARINFOEX returns rects in screen coordinates in pixels. 30 // WM_GETTITLEBARINFOEX returns rects in screen coordinates in pixels.
31 // We need to convert the minimize button corner offset to DIP before 31 // We need to convert the minimize button corner offset to DIP before
32 // returning it. 32 // returning it.
33 POINT minimize_button_corner = { titlebar_info.rgrect[2].left, 0 }; 33 POINT minimize_button_corner = { titlebar_info.rgrect[2].left, 0 };
34 MapWindowPoints(HWND_DESKTOP, hwnd, &minimize_button_corner, 1); 34 MapWindowPoints(HWND_DESKTOP, hwnd, &minimize_button_corner, 1);
35 return minimize_button_corner.x / gfx::win::GetDeviceScaleFactor(); 35 return minimize_button_corner.x / gfx::GetDeviceScaleFactor();
36 } 36 }
37 37
38 } // namespace 38 } // namespace
39 39
40 // static 40 // static
41 int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0; 41 int MinimizeButtonMetrics::last_cached_minimize_button_x_delta_ = 0;
42 42
43 MinimizeButtonMetrics::MinimizeButtonMetrics() 43 MinimizeButtonMetrics::MinimizeButtonMetrics()
44 : hwnd_(NULL), 44 : hwnd_(NULL),
45 cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_), 45 cached_minimize_button_x_delta_(last_cached_minimize_button_x_delta_),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 cached_minimize_button_x_delta_ = minimize_button_offset; 95 cached_minimize_button_x_delta_ = minimize_button_offset;
96 } else { 96 } else {
97 RECT client_rect = {0}; 97 RECT client_rect = {0};
98 GetClientRect(hwnd_, &client_rect); 98 GetClientRect(hwnd_, &client_rect);
99 cached_minimize_button_x_delta_ = 99 cached_minimize_button_x_delta_ =
100 client_rect.right - minimize_button_offset; 100 client_rect.right - minimize_button_offset;
101 } 101 }
102 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_; 102 last_cached_minimize_button_x_delta_ = cached_minimize_button_x_delta_;
103 return minimize_button_offset; 103 return minimize_button_offset;
104 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698