mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-23 18:15:35 +00:00
haiku: Remove BDirectWindow, fix OpenGL handling.
From e6cc4e7f4b8189be55dd3b0e13e54e59f73d7672 Mon Sep 17 00:00:00 2001 From: X512 <danger_mail@list.ru> Date: Thu, 30 Jan 2020 04:01:58 +0900 Subject: libsdl2: Remove BDirectWindow, fix OpenGL handling. * BDirectWindow changed to BWindow. * Implemented fullscreen. * Introduced view for non-OpenGL drawing. * Drawing thread removed, window thread is used instead. * Use BGLView as OpenGL context. Implement proper context switching and OpenGL locking. Only one context per window is supported. BGLView should be not deleted when window is closed, it deleted when deleting context.
This commit is contained in:
parent
407d4e470a
commit
094e94402d
|
@ -21,6 +21,7 @@
|
|||
#ifndef SDL_BAPP_H
|
||||
#define SDL_BAPP_H
|
||||
|
||||
#include <Path.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include <LocaleRoster.h>
|
||||
#if SDL_VIDEO_OPENGL
|
||||
|
@ -93,6 +94,15 @@ public:
|
|||
}
|
||||
|
||||
|
||||
virtual void RefsReceived(BMessage* message) {
|
||||
char filePath[512];
|
||||
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) {
|
||||
|
@ -198,6 +208,10 @@ public:
|
|||
}
|
||||
|
||||
#if SDL_VIDEO_OPENGL
|
||||
BGLView *GetCurrentContext() {
|
||||
return _current_context;
|
||||
}
|
||||
|
||||
void SetCurrentContext(BGLView *newContext) {
|
||||
if(_current_context)
|
||||
_current_context->UnlockGL();
|
||||
|
@ -234,25 +248,22 @@ private:
|
|||
}
|
||||
win = GetSDLWindow(winID);
|
||||
|
||||
// Simple relative mode support for mouse.
|
||||
if (SDL_GetMouse()->relative_mode) {
|
||||
int winWidth, winHeight, winPosX, winPosY;
|
||||
SDL_GetWindowSize(win, &winWidth, &winHeight);
|
||||
SDL_GetWindowPosition(win, &winPosX, &winPosY);
|
||||
int dx = x - (winWidth / 2);
|
||||
int dy = y - (winHeight / 2);
|
||||
SDL_SendMouseMotion(win, 0, SDL_GetMouse()->relative_mode, dx, dy);
|
||||
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
|
||||
if (!be_app->IsCursorHidden())
|
||||
be_app->HideCursor();
|
||||
} else {
|
||||
SDL_SendMouseMotion(win, 0, 0, x, y);
|
||||
if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
|
||||
be_app->ShowCursor();
|
||||
}
|
||||
|
||||
/* Tell the application that the mouse passed over, redraw needed */
|
||||
HAIKU_UpdateWindowFramebuffer(NULL,win,NULL,-1);
|
||||
// Simple relative mode support for mouse.
|
||||
if (SDL_GetMouse()->relative_mode) {
|
||||
int winWidth, winHeight, winPosX, winPosY;
|
||||
SDL_GetWindowSize(win, &winWidth, &winHeight);
|
||||
SDL_GetWindowPosition(win, &winPosX, &winPosY);
|
||||
int dx = x - (winWidth / 2);
|
||||
int dy = y - (winHeight / 2);
|
||||
SDL_SendMouseMotion(win, 0, SDL_GetMouse()->relative_mode, dx, dy);
|
||||
set_mouse_position((winPosX + winWidth / 2), (winPosY + winHeight / 2));
|
||||
if (!be_app->IsCursorHidden())
|
||||
be_app->HideCursor();
|
||||
} else {
|
||||
SDL_SendMouseMotion(win, 0, 0, x, y);
|
||||
if (SDL_ShowCursor(-1) && be_app->IsCursorHidden())
|
||||
be_app->ShowCursor();
|
||||
}
|
||||
}
|
||||
|
||||
void _HandleMouseButton(BMessage *msg) {
|
||||
|
@ -300,7 +311,7 @@ private:
|
|||
}
|
||||
HAIKU_SetKeyState(scancode, state);
|
||||
SDL_SendKeyboardKey(state, HAIKU_GetScancodeFromBeKey(scancode));
|
||||
|
||||
|
||||
if (state == SDL_PRESSED && SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) {
|
||||
const int8 *keyUtf8;
|
||||
ssize_t count;
|
||||
|
|
Loading…
Reference in a new issue