29#include "../../SDL_internal.h"
40#include <InterfaceKit.h>
41#include <game/DirectWindow.h>
43#include <opengl/GLView.h>
46#include "../../main/haiku/SDL_BApp.h"
69 : BDirectWindow(bounds,
"Untitled", look, B_NORMAL_WINDOW_FEEL,
flags)
92 B_NORMAL_PRIORITY, (
void*)
this);
105 _SDL_GLView->UnlockGL();
106 RemoveChild(_SDL_GLView);
132 virtual BGLView *CreateGLView(
Uint32 gl_flags) {
134 if (_SDL_GLView ==
NULL) {
135 _SDL_GLView =
new BGLView(Bounds(),
"SDL GLView",
137 (B_WILL_DRAW | B_FRAME_EVENTS),
141 AddChild(_SDL_GLView);
142 _SDL_GLView->EnableDirectMode(
true);
143 _SDL_GLView->LockGL();
145 return (_SDL_GLView);
148 virtual void RemoveGLView() {
151 _SDL_GLView->UnlockGL();
152 RemoveChild(_SDL_GLView);
157 virtual void SwapBuffers(
void) {
158 _SDL_GLView->UnlockGL();
159 _SDL_GLView->LockGL();
160 _SDL_GLView->SwapBuffers();
172 || ((info->buffer_state & B_BUFFER_RESIZED)
173 || (info->buffer_state & B_BUFFER_RESET)
174 || (info->driver_state == B_MODE_CHANGED));
177 switch(info->buffer_state & B_DIRECT_MODE_MASK) {
181 case B_DIRECT_MODIFY:
193 _bits = (uint8*) info->bits;
207 _SDL_GLView->DirectConnected(info);
213 BDirectWindow::DirectConnected(info);
227 msg.AddInt32(
"window-x", (
int)origin.x);
228 msg.AddInt32(
"window-y", (
int)origin.y);
232 BDirectWindow::FrameMoved(origin);
239 msg.AddInt32(
"window-w", (
int)
width + 1);
240 msg.AddInt32(
"window-h", (
int)
height + 1);
257 msg.AddBool(
"focusGained",
active);
261 virtual void Zoom(BPoint origin,
278 BDirectWindow::Show();
287 BDirectWindow::Hide();
295 BDirectWindow::Minimize(minimize);
298 BMessage msg(minState);
313 if (msg->FindPoint(
"where", &where) == B_OK
314 && msg->FindInt32(
"be:transit", &transit) == B_OK) {
322 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
331 if (msg->FindInt32(
"buttons", &buttons) == B_OK) {
336 case B_MOUSE_WHEEL_CHANGED:
338 if (msg->FindFloat(
"be:wheel_delta_x", &
x) == B_OK
339 && msg->FindFloat(
"be:wheel_delta_y", &
y) == B_OK) {
348 int8 bytes[4] = { 0, 0, 0, 0 };
349 while (i < 4 && msg->FindInt8(
"byte",
i, &
byte) == B_OK) {
353 if (msg->FindInt32(
"key", &
key) == B_OK) {
359 case B_UNMAPPED_KEY_DOWN:
360 if (msg->FindInt32(
"key", &
key) == B_OK) {
366 case B_UNMAPPED_KEY_UP:
367 if (msg->FindInt32(
"key", &
key) == B_OK) {
382 BDirectWindow::DispatchMessage(msg,
target);
424 BDirectWindow::MessageReceived(
message);
449 BGLView *GetGLView() {
return _SDL_GLView; }
450 Uint32 GetGLType() {
return _gl_type; }
466 if(transit == B_EXITED_VIEW) {
477 msg.AddInt32(
"x", (
int)where.x);
478 msg.AddInt32(
"y", (
int)where.y);
487 msg.AddBool(
"focusGained", focusGained);
499 if( !(buttonStateChange) ) {
504 if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
506 B_PRIMARY_MOUSE_BUTTON);
508 if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
510 B_PRIMARY_MOUSE_BUTTON);
512 if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
514 B_PRIMARY_MOUSE_BUTTON);
522 msg.AddInt32(
"button-id",
button);
523 msg.AddInt32(
"button-state",
state);
530 msg.AddInt32(
"xticks",
x);
531 msg.AddInt32(
"yticks",
y);
535 void _KeyEvent(int32 keyCode,
const int8 *keyUtf8,
const ssize_t &
len, int32 keyState) {
538 msg.AddInt32(
"key-state", keyState);
539 msg.AddInt32(
"key-scancode", keyCode);
540 if (keyUtf8 !=
NULL) {
541 msg.AddData(
"key-utf8", B_INT8_TYPE, (
const void*)keyUtf8,
len);
543 be_app->PostMessage(&msg);
552 msg.AddInt32(
"window-id",
_id);
553 be_app->PostMessage(&msg);
560 msg->FindString(
"window-title", &title) != B_OK
570 msg->FindInt32(
"window-x", &
x) != B_OK ||
571 msg->FindInt32(
"window-y", &
y) != B_OK
581 msg->FindInt32(
"window-w", &
w) != B_OK ||
582 msg->FindInt32(
"window-h", &
h) != B_OK
591 if(msg->FindBool(
"window-border", &bEnabled) != B_OK) {
594 SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
599 if(msg->FindBool(
"window-resizable", &bEnabled) != B_OK) {
603 SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
605 SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
612 }
else if(IsHidden()) {
623 msg->FindBool(
"fullscreen", &fullscreen) != B_OK
627 SetFullScreen(fullscreen);
632 BGLView * _SDL_GLView;
@ BAPP_WINDOW_CLOSE_REQUESTED
int32 HAIKU_DrawThread(void *data)
#define SDL_BUTTON_MIDDLE
GLint GLint GLint GLint GLint GLint y
GLint GLint GLsizei width
GLint GLint GLint GLint GLint x
GLint GLint GLsizei GLsizei height
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
GLuint GLsizei const GLchar * message
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w
SDL_Scancode
The SDL keyboard scancode representation.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
virtual void MessageReceived(BMessage *message)
virtual void DispatchMessage(BMessage *msg, BHandler *target)
virtual bool QuitRequested()
void _SendMouseButton(int32 button, int32 state)
thread_id _draw_thread_id
void _SetFullScreen(BMessage *msg)
bool _trash_window_buffer
SDL_BWin(BRect bounds, window_look look, uint32 flags)
void _MouseWheelEvent(int32 x, int32 y)
void _MouseMotionEvent(BPoint &where, int32 transit)
virtual void FrameResized(float width, float height)
bool _connection_disabled
virtual void WindowActivated(bool active)
virtual void DirectConnected(direct_buffer_info *info)
bool CanTrashWindowBuffer()
void SetBufferExists(bool bufferExists)
void _MouseFocusEvent(bool focusGained)
void _SetTitle(BMessage *msg)
clipping_rect * GetClips()
void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState)
virtual void Minimize(bool minimize)
void _SetResizable(BMessage *msg)
virtual void Zoom(BPoint origin, float width, float height)
void SetBitmap(BBitmap *bitmap)
void SetTrashBuffer(bool trash)
void _MouseButtonEvent(int32 buttons)
virtual void FrameMoved(BPoint origin)
void _PostWindowEvent(BMessage &msg)
void _ResizeTo(BMessage *msg)
void _MoveTo(BMessage *msg)
void SetBufferDirty(bool bufferDirty)
void _SetBordered(BMessage *msg)