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, Uint8 state)
 
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
 
uint32 _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.

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  _num_clips = 0;
90 
91 #ifdef DRAWTHREAD
92  _draw_thread_id = spawn_thread(HAIKU_DrawThread, "drawing_thread",
93  B_NORMAL_PRIORITY, (void*) this);
94  resume_thread(_draw_thread_id);
95 #endif
96  }

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

◆ ~ SDL_BWin()

virtual SDL_BWin::~ SDL_BWin ( )
inlinevirtual

Definition at line 98 of file SDL_BWin.h.

99  {
100  Lock();
101  _connection_disabled = true;
102  int32 result;
103 
104 #if SDL_VIDEO_OPENGL
105  if (_SDL_GLView) {
106  _SDL_GLView->UnlockGL();
107  RemoveChild(_SDL_GLView); /* Why was this outside the if
108  statement before? */
109  }
110 
111 #endif
112  Unlock();
113 #if SDL_VIDEO_OPENGL
114  if (_SDL_GLView) {
115  delete _SDL_GLView;
116  }
117 #endif
118 
119  delete _prev_frame;
120 
121  /* Clean up framebuffer stuff */
122  _buffer_locker->Lock();
123 #ifdef DRAWTHREAD
124  wait_for_thread(_draw_thread_id, &result);
125 #endif
126  free(_clips);
127  delete _buffer_locker;
128  }

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

Member Function Documentation

◆ _KeyEvent()

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

Definition at line 527 of file SDL_BWin.h.

527  {
528  /* Create a message to pass along to the BeApp thread */
529  BMessage msg(BAPP_KEY);
530  msg.AddInt32("key-state", keyState);
531  msg.AddInt32("key-scancode", keyCode);
532  if (keyUtf8 != NULL) {
533  msg.AddData("key-utf8", B_INT8_TYPE, (const void*)keyUtf8, len);
534  }
535  be_app->PostMessage(&msg);
536  }

References BAPP_KEY, and NULL.

Referenced by DispatchMessage().

◆ _MouseButtonEvent()

void SDL_BWin::_MouseButtonEvent ( int32  buttons,
Uint8  state 
)
inlineprivate

Definition at line 496 of file SDL_BWin.h.

496  {
497  int32 buttonStateChange = buttons ^ _last_buttons;
498 
499  if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
501  }
502  if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
504  }
505  if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
507  }
508 
509  _last_buttons = buttons;
510  }

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

Referenced by DispatchMessage().

◆ _MouseFocusEvent()

void SDL_BWin::_MouseFocusEvent ( bool  focusGained)
inlineprivate

Definition at line 485 of file SDL_BWin.h.

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

References _mouse_focused, _PostWindowEvent(), and BAPP_MOUSE_FOCUS.

Referenced by _MouseMotionEvent().

◆ _MouseMotionEvent()

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

Definition at line 466 of file SDL_BWin.h.

466  {
467  if(transit == B_EXITED_VIEW) {
468  /* Change mouse focus */
469  if(_mouse_focused) {
470  _MouseFocusEvent(false);
471  }
472  } else {
473  /* Change mouse focus */
474  if (!_mouse_focused) {
475  _MouseFocusEvent(true);
476  }
477  BMessage msg(BAPP_MOUSE_MOVED);
478  msg.AddInt32("x", (int)where.x);
479  msg.AddInt32("y", (int)where.y);
480 
481  _PostWindowEvent(msg);
482  }
483  }

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

Referenced by DispatchMessage().

◆ _MouseWheelEvent()

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

Definition at line 519 of file SDL_BWin.h.

519  {
520  /* Create a message to pass along to the BeApp thread */
521  BMessage msg(BAPP_MOUSE_WHEEL);
522  msg.AddInt32("xticks", x);
523  msg.AddInt32("yticks", y);
524  _PostWindowEvent(msg);
525  }

References _PostWindowEvent(), and BAPP_MOUSE_WHEEL.

Referenced by DispatchMessage().

◆ _MoveTo()

void SDL_BWin::_MoveTo ( BMessage *  msg)
inlineprivate

Definition at line 559 of file SDL_BWin.h.

559  {
560  int32 x, y;
561  if(
562  msg->FindInt32("window-x", &x) != B_OK ||
563  msg->FindInt32("window-y", &y) != B_OK
564  ) {
565  return;
566  }
567  MoveTo(x, y);
568  }

Referenced by MessageReceived().

◆ _PostWindowEvent()

void SDL_BWin::_PostWindowEvent ( BMessage &  msg)
inlineprivate

Definition at line 543 of file SDL_BWin.h.

543  {
544  msg.AddInt32("window-id", _id);
545  be_app->PostMessage(&msg);
546  }

References _id.

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

◆ _RepaintEvent()

void SDL_BWin::_RepaintEvent ( )
inlineprivate

Definition at line 538 of file SDL_BWin.h.

538  {
539  /* Force a repaint: Call the SDL exposed event */
540  BMessage msg(BAPP_REPAINT);
541  _PostWindowEvent(msg);
542  }

References _PostWindowEvent(), and BAPP_REPAINT.

◆ _ResizeTo()

void SDL_BWin::_ResizeTo ( BMessage *  msg)
inlineprivate

Definition at line 570 of file SDL_BWin.h.

570  {
571  int32 w, h;
572  if(
573  msg->FindInt32("window-w", &w) != B_OK ||
574  msg->FindInt32("window-h", &h) != B_OK
575  ) {
576  return;
577  }
578  ResizeTo(w, h);
579  }

Referenced by MessageReceived().

◆ _Restore()

void SDL_BWin::_Restore ( )
inlineprivate

Definition at line 601 of file SDL_BWin.h.

601  {
602  if(IsMinimized()) {
603  Minimize(false);
604  } else if(IsHidden()) {
605  Show();
606  } else if(_prev_frame != NULL) { /* Zoomed */
607  MoveTo(_prev_frame->left, _prev_frame->top);
608  ResizeTo(_prev_frame->Width(), _prev_frame->Height());
609  }
610  }

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

Referenced by MessageReceived().

◆ _SendMouseButton()

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

Definition at line 512 of file SDL_BWin.h.

512  {
513  BMessage msg(BAPP_MOUSE_BUTTON);
514  msg.AddInt32("button-id", button);
515  msg.AddInt32("button-state", state);
516  _PostWindowEvent(msg);
517  }

References _PostWindowEvent(), BAPP_MOUSE_BUTTON, button, and state.

Referenced by _MouseButtonEvent().

◆ _SetBordered()

void SDL_BWin::_SetBordered ( BMessage *  msg)
inlineprivate

Definition at line 581 of file SDL_BWin.h.

581  {
582  bool bEnabled;
583  if(msg->FindBool("window-border", &bEnabled) != B_OK) {
584  return;
585  }
586  SetLook(bEnabled ? B_TITLED_WINDOW_LOOK : B_NO_BORDER_WINDOW_LOOK);
587  }

Referenced by MessageReceived().

◆ _SetFullScreen()

void SDL_BWin::_SetFullScreen ( BMessage *  msg)
inlineprivate

Definition at line 612 of file SDL_BWin.h.

612  {
613  bool fullscreen;
614  if(
615  msg->FindBool("fullscreen", &fullscreen) != B_OK
616  ) {
617  return;
618  }
619  SetFullScreen(fullscreen);
620  }

Referenced by MessageReceived().

◆ _SetResizable()

void SDL_BWin::_SetResizable ( BMessage *  msg)
inlineprivate

Definition at line 589 of file SDL_BWin.h.

589  {
590  bool bEnabled;
591  if(msg->FindBool("window-resizable", &bEnabled) != B_OK) {
592  return;
593  }
594  if (bEnabled) {
595  SetFlags(Flags() & ~(B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
596  } else {
597  SetFlags(Flags() | (B_NOT_RESIZABLE | B_NOT_ZOOMABLE));
598  }
599  }

Referenced by MessageReceived().

◆ _SetTitle()

void SDL_BWin::_SetTitle ( BMessage *  msg)
inlineprivate

Definition at line 549 of file SDL_BWin.h.

549  {
550  const char *title;
551  if(
552  msg->FindString("window-title", &title) != B_OK
553  ) {
554  return;
555  }
556  SetTitle(title);
557  }

Referenced by MessageReceived().

◆ BufferExists()

bool SDL_BWin::BufferExists ( )
inline

Definition at line 446 of file SDL_BWin.h.

446 { return _buffer_created; }

References _buffer_created.

◆ BufferIsDirty()

bool SDL_BWin::BufferIsDirty ( )
inline

Definition at line 447 of file SDL_BWin.h.

447 { return _buffer_dirty; }

References _buffer_dirty.

◆ CanTrashWindowBuffer()

bool SDL_BWin::CanTrashWindowBuffer ( )
inline

Definition at line 445 of file SDL_BWin.h.

445 { return _trash_window_buffer; }

References _trash_window_buffer.

◆ Connected()

bool SDL_BWin::Connected ( )
inline

Definition at line 440 of file SDL_BWin.h.

440 { return _connected; }

References _connected.

◆ ConnectionEnabled()

bool SDL_BWin::ConnectionEnabled ( )
inline

Definition at line 439 of file SDL_BWin.h.

439 { return !_connection_disabled; }

References _connection_disabled.

◆ CreateGLView()

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

Definition at line 133 of file SDL_BWin.h.

133  {
134  Lock();
135  if (_SDL_GLView == NULL) {
136  _SDL_GLView = new BGLView(Bounds(), "SDL GLView",
137  B_FOLLOW_ALL_SIDES,
138  (B_WILL_DRAW | B_FRAME_EVENTS),
139  gl_flags);
140  _gl_type = gl_flags;
141  }
142  AddChild(_SDL_GLView);
143  _SDL_GLView->SetEventMask(B_POINTER_EVENTS | B_KEYBOARD_EVENTS, B_NO_POINTER_HISTORY);
144  _SDL_GLView->EnableDirectMode(true);
145  _SDL_GLView->LockGL(); /* "New" GLViews are created */
146  Unlock();
147  return (_SDL_GLView);
148  }

References _gl_type, _SDL_GLView, and NULL.

◆ DirectConnected()

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

Definition at line 167 of file SDL_BWin.h.

167  {
169  return;
170  }
171 
172  /* Determine if the pixel buffer is usable after this update */
174  || ((info->buffer_state & B_BUFFER_RESIZED)
175  || (info->buffer_state & B_BUFFER_RESET)
176  || (info->driver_state == B_MODE_CHANGED));
177  LockBuffer();
178 
179  switch(info->buffer_state & B_DIRECT_MODE_MASK) {
180  case B_DIRECT_START:
181  _connected = true;
182 
183  case B_DIRECT_MODIFY:
184  if (info->clip_list_count > _num_clips)
185  {
186  if(_clips) {
187  free(_clips);
188  _clips = NULL;
189  }
190  }
191 
192  _num_clips = info->clip_list_count;
193  if (_clips == NULL)
194  _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
195  if(_clips) {
196  memcpy(_clips, info->clip_list,
197  _num_clips*sizeof(clipping_rect));
198 
199  _bits = (uint8*) info->bits;
200  _row_bytes = info->bytes_per_row;
201  _bounds = info->window_bounds;
202  _bytes_per_px = info->bits_per_pixel / 8;
203  _buffer_dirty = true;
204  }
205  break;
206 
207  case B_DIRECT_STOP:
208  _connected = false;
209  break;
210  }
211 #if SDL_VIDEO_OPENGL
212  if(_SDL_GLView) {
213  _SDL_GLView->DirectConnected(info);
214  }
215 #endif
216 
217 
218  /* Call the base object directconnected */
219  BDirectWindow::DirectConnected(info);
220 
221  UnlockBuffer();
222 
223  }

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().

◆ DispatchMessage()

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

Definition at line 310 of file SDL_BWin.h.

311  {
312  BPoint where; /* Used by mouse moved */
313  int32 buttons; /* Used for mouse button events */
314  int32 key; /* Used for key events */
315 
316  switch (msg->what) {
317  case B_MOUSE_MOVED:
318  int32 transit;
319  if (msg->FindPoint("where", &where) == B_OK
320  && msg->FindInt32("be:transit", &transit) == B_OK) {
321  _MouseMotionEvent(where, transit);
322  }
323  break;
324 
325  case B_MOUSE_DOWN:
326  if (msg->FindInt32("buttons", &buttons) == B_OK) {
327  _MouseButtonEvent(buttons, SDL_PRESSED);
328  }
329  break;
330 
331  case B_MOUSE_UP:
332  if (msg->FindInt32("buttons", &buttons) == B_OK) {
334  }
335  break;
336 
337  case B_MOUSE_WHEEL_CHANGED:
338  float x, y;
339  if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
340  && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
341  _MouseWheelEvent((int)x, (int)y);
342  }
343  break;
344 
345  case B_KEY_DOWN:
346  {
347  int32 i = 0;
348  int8 byte;
349  int8 bytes[4] = { 0, 0, 0, 0 };
350  while (i < 4 && msg->FindInt8("byte", i, &byte) == B_OK) {
351  bytes[i] = byte;
352  i++;
353  }
354  if (msg->FindInt32("key", &key) == B_OK) {
355  _KeyEvent((SDL_Scancode)key, &bytes[0], i, SDL_PRESSED);
356  }
357  }
358  break;
359 
360  case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
361  if (msg->FindInt32("key", &key) == B_OK) {
363  }
364  break;
365 
366  case B_KEY_UP:
367  case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
368  if (msg->FindInt32("key", &key) == B_OK) {
370  }
371  break;
372 
373  default:
374  /* move it after switch{} so it's always handled
375  that way we keep Haiku features like:
376  - CTRL+Q to close window (and other shortcuts)
377  - PrintScreen to make screenshot into /boot/home
378  - etc.. */
379  /* BDirectWindow::DispatchMessage(msg, target); */
380  break;
381  }
382 
383  BDirectWindow::DispatchMessage(msg, target);
384  }

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

◆ FrameMoved()

virtual void SDL_BWin::FrameMoved ( BPoint  origin)
inlinevirtual

Definition at line 230 of file SDL_BWin.h.

230  {
231  /* Post a message to the BApp so that it can handle the window event */
232  BMessage msg(BAPP_WINDOW_MOVED);
233  msg.AddInt32("window-x", (int)origin.x);
234  msg.AddInt32("window-y", (int)origin.y);
235  _PostWindowEvent(msg);
236 
237  /* Perform normal hook operations */
238  BDirectWindow::FrameMoved(origin);
239  }

References _PostWindowEvent(), and BAPP_WINDOW_MOVED.

◆ FrameResized()

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

Definition at line 241 of file SDL_BWin.h.

241  {
242  /* Post a message to the BApp so that it can handle the window event */
243  BMessage msg(BAPP_WINDOW_RESIZED);
244 
245  msg.AddInt32("window-w", (int)width + 1);
246  msg.AddInt32("window-h", (int)height + 1);
247  _PostWindowEvent(msg);
248 
249  /* Perform normal hook operations */
250  BDirectWindow::FrameResized(width, height);
251  }

References _PostWindowEvent(), and BAPP_WINDOW_RESIZED.

◆ GetBitmap()

BBitmap* SDL_BWin::GetBitmap ( )
inline

Definition at line 448 of file SDL_BWin.h.

448 { return _bitmap; }

References _bitmap.

◆ GetBufferPx()

uint8* SDL_BWin::GetBufferPx ( )
inline

Definition at line 443 of file SDL_BWin.h.

443 { return _bits; }

References _bits.

◆ GetBytesPerPx()

int32 SDL_BWin::GetBytesPerPx ( )
inline

Definition at line 444 of file SDL_BWin.h.

444 { return _bytes_per_px; }

References _bytes_per_px.

◆ GetClips()

clipping_rect* SDL_BWin::GetClips ( )
inline

Definition at line 441 of file SDL_BWin.h.

441 { return _clips; }

References _clips.

◆ GetFbX()

int32 SDL_BWin::GetFbX ( )
inline

Definition at line 437 of file SDL_BWin.h.

437 { return _bounds.left; }

References _bounds.

◆ GetFbY()

int32 SDL_BWin::GetFbY ( )
inline

Definition at line 438 of file SDL_BWin.h.

438 { return _bounds.top; }

References _bounds.

◆ GetGLType()

Uint32 SDL_BWin::GetGLType ( )
inline

Definition at line 451 of file SDL_BWin.h.

451 { return _gl_type; }

References _gl_type.

◆ GetGLView()

BGLView* SDL_BWin::GetGLView ( )
inline

Definition at line 450 of file SDL_BWin.h.

450 { return _SDL_GLView; }

References _SDL_GLView.

◆ GetID()

int32 SDL_BWin::GetID ( )
inline

Definition at line 435 of file SDL_BWin.h.

435 { return _id; }

References _id.

◆ GetNumClips()

int32 SDL_BWin::GetNumClips ( )
inline

Definition at line 442 of file SDL_BWin.h.

442 { return _num_clips; }

References _num_clips.

◆ GetRowBytes()

uint32 SDL_BWin::GetRowBytes ( )
inline

Definition at line 436 of file SDL_BWin.h.

436 { return _row_bytes; }

References _row_bytes.

◆ Hide()

virtual void SDL_BWin::Hide ( )
inlinevirtual

Definition at line 292 of file SDL_BWin.h.

292  {
293  BDirectWindow::Hide();
294  _shown = false;
295 
296  BMessage msg(BAPP_HIDE);
297  _PostWindowEvent(msg);
298  }

References _PostWindowEvent(), _shown, and BAPP_HIDE.

Referenced by MessageReceived().

◆ IsShown()

bool SDL_BWin::IsShown ( )
inline

Definition at line 434 of file SDL_BWin.h.

434 { return _shown; }

References _shown.

◆ LockBuffer()

void SDL_BWin::LockBuffer ( )
inline

Definition at line 457 of file SDL_BWin.h.

457 { _buffer_locker->Lock(); }

References _buffer_locker.

Referenced by DirectConnected().

◆ MessageReceived()

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

Definition at line 387 of file SDL_BWin.h.

387  {
388  switch (message->what) {
389  /* Handle commands from SDL */
390  case BWIN_SET_TITLE:
392  break;
393  case BWIN_MOVE_WINDOW:
394  _MoveTo(message);
395  break;
396  case BWIN_RESIZE_WINDOW:
398  break;
399  case BWIN_SET_BORDERED:
401  break;
402  case BWIN_SET_RESIZABLE:
404  break;
405  case BWIN_SHOW_WINDOW:
406  Show();
407  break;
408  case BWIN_HIDE_WINDOW:
409  Hide();
410  break;
412  BWindow::Zoom();
413  break;
415  Minimize(true);
416  break;
417  case BWIN_RESTORE_WINDOW:
418  _Restore();
419  break;
420  case BWIN_FULLSCREEN:
422  break;
423  default:
424  /* Perform normal message handling */
425  BDirectWindow::MessageReceived(message);
426  break;
427  }
428 
429  }

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().

◆ Minimize()

virtual void SDL_BWin::Minimize ( bool  minimize)
inlinevirtual

Definition at line 300 of file SDL_BWin.h.

300  {
301  BDirectWindow::Minimize(minimize);
302  int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
303 
304  BMessage msg(minState);
305  _PostWindowEvent(msg);
306  }

References _PostWindowEvent(), BAPP_MINIMIZE, and BAPP_RESTORE.

Referenced by _Restore(), and MessageReceived().

◆ QuitRequested()

virtual bool SDL_BWin::QuitRequested ( )
inlinevirtual

Definition at line 253 of file SDL_BWin.h.

253  {
254  BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
255  _PostWindowEvent(msg);
256 
257  /* We won't allow a quit unless asked by DestroyWindow() */
258  return false;
259  }

References _PostWindowEvent(), and BAPP_WINDOW_CLOSE_REQUESTED.

◆ RemoveGLView()

virtual void SDL_BWin::RemoveGLView ( )
inlinevirtual

Definition at line 150 of file SDL_BWin.h.

150  {
151  Lock();
152  if(_SDL_GLView) {
153  _SDL_GLView->UnlockGL();
154  RemoveChild(_SDL_GLView);
155  }
156  Unlock();
157  }

References _SDL_GLView.

◆ SetBitmap()

void SDL_BWin::SetBitmap ( BBitmap *  bitmap)
inline

Definition at line 461 of file SDL_BWin.h.

461 { _bitmap = bitmap; }

References _bitmap.

◆ SetBufferDirty()

void SDL_BWin::SetBufferDirty ( bool  bufferDirty)
inline

Definition at line 459 of file SDL_BWin.h.

459 { _buffer_dirty = bufferDirty; }

References _buffer_dirty.

◆ SetBufferExists()

void SDL_BWin::SetBufferExists ( bool  bufferExists)
inline

Definition at line 456 of file SDL_BWin.h.

456 { _buffer_created = bufferExists; }

References _buffer_created.

◆ SetID()

void SDL_BWin::SetID ( int32  id)
inline

Definition at line 455 of file SDL_BWin.h.

455 { _id = id; }

References _id.

◆ SetTrashBuffer()

void SDL_BWin::SetTrashBuffer ( bool  trash)
inline

Definition at line 460 of file SDL_BWin.h.

460 { _trash_window_buffer = trash; }

References _trash_window_buffer.

◆ Show()

virtual void SDL_BWin::Show ( )
inlinevirtual

Definition at line 282 of file SDL_BWin.h.

282  {
283  while(IsHidden()) {
284  BDirectWindow::Show();
285  }
286  _shown = true;
287 
288  BMessage msg(BAPP_SHOW);
289  _PostWindowEvent(msg);
290  }

References _PostWindowEvent(), _shown, and BAPP_SHOW.

Referenced by _Restore(), and MessageReceived().

◆ SwapBuffers()

virtual void SDL_BWin::SwapBuffers ( void  )
inlinevirtual

Definition at line 159 of file SDL_BWin.h.

159  {
160  _SDL_GLView->UnlockGL();
161  _SDL_GLView->LockGL();
162  _SDL_GLView->SwapBuffers();
163  }

References _SDL_GLView.

◆ UnlockBuffer()

void SDL_BWin::UnlockBuffer ( )
inline

Definition at line 458 of file SDL_BWin.h.

458 { _buffer_locker->Unlock(); }

References _buffer_locker.

Referenced by DirectConnected().

◆ WindowActivated()

virtual void SDL_BWin::WindowActivated ( bool  active)
inlinevirtual

Definition at line 261 of file SDL_BWin.h.

261  {
262  BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
263  msg.AddBool("focusGained", active);
264  _PostWindowEvent(msg);
265  }

References _PostWindowEvent(), active, and BAPP_KEYBOARD_FOCUS.

◆ Zoom()

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

Definition at line 267 of file SDL_BWin.h.

269  {
270  BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
271  _PostWindowEvent(msg);
272 
273  /* Before the window zooms, record its size */
274  if( !_prev_frame )
275  _prev_frame = new BRect(Frame());
276 
277  /* Perform normal hook operations */
278  BDirectWindow::Zoom(origin, width, height);
279  }

References _PostWindowEvent(), _prev_frame, and BAPP_MAXIMIZE.

Field Documentation

◆ _bitmap

BBitmap* SDL_BWin::_bitmap
private

Definition at line 651 of file SDL_BWin.h.

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

◆ _bits

uint8* SDL_BWin::_bits
private

Definition at line 642 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBufferPx().

◆ _bounds

clipping_rect SDL_BWin::_bounds
private

Definition at line 644 of file SDL_BWin.h.

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

◆ _buffer_created

bool SDL_BWin::_buffer_created
private

Definition at line 639 of file SDL_BWin.h.

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

◆ _buffer_dirty

bool SDL_BWin::_buffer_dirty
private

Definition at line 640 of file SDL_BWin.h.

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

◆ _buffer_locker

BLocker* SDL_BWin::_buffer_locker
private

Definition at line 645 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 648 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBytesPerPx().

◆ _clips

clipping_rect* SDL_BWin::_clips
private

Definition at line 646 of file SDL_BWin.h.

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

◆ _connected

bool SDL_BWin::_connected
private

Definition at line 637 of file SDL_BWin.h.

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

◆ _connection_disabled

bool SDL_BWin::_connection_disabled
private

Definition at line 638 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 649 of file SDL_BWin.h.

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

◆ _gl_type

Uint32 SDL_BWin::_gl_type
private

Definition at line 625 of file SDL_BWin.h.

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

◆ _id

int32 SDL_BWin::_id
private

Definition at line 629 of file SDL_BWin.h.

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

◆ _inhibit_resize

bool SDL_BWin::_inhibit_resize
private

Definition at line 632 of file SDL_BWin.h.

Referenced by SDL_BWin().

◆ _last_buttons

int32 SDL_BWin::_last_buttons
private

Definition at line 628 of file SDL_BWin.h.

Referenced by _MouseButtonEvent(), and SDL_BWin().

◆ _mouse_focused

bool SDL_BWin::_mouse_focused
private

Definition at line 630 of file SDL_BWin.h.

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

◆ _num_clips

uint32 SDL_BWin::_num_clips
private

Definition at line 647 of file SDL_BWin.h.

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

◆ _prev_frame

BRect* SDL_BWin::_prev_frame
private

Definition at line 634 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 643 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 631 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 641 of file SDL_BWin.h.

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


The documentation for this class was generated from the following file:
SDL_BWin::_SetTitle
void _SetTitle(BMessage *msg)
Definition: SDL_BWin.h:549
malloc
#define malloc
Definition: SDL_qsort.c:47
SDL_BWin::_SDL_GLView
BGLView * _SDL_GLView
Definition: SDL_BWin.h:624
target
GLenum target
Definition: SDL_opengl_glext.h:1554
BWIN_RESIZE_WINDOW
@ BWIN_RESIZE_WINDOW
Definition: SDL_BWin.h:51
SDL_BWin::_connection_disabled
bool _connection_disabled
Definition: SDL_BWin.h:638
BAPP_RESTORE
@ BAPP_RESTORE
Definition: SDL_BApp.h:67
SDL_BWin::_MouseButtonEvent
void _MouseButtonEvent(int32 buttons, Uint8 state)
Definition: SDL_BWin.h:496
SDL_BWin::Minimize
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:300
BAPP_MOUSE_MOVED
@ BAPP_MOUSE_MOVED
Definition: SDL_BApp.h:59
NULL
#define NULL
Definition: begin_code.h:167
SDL_BWin::_clips
clipping_rect * _clips
Definition: SDL_BWin.h:646
width
GLint GLint GLsizei width
Definition: SDL_opengl.h:1572
message
GLuint GLsizei const GLchar * message
Definition: SDL_opengl_glext.h:2486
SDL_BUTTON_RIGHT
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
BAPP_KEY
@ BAPP_KEY
Definition: SDL_BApp.h:62
SDL_BWin::_MouseMotionEvent
void _MouseMotionEvent(BPoint &where, int32 transit)
Definition: SDL_BWin.h:466
BAPP_HIDE
@ BAPP_HIDE
Definition: SDL_BApp.h:69
SDL_BWin::_SetBordered
void _SetBordered(BMessage *msg)
Definition: SDL_BWin.h:581
BWIN_HIDE_WINDOW
@ BWIN_HIDE_WINDOW
Definition: SDL_BWin.h:53
SDL_BWin::_ResizeTo
void _ResizeTo(BMessage *msg)
Definition: SDL_BWin.h:570
BAPP_SHOW
@ BAPP_SHOW
Definition: SDL_BApp.h:68
BAPP_MINIMIZE
@ BAPP_MINIMIZE
Definition: SDL_BApp.h:66
BAPP_REPAINT
@ BAPP_REPAINT
Definition: SDL_BApp.h:63
SDL_Scancode
SDL_Scancode
The SDL keyboard scancode representation.
Definition: SDL_scancode.h:44
BAPP_KEYBOARD_FOCUS
@ BAPP_KEYBOARD_FOCUS
Definition: SDL_BApp.h:71
BWIN_MINIMIZE_WINDOW
@ BWIN_MINIMIZE_WINDOW
Definition: SDL_BWin.h:55
SDL_BWin::_SetResizable
void _SetResizable(BMessage *msg)
Definition: SDL_BWin.h:589
SDL_RELEASED
#define SDL_RELEASED
Definition: SDL_events.h:49
memcpy
#define memcpy
Definition: SDL_malloc.c:630
h
GLfloat GLfloat GLfloat GLfloat h
Definition: SDL_opengl_glext.h:1949
BWIN_SET_RESIZABLE
@ BWIN_SET_RESIZABLE
Definition: SDL_BWin.h:59
SDL_BWin::_last_buttons
int32 _last_buttons
Definition: SDL_BWin.h:628
result
GLuint64EXT * result
Definition: SDL_opengl_glext.h:9435
BWIN_SET_BORDERED
@ BWIN_SET_BORDERED
Definition: SDL_BWin.h:58
SDL_BWin::_buffer_created
bool _buffer_created
Definition: SDL_BWin.h:639
SDL_BWin::Hide
virtual void Hide()
Definition: SDL_BWin.h:292
SDL_BWin::_MouseFocusEvent
void _MouseFocusEvent(bool focusGained)
Definition: SDL_BWin.h:485
SDL_BWin::_connected
bool _connected
Definition: SDL_BWin.h:637
SDL_PRESSED
#define SDL_PRESSED
Definition: SDL_events.h:50
SDL_BWin::_shown
bool _shown
Definition: SDL_BWin.h:631
len
GLenum GLsizei len
Definition: SDL_opengl_glext.h:2929
BWIN_SET_TITLE
@ BWIN_SET_TITLE
Definition: SDL_BWin.h:57
SDL_BWin::UnlockBuffer
void UnlockBuffer()
Definition: SDL_BWin.h:458
SDL_BUTTON_LEFT
#define SDL_BUTTON_LEFT
Definition: SDL_mouse.h:282
BAPP_MOUSE_FOCUS
@ BAPP_MOUSE_FOCUS
Definition: SDL_BApp.h:70
SDL_BWin::_MouseWheelEvent
void _MouseWheelEvent(int32 x, int32 y)
Definition: SDL_BWin.h:519
SDL_BWin::_bitmap
BBitmap * _bitmap
Definition: SDL_BWin.h:651
SDL_BWin::_prev_frame
BRect * _prev_frame
Definition: SDL_BWin.h:634
x
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1574
BWIN_SHOW_WINDOW
@ BWIN_SHOW_WINDOW
Definition: SDL_BWin.h:52
SDL_BWin::_Restore
void _Restore()
Definition: SDL_BWin.h:601
SDL_BWin::_MoveTo
void _MoveTo(BMessage *msg)
Definition: SDL_BWin.h:559
active
SDL_atomic_t active
Definition: SDL_events.c:84
height
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1572
SDL_BWin::LockBuffer
void LockBuffer()
Definition: SDL_BWin.h:457
SDL_BWin::_bytes_per_px
int32 _bytes_per_px
Definition: SDL_BWin.h:648
BWIN_MOVE_WINDOW
@ BWIN_MOVE_WINDOW
Definition: SDL_BWin.h:50
SDL_BUTTON_MIDDLE
#define SDL_BUTTON_MIDDLE
Definition: SDL_mouse.h:283
key
GLuint64 key
Definition: gl2ext.h:2192
SDL_BWin::Show
virtual void Show()
Definition: SDL_BWin.h:282
HAIKU_DrawThread
int32 HAIKU_DrawThread(void *data)
SDL_BWin::_PostWindowEvent
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:543
SDL_BWin::_buffer_dirty
bool _buffer_dirty
Definition: SDL_BWin.h:640
SDL_BWin::_KeyEvent
void _KeyEvent(int32 keyCode, const int8 *keyUtf8, const ssize_t &len, int32 keyState)
Definition: SDL_BWin.h:527
y
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1574
id
GLuint id
Definition: SDL_opengl_glext.h:531
bitmap
GLsizei GLfixed GLfixed GLfixed GLfixed const GLubyte * bitmap
Definition: SDL_opengl_glext.h:4537
SDL_BWin::_row_bytes
uint32 _row_bytes
Definition: SDL_BWin.h:643
BWIN_FULLSCREEN
@ BWIN_FULLSCREEN
Definition: SDL_BWin.h:60
SDL_BWin::_draw_thread_id
thread_id _draw_thread_id
Definition: SDL_BWin.h:649
SDL_BWin::_trash_window_buffer
bool _trash_window_buffer
Definition: SDL_BWin.h:641
SDL_BWin::_mouse_focused
bool _mouse_focused
Definition: SDL_BWin.h:630
BAPP_WINDOW_CLOSE_REQUESTED
@ BAPP_WINDOW_CLOSE_REQUESTED
Definition: SDL_BApp.h:72
SDL_BWin::_id
int32 _id
Definition: SDL_BWin.h:629
SDL_BWin::_SetFullScreen
void _SetFullScreen(BMessage *msg)
Definition: SDL_BWin.h:612
SDL_BWin::_buffer_locker
BLocker * _buffer_locker
Definition: SDL_BWin.h:645
BAPP_WINDOW_MOVED
@ BAPP_WINDOW_MOVED
Definition: SDL_BApp.h:73
BWIN_RESTORE_WINDOW
@ BWIN_RESTORE_WINDOW
Definition: SDL_BWin.h:56
BAPP_WINDOW_RESIZED
@ BAPP_WINDOW_RESIZED
Definition: SDL_BApp.h:74
BAPP_MAXIMIZE
@ BAPP_MAXIMIZE
Definition: SDL_BApp.h:65
SDL_BWin::_num_clips
uint32 _num_clips
Definition: SDL_BWin.h:647
SDL_BWin::_bits
uint8 * _bits
Definition: SDL_BWin.h:642
SDL_BWin::_bounds
clipping_rect _bounds
Definition: SDL_BWin.h:644
flags
GLbitfield flags
Definition: SDL_opengl_glext.h:1483
BWIN_MAXIMIZE_WINDOW
@ BWIN_MAXIMIZE_WINDOW
Definition: SDL_BWin.h:54
SDL_BWin::_SendMouseButton
void _SendMouseButton(int32 button, int32 state)
Definition: SDL_BWin.h:512
SDL_BWin::_inhibit_resize
bool _inhibit_resize
Definition: SDL_BWin.h:632
free
SDL_EventEntry * free
Definition: SDL_events.c:89
BAPP_MOUSE_BUTTON
@ BAPP_MOUSE_BUTTON
Definition: SDL_BApp.h:60
state
struct xkb_state * state
Definition: SDL_waylandsym.h:114
button
SDL_Texture * button
Definition: testgamecontroller.c:67
i
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
SDL_BWin::_gl_type
Uint32 _gl_type
Definition: SDL_BWin.h:625
BAPP_MOUSE_WHEEL
@ BAPP_MOUSE_WHEEL
Definition: SDL_BApp.h:61
w
GLubyte GLubyte GLubyte GLubyte w
Definition: SDL_opengl_glext.h:734