#pragma once #include #include #include #include "alvin/error.hpp" namespace alvin { struct Point { int x = 0; int y = 0; friend bool operator==(const Point&, const Point&) = default; }; struct Size { int width = 0; int height = 0; friend bool operator==(const Size&, const Size&) = default; }; // All rectangles are in global desktop coordinates (logical pixels, i.e. after // monitor scaling) unless documented otherwise. struct Rect { int x = 0; int y = 0; int width = 0; int height = 0; int right() const { return x + width; } int bottom() const { return y + height; } Point center() const { return {x + width / 2, y + height / 2}; } bool empty() const { return width <= 0 || height <= 0; } bool contains(Point p) const { return p.x >= x && p.y >= y && p.x < right() && p.y < bottom(); } // Smallest rect containing both. An empty rect acts as identity. Rect united(const Rect& o) const; friend bool operator==(const Rect&, const Rect&) = default; }; struct Monitor { std::string name; // connector name, e.g. "DP-1" or "\\\\.\\DISPLAY1" std::string description; Rect bounds; // logical position/size in the global desktop Size pixelSize; // physical mode size in pixels double scale = 1.0; bool primary = false; }; // Enumerate monitors on the current session. Result> listMonitors(); // Bounding box of all monitors, i.e. the space absolute pointer motion maps onto. Result desktopBounds(); } // namespace alvin