SDL_BWin Class Reference

`#include <SDL_BWin.h>`

Inheritance diagram for SDL_BWin:
[legend]
Collaboration diagram for SDL_BWin:
[legend]

## Public Member Functions

| SDL_BWin (BRect bounds, window_look look, uint32 flags)
virtual | ~SDL_BWin ()
virtual BGLView * | CreateGLView (Uint32 gl_flags)
virtual void | RemoveGLView ()
virtual void | SwapBuffers (void)
virtual void | DirectConnected (direct_buffer_info *info)
virtual void | FrameMoved (BPoint origin)
virtual void | FrameResized (float width, float height)
virtual bool | QuitRequested ()
virtual void | WindowActivated (bool active)
virtual void | Zoom (BPoint origin, float width, float height)
virtual void | Show ()
virtual void | Hide ()
virtual void | Minimize (bool minimize)
virtual void | DispatchMessage (BMessage *msg, BHandler *target)
virtual void | MessageReceived (BMessage *message)
bool | IsShown ()
int32 | GetID ()
uint32 | GetRowBytes ()
int32 | GetFbX ()
int32 | GetFbY ()
bool | ConnectionEnabled ()
bool | Connected ()
clipping_rect * | GetClips ()
int32 | GetNumClips ()
uint8 * | GetBufferPx ()
int32 | GetBytesPerPx ()
bool | CanTrashWindowBuffer ()
bool | BufferExists ()
bool | BufferIsDirty ()
BBitmap * | GetBitmap ()
BGLView * | GetGLView ()
void | SetID (int32 id)
void | SetBufferExists (bool bufferExists)
void | LockBuffer ()
void | UnlockBuffer ()
void | SetBufferDirty (bool bufferDirty)
void | SetTrashBuffer (bool trash)
void | SetBitmap (BBitmap *bitmap)

## Private Member Functions

void | _MouseMotionEvent (BPoint &where, int32 transit)
void | _MouseFocusEvent (bool focusGained)
void | _MouseButtonEvent (int32 buttons)
void | _SendMouseButton (int32 button, int32 state)
void | _MouseWheelEvent (int32 x, int32 y)
void | _KeyEvent (int32 keyCode, int32 keyState)
void | _RepaintEvent ()
void | _PostWindowEvent (BMessage &msg)
void | _SetTitle (BMessage *msg)
void | _MoveTo (BMessage *msg)
void | _ResizeTo (BMessage *msg)
void | _SetBordered (BMessage *msg)
void | _Restore ()
void | _SetFullScreen (BMessage *msg)

## Private Attributes

BGLView * | _SDL_GLView
int32 | _last_buttons
int32 | _id
bool | _mouse_focused
bool | _shown
bool | _inhibit_resize
BRect * | _prev_frame
bool | _connected
bool | _connection_disabled
bool | _buffer_created
bool | _buffer_dirty
bool | _trash_window_buffer
uint8 * | _bits
uint32 | _row_bytes
clipping_rect | _bounds
BLocker * | _buffer_locker
clipping_rect * | _clips
int32 | _num_clips
int32 | _bytes_per_px
thread_id | _draw_thread_id
BBitmap * | _bitmap

## Detailed Description

Definition at line 63 of file SDL_BWin.h.

## Constructor & Destructor Documentation

SDL_BWin::SDL_BWin | ( | BRect | bounds,
|  | window_look | look,
|  | uint32 | flags
| ) |  |

inline

Definition at line 67 of file SDL_BWin.h.

References _bitmap, _buffer_created, _buffer_dirty, _buffer_locker, _clips, _connected, _connection_disabled, _draw_thread_id, _inhibit_resize, _last_buttons, _mouse_focused, _prev_frame, _SDL_GLView, _shown, _trash_window_buffer, BE_DrawThread(), and NULL.

: BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
{
_last_buttons = 0;
#if SDL_VIDEO_OPENGL
_SDL_GLView = NULL;
#endif
_shown = false;
_inhibit_resize = false;
_mouse_focused = false;
_prev_frame = NULL;
/* Handle framebuffer stuff */
_connected = _connection_disabled = false;
_buffer_created = _buffer_dirty = false;
_trash_window_buffer = false;
_buffer_locker = new BLocker();
_bitmap = NULL;
_clips = NULL;
#ifdef DRAWTHREAD
_draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
B_NORMAL_PRIORITY, (void*) this);
resume_thread(_draw_thread_id);
#endif
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
SDL_BWin::_last_buttons
int32 _last_buttons
Definition: SDL_BWin.h:597
SDL_BWin::_connected
bool _connected
Definition: SDL_BWin.h:606
SDL_BWin::_buffer_dirty
bool _buffer_dirty
Definition: SDL_BWin.h:606
SDL_BWin::_connection_disabled
bool _connection_disabled
Definition: SDL_BWin.h:606
SDL_BWin::_shown
bool _shown
Definition: SDL_BWin.h:600
SDL_BWin::_buffer_locker
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
SDL_BWin::_inhibit_resize
bool _inhibit_resize
Definition: SDL_BWin.h:601
SDL_BWin::_mouse_focused
bool _mouse_focused
Definition: SDL_BWin.h:599
SDL_BWin::_clips
clipping_rect * _clips
Definition: SDL_BWin.h:615
SDL_BWin::_prev_frame
BRect * _prev_frame
Definition: SDL_BWin.h:603
NULL
#define NULL
Definition: begin_code.h:143
SDL_BWin::_trash_window_buffer
bool _trash_window_buffer
Definition: SDL_BWin.h:606
SDL_BWin::_buffer_created
bool _buffer_created
Definition: SDL_BWin.h:606
SDL_BWin::_bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:620
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1480
SDL_BWin::_draw_thread_id
thread_id _draw_thread_id
Definition: SDL_BWin.h:618
BE_DrawThread
int32 BE_DrawThread(void *data)

virtual SDL_BWin::~SDL_BWin | ( |  | ) |

inline virtual

Definition at line 95 of file SDL_BWin.h.

References _buffer_locker, _clips, _connection_disabled, _draw_thread_id, _SDL_GLView, and free.

{
Lock();
_connection_disabled = true;
int32 result;
#if SDL_VIDEO_OPENGL
if (_SDL_GLView) {
_SDL_GLView->UnlockGL();
RemoveChild(_SDL_GLView); /* Why was this outside the if
statement before? */
}
#endif
Unlock();
#if SDL_VIDEO_OPENGL
if (_SDL_GLView) {
delete _SDL_GLView;
}
#endif
/* Clean up framebuffer stuff */
_buffer_locker->Lock();
#ifdef DRAWTHREAD
wait_for_thread(_draw_thread_id, &result);
#endif
free(_clips);
delete _buffer_locker;
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9432
SDL_BWin::_connection_disabled
bool _connection_disabled
Definition: SDL_BWin.h:606
free
SDL_EventEntry * free
Definition: SDL_events.c:81
SDL_BWin::_buffer_locker
BLocker * _buffer_locker
Definition: SDL_BWin.h:614
SDL_BWin::_clips
clipping_rect * _clips
Definition: SDL_BWin.h:615
SDL_BWin::_draw_thread_id
thread_id _draw_thread_id
Definition: SDL_BWin.h:618

## Member Function Documentation

void SDL_BWin::_KeyEvent | ( | int32 | keyCode,
|  | int32 | keyState
| ) |  |

inline private

Definition at line 511 of file SDL_BWin.h.

References BAPP_KEY.

Referenced by DispatchMessage().

{
/* Create a message to pass along to the BeApp thread */
BMessage msg(BAPP_KEY);
msg.AddInt32("key-state", keyState);
msg.AddInt32("key-scancode", keyCode);
be_app->PostMessage(&msg);
/* Apparently SDL only uses the scancode */
}
BAPP_KEY
Definition: SDL_BApp.h:61

void SDL_BWin::_MouseButtonEvent | ( | int32 | buttons | ) |

inline private

Definition at line 471 of file SDL_BWin.h.

References _last_buttons, _SendMouseButton(), SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, and SDL_BUTTON_RIGHT.

Referenced by DispatchMessage().

{
int32 buttonStateChange = buttons ^ _last_buttons;
/* Make sure at least one button has changed state */
if( !(buttonStateChange) ) {
return;
}
/* Add any mouse button events */
if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
_SendMouseButton(SDL_BUTTON_LEFT, buttons &
B_PRIMARY_MOUSE_BUTTON);
}
if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
_SendMouseButton(SDL_BUTTON_RIGHT, buttons &
B_PRIMARY_MOUSE_BUTTON);
}
if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
_SendMouseButton(SDL_BUTTON_MIDDLE, buttons &
B_PRIMARY_MOUSE_BUTTON);
}
_last_buttons = buttons;
}
SDL_BWin::_last_buttons
int32 _last_buttons
Definition: SDL_BWin.h:597
SDL_BUTTON_RIGHT
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:282
SDL_BWin::_SendMouseButton
void _SendMouseButton(int32 button, int32 state)
Definition: SDL_BWin.h:496
SDL_BUTTON_LEFT
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:280
SDL_BUTTON_MIDDLE
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:281

void SDL_BWin::_MouseFocusEvent | ( | bool | focusGained | ) |

inline private

Definition at line 460 of file SDL_BWin.h.

References _mouse_focused, _PostWindowEvent(), and BAPP_MOUSE_FOCUS.

Referenced by _MouseMotionEvent().

{
_mouse_focused = focusGained;
BMessage msg(BAPP_MOUSE_FOCUS);
msg.AddBool("focusGained", focusGained);
_PostWindowEvent(msg);
/* FIXME: Why were these here?
if false: be_app->SetCursor(B_HAND_CURSOR);
if true: SDL_SetCursor(NULL); */
}
SDL_BWin::_mouse_focused
bool _mouse_focused
Definition: SDL_BWin.h:599
BAPP_MOUSE_FOCUS
Definition: SDL_BApp.h:69
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

void SDL_BWin::_MouseMotionEvent | ( | BPoint & | where,
|  | int32 | transit
| ) |  |

inline private

Definition at line 441 of file SDL_BWin.h.

References _mouse_focused, _MouseFocusEvent(), _PostWindowEvent(), and BAPP_MOUSE_MOVED.

Referenced by DispatchMessage().

{
if(transit == B_EXITED_VIEW) {
/* Change mouse focus */
if(_mouse_focused) {
_MouseFocusEvent(false);
}
} else {
/* Change mouse focus */
if (!_mouse_focused) {
_MouseFocusEvent(true);
}
BMessage msg(BAPP_MOUSE_MOVED);
msg.AddInt32("x", (int)where.x);
msg.AddInt32("y", (int)where.y);
_PostWindowEvent(msg);
}
}
SDL_BWin::_mouse_focused
bool _mouse_focused
Definition: SDL_BWin.h:599
SDL_BWin::_MouseFocusEvent
void _MouseFocusEvent(bool focusGained)
Definition: SDL_BWin.h:460
BAPP_MOUSE_MOVED
Definition: SDL_BApp.h:58
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

void SDL_BWin::_MouseWheelEvent | ( | int32 | x,
|  | int32 | y
| ) |  |

inline private

Definition at line 503 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_WHEEL.

Referenced by DispatchMessage().

{
/* Create a message to pass along to the BeApp thread */
BMessage msg(BAPP_MOUSE_WHEEL);
msg.AddInt32("xticks", x);
msg.AddInt32("yticks", y);
_PostWindowEvent(msg);
}
BAPP_MOUSE_WHEEL
Definition: SDL_BApp.h:60
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

void SDL_BWin::_MoveTo | ( | BMessage * | msg | ) |

inline private

Definition at line 541 of file SDL_BWin.h.

Referenced by MessageReceived().

{
int32 x, y;
if(
msg->FindInt32("window-x", &x) != B_OK ||
msg->FindInt32("window-y", &y) != B_OK
) {
return;
}
MoveTo(x, y);
}
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

void SDL_BWin::_PostWindowEvent | ( | BMessage & | msg | ) |

inline private

Definition at line 525 of file SDL_BWin.h.

References _id.

Referenced by _MouseFocusEvent(), _MouseMotionEvent(), _MouseWheelEvent(), _RepaintEvent(), _SendMouseButton(), FrameMoved(), FrameResized(), Hide(), Minimize(), QuitRequested(), Show(), WindowActivated(), and Zoom().

{
msg.AddInt32("window-id", _id);
be_app->PostMessage(&msg);
}
SDL_BWin::_id
int32 _id
Definition: SDL_BWin.h:598

void SDL_BWin::_RepaintEvent | ( |  | ) |

inline private

Definition at line 520 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_REPAINT.

{
/* Force a repaint: Call the SDL exposed event */
BMessage msg(BAPP_REPAINT);
_PostWindowEvent(msg);
}
BAPP_REPAINT
Definition: SDL_BApp.h:62
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

void SDL_BWin::_ResizeTo | ( | BMessage * | msg | ) |

inline private

Definition at line 552 of file SDL_BWin.h.

Referenced by MessageReceived().

{
int32 w, h;
if(
msg->FindInt32("window-w", &w) != B_OK ||
msg->FindInt32("window-h", &h) != B_OK
) {
return;
}
ResizeTo(w, h);
}
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:731
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1946

void SDL_BWin::_Restore | ( |  | ) |

inline private

Definition at line 571 of file SDL_BWin.h.

References _prev_frame, Minimize(), NULL, and Show().

Referenced by MessageReceived().

{
if(IsMinimized()) {
Minimize(false);
} else if(IsHidden()) {
Show();
} else if(_prev_frame != NULL) { /* Zoomed */
MoveTo(_prev_frame->left, _prev_frame->top);
ResizeTo(_prev_frame->Width(), _prev_frame->Height());
}
}
SDL_BWin::Show
virtual void Show()
Definition: SDL_BWin.h:270
SDL_BWin::Minimize
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:288
SDL_BWin::_prev_frame
BRect * _prev_frame
Definition: SDL_BWin.h:603
NULL
#define NULL
Definition: begin_code.h:143

void SDL_BWin::_SendMouseButton | ( | int32 | button,
|  | int32 | state
| ) |  |

inline private

Definition at line 496 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_BUTTON.

Referenced by _MouseButtonEvent().

{
BMessage msg(BAPP_MOUSE_BUTTON);
msg.AddInt32("button-id", button);
msg.AddInt32("button-state", state);
_PostWindowEvent(msg);
}
button
SDL_Texture * button
Definition: testgamecontroller.c:67
BAPP_MOUSE_BUTTON
Definition: SDL_BApp.h:59
state
struct xkb_state * state
Definition: SDL_waylandsym.h:97
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

void SDL_BWin::_SetBordered | ( | BMessage * | msg | ) |

inline private

Definition at line 563 of file SDL_BWin.h.

Referenced by MessageReceived().

{
bool bEnabled;
if(msg->FindBool("window-border", &bEnabled) != B_OK) {
return;
}
SetLook(bEnabled ? B_BORDERED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
}

void SDL_BWin::_SetFullScreen | ( | BMessage * | msg | ) |

inline private

Definition at line 582 of file SDL_BWin.h.

Referenced by MessageReceived().

{
bool fullscreen;
if(
msg->FindBool("fullscreen", &fullscreen) != B_OK
) {
return;
}
SetFullScreen(fullscreen);
}

void SDL_BWin::_SetTitle | ( | BMessage * | msg | ) |

inline private

Definition at line 531 of file SDL_BWin.h.

Referenced by MessageReceived().

{
const char *title;
if(
msg->FindString("window-title", &title) != B_OK
) {
return;
}
SetTitle(title);
}

bool SDL_BWin::BufferExists | ( |  | ) |

inline

Definition at line 422 of file SDL_BWin.h.

References _buffer_created.

{ return _buffer_created; }
SDL_BWin::_buffer_created
bool _buffer_created
Definition: SDL_BWin.h:606

bool SDL_BWin::BufferIsDirty | ( |  | ) |

inline

Definition at line 423 of file SDL_BWin.h.

References _buffer_dirty.

{ return _buffer_dirty; }
SDL_BWin::_buffer_dirty
bool _buffer_dirty
Definition: SDL_BWin.h:606

bool SDL_BWin::CanTrashWindowBuffer | ( |  | ) |

inline

Definition at line 421 of file SDL_BWin.h.

References _trash_window_buffer.

{ return _trash_window_buffer; }
SDL_BWin::_trash_window_buffer
bool _trash_window_buffer
Definition: SDL_BWin.h:606

bool SDL_BWin::Connected | ( |  | ) |

inline

Definition at line 416 of file SDL_BWin.h.

References _connected.

{ return _connected; }
SDL_BWin::_connected
bool _connected
Definition: SDL_BWin.h:606

bool SDL_BWin::ConnectionEnabled | ( |  | ) |

inline

Definition at line 415 of file SDL_BWin.h.

References _connection_disabled.

{ return !_connection_disabled; }
SDL_BWin::_connection_disabled
bool _connection_disabled
Definition: SDL_BWin.h:606

virtual BGLView* SDL_BWin::CreateGLView | ( | Uint32 | gl_flags | ) |

inline virtual

Definition at line 128 of file SDL_BWin.h.

References _SDL_GLView, and NULL.

{
Lock();
if (_SDL_GLView == NULL) {
_SDL_GLView = new BGLView(Bounds(), "SDL GLView",
B_FOLLOW_ALL_SIDES,
(B_WILL_DRAW | B_FRAME_EVENTS),
gl_flags);
}
AddChild(_SDL_GLView);
_SDL_GLView->EnableDirectMode(true);
_SDL_GLView->LockGL(); /* "New" GLViews are created */
Unlock();
return (_SDL_GLView);
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
NULL
#define NULL
Definition: begin_code.h:143

virtual void SDL_BWin::DirectConnected | ( | direct_buffer_info * | info | ) |

inline virtual

Definition at line 160 of file SDL_BWin.h.

References _bits, _bounds, _buffer_dirty, _bytes_per_px, _clips, _connected, _connection_disabled, _num_clips, _row_bytes, _SDL_GLView, _trash_window_buffer, free, LockBuffer(), malloc, memcpy, NULL, and UnlockBuffer().

{
if(!_connected && _connection_disabled) {
return;
}
/* Determine if the pixel buffer is usable after this update */
_trash_window_buffer = _trash_window_buffer
|| ((info->buffer_state & B_BUFFER_RESIZED)
|| (info->buffer_state & B_BUFFER_RESET)
|| (info->driver_state == B_MODE_CHANGED));
LockBuffer();
switch(info->buffer_state & B_DIRECT_MODE_MASK) {
case B_DIRECT_START:
_connected = true;
case B_DIRECT_MODIFY:
if(_clips) {
free(_clips);
_clips = NULL;
}
_num_clips = info->clip_list_count;
_clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
if(_clips) {
memcpy(_clips, info->clip_list,
_num_clips*sizeof(clipping_rect));
_bits = (uint8*) info->bits;
_row_bytes = info->bytes_per_row;
_bounds = info->window_bounds;
_bytes_per_px = info->bits_per_pixel / 8;
_buffer_dirty = true;
}
break;
case B_DIRECT_STOP:
_connected = false;
break;
}
#if SDL_VIDEO_OPENGL
if(_SDL_GLView) {
_SDL_GLView->DirectConnected(info);
}
#endif
/* Call the base object directconnected */
BDirectWindow::DirectConnected(info);
UnlockBuffer();
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594
SDL_BWin::UnlockBuffer
void UnlockBuffer()
Definition: SDL_BWin.h:433
SDL_BWin::_connected
bool _connected
Definition: SDL_BWin.h:606
SDL_BWin::_buffer_dirty
bool _buffer_dirty
Definition: SDL_BWin.h:606
SDL_BWin::_connection_disabled
bool _connection_disabled
Definition: SDL_BWin.h:606
SDL_BWin::_bits
uint8 * _bits
Definition: SDL_BWin.h:611
free
SDL_EventEntry * free
Definition: SDL_events.c:81
SDL_BWin::_bytes_per_px
int32 _bytes_per_px
Definition: SDL_BWin.h:617
SDL_BWin::LockBuffer
void LockBuffer()
Definition: SDL_BWin.h:432
SDL_BWin::_num_clips
int32 _num_clips
Definition: SDL_BWin.h:616
SDL_BWin::_clips
clipping_rect * _clips
Definition: SDL_BWin.h:615
SDL_BWin::_bounds
clipping_rect _bounds
Definition: SDL_BWin.h:613
NULL
#define NULL
Definition: begin_code.h:143
malloc
#define malloc
Definition: SDL_malloc.c:641
SDL_BWin::_trash_window_buffer
bool _trash_window_buffer
Definition: SDL_BWin.h:606
memcpy
#define memcpy
Definition: SDL_malloc.c:640
SDL_BWin::_row_bytes
uint32 _row_bytes
Definition: SDL_BWin.h:612

virtual void SDL_BWin::DispatchMessage | ( | BMessage * | msg,
|  | BHandler * | target
| ) |  |

inline virtual

Definition at line 298 of file SDL_BWin.h.

References _KeyEvent(), _MouseButtonEvent(), _MouseMotionEvent(), _MouseWheelEvent(), SDL_PRESSED, and SDL_RELEASED.

{
BPoint where; /* Used by mouse moved */
int32 buttons; /* Used for mouse button events */
int32 key; /* Used for key events */
switch (msg->what) {
case B_MOUSE_MOVED:
int32 transit;
if (msg->FindPoint("where", &where) == B_OK
&& msg->FindInt32("be:transit", &transit) == B_OK) {
_MouseMotionEvent(where, transit);
}
/* FIXME: Apparently a button press/release event might be dropped
if made before before a different button is released. Does
B_MOUSE_MOVED have the data needed to check if a mouse button
state has changed? */
if (msg->FindInt32("buttons", &buttons) == B_OK) {
_MouseButtonEvent(buttons);
}
break;
case B_MOUSE_DOWN:
case B_MOUSE_UP:
/* _MouseButtonEvent() detects any and all buttons that may have
changed state, as well as that button's new state */
if (msg->FindInt32("buttons", &buttons) == B_OK) {
_MouseButtonEvent(buttons);
}
break;
case B_MOUSE_WHEEL_CHANGED:
float x, y;
if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
&& msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
_MouseWheelEvent((int)x, (int)y);
}
break;
case B_KEY_DOWN:
case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
if (msg->FindInt32("key", &key) == B_OK) {
_KeyEvent((SDL_Scancode)key, SDL_PRESSED);
}
break;
case B_KEY_UP:
case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
if (msg->FindInt32("key", &key) == B_OK) {
_KeyEvent(key, SDL_RELEASED);
}
break;
default:
/* move it after switch{} so it's always handled
that way we keep Haiku features like:
- CTRL+Q to close window (and other shortcuts)
- PrintScreen to make screenshot into /boot/home
- etc.. */
/* BDirectWindow::DispatchMessage(msg, target); */
break;
}
BDirectWindow::DispatchMessage(msg, target);
}
SDL_BWin::_KeyEvent
void _KeyEvent(int32 keyCode, int32 keyState)
Definition: SDL_BWin.h:511
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
SDL_BWin::_MouseButtonEvent
void _MouseButtonEvent(int32 buttons)
Definition: SDL_BWin.h:471
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567
target
GLenum target
Definition: SDL_opengl_glext.h:1551
SDL_BWin::_MouseMotionEvent
void _MouseMotionEvent(BPoint &where, int32 transit)
Definition: SDL_BWin.h:441
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
SDL_Scancode
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
SDL_BWin::_MouseWheelEvent
void _MouseWheelEvent(int32 x, int32 y)
Definition: SDL_BWin.h:503

virtual void SDL_BWin::FrameMoved | ( | BPoint | origin | ) |

inline virtual

Definition at line 219 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_MOVED.

{
/* Post a message to the BApp so that it can handle the window event */
BMessage msg(BAPP_WINDOW_MOVED);
msg.AddInt32("window-x", (int)origin.x);
msg.AddInt32("window-y", (int)origin.y);
_PostWindowEvent(msg);
/* Perform normal hook operations */
BDirectWindow::FrameMoved(origin);
}
BAPP_WINDOW_MOVED
Definition: SDL_BApp.h:72
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

virtual void SDL_BWin::FrameResized | ( | float | width,
|  | float | height
| ) |  |

inline virtual

Definition at line 230 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_RESIZED.

{
/* Post a message to the BApp so that it can handle the window event */
BMessage msg(BAPP_WINDOW_RESIZED);
msg.AddInt32("window-w", (int)width + 1);
msg.AddInt32("window-h", (int)height + 1);
_PostWindowEvent(msg);
/* Perform normal hook operations */
BDirectWindow::FrameResized(width, height);
}
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
BAPP_WINDOW_RESIZED
Definition: SDL_BApp.h:73
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

BBitmap* SDL_BWin::GetBitmap | ( |  | ) |

inline

Definition at line 424 of file SDL_BWin.h.

References _bitmap.

{ return _bitmap; }
SDL_BWin::_bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:620

uint8* SDL_BWin::GetBufferPx | ( |  | ) |

inline

Definition at line 419 of file SDL_BWin.h.

References _bits.

{ return _bits; }
SDL_BWin::_bits
uint8 * _bits
Definition: SDL_BWin.h:611

int32 SDL_BWin::GetBytesPerPx | ( |  | ) |

inline

Definition at line 420 of file SDL_BWin.h.

References _bytes_per_px.

{ return _bytes_per_px; }
SDL_BWin::_bytes_per_px
int32 _bytes_per_px
Definition: SDL_BWin.h:617

clipping_rect* SDL_BWin::GetClips | ( |  | ) |

inline

Definition at line 417 of file SDL_BWin.h.

References _clips.

{ return _clips; }
SDL_BWin::_clips
clipping_rect * _clips
Definition: SDL_BWin.h:615

int32 SDL_BWin::GetFbX | ( |  | ) |

inline

Definition at line 413 of file SDL_BWin.h.

References _bounds.

{ return _bounds.left; }
SDL_BWin::_bounds
clipping_rect _bounds
Definition: SDL_BWin.h:613

int32 SDL_BWin::GetFbY | ( |  | ) |

inline

Definition at line 414 of file SDL_BWin.h.

References _bounds.

{ return _bounds.top; }
SDL_BWin::_bounds
clipping_rect _bounds
Definition: SDL_BWin.h:613

BGLView* SDL_BWin::GetGLView | ( |  | ) |

inline

Definition at line 426 of file SDL_BWin.h.

References _SDL_GLView.

{ return _SDL_GLView; }
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594

int32 SDL_BWin::GetID | ( |  | ) |

inline

Definition at line 411 of file SDL_BWin.h.

References _id.

{ return _id; }
SDL_BWin::_id
int32 _id
Definition: SDL_BWin.h:598

int32 SDL_BWin::GetNumClips | ( |  | ) |

inline

Definition at line 418 of file SDL_BWin.h.

References _num_clips.

{ return _num_clips; }
SDL_BWin::_num_clips
int32 _num_clips
Definition: SDL_BWin.h:616

uint32 SDL_BWin::GetRowBytes | ( |  | ) |

inline

Definition at line 412 of file SDL_BWin.h.

References _row_bytes.

{ return _row_bytes; }
SDL_BWin::_row_bytes
uint32 _row_bytes
Definition: SDL_BWin.h:612

virtual void SDL_BWin::Hide | ( |  | ) |

inline virtual

Definition at line 280 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_HIDE.

Referenced by MessageReceived().

{
BDirectWindow::Hide();
_shown = false;
BMessage msg(BAPP_HIDE);
_PostWindowEvent(msg);
}
BAPP_HIDE
Definition: SDL_BApp.h:68
SDL_BWin::_shown
bool _shown
Definition: SDL_BWin.h:600
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

bool SDL_BWin::IsShown | ( |  | ) |

inline

Definition at line 410 of file SDL_BWin.h.

References _shown.

{ return _shown; }
SDL_BWin::_shown
bool _shown
Definition: SDL_BWin.h:600

void SDL_BWin::LockBuffer | ( |  | ) |

inline

Definition at line 432 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

{ _buffer_locker->Lock(); }
SDL_BWin::_buffer_locker
BLocker * _buffer_locker
Definition: SDL_BWin.h:614

virtual void SDL_BWin::MessageReceived | ( | BMessage * | message | ) |

inline virtual

Definition at line 366 of file SDL_BWin.h.

References _MoveTo(), _ResizeTo(), _Restore(), _SetBordered(), _SetFullScreen(), _SetTitle(), BWIN_FULLSCREEN, BWIN_HIDE_WINDOW, BWIN_MAXIMIZE_WINDOW, BWIN_MINIMIZE_WINDOW, BWIN_MOVE_WINDOW, BWIN_RESIZE_WINDOW, BWIN_RESTORE_WINDOW, BWIN_SET_BORDERED, BWIN_SET_TITLE, BWIN_SHOW_WINDOW, Hide(), Minimize(), and Show().

{
switch (message->what) {
/* Handle commands from SDL */
case BWIN_SET_TITLE:
_SetTitle(message);
break;
case BWIN_MOVE_WINDOW:
_MoveTo(message);
break;
case BWIN_RESIZE_WINDOW:
_ResizeTo(message);
break;
case BWIN_SET_BORDERED:
_SetBordered(message);
break;
case BWIN_SHOW_WINDOW:
Show();
break;
case BWIN_HIDE_WINDOW:
Hide();
break;
case BWIN_MAXIMIZE_WINDOW:
BWindow::Zoom();
break;
case BWIN_MINIMIZE_WINDOW:
Minimize(true);
break;
case BWIN_RESTORE_WINDOW:
_Restore();
break;
case BWIN_FULLSCREEN:
_SetFullScreen(message);
break;
default:
/* Perform normal message handling */
BDirectWindow::MessageReceived(message);
break;
}
}
SDL_BWin::Show
virtual void Show()
Definition: SDL_BWin.h:270
SDL_BWin::_ResizeTo
void _ResizeTo(BMessage *msg)
Definition: SDL_BWin.h:552
BWIN_SET_TITLE
Definition: SDL_BWin.h:57
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2483
BWIN_HIDE_WINDOW
Definition: SDL_BWin.h:53
BWIN_SET_BORDERED
Definition: SDL_BWin.h:58
SDL_BWin::Hide
virtual void Hide()
Definition: SDL_BWin.h:280
SDL_BWin::_SetFullScreen
void _SetFullScreen(BMessage *msg)
Definition: SDL_BWin.h:582
SDL_BWin::Minimize
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:288
BWIN_RESIZE_WINDOW
Definition: SDL_BWin.h:51
BWIN_MOVE_WINDOW
Definition: SDL_BWin.h:50
BWIN_FULLSCREEN
Definition: SDL_BWin.h:59
SDL_BWin::_MoveTo
void _MoveTo(BMessage *msg)
Definition: SDL_BWin.h:541
BWIN_SHOW_WINDOW
Definition: SDL_BWin.h:52
BWIN_MAXIMIZE_WINDOW
Definition: SDL_BWin.h:54
SDL_BWin::_SetTitle
void _SetTitle(BMessage *msg)
Definition: SDL_BWin.h:531
SDL_BWin::_SetBordered
void _SetBordered(BMessage *msg)
Definition: SDL_BWin.h:563
BWIN_RESTORE_WINDOW
Definition: SDL_BWin.h:56
BWIN_MINIMIZE_WINDOW
Definition: SDL_BWin.h:55
SDL_BWin::_Restore
void _Restore()
Definition: SDL_BWin.h:571

virtual void SDL_BWin::Minimize | ( | bool | minimize | ) |

inline virtual

Definition at line 288 of file SDL_BWin.h.

References _PostWindowEvent(), BAPP_MINIMIZE, and BAPP_RESTORE.

Referenced by _Restore(), and MessageReceived().

{
BDirectWindow::Minimize(minimize);
int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
BMessage msg(minState);
_PostWindowEvent(msg);
}
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
BAPP_MINIMIZE
Definition: SDL_BApp.h:65
BAPP_RESTORE
Definition: SDL_BApp.h:66

virtual bool SDL_BWin::QuitRequested | ( |  | ) |

inline virtual

Definition at line 242 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_CLOSE_REQUESTED.

{
BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
_PostWindowEvent(msg);
/* We won't allow a quit unless asked by DestroyWindow() */
return false;
}
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525
BAPP_WINDOW_CLOSE_REQUESTED
Definition: SDL_BApp.h:71

virtual void SDL_BWin::RemoveGLView | ( |  | ) |

inline virtual

Definition at line 143 of file SDL_BWin.h.

References _SDL_GLView.

{
Lock();
if(_SDL_GLView) {
_SDL_GLView->UnlockGL();
RemoveChild(_SDL_GLView);
}
Unlock();
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594

void SDL_BWin::SetBitmap | ( | BBitmap * | bitmap | ) |

inline

Definition at line 436 of file SDL_BWin.h.

References _bitmap.

{ _bitmap = bitmap; }
bitmap
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Definition: SDL_opengl_glext.h:4534
SDL_BWin::_bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:620

void SDL_BWin::SetBufferDirty | ( | bool | bufferDirty | ) |

inline

Definition at line 434 of file SDL_BWin.h.

References _buffer_dirty.

{ _buffer_dirty = bufferDirty; }
SDL_BWin::_buffer_dirty
bool _buffer_dirty
Definition: SDL_BWin.h:606

void SDL_BWin::SetBufferExists | ( | bool | bufferExists | ) |

inline

Definition at line 431 of file SDL_BWin.h.

References _buffer_created.

{ _buffer_created = bufferExists; }
SDL_BWin::_buffer_created
bool _buffer_created
Definition: SDL_BWin.h:606

void SDL_BWin::SetID | ( | int32 | id | ) |

inline

Definition at line 430 of file SDL_BWin.h.

References _id.

{ _id = id; }
id
GLuint id
Definition: SDL_opengl_glext.h:528
SDL_BWin::_id
int32 _id
Definition: SDL_BWin.h:598

void SDL_BWin::SetTrashBuffer | ( | bool | trash | ) |

inline

Definition at line 435 of file SDL_BWin.h.

References _trash_window_buffer.

{ _trash_window_buffer = trash; }
SDL_BWin::_trash_window_buffer
bool _trash_window_buffer
Definition: SDL_BWin.h:606

virtual void SDL_BWin::Show | ( |  | ) |

inline virtual

Definition at line 270 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_SHOW.

Referenced by _Restore(), and MessageReceived().

{
while(IsHidden()) {
BDirectWindow::Show();
}
_shown = true;
BMessage msg(BAPP_SHOW);
_PostWindowEvent(msg);
}
BAPP_SHOW
Definition: SDL_BApp.h:67
SDL_BWin::_shown
bool _shown
Definition: SDL_BWin.h:600
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

virtual void SDL_BWin::SwapBuffers | ( | void |  | ) |

inline virtual

Definition at line 152 of file SDL_BWin.h.

References _SDL_GLView.

{
_SDL_GLView->UnlockGL();
_SDL_GLView->LockGL();
_SDL_GLView->SwapBuffers();
}
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:594

void SDL_BWin::UnlockBuffer | ( |  | ) |

inline

Definition at line 433 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

{ _buffer_locker->Unlock(); }
SDL_BWin::_buffer_locker
BLocker * _buffer_locker
Definition: SDL_BWin.h:614

virtual void SDL_BWin::WindowActivated | ( | bool | active | ) |

inline virtual

Definition at line 250 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_KEYBOARD_FOCUS.

{
BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
_PostWindowEvent(msg);
}
BAPP_KEYBOARD_FOCUS
Definition: SDL_BApp.h:70
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

virtual void SDL_BWin::Zoom | ( | BPoint | origin,
|  | float | width,
|  | float | height
| ) |  |

inline virtual

Definition at line 255 of file SDL_BWin.h.

References _PostWindowEvent(), _prev_frame, and BAPP_MAXIMIZE.

{
BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
_PostWindowEvent(msg);
/* Before the window zooms, record its size */
if( !_prev_frame )
_prev_frame = new BRect(Frame());
/* Perform normal hook operations */
BDirectWindow::Zoom(origin, width, height);
}
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
BAPP_MAXIMIZE
Definition: SDL_BApp.h:64
SDL_BWin::_prev_frame
BRect * _prev_frame
Definition: SDL_BWin.h:603
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:525

## Field Documentation

BBitmap* SDL_BWin::_bitmap

private

Definition at line 620 of file SDL_BWin.h.

Referenced by GetBitmap(), SDL_BWin(), and SetBitmap().

uint8* SDL_BWin::_bits

private

Definition at line 611 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBufferPx().

clipping_rect SDL_BWin::_bounds

private

Definition at line 613 of file SDL_BWin.h.

Referenced by DirectConnected(), GetFbX(), and GetFbY().

bool SDL_BWin::_buffer_created

private

Definition at line 606 of file SDL_BWin.h.

Referenced by BufferExists(), SDL_BWin(), and SetBufferExists().

bool SDL_BWin::_buffer_dirty

private

Definition at line 606 of file SDL_BWin.h.

Referenced by BufferIsDirty(), DirectConnected(), SDL_BWin(), and SetBufferDirty().

BLocker* SDL_BWin::_buffer_locker

private

Definition at line 614 of file SDL_BWin.h.

Referenced by LockBuffer(), SDL_BWin(), UnlockBuffer(), and ~SDL_BWin().

int32 SDL_BWin::_bytes_per_px

private

Definition at line 617 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBytesPerPx().

clipping_rect* SDL_BWin::_clips

private

Definition at line 615 of file SDL_BWin.h.

Referenced by DirectConnected(), GetClips(), SDL_BWin(), and ~SDL_BWin().

bool SDL_BWin::_connected

private

Definition at line 606 of file SDL_BWin.h.

Referenced by Connected(), DirectConnected(), and SDL_BWin().

bool SDL_BWin::_connection_disabled

private

Definition at line 606 of file SDL_BWin.h.

Referenced by ConnectionEnabled(), DirectConnected(), SDL_BWin(), and ~SDL_BWin().

thread_id SDL_BWin::_draw_thread_id

private

Definition at line 618 of file SDL_BWin.h.

Referenced by SDL_BWin(), and ~SDL_BWin().

int32 SDL_BWin::_id

private

Definition at line 598 of file SDL_BWin.h.

Referenced by _PostWindowEvent(), GetID(), and SetID().

bool SDL_BWin::_inhibit_resize

private

Definition at line 601 of file SDL_BWin.h.

Referenced by SDL_BWin().

int32 SDL_BWin::_last_buttons

private

Definition at line 597 of file SDL_BWin.h.

Referenced by _MouseButtonEvent(), and SDL_BWin().

bool SDL_BWin::_mouse_focused

private

Definition at line 599 of file SDL_BWin.h.

Referenced by _MouseFocusEvent(), _MouseMotionEvent(), and SDL_BWin().

int32 SDL_BWin::_num_clips

private

Definition at line 616 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetNumClips().

BRect* SDL_BWin::_prev_frame

private

Definition at line 603 of file SDL_BWin.h.

Referenced by _Restore(), SDL_BWin(), and Zoom().

uint32 SDL_BWin::_row_bytes

private

Definition at line 612 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetRowBytes().

BGLView* SDL_BWin::_SDL_GLView

private

Definition at line 594 of file SDL_BWin.h.

Referenced by CreateGLView(), DirectConnected(), GetGLView(), RemoveGLView(), SDL_BWin(), SwapBuffers(), and ~SDL_BWin().

bool SDL_BWin::_shown

private

Definition at line 600 of file SDL_BWin.h.

Referenced by Hide(), IsShown(), SDL_BWin(), and Show().

bool SDL_BWin::_trash_window_buffer

private

Definition at line 606 of file SDL_BWin.h.

Referenced by CanTrashWindowBuffer(), DirectConnected(), SDL_BWin(), and SetTrashBuffer().

The documentation for this class was generated from the following file:

- src/video/haiku/SDL_BWin.h