24 #include <InterfaceKit.h>
25 #include <OpenGLKit.h>
27 #include "../../video/bwindow/SDL_bkeyboard.h"
39 #include "../../events/SDL_events_c.h"
40 #include "../../video/bwindow/SDL_bkeyboard.h"
41 #include "../../video/bwindow/SDL_bframebuffer.h"
83 BApplication(signature) {
84 _current_context =
NULL;
96 switch ( message->what ) {
98 _HandleMouseMove(message);
102 _HandleMouseButton(message);
106 _HandleMouseWheel(message);
134 _HandleMouseFocus(message);
138 _HandleKeyboardFocus(message);
146 _HandleWindowMoved(message);
150 _HandleWindowResized(message);
158 BApplication::MessageReceived(message);
166 for(i = 0; i < _GetNumWindowSlots(); ++
i) {
168 _SetSDLWindow(win, i);
174 if( i == _GetNumWindowSlots() ) {
175 _PushBackWindow(win);
189 return _window_map[winID];
194 _current_context->UnlockGL();
195 _current_context = newContext;
196 _current_context->LockGL();
200 void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) {
204 !_GetWinID(msg, &winID)
212 void _HandleMouseMove(BMessage *msg) {
217 !_GetWinID(msg, &winID) ||
218 msg->FindInt32(
"x", &x) != B_OK ||
219 msg->FindInt32(
"y", &
y) != B_OK
230 void _HandleMouseButton(BMessage *msg) {
235 !_GetWinID(msg, &winID) ||
236 msg->FindInt32(
"button-id", &button) != B_OK ||
237 msg->FindInt32(
"button-state", &state) != B_OK
245 void _HandleMouseWheel(BMessage *msg) {
248 int32 xTicks, yTicks;
250 !_GetWinID(msg, &winID) ||
251 msg->FindInt32(
"xticks", &xTicks) != B_OK ||
252 msg->FindInt32(
"yticks", &yTicks) != B_OK
260 void _HandleKey(BMessage *msg) {
261 int32 scancode, state;
263 msg->FindInt32(
"key-state", &state) != B_OK ||
264 msg->FindInt32(
"key-scancode", &scancode) != B_OK
277 void _HandleMouseFocus(BMessage *msg) {
282 !_GetWinID(msg, &winID) ||
283 msg->FindBool(
"focusGained", &bSetFocus) != B_OK
296 void _HandleKeyboardFocus(BMessage *msg) {
301 !_GetWinID(msg, &winID) ||
302 msg->FindBool(
"focusGained", &bSetFocus) != B_OK
315 void _HandleWindowMoved(BMessage *msg) {
321 !_GetWinID(msg, &winID) ||
322 msg->FindInt32(
"window-x", &xPos) != B_OK ||
323 msg->FindInt32(
"window-y", &yPos) != B_OK
331 void _HandleWindowResized(BMessage *msg) {
337 !_GetWinID(msg, &winID) ||
338 msg->FindInt32(
"window-w", &w) != B_OK ||
339 msg->FindInt32(
"window-h", &h) != B_OK
347 bool _GetWinID(BMessage *msg, int32 *winID) {
348 return msg->FindInt32(
"window-id", winID) == B_OK;
355 void _SetSDLWindow(
SDL_Window *win, int32 winID) {
356 _window_map[winID] = win;
359 int32 _GetNumWindowSlots() {
360 return _window_map.size();
364 void _PopBackWindow() {
365 _window_map.pop_back();
369 _window_map.push_back(win);
374 std::vector<SDL_Window*> _window_map;
376 display_mode *_saved_mode;
377 BGLView *_current_context;
GLfloat GLfloat GLfloat GLfloat h
void SDL_SetKeyboardFocus(SDL_Window *window)
virtual void MessageReceived(BMessage *message)
GLsizei GLenum GLuint GLuint GLsizei GLchar * message
DECLSPEC SDL_Window *SDLCALL SDL_GetMouseFocus(void)
Get the window which currently has mouse focus.
void BE_SetKeyState(int32 bkey, int8 state)
int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1, int data2)
void SDL_SetMouseFocus(SDL_Window *window)
int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode)
void SetCurrentContext(BGLView *newContext)
int SDL_SendMouseMotion(SDL_Window *window, SDL_MouseID mouseID, int relative, int x, int y)
SDL_BApp(const char *signature)
SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey)
int8 BE_GetKeyState(int32 bkey)
int BE_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect *rects, int numrects)
SDL_Window * GetSDLWindow(int32 winID)
int32 GetID(SDL_Window *win)
EGLSurface EGLint EGLint y
void ClearID(SDL_BWin *bwin)
int SDL_SendMouseWheel(SDL_Window *window, SDL_MouseID mouseID, int x, int y)
GLint GLint GLint GLint GLint w
DECLSPEC SDL_Window *SDLCALL SDL_GetKeyboardFocus(void)
Get the window which currently has keyboard focus.
int SDL_SendMouseButton(SDL_Window *window, SDL_MouseID mouseID, Uint8 state, Uint8 button)