/* * hosts.hpp * Montauk Toolkit host adapters for desktop and standalone apps * Copyright (c) 2026 Daniel Hammer */ #pragma once #include "gui/canvas.hpp" #include "gui/standalone.hpp" #include "gui/window.hpp" namespace gui::mtk { struct DesktopHost { Window* window; explicit DesktopHost(Window* win) : window(win) {} Canvas canvas() const { return window ? Canvas(window) : Canvas(nullptr, 0, 0); } Rect bounds() const { return {0, 0, window ? window->content_w : 0, window ? window->content_h : 0}; } bool map_mouse(const MouseEvent& ev, int* out_x, int* out_y) const { if (!window || !out_x || !out_y) return false; Rect cr = window->content_rect(); *out_x = ev.x - cr.x; *out_y = ev.y - cr.y; return true; } void invalidate() const { if (window) window->dirty = true; } }; struct StandaloneHost { WsWindow* window; explicit StandaloneHost(WsWindow* win) : window(win) {} Canvas canvas() const { return window ? window->canvas() : Canvas(nullptr, 0, 0); } Rect bounds() const { return {0, 0, window ? window->width : 0, window ? window->height : 0}; } void present() const { if (window) window->present(); } void set_cursor(int cursor) const { if (window) window->set_cursor(cursor); } }; } // namespace gui::mtk