2 * Carla Main-Loop utils
3 * Copyright (C) 2017 Filipe Coelho <falktx@falktx.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * For a full copy of the GNU General Public License see the doc/GPL.txt file.
18 #ifndef CARLA_MAIN_LOOP_HPP_INCLUDED
19 #define CARLA_MAIN_LOOP_HPP_INCLUDED
21 #include "CarlaBackend.h"
22 #include "CarlaUtils.hpp"
25 # import <Cocoa/Cocoa.h>
28 // ---------------------------------------------------------------------------------------------------------------------
30 CARLA_BACKEND_START_NAMESPACE
33 bool runMainLoopOnce()
35 #if defined(CARLA_OS_MAC)
36 NSAutoreleasePool
* const pool
= [[NSAutoreleasePool alloc
] init
];
37 NSDate
* const date
= [NSDate distantPast
];
44 nextEventMatchingMask
:NSEventMaskAny
46 nextEventMatchingMask
:NSAnyEventMask
49 inMode
:NSDefaultRunLoopMode
55 [NSApp sendEvent
: event
];
59 #elif defined(CARLA_OS_WIN)
61 if (! ::PeekMessage(&msg
, nullptr, 0, 0, PM_NOREMOVE
))
64 if (::GetMessage(&msg
, nullptr, 0, 0) >= 0)
66 if (msg
.message
== WM_QUIT
)
69 //TranslateMessage(&msg);
70 DispatchMessage(&msg
);
77 CARLA_BACKEND_END_NAMESPACE
79 // ---------------------------------------------------------------------------------------------------------------------
81 #endif // CARLA_MAIN_LOOP_HPP_INCLUDED