Skip to content

Window module


ClipboardContent class

ClipboardContent

Structure representing the content of the clipboard.

This structure holds optional text content and a map of format-specific data.

text variable

std::optional<std::string> text

Optional text content from the clipboard.

formats variable

std::unordered_map<ClipboardFormat, Bytes> formats

A map of format-specific data stored in the clipboard, keyed by ClipboardFormat.


Display class

Display

DisplayA class that provides information about a monitor (display) device, including content scale and coordinate conversion.

The Display class is an abstract base class that represents a monitor. It provides methods to retrieve various attributes of the display such as position, size, resolution, DPI, and name. It also offers methods for coordinate conversion between desktop and monitor coordinates.
Details All methods are thread-safe.

position function

virtual Point position() const = 0

Get the position of the display in desktop coordinates.
Returns The top-left position of the display.

size function

virtual Size size() const = 0

Get the size of the display in desktop coordinates.
Returns The size of the display in pixels.

workarea function

virtual Rectangle workarea() const = 0

Get the work area of the display.
Returns The work area of the display excluding taskbars, docks, and other furniture.

resolution function

virtual Size resolution() const = 0

Get the current resolution of the display.
Returns The current resolution of the display in pixels.
Details On macOS this returns virtual resolution before scaling down to the display's native resolution. Same as resolution of screenshots.

nativeResolution function

virtual Size nativeResolution() const = 0

Get the native resolution of the display.
Returns The native resolution of the display in pixels.
Details On macOS this returns actual resolution selected for the display.

physicalSize function

virtual SizeF physicalSize() const = 0

Get the physical size of the display.
Returns The physical size of the display in millimeters.

dpi function

virtual int dpi() const = 0

Get the DPI (dots per inch) of the display.
Returns The DPI of the display.

name function

virtual const std::string &name() const = 0

Get the name of the display.
Returns The name of the display as a string.

id function

virtual const std::string &id() const = 0

Get the unique identifier of the display.
Returns The unique identifier of the display as a string.

adapterName function

virtual const std::string &adapterName() const = 0

Get the name of the adapter associated with the display.
Returns The adapter name as a string.
Details May return an empty string if the adapter name is not available

adapterId function

virtual const std::string &adapterId() const = 0

Get the unique identifier of the adapter associated with the display.
Returns The adapter identifier as a string.
Details May return an empty string if the adapter identifier is not available

flags function

virtual DisplayFlags flags() const = 0

Get the display flags.
Returns The flags associated with the display.

contentScale function

virtual float contentScale() const = 0

Get the content scale factor of the display.
Returns The content scale factor of the display.

refreshRate function

virtual double refreshRate() const = 0

Get the refresh rate of the display.
Returns The refresh rate of the display in hertz.

desktopToMonitor function

virtual Point desktopToMonitor(Point pt) const = 0

Convert a point from desktop coordinates to monitor coordinates.
Param pt The point in desktop coordinates.
Returns The point in monitor coordinates.

monitorToDesktop function

virtual Point monitorToDesktop(Point pt) const = 0

Convert a point from monitor coordinates to desktop coordinates.
Param pt The point in monitor coordinates.
Returns The point in desktop coordinates.

backingScaleFactor function

virtual int backingScaleFactor() const = 0

Get the backing scale factor of the display.
Returns The backing scale factor of the display.
Details macOS specific

all function

static std::vector<RC<Display>> all()

Get all connected displays.
Returns A vector of RC-pointers to all connected displays.

primary function

static RC<Display> primary()

Get the primary display.
Returns An RC-pointer to the primary display.


addWindow function

void addWindow(RC<Window> window, bool makeVisible = true)

Adds window to the window application
Param window window to add


clipboardHasFormat function

bool clipboardHasFormat(ClipboardFormat format)

Checks if the clipboard contains data in the specified format.
Param format The format to check for.
Returns True if the clipboard has data in the specified format, otherwise false.


clipboardHasText function

inline bool clipboardHasText()

Checks if the clipboard contains text data.
Returns True if the clipboard has text data, otherwise false.


copyBytesToClipboard function

inline bool copyBytesToClipboard(bytes_view content,
                                 ClipboardFormat format)

Copies binary data to the clipboard for a specific format.
Param content The binary data to copy.
Param format The ClipboardFormat to associate with the binary data.
Returns True if the binary data was successfully copied, otherwise false.


copyTextToClipboard function

inline bool copyTextToClipboard(string_view content)

Copies text content to the clipboard.
Param content The text content to copy to the clipboard.
Returns True if the text content was successfully copied, otherwise false.


currentWindow variable

extern Window *currentWindow

Current window instance. Available in UI thread. Set in uiThreadBody


cycle function

void cycle(bool wait)

Run one cycle of the main loop
Param wait Wait for OS events
Details This function is internal. Use only if you know what you do


getBounds function

Rectangle getBounds() const

Get the bounds of window in desktop coordinates,

Equals to Rectangle(Point(0,0),getSize())
Details If the window is not visible, returns the most recent value.


getBytesFromClipboard function

inline optional<Bytes>
getBytesFromClipboard(ClipboardFormat format)

Retrieves binary data from the clipboard for a specific format.
Param format The ClipboardFormat to retrieve data for.
Returns An optional vector of bytes containing the clipboard data for the specified format, or std::nullopt if not found.


getClipboardContent function

ClipboardContent getClipboardContent(
    std::initializer_list<ClipboardFormat> formats)

Retrieves the content of the clipboard for the specified formats.
Param formats A list of ClipboardFormats to retrieve.
Returns The ClipboardContent containing the data in the requested formats.


getPosition function

Point getPosition() const

Get the position of window in desktop coordinates
Details If the window is not visible, returns the most recent value.


getRectangle function

Rectangle getRectangle() const

Get the position and size of window in desktop coordinates,

Equals to Rectangle(getPosition(),getSize())
Details If the window is not visible, returns the most recent value.


getSize function

Size getSize() const

Get the size of window in desktop coordinates
Details If the window is not visible, returns the most recent value.


getTextFromClipboard function

inline optional<std::string> getTextFromClipboard()

Retrieves text content from the clipboard.
Returns An optional string containing the clipboard text if available, otherwise std::nullopt.


hasQuit function

bool hasQuit() const

Returns true if quit has called


hasWindow function

bool hasWindow(const RC<Window> &window)

Checks if the specific window is registered to the WindowApplication
Details Safe to call from main or UI thread
Param window


isActive function

bool isActive() const

Returns true if the main loop is active


m_closing variable

std::atomic_bool m_closing

Desired value. Will be applied to OS window when open


m_cursor variable

Cursor m_cursor = Cursor::Arrow

UI-thread


m_framebufferSize variable

Size m_framebufferSize

UI-thread


m_maximumSize variable

Size m_maximumSize

UI-thread


m_minimumSize variable

Size m_minimumSize

UI-thread


m_position variable

Point m_position

UI-thread


m_title variable

std::string m_title

UI-thread


m_windowSize variable

Size m_windowSize

UI-thread


paint function

virtual void paint(RenderContext &context)

true if rendering is active


quit function

void quit(int exitCode = 0)

Quits the application and returns from run
Param exitCode Exit code to return from run


registerClipboardFormat function

ClipboardFormat
registerClipboardFormat(string_view formatID)

Registers a custom clipboard format.
Param formatID The identifier of the format to register.
Returns The registered ClipboardFormat.


run function

int run()

Runs the application event loop.

Creates PlatformWindow for each added Window instance and makes it visible if not hidden
Param idle Function to call on every cycle
Returns int Exit code if quit called, otherwise 0


int run(RC<Window> mainWindow)

Sets main window and runs the application event loop
Note (UNKNOWN ID: ('ref', 'WindowApplication::run()'))


separateRenderThread variable

extern bool separateRenderThread

Controls whether the application should render in a separate threads. Default true


setClipboardContent function

bool setClipboardContent(const ClipboardContent &content)

Sets the content of the clipboard.
Param content The ClipboardContent to set in the clipboard.
Returns True if the clipboard content was successfully set, otherwise false.


setVisible function

void setVisible(bool newVisible)

If true, application will remove this window from windows list


showModalWindow function

template <std::derived_from<Window> TWindow>
RC<TWindow> showModalWindow(RC<TWindow> window)

Adds window to the window application and open it as a modal window
Param window window to be shown


start function

void start()

Start the main loop
Details This function is internal. Use only if you know what you do


stop function

void stop()

Stops the main loop
Details This function is internal. Use only if you know what you do


textFormat variable

extern ClipboardFormat textFormat

Global variable that represents the text format identifier for the clipboard.


windows function

std::vector<RC<Window>> windows() const

Returns a copy of the windows list.
Details Safe to call from main or UI thread


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/