Haiku: use a BLooper for events, only create a BApplication when it doesn't already exist. (#7555)

This commit is contained in:
Jérôme Duval
2023-03-30 16:12:10 +02:00
committed by GitHub
parent cae6b4489d
commit 2d64f419c5
10 changed files with 113 additions and 81 deletions

View File

@@ -47,6 +47,7 @@ extern "C" {
#include <vector>
/* Forward declarations */
class SDL_BLooper;
class SDL_BWin;
/* Message constants */
@@ -72,31 +73,25 @@ enum ToSDL
BAPP_SCREEN_CHANGED
};
/* Create a descendant of BApplication */
class SDL_BApp : public BApplication
extern "C" SDL_BLooper *SDL_Looper;
/* Create a descendant of BLooper */
class SDL_BLooper : public BLooper
{
public:
SDL_BApp(const char *signature) : BApplication(signature)
SDL_BLooper(const char* name) : BLooper(name)
{
#ifdef SDL_VIDEO_OPENGL
_current_context = NULL;
#endif
}
virtual ~SDL_BApp()
virtual ~SDL_BLooper()
{
}
virtual void RefsReceived(BMessage *message)
{
entry_ref entryRef;
for (int32 i = 0; message->FindRef("refs", i, &entryRef) == B_OK; i++) {
BPath referencePath = BPath(&entryRef);
SDL_SendDropFile(NULL, referencePath.Path());
}
return;
}
/* Event-handling functions */
virtual void MessageReceived(BMessage *message)
{
@@ -167,7 +162,7 @@ class SDL_BApp : public BApplication
break;
default:
BApplication::MessageReceived(message);
BLooper::MessageReceived(message);
break;
}
}