Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.7KB

  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2021 Filipe Coelho <falktx@falktx.com>
  4. *
  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.
  8. *
  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.
  15. */
  16. #ifndef DGL_APP_PRIVATE_DATA_HPP_INCLUDED
  17. #define DGL_APP_PRIVATE_DATA_HPP_INCLUDED
  18. #include "../Application.hpp"
  19. #include <list>
  20. #ifdef DISTRHO_OS_WINDOWS
  21. # include <winsock2.h>
  22. # include <windows.h>
  23. typedef HANDLE d_ThreadHandle;
  24. #else
  25. # include <pthread.h>
  26. typedef pthread_t d_ThreadHandle;
  27. #endif
  28. typedef struct PuglWorldImpl PuglWorld;
  29. START_NAMESPACE_DGL
  30. class Window;
  31. // --------------------------------------------------------------------------------------------------------------------
  32. struct Application::PrivateData {
  33. /** Pugl world instance. */
  34. PuglWorld* const world;
  35. /** Whether the application is running as standalone, otherwise it is part of a plugin. */
  36. const bool isStandalone;
  37. /** Whether the applicating is about to quit, or already stopped. Defaults to false. */
  38. bool isQuitting;
  39. /** Helper for safely close everything from main thread. */
  40. bool isQuittingInNextCycle;
  41. /** Whether the applicating is starting up, that is, no windows have been made visible yet. Defaults to true. */
  42. bool isStarting;
  43. /** Counter of visible windows, only used in standalone mode.
  44. If 0->1, application is starting. If 1->0, application is quitting/stopping. */
  45. uint visibleWindows;
  46. /** Handle that identifies the main thread. Used to check if calls belong to current thread or not. */
  47. d_ThreadHandle mainThreadHandle;
  48. /** List of windows for this application. Only used during `close`. */
  49. std::list<DGL_NAMESPACE::Window*> windows;
  50. /** List of idle callbacks for this application. */
  51. std::list<DGL_NAMESPACE::IdleCallback*> idleCallbacks;
  52. /** Constructor and destructor */
  53. explicit PrivateData(bool standalone);
  54. ~PrivateData();
  55. /** Flag one window as shown, which increments @a visibleWindows.
  56. Sets @a isQuitting and @a isStarting as false if this is the first window.
  57. For standalone mode only. */
  58. void oneWindowShown() noexcept;
  59. /** Flag one window as closed, which decrements @a visibleWindows.
  60. Sets @a isQuitting as true if this is the last window.
  61. For standalone mode only. */
  62. void oneWindowClosed() noexcept;
  63. /** Run Pugl world update for @a timeoutInMs, and then each idle callback in order of registration. */
  64. void idle(uint timeoutInMs);
  65. /** Run each idle callback without updating pugl world. */
  66. void triggerIdleCallbacks();
  67. /** Set flag indicating application is quitting, and close all windows in reverse order of registration.
  68. For standalone mode only. */
  69. void quit();
  70. /** Set pugl world class name. */
  71. void setClassName(const char* name);
  72. DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PrivateData)
  73. };
  74. // --------------------------------------------------------------------------------------------------------------------
  75. END_NAMESPACE_DGL
  76. #endif // DGL_APP_PRIVATE_DATA_HPP_INCLUDED