Blender V5.0
GHOST_System Class Referenceabstract

#include <GHOST_System.hh>

Inherits GHOST_ISystem.

Inherited by GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

Public Member Functions

GHOST_ITimerTaskinstallTimer (uint64_t delay, uint64_t interval, GHOST_TimerProcPtr timer_proc, GHOST_TUserDataPtr user_data=nullptr) override
GHOST_TSuccess removeTimer (GHOST_ITimerTask *timerTask) override
GHOST_TSuccess disposeWindow (GHOST_IWindow *window) override
GHOST_IContextcreateOffscreenContext (GHOST_GPUSettings gpu_settings) override=0
bool validWindow (GHOST_IWindow *window) override
bool useNativePixel () override
void useWindowFocus (const bool use_focus) override
void setAutoFocus (const bool auto_focus) override
GHOST_IWindowgetWindowUnderCursor (int32_t x, int32_t y) override
void dispatchEvents () override
GHOST_TSuccess addEventConsumer (GHOST_IEventConsumer *consumer) override
GHOST_TSuccess removeEventConsumer (GHOST_IEventConsumer *consumer) override
GHOST_TSuccess getCursorPositionClientRelative (const GHOST_IWindow *window, int32_t &x, int32_t &y) const override
GHOST_TSuccess setCursorPositionClientRelative (GHOST_IWindow *window, int32_t x, int32_t y) override
uint32_t getCursorPreferredLogicalSize () const override
GHOST_TSuccess getModifierKeyState (GHOST_TModifierKey mask, bool &is_down) const override
GHOST_TSuccess getButtonState (GHOST_TButton mask, bool &is_down) const override
void setMultitouchGestures (const bool use) override
void setTabletAPI (GHOST_TTabletAPI api) override
GHOST_TTabletAPI getTabletAPI ()
GHOST_TSuccess getPixelAtCursor (float r_color[3]) const override
char * getClipboard (bool selection) const override=0
void putClipboard (const char *buffer, bool selection) const override=0
GHOST_TSuccess hasClipboardImage () const override
uintgetClipboardImage (int *r_width, int *r_height) const override
GHOST_TSuccess putClipboardImage (uint *rgba, int width, int height) const override
GHOST_TSuccess showMessageBox (const char *, const char *, const char *, const char *, const char *, GHOST_DialogOptions) const override
GHOST_TSuccess pushEvent (const GHOST_IEvent *event)
GHOST_TimerManagergetTimerManager () const
GHOST_EventManagergetEventManager () const
GHOST_WindowManagergetWindowManager () const
virtual GHOST_TSuccess getModifierKeys (GHOST_ModifierKeys &keys) const =0
virtual GHOST_TSuccess getButtons (GHOST_Buttons &buttons) const =0
void initDebug (GHOST_Debug debug) override
bool isDebugEnabled () override
Public Member Functions inherited from GHOST_ISystem
virtual uint64_t getMilliSeconds () const =0
virtual uint8_t getNumDisplays () const =0
virtual void getMainDisplayDimensions (uint32_t &width, uint32_t &height) const =0
virtual void getAllDisplayDimensions (uint32_t &width, uint32_t &height) const =0
virtual GHOST_IWindowcreateWindow (const char *title, int32_t left, int32_t top, uint32_t width, uint32_t height, GHOST_TWindowState state, GHOST_GPUSettings gpu_settings, const bool exclusive=false, const bool is_dialog=false, const GHOST_IWindow *parent_window=nullptr)=0
virtual GHOST_TSuccess disposeContext (GHOST_IContext *context)=0
virtual GHOST_TCapabilityFlag getCapabilities () const =0
virtual bool processEvents (bool waitForEvent)=0
virtual GHOST_TSuccess getCursorPosition (int32_t &x, int32_t &y) const =0
virtual GHOST_TSuccess setCursorPosition (int32_t x, int32_t y)=0
virtual bool setConsoleWindowState (GHOST_TConsoleWindowState action)=0

Public Attributes

bool native_pixel_
bool window_focus_
bool auto_focus_

Protected Member Functions

 GHOST_System ()
 ~GHOST_System () override
GHOST_TSuccess init () override
GHOST_TSuccess exit () override
Protected Member Functions inherited from GHOST_ISystem
 GHOST_ISystem ()
virtual ~GHOST_ISystem ()=default

Protected Attributes

GHOST_TimerManagertimer_manager_
GHOST_WindowManagerwindow_manager_
GHOST_EventManagerevent_manager_
bool multitouch_gestures_
GHOST_TTabletAPI tablet_api_
bool is_debug_enabled_

Additional Inherited Members

Static Public Member Functions inherited from GHOST_ISystem
static GHOST_TSuccess createSystem (bool verbose, bool background)
static GHOST_TSuccess createSystemBackground ()
static GHOST_TSuccess disposeSystem ()
static GHOST_ISystemgetSystem ()
static const char * getSystemBackend ()
static GHOST_TBacktraceFn getBacktraceFn ()
static void setBacktraceFn (GHOST_TBacktraceFn backtrace_fn)
static bool getUseWindowFrame ()
static void setUseWindowFrame (bool use_window_frame)
Static Protected Attributes inherited from GHOST_ISystem
static GHOST_ISystemsystem_ = nullptr
static const char * system_backend_id_ = nullptr
static GHOST_TBacktraceFn backtrace_fn_ = nullptr
static bool use_window_frame_ = true

Detailed Description

Implementation of platform independent functionality of the GHOST_ISystem interface. GHOST_System is an abstract class because not all methods of GHOST_ISystem are implemented.

See also
GHOST_ISystem.

Definition at line 37 of file GHOST_System.hh.

Constructor & Destructor Documentation

◆ GHOST_System()

◆ ~GHOST_System()

GHOST_System::~GHOST_System ( )
overrideprotected

Destructor. Protected default constructor to force use of static dispose member.

Definition at line 36 of file GHOST_System.cc.

References exit().

Member Function Documentation

◆ addEventConsumer()

GHOST_TSuccess GHOST_System::addEventConsumer ( GHOST_IEventConsumer * consumer)
overridevirtual

Adds the given event consumer to our list.

Parameters
consumerThe event consumer to add.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 158 of file GHOST_System.cc.

References event_manager_, and GHOST_kFailure.

◆ createOffscreenContext()

GHOST_IContext * GHOST_System::createOffscreenContext ( GHOST_GPUSettings gpu_settings)
overridepure virtual

Create a new off-screen context. Never explicitly delete the context, use disposeContext() instead.

Returns
The new context (or 0 if creation failed).

Implements GHOST_ISystem.

Implemented in GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

◆ dispatchEvents()

void GHOST_System::dispatchEvents ( )
overridevirtual

Inherited from GHOST_ISystem but left pure virtual

virtual bool processEvents(bool waitForEvent) = 0;

Retrieves events from the queue and send them to the event consumers. The event stack will be empty afterwards.

Implements GHOST_ISystem.

Definition at line 142 of file GHOST_System.cc.

References event_manager_, GHOST_ISystem::getMilliSeconds(), and timer_manager_.

Referenced by GHOST_SystemWin32::processWindowSizeEvent(), and GHOST_SystemWin32::s_wndProc().

◆ disposeWindow()

GHOST_TSuccess GHOST_System::disposeWindow ( GHOST_IWindow * window)
overridevirtual

Dispose a window.

Parameters
windowPointer to the window to be disposed.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 87 of file GHOST_System.cc.

References event_manager_, GHOST_kFailure, and window_manager_.

◆ exit()

GHOST_TSuccess GHOST_System::exit ( )
overrideprotectedvirtual

Shut the system down.

Returns
Indication of success.

WARNING: exit() may run more than once, since it may need to be called from a derived class destructor. Take it into account when modifying this function.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWin32.

Definition at line 294 of file GHOST_System.cc.

References event_manager_, GHOST_kSuccess, timer_manager_, and window_manager_.

Referenced by GHOST_SystemWin32::exit(), and ~GHOST_System().

◆ getButtons()

virtual GHOST_TSuccess GHOST_System::getButtons ( GHOST_Buttons & buttons) const
pure virtual

Returns the state of the mouse buttons (outside the message queue).

Parameters
buttonsThe state of the buttons.
Returns
Indication of success.

Implemented in GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

Referenced by getButtonState().

◆ getButtonState()

GHOST_TSuccess GHOST_System::getButtonState ( GHOST_TButton mask,
bool & is_down ) const
overridevirtual

Returns the state of a mouse button (outside the message queue).

Parameters
maskThe button state to retrieve.
is_downButton state.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 234 of file GHOST_System.cc.

References GHOST_Buttons::get(), getButtons(), and mask().

◆ getClipboard()

char * GHOST_System::getClipboard ( bool selection) const
overridepure virtual

Return the clipboard buffer or null.

Parameters
selectionUse the "primary" selection. Check the GHOST_kCapabilityClipboardPrimary for backends that support this.
Returns
Returns the clipboard data as a null terminated string or null when unavailable.

Implements GHOST_ISystem.

Implemented in GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

◆ getClipboardImage()

uint * GHOST_System::getClipboardImage ( int * r_width,
int * r_height ) const
overridevirtual

Get image data from the Clipboard

Parameters
r_widththe returned image width in pixels.
r_heightthe returned image height in pixels.
Returns
pointer uint array in RGBA byte order. Caller must free.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemWayland, and GHOST_SystemWin32.

Definition at line 46 of file GHOST_System.cc.

◆ getCursorPositionClientRelative()

GHOST_TSuccess GHOST_System::getCursorPositionClientRelative ( const GHOST_IWindow * window,
int32_t & x,
int32_t & y ) const
overridevirtual

Returns the current location of the cursor (location in window coordinates)

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
Indication of success.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWayland.

Definition at line 194 of file GHOST_System.cc.

References GHOST_ISystem::getCursorPosition(), GHOST_kSuccess, GHOST_IWindow::screenToClient(), x, and y.

◆ getCursorPreferredLogicalSize()

uint32_t GHOST_System::getCursorPreferredLogicalSize ( ) const
overridevirtual

Returns
the size of the cursor in logical pixels (before Hi-DPI scaling is applied).

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWayland, and GHOST_SystemWin32.

Definition at line 217 of file GHOST_System.cc.

◆ getEventManager()

GHOST_EventManager * GHOST_System::getEventManager ( ) const
inline
Returns
A pointer to our event manager.

Definition at line 292 of file GHOST_System.hh.

References event_manager_.

Referenced by GHOST_SystemWayland::processEvents(), and GHOST_SystemWin32::s_wndProc().

◆ getModifierKeys()

virtual GHOST_TSuccess GHOST_System::getModifierKeys ( GHOST_ModifierKeys & keys) const
pure virtual

Returns the state of all modifier keys.

Parameters
keysThe state of all modifier keys (true == pressed).
Returns
Indication of success.

Implemented in GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

Referenced by getModifierKeyState().

◆ getModifierKeyState()

GHOST_TSuccess GHOST_System::getModifierKeyState ( GHOST_TModifierKey mask,
bool & is_down ) const
overridevirtual

Inherited from GHOST_ISystem but left pure virtual

GHOST_TSuccess getCursorPosition(int32_t& x, int32_t& y) const = 0;
GHOST_TSuccess setCursorPosition(int32_t x, int32_t y)

Returns the state of a modifier key (outside the message queue).

Parameters
maskThe modifier key state to retrieve.
is_downThe state of a modifier key (true == pressed).
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 222 of file GHOST_System.cc.

References GHOST_ModifierKeys::get(), getModifierKeys(), and mask().

◆ getPixelAtCursor()

GHOST_TSuccess GHOST_System::getPixelAtCursor ( float r_color[3]) const
overridevirtual

Get the color of the pixel at the current mouse cursor location

Parameters
r_colorreturned sRGB float colors
Returns
Success value (true == successful and supported by platform)

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemWin32, and GHOST_SystemX11.

Definition at line 261 of file GHOST_System.cc.

References GHOST_kFailure.

◆ getTabletAPI()

GHOST_TTabletAPI GHOST_System::getTabletAPI ( )

Definition at line 256 of file GHOST_System.cc.

References tablet_api_.

Referenced by GHOST_WindowWin32::GHOST_WindowWin32().

◆ getTimerManager()

GHOST_TimerManager * GHOST_System::getTimerManager ( ) const
inline

◆ getWindowManager()

◆ getWindowUnderCursor()

GHOST_IWindow * GHOST_System::getWindowUnderCursor ( int32_t x,
int32_t y )
overridevirtual

Get the Window under the cursor. Although coordinates of the mouse are supplied, platform- specific implementations are free to ignore these and query the mouse location themselves, due to them possibly being incorrect under certain conditions, for example when using multiple monitors that vary in scale and/or DPI.

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
The window under the cursor or nullptr if none.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemHeadless, and GHOST_SystemWin32.

Definition at line 112 of file GHOST_System.cc.

References bounds(), GHOST_IWindow::getClientBounds(), GHOST_IWindow::getState(), GHOST_kWindowStateMinimized, window_manager_, x, and y.

◆ hasClipboardImage()

GHOST_TSuccess GHOST_System::hasClipboardImage ( void ) const
overridevirtual

Returns GHOST_kSuccess if the clipboard contains an image.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemWayland, and GHOST_SystemWin32.

Definition at line 41 of file GHOST_System.cc.

References GHOST_kFailure.

◆ init()

GHOST_TSuccess GHOST_System::init ( )
overrideprotectedvirtual

◆ initDebug()

void GHOST_System::initDebug ( GHOST_Debug debug)
overridevirtual

Specify whether debug messages are to be shown.

Parameters
debugFlag for systems to debug.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWin32.

Definition at line 332 of file GHOST_System.cc.

References GHOST_Debug::flags, GHOST_kDebugDefault, and is_debug_enabled_.

Referenced by GHOST_SystemWin32::initDebug().

◆ installTimer()

GHOST_ITimerTask * GHOST_System::installTimer ( uint64_t delay,
uint64_t interval,
GHOST_TimerProcPtr timer_proc,
GHOST_TUserDataPtr user_data = nullptr )
overridevirtual

Installs a timer.

Note
On most operating systems, messages need to be processed in order for the timer callbacks to be invoked.
Parameters
delayThe time to wait for the first call to the #timer_proc (in milliseconds).
intervalThe interval between calls to the #timer_proc.
timer_procThe callback invoked when the interval expires.
user_dataPlaceholder for user data.
Returns
A timer task (0 if timer task installation failed).

Implements GHOST_ISystem.

Definition at line 58 of file GHOST_System.cc.

References GHOST_ISystem::getMilliSeconds(), GHOST_kSuccess, timer, and timer_manager_.

Referenced by gwl_seat_key_repeat_timer_add().

◆ isDebugEnabled()

bool GHOST_System::isDebugEnabled ( )
overridevirtual

Check whether debug messages are to be shown.

Implements GHOST_ISystem.

Definition at line 337 of file GHOST_System.cc.

References is_debug_enabled_.

◆ pushEvent()

◆ putClipboard()

void GHOST_System::putClipboard ( const char * buffer,
bool selection ) const
overridepure virtual

Put data to the Clipboard

Parameters
bufferThe buffer to copy to the clipboard.
selectionThe clipboard to copy too only used on X11.

Implements GHOST_ISystem.

Implemented in GHOST_SystemCocoa, GHOST_SystemHeadless, GHOST_SystemSDL, GHOST_SystemWayland, GHOST_SystemWin32, and GHOST_SystemX11.

◆ putClipboardImage()

GHOST_TSuccess GHOST_System::putClipboardImage ( uint * rgba,
int width,
int height ) const
overridevirtual

Put image data to the Clipboard

Parameters
rgbauint array in RGBA byte order.
widththe image width in pixels.
heightthe image height in pixels.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemWayland, and GHOST_SystemWin32.

Definition at line 51 of file GHOST_System.cc.

References GHOST_kFailure.

◆ removeEventConsumer()

GHOST_TSuccess GHOST_System::removeEventConsumer ( GHOST_IEventConsumer * consumer)
overridevirtual

Removes the given event consumer to our list.

Parameters
consumerThe event consumer to remove.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 170 of file GHOST_System.cc.

References event_manager_, and GHOST_kFailure.

◆ removeTimer()

GHOST_TSuccess GHOST_System::removeTimer ( GHOST_ITimerTask * timerTask)
overridevirtual

Removes a timer.

Parameters
timerTaskTimer task to be removed.
Returns
Indication of success.

Implements GHOST_ISystem.

Definition at line 78 of file GHOST_System.cc.

References GHOST_kFailure, and timer_manager_.

Referenced by gwl_seat_key_repeat_timer_remove().

◆ setAutoFocus()

void GHOST_System::setAutoFocus ( const bool auto_focus)
overridevirtual

Focus and raise windows on mouse hover.

Implements GHOST_ISystem.

Definition at line 327 of file GHOST_System.cc.

References auto_focus_.

◆ setCursorPositionClientRelative()

GHOST_TSuccess GHOST_System::setCursorPositionClientRelative ( GHOST_IWindow * window,
int32_t x,
int32_t y )
overridevirtual

Updates the location of the cursor (location in window coordinates).

Parameters
xThe x-coordinate of the cursor.
yThe y-coordinate of the cursor.
Returns
Indication of success.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWayland.

Definition at line 207 of file GHOST_System.cc.

References GHOST_IWindow::clientToScreen(), GHOST_ISystem::setCursorPosition(), x, and y.

◆ setMultitouchGestures()

void GHOST_System::setMultitouchGestures ( const bool use)
overridevirtual

Enable multi-touch gestures if supported.

Parameters
useEnable or disable.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWayland.

Definition at line 246 of file GHOST_System.cc.

References multitouch_gestures_.

◆ setTabletAPI()

void GHOST_System::setTabletAPI ( GHOST_TTabletAPI api)
overridevirtual

Set which tablet API to use. Only affects Windows, other platforms have a single API.

Parameters
apiEnum indicating which API to use.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemWin32.

Definition at line 251 of file GHOST_System.cc.

References tablet_api_.

Referenced by GHOST_SystemWin32::setTabletAPI().

◆ showMessageBox()

GHOST_TSuccess GHOST_System::showMessageBox ( const char * ,
const char * ,
const char * ,
const char * ,
const char * ,
GHOST_DialogOptions  ) const
inlineoverridevirtual

Show a system message box

Parameters
titleThe title of the message box.
messageThe message to display.
help_labelHelp button label.
continue_labelContinue button label.
linkAn optional hyperlink.
dialog_optionsOptions how to display the message.

Implements GHOST_ISystem.

Reimplemented in GHOST_SystemCocoa, GHOST_SystemWin32, and GHOST_SystemX11.

Definition at line 185 of file GHOST_System.hh.

References GHOST_kFailure.

◆ useNativePixel()

bool GHOST_System::useNativePixel ( )
overridevirtual

Native pixel size support (MacBook 'retina').

Returns
The pixel size in float.

Implements GHOST_ISystem.

Definition at line 316 of file GHOST_System.cc.

References native_pixel_.

◆ useWindowFocus()

void GHOST_System::useWindowFocus ( const bool use_focus)
overridevirtual

Focus window after opening, or put them in the background.

Implements GHOST_ISystem.

Definition at line 322 of file GHOST_System.cc.

References window_focus_.

◆ validWindow()

bool GHOST_System::validWindow ( GHOST_IWindow * window)
overridevirtual

Returns whether a window is valid.

Parameters
windowPointer to the window to be checked.
Returns
Indication of validity.

Implements GHOST_ISystem.

Definition at line 107 of file GHOST_System.cc.

References window_manager_.

Referenced by GHOST_SystemCocoa::handleDraggingEvent(), and GHOST_SystemCocoa::handleWindowEvent().

Member Data Documentation

◆ auto_focus_

bool GHOST_System::auto_focus_

Definition at line 88 of file GHOST_System.hh.

Referenced by GHOST_System(), GHOST_SystemWin32::s_wndProc(), and setAutoFocus().

◆ event_manager_

◆ is_debug_enabled_

bool GHOST_System::is_debug_enabled_
protected

Definition at line 284 of file GHOST_System.hh.

Referenced by GHOST_System(), initDebug(), and isDebugEnabled().

◆ multitouch_gestures_

bool GHOST_System::multitouch_gestures_
protected

◆ native_pixel_

bool GHOST_System::native_pixel_

◆ tablet_api_

GHOST_TTabletAPI GHOST_System::tablet_api_
protected

Which tablet API to use.

Definition at line 282 of file GHOST_System.hh.

Referenced by getTabletAPI(), GHOST_System(), and setTabletAPI().

◆ timer_manager_

GHOST_TimerManager* GHOST_System::timer_manager_
protected

The timer manager.

Definition at line 260 of file GHOST_System.hh.

Referenced by dispatchEvents(), exit(), getTimerManager(), GHOST_System(), init(), installTimer(), and removeTimer().

◆ window_focus_

bool GHOST_System::window_focus_

Definition at line 84 of file GHOST_System.hh.

Referenced by GHOST_System(), GHOST_WindowX11::GHOST_WindowX11(), and useWindowFocus().

◆ window_manager_


The documentation for this class was generated from the following files: