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

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, _inhibit_resize, _last_buttons, _mouse_focused, _prev_frame, _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 #endif
76  _shown = false;
77  _inhibit_resize = false;
78  _mouse_focused = false;
79  _prev_frame = NULL;
80 
81  /* Handle framebuffer stuff */
84  _trash_window_buffer = false;
85  _buffer_locker = new BLocker();
86  _bitmap = NULL;
87  _clips = NULL;
88 
89 #ifdef DRAWTHREAD
90  _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
91  B_NORMAL_PRIORITY, (void*) this);
92  resume_thread(_draw_thread_id);
93 #endif
94  }
int32 _last_buttons
Definition: SDL_BWin.h:629
bool _connected
Definition: SDL_BWin.h:638
bool _buffer_dirty
Definition: SDL_BWin.h:638
bool _connection_disabled
Definition: SDL_BWin.h:638
bool _shown
Definition: SDL_BWin.h:632
BLocker * _buffer_locker
Definition: SDL_BWin.h:646
bool _inhibit_resize
Definition: SDL_BWin.h:633
bool _mouse_focused
Definition: SDL_BWin.h:631
clipping_rect * _clips
Definition: SDL_BWin.h:647
BRect * _prev_frame
Definition: SDL_BWin.h:635
#define NULL
Definition: begin_code.h:143
bool _trash_window_buffer
Definition: SDL_BWin.h:638
bool _buffer_created
Definition: SDL_BWin.h:638
BBitmap * _bitmap
Definition: SDL_BWin.h:652
GLbitfield flags
thread_id _draw_thread_id
Definition: SDL_BWin.h:650
int32 BE_DrawThread(void *data)

◆ ~ SDL_BWin()

virtual SDL_BWin::~ SDL_BWin ( )
inlinevirtual

Definition at line 96 of file SDL_BWin.h.

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

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

Member Function Documentation

◆ _KeyEvent()

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

Definition at line 529 of file SDL_BWin.h.

References BAPP_KEY, and NULL.

Referenced by DispatchMessage().

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

◆ _MouseButtonEvent()

void SDL_BWin::_MouseButtonEvent ( int32  buttons)
inlineprivate

Definition at line 489 of file SDL_BWin.h.

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

Referenced by DispatchMessage().

489  {
490  int32 buttonStateChange = buttons ^ _last_buttons;
491 
492  /* Make sure at least one button has changed state */
493  if( !(buttonStateChange) ) {
494  return;
495  }
496 
497  /* Add any mouse button events */
498  if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
500  B_PRIMARY_MOUSE_BUTTON);
501  }
502  if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
504  B_PRIMARY_MOUSE_BUTTON);
505  }
506  if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
508  B_PRIMARY_MOUSE_BUTTON);
509  }
510 
511  _last_buttons = buttons;
512  }
int32 _last_buttons
Definition: SDL_BWin.h:629
#define SDL_BUTTON_RIGHT
Definition: SDL_mouse.h:284
void _SendMouseButton(int32 button, int32 state)
Definition: SDL_BWin.h:514
#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 478 of file SDL_BWin.h.

References _mouse_focused, _PostWindowEvent(), and BAPP_MOUSE_FOCUS.

Referenced by _MouseMotionEvent().

478  {
479  _mouse_focused = focusGained;
480  BMessage msg(BAPP_MOUSE_FOCUS);
481  msg.AddBool("focusGained", focusGained);
482  _PostWindowEvent(msg);
483 
484 /* FIXME: Why were these here?
485  if false: be_app->SetCursor(B_HAND_CURSOR);
486  if true: SDL_SetCursor(NULL); */
487  }
bool _mouse_focused
Definition: SDL_BWin.h:631
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ _MouseMotionEvent()

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

Definition at line 459 of file SDL_BWin.h.

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

Referenced by DispatchMessage().

459  {
460  if(transit == B_EXITED_VIEW) {
461  /* Change mouse focus */
462  if(_mouse_focused) {
463  _MouseFocusEvent(false);
464  }
465  } else {
466  /* Change mouse focus */
467  if (!_mouse_focused) {
468  _MouseFocusEvent(true);
469  }
470  BMessage msg(BAPP_MOUSE_MOVED);
471  msg.AddInt32("x", (int)where.x);
472  msg.AddInt32("y", (int)where.y);
473 
474  _PostWindowEvent(msg);
475  }
476  }
bool _mouse_focused
Definition: SDL_BWin.h:631
void _MouseFocusEvent(bool focusGained)
Definition: SDL_BWin.h:478
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ _MouseWheelEvent()

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

Definition at line 521 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_WHEEL.

Referenced by DispatchMessage().

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

◆ _MoveTo()

void SDL_BWin::_MoveTo ( BMessage *  msg)
inlineprivate

Definition at line 561 of file SDL_BWin.h.

Referenced by MessageReceived().

561  {
562  int32 x, y;
563  if(
564  msg->FindInt32("window-x", &x) != B_OK ||
565  msg->FindInt32("window-y", &y) != B_OK
566  ) {
567  return;
568  }
569  MoveTo(x, y);
570  }
GLint GLint GLint GLint GLint x
Definition: SDL_opengl.h:1567
GLint GLint GLint GLint GLint GLint y
Definition: SDL_opengl.h:1567

◆ _PostWindowEvent()

void SDL_BWin::_PostWindowEvent ( BMessage &  msg)
inlineprivate

Definition at line 545 of file SDL_BWin.h.

References _id.

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

545  {
546  msg.AddInt32("window-id", _id);
547  be_app->PostMessage(&msg);
548  }
int32 _id
Definition: SDL_BWin.h:630

◆ _RepaintEvent()

void SDL_BWin::_RepaintEvent ( )
inlineprivate

Definition at line 540 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_REPAINT.

540  {
541  /* Force a repaint: Call the SDL exposed event */
542  BMessage msg(BAPP_REPAINT);
543  _PostWindowEvent(msg);
544  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ _ResizeTo()

void SDL_BWin::_ResizeTo ( BMessage *  msg)
inlineprivate

Definition at line 572 of file SDL_BWin.h.

Referenced by MessageReceived().

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

◆ _Restore()

void SDL_BWin::_Restore ( )
inlineprivate

Definition at line 603 of file SDL_BWin.h.

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

Referenced by MessageReceived().

603  {
604  if(IsMinimized()) {
605  Minimize(false);
606  } else if(IsHidden()) {
607  Show();
608  } else if(_prev_frame != NULL) { /* Zoomed */
609  MoveTo(_prev_frame->left, _prev_frame->top);
610  ResizeTo(_prev_frame->Width(), _prev_frame->Height());
611  }
612  }
virtual void Show()
Definition: SDL_BWin.h:271
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:289
BRect * _prev_frame
Definition: SDL_BWin.h:635
#define NULL
Definition: begin_code.h:143

◆ _SendMouseButton()

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

Definition at line 514 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_MOUSE_BUTTON.

Referenced by _MouseButtonEvent().

514  {
515  BMessage msg(BAPP_MOUSE_BUTTON);
516  msg.AddInt32("button-id", button);
517  msg.AddInt32("button-state", state);
518  _PostWindowEvent(msg);
519  }
SDL_Texture * button
struct xkb_state * state
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ _SetBordered()

void SDL_BWin::_SetBordered ( BMessage *  msg)
inlineprivate

Definition at line 583 of file SDL_BWin.h.

Referenced by MessageReceived().

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

◆ _SetFullScreen()

void SDL_BWin::_SetFullScreen ( BMessage *  msg)
inlineprivate

Definition at line 614 of file SDL_BWin.h.

Referenced by MessageReceived().

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

◆ _SetResizable()

void SDL_BWin::_SetResizable ( BMessage *  msg)
inlineprivate

Definition at line 591 of file SDL_BWin.h.

Referenced by MessageReceived().

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

◆ _SetTitle()

void SDL_BWin::_SetTitle ( BMessage *  msg)
inlineprivate

Definition at line 551 of file SDL_BWin.h.

Referenced by MessageReceived().

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

◆ BufferExists()

bool SDL_BWin::BufferExists ( )
inline

Definition at line 440 of file SDL_BWin.h.

References _buffer_created.

440 { return _buffer_created; }
bool _buffer_created
Definition: SDL_BWin.h:638

◆ BufferIsDirty()

bool SDL_BWin::BufferIsDirty ( )
inline

Definition at line 441 of file SDL_BWin.h.

References _buffer_dirty.

441 { return _buffer_dirty; }
bool _buffer_dirty
Definition: SDL_BWin.h:638

◆ CanTrashWindowBuffer()

bool SDL_BWin::CanTrashWindowBuffer ( )
inline

Definition at line 439 of file SDL_BWin.h.

References _trash_window_buffer.

439 { return _trash_window_buffer; }
bool _trash_window_buffer
Definition: SDL_BWin.h:638

◆ Connected()

bool SDL_BWin::Connected ( )
inline

Definition at line 434 of file SDL_BWin.h.

References _connected.

434 { return _connected; }
bool _connected
Definition: SDL_BWin.h:638

◆ ConnectionEnabled()

bool SDL_BWin::ConnectionEnabled ( )
inline

Definition at line 433 of file SDL_BWin.h.

References _connection_disabled.

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

◆ DirectConnected()

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

Definition at line 161 of file SDL_BWin.h.

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

161  {
163  return;
164  }
165 
166  /* Determine if the pixel buffer is usable after this update */
168  || ((info->buffer_state & B_BUFFER_RESIZED)
169  || (info->buffer_state & B_BUFFER_RESET)
170  || (info->driver_state == B_MODE_CHANGED));
171  LockBuffer();
172 
173  switch(info->buffer_state & B_DIRECT_MODE_MASK) {
174  case B_DIRECT_START:
175  _connected = true;
176 
177  case B_DIRECT_MODIFY:
178  if(_clips) {
179  free(_clips);
180  _clips = NULL;
181  }
182 
183  _num_clips = info->clip_list_count;
184  _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
185  if(_clips) {
186  memcpy(_clips, info->clip_list,
187  _num_clips*sizeof(clipping_rect));
188 
189  _bits = (uint8*) info->bits;
190  _row_bytes = info->bytes_per_row;
191  _bounds = info->window_bounds;
192  _bytes_per_px = info->bits_per_pixel / 8;
193  _buffer_dirty = true;
194  }
195  break;
196 
197  case B_DIRECT_STOP:
198  _connected = false;
199  break;
200  }
201 #if SDL_VIDEO_OPENGL
202  if(_SDL_GLView) {
203  _SDL_GLView->DirectConnected(info);
204  }
205 #endif
206 
207 
208  /* Call the base object directconnected */
209  BDirectWindow::DirectConnected(info);
210 
211  UnlockBuffer();
212 
213  }
void UnlockBuffer()
Definition: SDL_BWin.h:451
bool _connected
Definition: SDL_BWin.h:638
bool _buffer_dirty
Definition: SDL_BWin.h:638
bool _connection_disabled
Definition: SDL_BWin.h:638
uint8 * _bits
Definition: SDL_BWin.h:643
SDL_EventEntry * free
Definition: SDL_events.c:81
int32 _bytes_per_px
Definition: SDL_BWin.h:649
void LockBuffer()
Definition: SDL_BWin.h:450
int32 _num_clips
Definition: SDL_BWin.h:648
clipping_rect * _clips
Definition: SDL_BWin.h:647
clipping_rect _bounds
Definition: SDL_BWin.h:645
#define NULL
Definition: begin_code.h:143
#define malloc
Definition: SDL_malloc.c:641
bool _trash_window_buffer
Definition: SDL_BWin.h:638
#define memcpy
Definition: SDL_malloc.c:640
uint32 _row_bytes
Definition: SDL_BWin.h:644

◆ DispatchMessage()

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

Definition at line 299 of file SDL_BWin.h.

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

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

◆ FrameMoved()

virtual void SDL_BWin::FrameMoved ( BPoint  origin)
inlinevirtual

Definition at line 220 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_MOVED.

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

◆ FrameResized()

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

Definition at line 231 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_RESIZED.

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

◆ GetBitmap()

BBitmap* SDL_BWin::GetBitmap ( )
inline

Definition at line 442 of file SDL_BWin.h.

References _bitmap.

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

◆ GetBufferPx()

uint8* SDL_BWin::GetBufferPx ( )
inline

Definition at line 437 of file SDL_BWin.h.

References _bits.

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

◆ GetBytesPerPx()

int32 SDL_BWin::GetBytesPerPx ( )
inline

Definition at line 438 of file SDL_BWin.h.

References _bytes_per_px.

438 { return _bytes_per_px; }
int32 _bytes_per_px
Definition: SDL_BWin.h:649

◆ GetClips()

clipping_rect* SDL_BWin::GetClips ( )
inline

Definition at line 435 of file SDL_BWin.h.

References _clips.

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

◆ GetFbX()

int32 SDL_BWin::GetFbX ( )
inline

Definition at line 431 of file SDL_BWin.h.

References _bounds.

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

◆ GetFbY()

int32 SDL_BWin::GetFbY ( )
inline

Definition at line 432 of file SDL_BWin.h.

References _bounds.

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

◆ GetID()

int32 SDL_BWin::GetID ( )
inline

Definition at line 429 of file SDL_BWin.h.

References _id.

429 { return _id; }
int32 _id
Definition: SDL_BWin.h:630

◆ GetNumClips()

int32 SDL_BWin::GetNumClips ( )
inline

Definition at line 436 of file SDL_BWin.h.

References _num_clips.

436 { return _num_clips; }
int32 _num_clips
Definition: SDL_BWin.h:648

◆ GetRowBytes()

uint32 SDL_BWin::GetRowBytes ( )
inline

Definition at line 430 of file SDL_BWin.h.

References _row_bytes.

430 { return _row_bytes; }
uint32 _row_bytes
Definition: SDL_BWin.h:644

◆ Hide()

virtual void SDL_BWin::Hide ( )
inlinevirtual

Definition at line 281 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_HIDE.

Referenced by MessageReceived().

281  {
282  BDirectWindow::Hide();
283  _shown = false;
284 
285  BMessage msg(BAPP_HIDE);
286  _PostWindowEvent(msg);
287  }
bool _shown
Definition: SDL_BWin.h:632
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ IsShown()

bool SDL_BWin::IsShown ( )
inline

Definition at line 428 of file SDL_BWin.h.

References _shown.

428 { return _shown; }
bool _shown
Definition: SDL_BWin.h:632

◆ LockBuffer()

void SDL_BWin::LockBuffer ( )
inline

Definition at line 450 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

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

◆ MessageReceived()

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

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

381  {
382  switch (message->what) {
383  /* Handle commands from SDL */
384  case BWIN_SET_TITLE:
386  break;
387  case BWIN_MOVE_WINDOW:
388  _MoveTo(message);
389  break;
390  case BWIN_RESIZE_WINDOW:
392  break;
393  case BWIN_SET_BORDERED:
395  break;
396  case BWIN_SET_RESIZABLE:
398  break;
399  case BWIN_SHOW_WINDOW:
400  Show();
401  break;
402  case BWIN_HIDE_WINDOW:
403  Hide();
404  break;
406  BWindow::Zoom();
407  break;
409  Minimize(true);
410  break;
411  case BWIN_RESTORE_WINDOW:
412  _Restore();
413  break;
414  case BWIN_FULLSCREEN:
416  break;
417  default:
418  /* Perform normal message handling */
419  BDirectWindow::MessageReceived(message);
420  break;
421  }
422 
423  }
virtual void Show()
Definition: SDL_BWin.h:271
void _ResizeTo(BMessage *msg)
Definition: SDL_BWin.h:572
GLuint GLsizei const GLchar * message
virtual void Hide()
Definition: SDL_BWin.h:281
void _SetFullScreen(BMessage *msg)
Definition: SDL_BWin.h:614
virtual void Minimize(bool minimize)
Definition: SDL_BWin.h:289
void _MoveTo(BMessage *msg)
Definition: SDL_BWin.h:561
void _SetResizable(BMessage *msg)
Definition: SDL_BWin.h:591
void _SetTitle(BMessage *msg)
Definition: SDL_BWin.h:551
void _SetBordered(BMessage *msg)
Definition: SDL_BWin.h:583
void _Restore()
Definition: SDL_BWin.h:603

◆ Minimize()

virtual void SDL_BWin::Minimize ( bool  minimize)
inlinevirtual

Definition at line 289 of file SDL_BWin.h.

References _PostWindowEvent(), BAPP_MINIMIZE, and BAPP_RESTORE.

Referenced by _Restore(), and MessageReceived().

289  {
290  BDirectWindow::Minimize(minimize);
291  int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
292 
293  BMessage msg(minState);
294  _PostWindowEvent(msg);
295  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ QuitRequested()

virtual bool SDL_BWin::QuitRequested ( )
inlinevirtual

Definition at line 243 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_WINDOW_CLOSE_REQUESTED.

243  {
244  BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
245  _PostWindowEvent(msg);
246 
247  /* We won't allow a quit unless asked by DestroyWindow() */
248  return false;
249  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ SetBitmap()

void SDL_BWin::SetBitmap ( BBitmap *  bitmap)
inline

Definition at line 454 of file SDL_BWin.h.

References _bitmap.

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

◆ SetBufferDirty()

void SDL_BWin::SetBufferDirty ( bool  bufferDirty)
inline

Definition at line 452 of file SDL_BWin.h.

References _buffer_dirty.

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

◆ SetBufferExists()

void SDL_BWin::SetBufferExists ( bool  bufferExists)
inline

Definition at line 449 of file SDL_BWin.h.

References _buffer_created.

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

◆ SetID()

void SDL_BWin::SetID ( int32  id)
inline

Definition at line 448 of file SDL_BWin.h.

References _id.

448 { _id = id; }
GLuint id
int32 _id
Definition: SDL_BWin.h:630

◆ SetTrashBuffer()

void SDL_BWin::SetTrashBuffer ( bool  trash)
inline

Definition at line 453 of file SDL_BWin.h.

References _trash_window_buffer.

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

◆ Show()

virtual void SDL_BWin::Show ( )
inlinevirtual

Definition at line 271 of file SDL_BWin.h.

References _PostWindowEvent(), _shown, and BAPP_SHOW.

Referenced by _Restore(), and MessageReceived().

271  {
272  while(IsHidden()) {
273  BDirectWindow::Show();
274  }
275  _shown = true;
276 
277  BMessage msg(BAPP_SHOW);
278  _PostWindowEvent(msg);
279  }
bool _shown
Definition: SDL_BWin.h:632
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ UnlockBuffer()

void SDL_BWin::UnlockBuffer ( )
inline

Definition at line 451 of file SDL_BWin.h.

References _buffer_locker.

Referenced by DirectConnected().

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

◆ WindowActivated()

virtual void SDL_BWin::WindowActivated ( bool  active)
inlinevirtual

Definition at line 251 of file SDL_BWin.h.

References _PostWindowEvent(), and BAPP_KEYBOARD_FOCUS.

251  {
252  BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
253  _PostWindowEvent(msg);
254  }
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

◆ Zoom()

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

Definition at line 256 of file SDL_BWin.h.

References _PostWindowEvent(), _prev_frame, and BAPP_MAXIMIZE.

258  {
259  BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
260  _PostWindowEvent(msg);
261 
262  /* Before the window zooms, record its size */
263  if( !_prev_frame )
264  _prev_frame = new BRect(Frame());
265 
266  /* Perform normal hook operations */
267  BDirectWindow::Zoom(origin, width, height);
268  }
GLint GLint GLsizei width
Definition: SDL_opengl.h:1565
GLint GLint GLsizei GLsizei height
Definition: SDL_opengl.h:1565
BRect * _prev_frame
Definition: SDL_BWin.h:635
void _PostWindowEvent(BMessage &msg)
Definition: SDL_BWin.h:545

Field Documentation

◆ _bitmap

BBitmap* SDL_BWin::_bitmap
private

Definition at line 652 of file SDL_BWin.h.

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

◆ _bits

uint8* SDL_BWin::_bits
private

Definition at line 643 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetBufferPx().

◆ _bounds

clipping_rect SDL_BWin::_bounds
private

Definition at line 645 of file SDL_BWin.h.

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

◆ _buffer_created

bool SDL_BWin::_buffer_created
private

Definition at line 638 of file SDL_BWin.h.

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

◆ _buffer_dirty

bool SDL_BWin::_buffer_dirty
private

Definition at line 638 of file SDL_BWin.h.

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

◆ _buffer_locker

BLocker* SDL_BWin::_buffer_locker
private

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

Referenced by DirectConnected(), and GetBytesPerPx().

◆ _clips

clipping_rect* SDL_BWin::_clips
private

Definition at line 647 of file SDL_BWin.h.

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

◆ _connected

bool SDL_BWin::_connected
private

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

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

◆ _id

int32 SDL_BWin::_id
private

Definition at line 630 of file SDL_BWin.h.

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

◆ _inhibit_resize

bool SDL_BWin::_inhibit_resize
private

Definition at line 633 of file SDL_BWin.h.

Referenced by SDL_BWin().

◆ _last_buttons

int32 SDL_BWin::_last_buttons
private

Definition at line 629 of file SDL_BWin.h.

Referenced by _MouseButtonEvent(), and SDL_BWin().

◆ _mouse_focused

bool SDL_BWin::_mouse_focused
private

Definition at line 631 of file SDL_BWin.h.

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

◆ _num_clips

int32 SDL_BWin::_num_clips
private

Definition at line 648 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetNumClips().

◆ _prev_frame

BRect* SDL_BWin::_prev_frame
private

Definition at line 635 of file SDL_BWin.h.

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

◆ _row_bytes

uint32 SDL_BWin::_row_bytes
private

Definition at line 644 of file SDL_BWin.h.

Referenced by DirectConnected(), and GetRowBytes().

◆ _shown

bool SDL_BWin::_shown
private

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

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


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