OpenRoadCode
Public API reference for OpenRoadCode
Loading...
Searching...
No Matches
embedded_resize.hpp
1// SPDX-FileCopyrightText: 2026 Mark G. Russell
2// SPDX-License-Identifier: MIT
3
4#pragma once
5
6#include <optional>
7
8struct EmbeddedSize {
9 int width = 0;
10 int height = 0;
11
12 bool differsFrom(EmbeddedSize other) const {
13 return width != other.width || height != other.height;
14 }
15};
16
17struct EmbeddedResizePlan {
18 EmbeddedSize target;
19 bool resizeWindow;
20 bool resizeMap;
21 bool resizeFramebuffer;
22};
23
24// The X11 parent allocation is authoritative. A correctly sized native window
25// does not establish that GLFW callbacks updated MapLibre's cached viewports.
26inline std::optional<EmbeddedResizePlan> planEmbeddedResize(
27 EmbeddedSize parent, EmbeddedSize nativeWindow,
28 EmbeddedSize map, EmbeddedSize framebuffer) {
29 if (parent.width < 1 || parent.height < 1)
30 return std::nullopt;
31 return EmbeddedResizePlan{
32 parent, parent.differsFrom(nativeWindow), parent.differsFrom(map),
33 parent.differsFrom(framebuffer),
34 };
35}