SDL  2.0
SDL_BWin Class Reference

#include <SDL_BWin.h>

+ Inheritance diagram for SDL_BWin:
+ Collaboration diagram for SDL_BWin:

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 ()
 
Uint32 GetGLType ()
 
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, const int8 *keyUtf8, const ssize_t &len, 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 _SetResizable (BMessage *msg)
 
void _Restore ()
 
void _SetFullScreen (BMessage *msg)
 

Private Attributes

BGLView * _SDL_GLView
 
Uint32 _gl_type
 
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 64 of file SDL_BWin.h.

Constructor & Destructor Documentation

◆ SDL_BWin()

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

Definition at line 68 of file SDL_BWin.h.

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

69  : BDirectWindow(bounds, "Untitled", look, B_NORMAL_WINDOW_FEEL, flags)
70  {
71  _last_buttons = 0;
72 
73 #if SDL_VIDEO_OPENGL
74  _SDL_GLView = NULL;
75  _gl_type = 0;
76 #endif
77  _shown = false;
78  _inhibit_resize = false;
79  _mouse_focused = false;
80  _prev_frame = NULL;
81 
82  /* Handle framebuffer stuff */
85  _trash_window_buffer = false;
86  _buffer_locker = new BLocker();
87  _bitmap = NULL;
88  _clips = NULL;
89 
90 #ifdef DRAWTHREAD
91  _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
92  B_NORMAL_PRIORITY, (void*) this);
93  resume_thread(_draw_thread_id);
94 #endif
95  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632
int32 _last_buttons
Definition: SDL_BWin.h:636
bool _connected
Definition: SDL_BWin.h:645
bool _buffer_dirty
Definition: SDL_BWin.h:645
bool _connection_disabled
Definition: SDL_BWin.h:645
bool _shown
Definition: SDL_BWin.h:639
BLocker * _buffer_locker
Definition: SDL_BWin.h:653
bool _inhibit_resize
Definition: SDL_BWin.h:640
bool _mouse_focused
Definition: SDL_BWin.h:638
Uint32 _gl_type
Definition: SDL_BWin.h:633
clipping_rect * _clips
Definition: SDL_BWin.h:654
BRect * _prev_frame
Definition: SDL_BWin.h:642
#define NULL
Definition: begin_code.h:164
bool _trash_window_buffer
Definition: SDL_BWin.h:645
GLbitfield flags
bool _buffer_created
Definition: SDL_BWin.h:645
BBitmap * _bitmap
Definition: SDL_BWin.h:659
thread_id _draw_thread_id
Definition: SDL_BWin.h:657
int32 BE_DrawThread(void *data)

◆ ~ SDL_BWin()

virtual SDL_BWin::~ SDL_BWin ( )
inlinevirtual

Definition at line 97 of file SDL_BWin.h.

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

98  {
99  Lock();
100  _connection_disabled = true;
101  int32 result;
102 
103 #if SDL_VIDEO_OPENGL
104  if (_SDL_GLView) {
105  _SDL_GLView->UnlockGL();
106  RemoveChild(_SDL_GLView); /* Why was this outside the if
107  statement before? */
108  }
109 
110 #endif
111  Unlock();
112 #if SDL_VIDEO_OPENGL
113  if (_SDL_GLView) {
114  delete _SDL_GLView;
115  }
116 #endif
117 
118  delete _prev_frame;
119 
120  /* Clean up framebuffer stuff */
121  _buffer_locker->Lock();
122 #ifdef DRAWTHREAD
123  wait_for_thread(_draw_thread_id, &result);
124 #endif
125  free(_clips);
126  delete _buffer_locker;
127  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632
GLuint64EXT * result
bool _connection_disabled
Definition: SDL_BWin.h:645
SDL_EventEntry * free
Definition: SDL_events.c:84
BLocker * _buffer_locker
Definition: SDL_BWin.h:653
clipping_rect * _clips
Definition: SDL_BWin.h:654
BRect * _prev_frame
Definition: SDL_BWin.h:642
thread_id _draw_thread_id
Definition: SDL_BWin.h:657

Member Function Documentation

◆ _KeyEvent()

void SDL_BWin::_KeyEvent ( int32  keyCode,
const int8 *  keyUtf8,
const ssize_t &  len,
int32  keyState 
)
inlineprivate

Definition at line 535 of file SDL_BWin.h.

References BAPP_KEY, and NULL.

Referenced by DispatchMessage().

535  {
536  /* Create a message to pass along to the BeApp thread */
537  BMessage msg(BAPP_KEY);
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);
542  }
543  be_app->PostMessage(&msg);
544  }
GLenum GLsizei len
#define NULL
Definition: begin_code.h:164

◆ _MouseButtonEvent()

void SDL_BWin::_MouseButtonEvent ( int32  buttons)
inlineprivate

Definition at line 495 of file SDL_BWin.h.

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

Referenced by DispatchMessage().

495  {
496  int32 buttonStateChange = buttons ^ _last_buttons;
497 
498  /* Make sure at least one button has changed state */
499  if( !(buttonStateChange) ) {
500  return;
501  }
502 
503  /* Add any mouse button events */
504  if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
506  B_PRIMARY_MOUSE_BUTTON);
507  }
508  if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
510  B_PRIMARY_MOUSE_BUTTON);
511  }
512  if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
514  B_PRIMARY_MOUSE_BUTTON);
515  }
516 
517  _last_buttons = buttons;
518  }
int32 _last_buttons
Definition: SDL_BWin.h:636
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
void _SendMouseButton(int32 button, int32 state)
Definition: SDL_BWin.h:520
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:282
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:283

◆ _MouseFocusEvent()

void SDL_BWin::_MouseFocusEvent ( bool  focusGained)
inlineprivate

Definition at line 484 of file SDL_BWin.h.

References _mouse_focused, _PostWindowEvent(), and BAPP_MOUSE_FOCUS.

Referenced by _MouseMotionEvent().

484  {
485  _mouse_focused = focusGained;
486  BMessage msg(BAPP_MOUSE_FOCUS);
487  msg.AddBool("focusGained", focusGained);
488  _PostWindowEvent(msg);
489 
490 /* FIXME: Why were these here?
491  if false: be_app->SetCursor(B_HAND_CURSOR);
492  if true: SDL_SetCursor(NULL); */
493  }
bool _mouse_focused
Definition: SDL_BWin.h:638
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ _MouseMotionEvent()

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

Definition at line 465 of file SDL_BWin.h.

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

Referenced by DispatchMessage().

465  {
466  if(transit == B_EXITED_VIEW) {
467  /* Change mouse focus */
468  if(_mouse_focused) {
469  _MouseFocusEvent(false);
470  }
471  } else {
472  /* Change mouse focus */
473  if (!_mouse_focused) {
474  _MouseFocusEvent(true);
475  }
476  BMessage msg(BAPP_MOUSE_MOVED);
477  msg.AddInt32("x", (int)where.x);
478  msg.AddInt32("y", (int)where.y);
479 
480  _PostWindowEvent(msg);
481  }
482  }
bool _mouse_focused
Definition: SDL_BWin.h:638
void _MouseFocusEvent(bool focusGained)
Definition: SDL_BWin.h:484
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ _MouseWheelEvent()

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

Definition at line 527 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_WHEEL.

Referenced by DispatchMessage().

527  {
528  /* Create a message to pass along to the BeApp thread */
529  BMessage msg(BAPP_MOUSE_WHEEL);
530  msg.AddInt32("xticks", x);
531  msg.AddInt32("yticks", y);
532  _PostWindowEvent(msg);
533  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ _MoveTo()

void SDL_BWin::_MoveTo ( BMessage *  msg)
inlineprivate

Definition at line 567 of file SDL_BWin.h.

Referenced by MessageReceived().

567  {
568  int32 x, y;
569  if(
570  msg->FindInt32("window-x", &x) != B_OK ||
571  msg->FindInt32("window-y", &y) != B_OK
572  ) {
573  return;
574  }
575  MoveTo(x, y);
576  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574

◆ _PostWindowEvent()

void SDL_BWin::_PostWindowEvent ( BMessage &  msg)
inlineprivate

Definition at line 551 of file SDL_BWin.h.

References _id.

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

551  {
552  msg.AddInt32("window-id", _id);
553  be_app->PostMessage(&msg);
554  }
int32 _id
Definition: SDL_BWin.h:637

◆ _RepaintEvent()

void SDL_BWin::_RepaintEvent ( )
inlineprivate

Definition at line 546 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_REPAINT.

546  {
547  /* Force a repaint: Call the SDL exposed event */
548  BMessage msg(BAPP_REPAINT);
549  _PostWindowEvent(msg);
550  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ _ResizeTo()

void SDL_BWin::_ResizeTo ( BMessage *  msg)
inlineprivate

Definition at line 578 of file SDL_BWin.h.

Referenced by MessageReceived().

578  {
579  int32 w, h;
580  if(
581  msg->FindInt32("window-w", &w) != B_OK ||
582  msg->FindInt32("window-h", &h) != B_OK
583  ) {
584  return;
585  }
586  ResizeTo(w, h);
587  }
GLfloat GLfloat GLfloat GLfloat h
GLubyte GLubyte GLubyte GLubyte w

◆ _Restore()

void SDL_BWin::_Restore ( )
inlineprivate

Definition at line 609 of file SDL_BWin.h.

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

Referenced by MessageReceived().

609  {
610  if(IsMinimized()) {
611  Minimize(false);
612  } else if(IsHidden()) {
613  Show();
614  } else if(_prev_frame != NULL) { /* Zoomed */
615  MoveTo(_prev_frame->left, _prev_frame->top);
616  ResizeTo(_prev_frame->Width(), _prev_frame->Height());
617  }
618  }
virtual void Show()
Definition: SDL_BWin.h:276
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:294
BRect * _prev_frame
Definition: SDL_BWin.h:642
#define NULL
Definition: begin_code.h:164

◆ _SendMouseButton()

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

Definition at line 520 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_BUTTON.

Referenced by _MouseButtonEvent().

520  {
521  BMessage msg(BAPP_MOUSE_BUTTON);
522  msg.AddInt32("button-id", button);
523  msg.AddInt32("button-state", state);
524  _PostWindowEvent(msg);
525  }
SDL_Texture * button
struct xkb_state * state
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ _SetBordered()

void SDL_BWin::_SetBordered ( BMessage *  msg)
inlineprivate

Definition at line 589 of file SDL_BWin.h.

Referenced by MessageReceived().

589  {
590  bool bEnabled;
591  if(msg->FindBool("window-border", &bEnabled) != B_OK) {
592  return;
593  }
594  SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
595  }

◆ _SetFullScreen()

void SDL_BWin::_SetFullScreen ( BMessage *  msg)
inlineprivate

Definition at line 620 of file SDL_BWin.h.

Referenced by MessageReceived().

620  {
621  bool fullscreen;
622  if(
623  msg->FindBool("fullscreen", &fullscreen) != B_OK
624  ) {
625  return;
626  }
627  SetFullScreen(fullscreen);
628  }

◆ _SetResizable()

void SDL_BWin::_SetResizable ( BMessage *  msg)
inlineprivate

Definition at line 597 of file SDL_BWin.h.

Referenced by MessageReceived().

597  {
598  bool bEnabled;
599  if(msg->FindBool("window-resizable", &bEnabled) != B_OK) {
600  return;
601  }
602  if (bEnabled) {
603  SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
604  } else {
605  SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
606  }
607  }

◆ _SetTitle()

void SDL_BWin::_SetTitle ( BMessage *  msg)
inlineprivate

Definition at line 557 of file SDL_BWin.h.

Referenced by MessageReceived().

557  {
558  const char *title;
559  if(
560  msg->FindString("window-title", &title) != B_OK
561  ) {
562  return;
563  }
564  SetTitle(title);
565  }

◆ BufferExists()

bool SDL_BWin::BufferExists ( )
inline

Definition at line 445 of file SDL_BWin.h.

References _buffer_created.

445 { return _buffer_created; }
bool _buffer_created
Definition: SDL_BWin.h:645

◆ BufferIsDirty()

bool SDL_BWin::BufferIsDirty ( )
inline

Definition at line 446 of file SDL_BWin.h.

References _buffer_dirty.

446 { return _buffer_dirty; }
bool _buffer_dirty
Definition: SDL_BWin.h:645

◆ CanTrashWindowBuffer()

bool SDL_BWin::CanTrashWindowBuffer ( )
inline

Definition at line 444 of file SDL_BWin.h.

References _trash_window_buffer.

444 { return _trash_window_buffer; }
bool _trash_window_buffer
Definition: SDL_BWin.h:645

◆ Connected()

bool SDL_BWin::Connected ( )
inline

Definition at line 439 of file SDL_BWin.h.

References _connected.

439 { return _connected; }
bool _connected
Definition: SDL_BWin.h:645

◆ ConnectionEnabled()

bool SDL_BWin::ConnectionEnabled ( )
inline

Definition at line 438 of file SDL_BWin.h.

References _connection_disabled.

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

◆ CreateGLView()

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

Definition at line 132 of file SDL_BWin.h.

References _gl_type, _SDL_GLView, and NULL.

132  {
133  Lock();
134  if (_SDL_GLView == NULL) {
135  _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
136  B_FOLLOW_ALL_SIDES,
137  (B_WILL_DRAW | B_FRAME_EVENTS),
138  gl_flags);
139  _gl_type = gl_flags;
140  }
141  AddChild(_SDL_GLView);
142  _SDL_GLView->EnableDirectMode(true);
143  _SDL_GLView->LockGL(); /* "New" GLViews are created */
144  Unlock();
145  return (_SDL_GLView);
146  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632
Uint32 _gl_type
Definition: SDL_BWin.h:633
#define NULL
Definition: begin_code.h:164

◆ DirectConnected()

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

Definition at line 165 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().

165  {
167  return;
168  }
169 
170  /* Determine if the pixel buffer is usable after this update */
172  || ((info->buffer_state & B_BUFFER_RESIZED)
173  || (info->buffer_state & B_BUFFER_RESET)
174  || (info->driver_state == B_MODE_CHANGED));
175  LockBuffer();
176 
177  switch(info->buffer_state & B_DIRECT_MODE_MASK) {
178  case B_DIRECT_START:
179  _connected = true;
180 
181  case B_DIRECT_MODIFY:
182  if(_clips) {
183  free(_clips);
184  _clips = NULL;
185  }
186 
187  _num_clips = info->clip_list_count;
188  _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
189  if(_clips) {
190  memcpy(_clips, info->clip_list,
191  _num_clips*sizeof(clipping_rect));
192 
193  _bits = (uint8*) info->bits;
194  _row_bytes = info->bytes_per_row;
195  _bounds = info->window_bounds;
196  _bytes_per_px = info->bits_per_pixel / 8;
197  _buffer_dirty = true;
198  }
199  break;
200 
201  case B_DIRECT_STOP:
202  _connected = false;
203  break;
204  }
205 #if SDL_VIDEO_OPENGL
206  if(_SDL_GLView) {
207  _SDL_GLView->DirectConnected(info);
208  }
209 #endif
210 
211 
212  /* Call the base object directconnected */
213  BDirectWindow::DirectConnected(info);
214 
215  UnlockBuffer();
216 
217  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632
void UnlockBuffer()
Definition: SDL_BWin.h:457
bool _connected
Definition: SDL_BWin.h:645
bool _buffer_dirty
Definition: SDL_BWin.h:645
bool _connection_disabled
Definition: SDL_BWin.h:645
uint8 * _bits
Definition: SDL_BWin.h:650
SDL_EventEntry * free
Definition: SDL_events.c:84
int32 _bytes_per_px
Definition: SDL_BWin.h:656
void LockBuffer()
Definition: SDL_BWin.h:456
int32 _num_clips
Definition: SDL_BWin.h:655
clipping_rect * _clips
Definition: SDL_BWin.h:654
clipping_rect _bounds
Definition: SDL_BWin.h:652
#define NULL
Definition: begin_code.h:164
bool _trash_window_buffer
Definition: SDL_BWin.h:645
#define memcpy
Definition: SDL_malloc.c:622
uint32 _row_bytes
Definition: SDL_BWin.h:651
#define malloc
Definition: SDL_qsort.c:47

◆ DispatchMessage()

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

Definition at line 304 of file SDL_BWin.h.

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

305  {
306  BPoint where; /* Used by mouse moved */
307  int32 buttons; /* Used for mouse button events */
308  int32 key; /* Used for key events */
309 
310  switch (msg->what) {
311  case B_MOUSE_MOVED:
312  int32 transit;
313  if (msg->FindPoint("where", &where) == B_OK
314  && msg->FindInt32("be:transit", &transit) == B_OK) {
315  _MouseMotionEvent(where, transit);
316  }
317 
318  /* FIXME: Apparently a button press/release event might be dropped
319  if made before before a different button is released. Does
320  B_MOUSE_MOVED have the data needed to check if a mouse button
321  state has changed? */
322  if (msg->FindInt32("buttons", &buttons) == B_OK) {
323  _MouseButtonEvent(buttons);
324  }
325  break;
326 
327  case B_MOUSE_DOWN:
328  case B_MOUSE_UP:
329  /* _MouseButtonEvent() detects any and all buttons that may have
330  changed state, as well as that button's new state */
331  if (msg->FindInt32("buttons", &buttons) == B_OK) {
332  _MouseButtonEvent(buttons);
333  }
334  break;
335 
336  case B_MOUSE_WHEEL_CHANGED:
337  float x, y;
338  if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
339  && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
340  _MouseWheelEvent((int)x, (int)y);
341  }
342  break;
343 
344  case B_KEY_DOWN:
345  {
346  int32 i = 0;
347  int8 byte;
348  int8 bytes[4] = { 0, 0, 0, 0 };
349  while (i < 4 && msg->FindInt8("byte", i, &byte) == B_OK) {
350  bytes[i] = byte;
351  i++;
352  }
353  if (msg->FindInt32("key", &key) == B_OK) {
354  _KeyEvent((SDL_Scancode)key, &bytes[0], i, SDL_PRESSED);
355  }
356  }
357  break;
358 
359  case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
360  if (msg->FindInt32("key", &key) == B_OK) {
362  }
363  break;
364 
365  case B_KEY_UP:
366  case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
367  if (msg->FindInt32("key", &key) == B_OK) {
368  _KeyEvent(key, NULL, 0, SDL_RELEASED);
369  }
370  break;
371 
372  default:
373  /* move it after switch{} so it's always handled
374  that way we keep Haiku features like:
375  - CTRL+Q to close window (and other shortcuts)
376  - PrintScreen to make screenshot into /boot/home
377  - etc.. */
378  /* BDirectWindow::DispatchMessage(msg, target); */
379  break;
380  }
381 
382  BDirectWindow::DispatchMessage(msg, target);
383  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
void _MouseButtonEvent(int32 buttons)
Definition: SDL_BWin.h:495
GLuint64 key
Definition: gl2ext.h:2192
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
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)
Definition: SDL_x11sym.h:50
GLenum target
#define NULL
Definition: begin_code.h:164
void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState)
Definition: SDL_BWin.h:535
void _MouseMotionEvent(BPoint &where, int32 transit)
Definition: SDL_BWin.h:465
#define SDL_PRESSED
Definition: SDL_events.h:50
#define SDL_RELEASED
Definition: SDL_events.h:49
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:43
void _MouseWheelEvent(int32 x, int32 y)
Definition: SDL_BWin.h:527

◆ FrameMoved()

virtual void SDL_BWin::FrameMoved ( BPoint  origin)
inlinevirtual

Definition at line 224 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_MOVED.

224  {
225  /* Post a message to the BApp so that it can handle the window event */
226  BMessage msg(BAPP_WINDOW_MOVED);
227  msg.AddInt32("window-x", (int)origin.x);
228  msg.AddInt32("window-y", (int)origin.y);
229  _PostWindowEvent(msg);
230 
231  /* Perform normal hook operations */
232  BDirectWindow::FrameMoved(origin);
233  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ FrameResized()

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

Definition at line 235 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_RESIZED.

235  {
236  /* Post a message to the BApp so that it can handle the window event */
237  BMessage msg(BAPP_WINDOW_RESIZED);
238 
239  msg.AddInt32("window-w", (int)width + 1);
240  msg.AddInt32("window-h", (int)height + 1);
241  _PostWindowEvent(msg);
242 
243  /* Perform normal hook operations */
244  BDirectWindow::FrameResized(width, height);
245  }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572

◆ GetBitmap()

BBitmap* SDL_BWin::GetBitmap ( )
inline

Definition at line 447 of file SDL_BWin.h.

References _bitmap.

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

◆ GetBufferPx()

uint8* SDL_BWin::GetBufferPx ( )
inline

Definition at line 442 of file SDL_BWin.h.

References _bits.

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

◆ GetBytesPerPx()

int32 SDL_BWin::GetBytesPerPx ( )
inline

Definition at line 443 of file SDL_BWin.h.

References _bytes_per_px.

443 { return _bytes_per_px; }
int32 _bytes_per_px
Definition: SDL_BWin.h:656

◆ GetClips()

clipping_rect* SDL_BWin::GetClips ( )
inline

Definition at line 440 of file SDL_BWin.h.

References _clips.

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

◆ GetFbX()

int32 SDL_BWin::GetFbX ( )
inline

Definition at line 436 of file SDL_BWin.h.

References _bounds.

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

◆ GetFbY()

int32 SDL_BWin::GetFbY ( )
inline

Definition at line 437 of file SDL_BWin.h.

References _bounds.

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

◆ GetGLType()

Uint32 SDL_BWin::GetGLType ( )
inline

Definition at line 450 of file SDL_BWin.h.

References _gl_type.

450 { return _gl_type; }
Uint32 _gl_type
Definition: SDL_BWin.h:633

◆ GetGLView()

BGLView* SDL_BWin::GetGLView ( )
inline

Definition at line 449 of file SDL_BWin.h.

References _SDL_GLView.

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

◆ GetID()

int32 SDL_BWin::GetID ( )
inline

Definition at line 434 of file SDL_BWin.h.

References _id.

434 { return _id; }
int32 _id
Definition: SDL_BWin.h:637

◆ GetNumClips()

int32 SDL_BWin::GetNumClips ( )
inline

Definition at line 441 of file SDL_BWin.h.

References _num_clips.

441 { return _num_clips; }
int32 _num_clips
Definition: SDL_BWin.h:655

◆ GetRowBytes()

uint32 SDL_BWin::GetRowBytes ( )
inline

Definition at line 435 of file SDL_BWin.h.

References _row_bytes.

435 { return _row_bytes; }
uint32 _row_bytes
Definition: SDL_BWin.h:651

◆ Hide()

virtual void SDL_BWin::Hide ( )
inlinevirtual

Definition at line 286 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_HIDE.

Referenced by MessageReceived().

286  {
287  BDirectWindow::Hide();
288  _shown = false;
289 
290  BMessage msg(BAPP_HIDE);
291  _PostWindowEvent(msg);
292  }
bool _shown
Definition: SDL_BWin.h:639
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ IsShown()

bool SDL_BWin::IsShown ( )
inline

Definition at line 433 of file SDL_BWin.h.

References _shown.

433 { return _shown; }
bool _shown
Definition: SDL_BWin.h:639

◆ LockBuffer()

void SDL_BWin::LockBuffer ( )
inline

Definition at line 456 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

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

◆ MessageReceived()

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

Definition at line 386 of file SDL_BWin.h.

References _MoveTo(), _ResizeTo(), _Restore(), _SetBordered(), _SetFullScreen(), _SetResizable(), _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_RESIZABLE, BWIN_SET_TITLE, BWIN_SHOW_WINDOW, Hide(), Minimize(), and Show().

386  {
387  switch (message->what) {
388  /* Handle commands from SDL */
389  case BWIN_SET_TITLE:
391  break;
392  case BWIN_MOVE_WINDOW:
393  _MoveTo(message);
394  break;
395  case BWIN_RESIZE_WINDOW:
397  break;
398  case BWIN_SET_BORDERED:
400  break;
401  case BWIN_SET_RESIZABLE:
403  break;
404  case BWIN_SHOW_WINDOW:
405  Show();
406  break;
407  case BWIN_HIDE_WINDOW:
408  Hide();
409  break;
411  BWindow::Zoom();
412  break;
414  Minimize(true);
415  break;
416  case BWIN_RESTORE_WINDOW:
417  _Restore();
418  break;
419  case BWIN_FULLSCREEN:
421  break;
422  default:
423  /* Perform normal message handling */
424  BDirectWindow::MessageReceived(message);
425  break;
426  }
427 
428  }
virtual void Show()
Definition: SDL_BWin.h:276
void _ResizeTo(BMessage *msg)
Definition: SDL_BWin.h:578
GLuint GLsizei const GLchar * message
virtual void Hide()
Definition: SDL_BWin.h:286
void _SetFullScreen(BMessage *msg)
Definition: SDL_BWin.h:620
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:294
void _MoveTo(BMessage *msg)
Definition: SDL_BWin.h:567
void _SetResizable(BMessage *msg)
Definition: SDL_BWin.h:597
void _SetTitle(BMessage *msg)
Definition: SDL_BWin.h:557
void _SetBordered(BMessage *msg)
Definition: SDL_BWin.h:589
void _Restore()
Definition: SDL_BWin.h:609

◆ Minimize()

virtual void SDL_BWin::Minimize ( bool  minimize)
inlinevirtual

Definition at line 294 of file SDL_BWin.h.

References _PostWindowEvent(), BAPP_MINIMIZE, and BAPP_RESTORE.

Referenced by _Restore(), and MessageReceived().

294  {
295  BDirectWindow::Minimize(minimize);
296  int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
297 
298  BMessage msg(minState);
299  _PostWindowEvent(msg);
300  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ QuitRequested()

virtual bool SDL_BWin::QuitRequested ( )
inlinevirtual

Definition at line 247 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_CLOSE_REQUESTED.

247  {
248  BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
249  _PostWindowEvent(msg);
250 
251  /* We won't allow a quit unless asked by DestroyWindow() */
252  return false;
253  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ RemoveGLView()

virtual void SDL_BWin::RemoveGLView ( )
inlinevirtual

Definition at line 148 of file SDL_BWin.h.

References _SDL_GLView.

148  {
149  Lock();
150  if(_SDL_GLView) {
151  _SDL_GLView->UnlockGL();
152  RemoveChild(_SDL_GLView);
153  }
154  Unlock();
155  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632

◆ SetBitmap()

void SDL_BWin::SetBitmap ( BBitmap *  bitmap)
inline

Definition at line 460 of file SDL_BWin.h.

References _bitmap.

460 { _bitmap = bitmap; }
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:659

◆ SetBufferDirty()

void SDL_BWin::SetBufferDirty ( bool  bufferDirty)
inline

Definition at line 458 of file SDL_BWin.h.

References _buffer_dirty.

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

◆ SetBufferExists()

void SDL_BWin::SetBufferExists ( bool  bufferExists)
inline

Definition at line 455 of file SDL_BWin.h.

References _buffer_created.

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

◆ SetID()

void SDL_BWin::SetID ( int32  id)
inline

Definition at line 454 of file SDL_BWin.h.

References _id.

454 { _id = id; }
GLuint id
int32 _id
Definition: SDL_BWin.h:637

◆ SetTrashBuffer()

void SDL_BWin::SetTrashBuffer ( bool  trash)
inline

Definition at line 459 of file SDL_BWin.h.

References _trash_window_buffer.

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

◆ Show()

virtual void SDL_BWin::Show ( )
inlinevirtual

Definition at line 276 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_SHOW.

Referenced by _Restore(), and MessageReceived().

276  {
277  while(IsHidden()) {
278  BDirectWindow::Show();
279  }
280  _shown = true;
281 
282  BMessage msg(BAPP_SHOW);
283  _PostWindowEvent(msg);
284  }
bool _shown
Definition: SDL_BWin.h:639
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ SwapBuffers()

virtual void SDL_BWin::SwapBuffers ( void  )
inlinevirtual

Definition at line 157 of file SDL_BWin.h.

References _SDL_GLView.

157  {
158  _SDL_GLView->UnlockGL();
159  _SDL_GLView->LockGL();
160  _SDL_GLView->SwapBuffers();
161  }
BGLView * _SDL_GLView
Definition: SDL_BWin.h:632

◆ UnlockBuffer()

void SDL_BWin::UnlockBuffer ( )
inline

Definition at line 457 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

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

◆ WindowActivated()

virtual void SDL_BWin::WindowActivated ( bool  active)
inlinevirtual

Definition at line 255 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_KEYBOARD_FOCUS.

255  {
256  BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
257  msg.AddBool("focusGained", active);
258  _PostWindowEvent(msg);
259  }
SDL_atomic_t active
Definition: SDL_events.c:79
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551

◆ Zoom()

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

Definition at line 261 of file SDL_BWin.h.

References _PostWindowEvent(), _prev_frame, and BAPP_MAXIMIZE.

263  {
264  BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
265  _PostWindowEvent(msg);
266 
267  /* Before the window zooms, record its size */
268  if( !_prev_frame )
269  _prev_frame = new BRect(Frame());
270 
271  /* Perform normal hook operations */
272  BDirectWindow::Zoom(origin, width, height);
273  }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
BRect * _prev_frame
Definition: SDL_BWin.h:642
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:551
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572

Field Documentation

◆ _bitmap

BBitmap* SDL_BWin::_bitmap
private

Definition at line 659 of file SDL_BWin.h.

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

◆ _bits

uint8* SDL_BWin::_bits
private

Definition at line 650 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBufferPx().

◆ _bounds

clipping_rect SDL_BWin::_bounds
private

Definition at line 652 of file SDL_BWin.h.

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

◆ _buffer_created

bool SDL_BWin::_buffer_created
private

Definition at line 645 of file SDL_BWin.h.

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

◆ _buffer_dirty

bool SDL_BWin::_buffer_dirty
private

Definition at line 645 of file SDL_BWin.h.

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

◆ _buffer_locker

BLocker* SDL_BWin::_buffer_locker
private

Definition at line 653 of file SDL_BWin.h.

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

◆ _bytes_per_px

int32 SDL_BWin::_bytes_per_px
private

Definition at line 656 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBytesPerPx().

◆ _clips

clipping_rect* SDL_BWin::_clips
private

Definition at line 654 of file SDL_BWin.h.

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

◆ _connected

bool SDL_BWin::_connected
private

Definition at line 645 of file SDL_BWin.h.

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

◆ _connection_disabled

bool SDL_BWin::_connection_disabled
private

Definition at line 645 of file SDL_BWin.h.

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

◆ _draw_thread_id

thread_id SDL_BWin::_draw_thread_id
private

Definition at line 657 of file SDL_BWin.h.

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

◆ _gl_type

Uint32 SDL_BWin::_gl_type
private

Definition at line 633 of file SDL_BWin.h.

Referenced by CreateGLView(), GetGLType(), and SDL_BWin().

◆ _id

int32 SDL_BWin::_id
private

Definition at line 637 of file SDL_BWin.h.

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

◆ _inhibit_resize

bool SDL_BWin::_inhibit_resize
private

Definition at line 640 of file SDL_BWin.h.

Referenced by SDL_BWin().

◆ _last_buttons

int32 SDL_BWin::_last_buttons
private

Definition at line 636 of file SDL_BWin.h.

Referenced by _MouseButtonEvent(), and SDL_BWin().

◆ _mouse_focused

bool SDL_BWin::_mouse_focused
private

Definition at line 638 of file SDL_BWin.h.

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

◆ _num_clips

int32 SDL_BWin::_num_clips
private

Definition at line 655 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetNumClips().

◆ _prev_frame

BRect* SDL_BWin::_prev_frame
private

Definition at line 642 of file SDL_BWin.h.

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

◆ _row_bytes

uint32 SDL_BWin::_row_bytes
private

Definition at line 651 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetRowBytes().

◆ _SDL_GLView

BGLView* SDL_BWin::_SDL_GLView
private

◆ _shown

bool SDL_BWin::_shown
private

Definition at line 639 of file SDL_BWin.h.

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

◆ _trash_window_buffer

bool SDL_BWin::_trash_window_buffer
private

Definition at line 645 of file SDL_BWin.h.

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


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