blob: e0716d4a41d535ed1158d171583163400c33fcda [file] [log] [blame]
Avi Drissman3e1a26c2022-09-15 20:26:031// Copyright 2018 The Chromium Authors
Taylor Bergquist156336352018-08-23 02:34:272// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "ui/base/win/hwnd_metrics.h"
6
Peter Kvitek7decb432025-04-17 20:40:407#include "ui/display/screen.h"
Taylor Bergquist156336352018-08-23 02:34:278#include "ui/display/win/screen_win.h"
Peter Kvitek7decb432025-04-17 20:40:409#include "ui/display/win/screen_win_headless.h"
Taylor Bergquist156336352018-08-23 02:34:2710
11namespace ui {
12
Peter Kvitek7decb432025-04-17 20:40:4013namespace {
14
15int GetFrameThicknessFromDisplayId(int64_t id) {
16 const int resize_frame_thickness =
17 display::win::GetScreenWinHeadless()->GetSystemMetricsForDisplayId(
18 id, SM_CXSIZEFRAME);
19 const int padding_thickness =
20 display::win::GetScreenWinHeadless()->GetSystemMetricsForDisplayId(
21 id, SM_CXPADDEDBORDER);
22
23 return resize_frame_thickness + padding_thickness;
24}
25
26} // namespace
27
Trevor Perrierbe7dbb52025-05-30 01:34:5228int GetResizableFrameThicknessFromMonitorInPixels(HMONITOR monitor,
29 bool has_caption) {
30 const int resize_handle_thickness =
31 display::win::GetScreenWin()->GetSystemMetricsForMonitor(monitor,
32 SM_CXSIZEFRAME);
33 // SM_CXPADDEDBORDER is some extra padding not part of the resize handle.
Taylor Bergquist156336352018-08-23 02:34:2734 const int padding_thickness =
Peter Kvitekbc8af9c2025-04-07 17:43:4935 display::win::GetScreenWin()->GetSystemMetricsForMonitor(
36 monitor, SM_CXPADDEDBORDER);
Trevor Perrierbe7dbb52025-05-30 01:34:5237 // If a window has WS_CAPTION set the frame thickness includes a 1px border.
38 // This border must be removed if WS_CAPTION is not set.
39 return resize_handle_thickness + padding_thickness - (has_caption ? 0 : 1);
40}
41
42int GetResizableFrameThicknessFromMonitorInDIP(HMONITOR monitor,
43 bool has_caption) {
44 return GetResizableFrameThicknessFromMonitorInPixels(monitor, has_caption) /
45 display::win::GetScreenWin()->GetScaleFactorForMonitor(monitor);
Taylor Bergquist156336352018-08-23 02:34:2746}
47
Peter Kvitek7decb432025-04-17 20:40:40