mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
windows: Fix size/placement with multi-DPI screen setup (fixes issue #3359)
Use ScreenWin functions to correctly compute DIP/pixel conversions for CEF-created top-level windows. Fix incorrect DIPToScreenRect usage in DesktopWindowTreeHostWin when |has_external_parent_| is true.
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int kMinWidth = 0;
|
||||
@@ -25,15 +27,17 @@ int clamp_segment_start(int start, int len, int min, int max) {
|
||||
|
||||
} // namespace
|
||||
|
||||
CefRect MakeVisibleOnScreenRect(const CefRect& rect, const CefRect& screen) {
|
||||
const int width = std::clamp(rect.width, kMinWidth, screen.width);
|
||||
const int height = std::clamp(rect.height, kMinHeight, screen.height);
|
||||
gfx::Rect MakeVisibleOnScreenRect(const gfx::Rect& rect,
|
||||
const gfx::Rect& screen) {
|
||||
const int width = std::clamp(rect.width(), kMinWidth, screen.width());
|
||||
const int height = std::clamp(rect.height(), kMinHeight, screen.height());
|
||||
|
||||
const int right_border = screen.x + screen.width;
|
||||
const int x = clamp_segment_start(rect.x, width, screen.x, right_border);
|
||||
const int right_border = screen.x() + screen.width();
|
||||
const int x = clamp_segment_start(rect.x(), width, screen.x(), right_border);
|
||||
|
||||
const int bottom_border = screen.y + screen.height;
|
||||
const int y = clamp_segment_start(rect.y, height, screen.y, bottom_border);
|
||||
const int bottom_border = screen.y() + screen.height();
|
||||
const int y =
|
||||
clamp_segment_start(rect.y(), height, screen.y(), bottom_border);
|
||||
|
||||
return CefRect(x, y, width, height);
|
||||
return gfx::Rect(x, y, width, height);
|
||||
}
|
||||
|
Reference in New Issue
Block a user