2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef DGL_APP_PRIVATE_DATA_HPP_INCLUDED
18 #define DGL_APP_PRIVATE_DATA_HPP_INCLUDED
20 #include "../Application.hpp"
24 #ifdef DISTRHO_OS_WINDOWS
28 # include <winsock2.h>
30 typedef HANDLE d_ThreadHandle
;
33 typedef pthread_t d_ThreadHandle
;
37 typedef struct PuglWorldImpl PuglWorld
;
44 #ifndef DISTRHO_OS_MAC
45 typedef struct PuglWorldImpl PuglWorld
;
48 // --------------------------------------------------------------------------------------------------------------------
50 struct Application::PrivateData
{
51 /** Pugl world instance. */
52 PuglWorld
* const world
;
54 /** Whether the application is running as standalone, otherwise it is part of a plugin. */
55 const bool isStandalone
;
57 /** Whether the applicating is about to quit, or already stopped. Defaults to false. */
60 /** Helper for safely close everything from main thread. */
61 bool isQuittingInNextCycle
;
63 /** Whether the applicating is starting up, that is, no windows have been made visible yet. Defaults to true. */
66 /** Counter of visible windows, only used in standalone mode.
67 If 0->1, application is starting. If 1->0, application is quitting/stopping. */
70 /** Handle that identifies the main thread. Used to check if calls belong to current thread or not. */
71 d_ThreadHandle mainThreadHandle
;
73 /** List of windows for this application. Only used during `close`. */
74 std::list
<DGL_NAMESPACE::Window
*> windows
;
76 /** List of idle callbacks for this application. */
77 std::list
<DGL_NAMESPACE::IdleCallback
*> idleCallbacks
;
79 /** Constructor and destructor */
80 explicit PrivateData(bool standalone
);
83 /** Flag one window as shown, which increments @a visibleWindows.
84 Sets @a isQuitting and @a isStarting as false if this is the first window.
85 For standalone mode only. */
86 void oneWindowShown() noexcept
;
88 /** Flag one window as closed, which decrements @a visibleWindows.
89 Sets @a isQuitting as true if this is the last window.
90 For standalone mode only. */
91 void oneWindowClosed() noexcept
;
93 /** Run Pugl world update for @a timeoutInMs, and then each idle callback in order of registration. */
94 void idle(uint timeoutInMs
);
96 /** Run each idle callback without updating pugl world. */
97 void triggerIdleCallbacks();
99 /** Set flag indicating application is quitting, and close all windows in reverse order of registration.
100 For standalone mode only. */
103 /** Get time via pugl */
104 double getTime() const;
106 /** Set pugl world class name. */
107 void setClassName(const char* name
);
109 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData
)
112 // --------------------------------------------------------------------------------------------------------------------
116 #endif // DGL_APP_PRIVATE_DATA_HPP_INCLUDED