Dusk Audio Framework
Loading...
Searching...
No Matches
Application Class Reference

#include <Application.hpp>

Public Types

enum  Type { kTypeAuto , kTypeClassic , kTypeModern }
enum  WindowSystem { kWindowSystemAuto , kWindowSystemX11 , kWindowSystemWayland }

Public Member Functions

 Application (bool isStandalone=true, Type type=kTypeAuto, WindowSystem windowSystem=kWindowSystemAuto)
 Application (int argc, char *argv[], WindowSystem windowSystem=kWindowSystemAuto)
virtual ~Application ()
void idle ()
void exec (uint idleTimeInMs=30)
void quit ()
bool isQuitting () const noexcept
bool isStandalone () const noexcept
double getTime () const
Type getType () const noexcept
WindowSystem getWindowSystem () const noexcept
void addIdleCallback (IdleCallback *callback)
void removeIdleCallback (IdleCallback *callback)
const char * getClassName () const noexcept
void setClassName (const char *name)

Friends

class Window
class DAF_NAMESPACE::PluginApplication

Detailed Description

Base DGL Application class.

One application instance is required for creating a window. There's no single/global application instance in DGL, and multiple windows can share the same app instance.

In standalone mode an application will automatically quit its event-loop when all its windows are closed.

Unless stated otherwise, functions within this class are not thread-safe.

Member Enumeration Documentation

◆ Type

Type of application to setup, either "classic" or "modern".

What this means depends on the OS.

◆ WindowSystem

Windowing system to open the application's windows on.

Only Linux and the other X11/Wayland systems have one to choose. A DGL_BACKEND=both build picks X11 or Wayland at runtime, by the rule in dgl/src/runtime-backend.md, unless the application asks for one. The request is final: if that system cannot be used, or the build does not have it, no window opens and a message says why, rather than the application ending up on the other one. It takes the place of the DAF_WINDOW_BACKEND environment variable.

On macOS, Windows and the other platforms with a single windowing system the request is ignored.

Constructor & Destructor Documentation

◆ Application() [1/2]

Application::Application ( bool isStandalone = true,
Type type = kTypeAuto,
WindowSystem windowSystem = kWindowSystemAuto )

Constructor for standalone or plugin application.

◆ Application() [2/2]

Application::Application ( int argc,
char * argv[],
WindowSystem windowSystem = kWindowSystemAuto )

Constructor for a standalone application. This specific constructor is required if using web views in standalone applications. On Linux a web view needs X11, see WindowSystem.

◆ ~Application()

virtual Application::~Application ( )
virtual

Destructor.

Member Function Documentation

◆ idle()

void Application::idle ( )

Idle function. This runs the application event-loop once.

◆ exec()

void Application::exec ( uint idleTimeInMs = 30)

Run the application event-loop until all Windows are closed. idle() is called at regular intervals.

Note
This function is meant for standalones only, never call this from plugins.

◆ quit()

void Application::quit ( )

Quit the application. This stops the event-loop and closes all Windows. This function is thread-safe.

◆ isQuitting()

bool Application::isQuitting ( ) const
noexcept

Check if the application is about to quit. Returning true means there's no event-loop running at the moment (or it's just about to stop). This function is thread-safe.

◆ isStandalone()

bool Application::isStandalone ( ) const
noexcept

Check if the application is standalone, otherwise running as a module or plugin. This function is thread-safe.

◆ getTime()

double Application::getTime ( ) const

Return the time in seconds.

This is a monotonically increasing clock with high resolution.
The returned time is only useful to compare against other times returned by this function, its absolute value has no meaning.

◆ getType()

Type Application::getType ( ) const
noexcept

Return the application type, either kTypeClassic or kTypeModern. This function never return kTypeAuto.

◆ getWindowSystem()

WindowSystem Application::getWindowSystem ( ) const
noexcept

Return the windowing system the application's windows open on, kWindowSystemX11 or kWindowSystemWayland. Returns kWindowSystemAuto where the platform has no choice of one, and when none could be opened.

◆ addIdleCallback()

void Application::addIdleCallback ( IdleCallback * callback)

Add a callback function to be triggered on every idle cycle. You can add more than one, and remove them at anytime with removeIdleCallback(). Idle callbacks trigger right after OS event handling and Window idle events (within the same cycle). There are no guarantees in terms of timing, use Window::addIdleCallback for time-relative callbacks. Registrations added during dispatch start on the next idle call. Removing a registration cancels its pending call immediately; nested idle calls do not re-enter an active registration.

◆ removeIdleCallback()

void Application::removeIdleCallback ( IdleCallback * callback)

Remove an idle callback previously added via addIdleCallback().

◆ getClassName()

const char * Application::getClassName ( ) const
noexcept

Get the class name of the application.

This is a stable identifier for the application, used as the window class/instance name on X11 and Windows. It is not displayed to the user, but can be used in scripts and by window managers, so it should be the same for every instance of the application, but different from other applications.

Plugins created with DAF have their class name automatically set based on DGL_NAMESPACE and plugin name.

◆ setClassName()

void Application::setClassName ( const char * name)

Set the class name of the application.

See also
getClassName

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