Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
600 lines (511 loc) · 16.3 KB

SDL_BWin.h

File metadata and controls

600 lines (511 loc) · 16.3 KB
 
Apr 26, 2001
Apr 26, 2001
1
/*
Apr 8, 2011
Apr 8, 2011
2
3
Simple DirectMedia Layer
Copyright (C) 1997-2011 Sam Lantinga <slouken@libsdl.org>
Apr 26, 2001
Apr 26, 2001
4
Apr 8, 2011
Apr 8, 2011
5
6
7
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Apr 26, 2001
Apr 26, 2001
8
Apr 8, 2011
Apr 8, 2011
9
10
11
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
Apr 26, 2001
Apr 26, 2001
12
Apr 8, 2011
Apr 8, 2011
13
14
15
16
17
18
19
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Apr 26, 2001
Apr 26, 2001
20
21
22
23
24
*/
#ifndef _SDL_BWin_h
#define _SDL_BWin_h
Jul 12, 2011
Jul 12, 2011
25
26
27
28
#ifdef __cplusplus
extern "C" {
#endif
Feb 17, 2006
Feb 17, 2006
29
#include "SDL_config.h"
Jul 12, 2011
Jul 12, 2011
30
31
#include "SDL.h"
#include "SDL_syswm.h"
Jul 30, 2011
Jul 30, 2011
32
#include "SDL_bframebuffer.h"
Jul 12, 2011
Jul 12, 2011
33
34
35
36
#ifdef __cplusplus
}
#endif
Feb 17, 2006
Feb 17, 2006
37
Apr 26, 2001
Apr 26, 2001
38
39
40
41
#include <stdio.h>
#include <AppKit.h>
#include <InterfaceKit.h>
#include <be/game/DirectWindow.h>
Feb 16, 2006
Feb 16, 2006
42
#if SDL_VIDEO_OPENGL
Apr 26, 2001
Apr 26, 2001
43
44
45
#include <be/opengl/GLView.h>
#endif
#include "SDL_events.h"
Jul 12, 2011
Jul 12, 2011
46
47
#include "../../main/beos/SDL_BApp.h"
Jul 30, 2011
Jul 30, 2011
48
Jul 12, 2011
Jul 12, 2011
49
50
51
52
53
54
55
56
57
58
enum WinCommands {
BWIN_MOVE_WINDOW,
BWIN_RESIZE_WINDOW,
BWIN_SHOW_WINDOW,
BWIN_HIDE_WINDOW,
BWIN_MAXIMIZE_WINDOW,
BWIN_MINIMIZE_WINDOW,
BWIN_RESTORE_WINDOW, /* TODO: IMPLEMENT THIS! */
BWIN_SET_TITLE,
BWIN_FULLSCREEN
Apr 26, 2001
Apr 26, 2001
59
60
};
Jul 12, 2011
Jul 12, 2011
61
Jul 10, 2006
Jul 10, 2006
62
class SDL_BWin:public BDirectWindow
Apr 26, 2001
Apr 26, 2001
63
{
Jul 10, 2006
Jul 10, 2006
64
public:
Jul 12, 2011
Jul 12, 2011
65
/* Constructor/Destructor */
Aug 3, 2011
Aug 3, 2011
66
67
SDL_BWin(BRect bounds, uint32 flags):BDirectWindow(bounds, "Untitled",
B_TITLED_WINDOW, flags)
Jul 10, 2006
Jul 10, 2006
68
{
Jul 25, 2011
Jul 25, 2011
69
_last_buttons = 0;
Jul 22, 2011
Jul 22, 2011
70
Feb 16, 2006
Feb 16, 2006
71
#if SDL_VIDEO_OPENGL
Jul 25, 2011
Jul 25, 2011
72
_SDL_GLView = NULL;
Apr 26, 2001
Apr 26, 2001
73
#endif
Jul 12, 2011
Jul 12, 2011
74
_shown = false;
Jul 25, 2011
Jul 25, 2011
75
76
77
78
_inhibit_resize = false;
_mouse_focused = false;
_prev_frame = NULL;
Jul 22, 2011
Jul 22, 2011
79
/* Handle framebuffer stuff */
Jul 25, 2011
Jul 25, 2011
80
_connected = _connection_disabled = false;
Jul 27, 2011
Jul 27, 2011
81
_buffer_created = _buffer_dirty = false;
Jul 28, 2011
Jul 28, 2011
82
_trash_window_buffer = false;
Jul 25, 2011
Jul 25, 2011
83
_buffer_locker = new BLocker();
Aug 3, 2011
Aug 3, 2011
84
_bitmap = NULL;
Jul 27, 2011
Jul 27, 2011
85
86
87
88
_draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread",
B_NORMAL_PRIORITY, (void*) this);
resume_thread(_draw_thread_id);
Jul 10, 2006
Jul 10, 2006
89
90
91
92
93
}
virtual ~ SDL_BWin()
{
Lock();
Jul 25, 2011
Jul 25, 2011
94
_connection_disabled = true;
Jul 27, 2011
Jul 27, 2011
95
int32 result;
Jul 22, 2011
Jul 22, 2011
96
Feb 16, 2006
Feb 16, 2006
97
#if SDL_VIDEO_OPENGL
Jul 25, 2011
Jul 25, 2011
98
99
if (_SDL_GLView) {
_SDL_GLView->UnlockGL();
Jul 10, 2006
Jul 10, 2006
100
}
Jul 25, 2011
Jul 25, 2011
101
RemoveChild(_SDL_GLView);
Jul 22, 2011
Jul 22, 2011
102
#endif
Jul 10, 2006
Jul 10, 2006
103
Unlock();
Feb 16, 2006
Feb 16, 2006
104
#if SDL_VIDEO_OPENGL
Jul 25, 2011
Jul 25, 2011
105
106
if (_SDL_GLView) {
delete _SDL_GLView;
Jul 10, 2006
Jul 10, 2006
107
}
Apr 26, 2001
Apr 26, 2001
108
#endif
Jul 22, 2011
Jul 22, 2011
109
110
/* Clean up framebuffer stuff */
Jul 25, 2011
Jul 25, 2011
111
_buffer_locker->Lock();
Jul 27, 2011
Jul 27, 2011
112
wait_for_thread(_draw_thread_id, &result);
Jul 22, 2011
Jul 22, 2011
113
free(_clips);
Jul 25, 2011
Jul 25, 2011
114
delete _buffer_locker;
Jul 10, 2006
Jul 10, 2006
115
}
Jul 12, 2011
Jul 12, 2011
116
Jul 22, 2011
Jul 22, 2011
117
Jul 30, 2011
Jul 30, 2011
118
/* * * * * OpenGL functionality * * * * */
Jul 22, 2011
Jul 22, 2011
119
#if SDL_VIDEO_OPENGL
Jul 30, 2011
Jul 30, 2011
120
virtual BGLView *CreateGLView(Uint32 gl_flags) {
Jul 10, 2006
Jul 10, 2006
121
Lock();
Jul 30, 2011
Jul 30, 2011
122
123
124
125
126
if (_SDL_GLView == NULL) {
_SDL_GLView = new BGLView(Bounds(), "SDL GLView",
B_FOLLOW_ALL_SIDES,
(B_WILL_DRAW | B_FRAME_EVENTS),
gl_flags);
Jul 10, 2006
Jul 10, 2006
127
}
Jul 30, 2011
Jul 30, 2011
128
129
AddChild(_SDL_GLView);
_SDL_GLView->LockGL(); /* "New" GLViews are created */
Jul 10, 2006
Jul 10, 2006
130
Unlock();
Jul 30, 2011
Jul 30, 2011
131
return (_SDL_GLView);
Jul 10, 2006
Jul 10, 2006
132
}
Jul 30, 2011
Jul 30, 2011
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
virtual void RemoveGLView() {
Lock();
if(_SDL_GLView) {
_SDL_GLView->UnlockGL();
RemoveChild(_SDL_GLView);
}
Unlock();
}
virtual void SwapBuffers(void) {
_SDL_GLView->UnlockGL();
_SDL_GLView->LockGL();
_SDL_GLView->SwapBuffers();
}
Jul 22, 2011
Jul 22, 2011
148
#endif
Jul 20, 2011
Jul 20, 2011
149
150
151
/* * * * * Framebuffering* * * * */
virtual void DirectConnected(direct_buffer_info *info) {
Jul 25, 2011
Jul 25, 2011
152
if(!_connected && _connection_disabled) {
Jul 22, 2011
Jul 22, 2011
153
154
return;
}
Jul 28, 2011
Jul 28, 2011
155
156
157
158
159
/* Determine if the pixel buffer is usable after this update */
_trash_window_buffer = _trash_window_buffer
|| ((info->buffer_state & B_BUFFER_RESIZED)
|| (info->buffer_state & B_BUFFER_RESET));
Jul 22, 2011
Jul 22, 2011
160
LockBuffer();
Jul 28, 2011
Jul 28, 2011
161
Jul 22, 2011
Jul 22, 2011
162
163
164
165
166
167
168
169
170
171
switch(info->buffer_state & B_DIRECT_MODE_MASK) {
case B_DIRECT_START:
_connected = true;
case B_DIRECT_MODIFY:
if(_clips) {
free(_clips);
_clips = NULL;
}
Jul 25, 2011
Jul 25, 2011
172
173
_num_clips = info->clip_list_count;
_clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect));
Jul 22, 2011
Jul 22, 2011
174
175
if(_clips) {
memcpy(_clips, info->clip_list,
Jul 25, 2011
Jul 25, 2011
176
_num_clips*sizeof(clipping_rect));
Jul 22, 2011
Jul 22, 2011
177
178
_bits = (uint8*) info->bits;
Jul 25, 2011
Jul 25, 2011
179
_row_bytes = info->bytes_per_row;
Jul 22, 2011
Jul 22, 2011
180
_bounds = info->window_bounds;
Jul 25, 2011
Jul 25, 2011
181
_bytes_per_px = info->bits_per_pixel / 8;
Jul 28, 2011
Jul 28, 2011
182
_buffer_dirty = true;
Jul 22, 2011
Jul 22, 2011
183
184
185
186
187
188
189
}
break;
case B_DIRECT_STOP:
_connected = false;
break;
}
Jul 30, 2011
Jul 30, 2011
190
191
192
193
194
#if SDL_VIDEO_OPENGL
if(_SDL_GLView) {
_SDL_GLView->DirectConnected(info);
}
#endif
Jul 28, 2011
Jul 28, 2011
195
Jul 22, 2011
Jul 22, 2011
196
UnlockBuffer();
Jul 20, 2011
Jul 20, 2011
197
198
199
}
Jul 22, 2011
Jul 22, 2011
200
201
Jul 12, 2011
Jul 12, 2011
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/* * * * * Event sending * * * * */
/* Hook functions */
virtual void FrameMoved(BPoint origin) {
/* Post a message to the BApp so that it can handle the window event */
BMessage msg(BAPP_WINDOW_MOVED);
msg.AddInt32("window-x", (int)origin.x);
msg.AddInt32("window-y", (int)origin.y);
_PostWindowEvent(msg);
/* Perform normal hook operations */
BDirectWindow::FrameMoved(origin);
}
virtual void FrameResized(float width, float height) {
/* Post a message to the BApp so that it can handle the window event */
BMessage msg(BAPP_WINDOW_RESIZED);
Jul 30, 2011
Jul 30, 2011
218
219
msg.AddInt32("window-w", (int)width + 1); /* TODO: Check that +1 is needed */
msg.AddInt32("window-h", (int)height + 1);
Jul 12, 2011
Jul 12, 2011
220
221
222
223
224
225
226
227
228
_PostWindowEvent(msg);
/* Perform normal hook operations */
BDirectWindow::FrameResized(width, height);
}
virtual bool QuitRequested() {
BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED);
_PostWindowEvent(msg);
Jul 25, 2011
Jul 25, 2011
229
Jul 12, 2011
Jul 12, 2011
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
/* We won't allow a quit unless asked by DestroyWindow() */
return false;
}
virtual void WindowActivated(bool active) {
BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */
_PostWindowEvent(msg);
}
virtual void Zoom(BPoint origin,
float width,
float height) {
BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */
_PostWindowEvent(msg);
/* Before the window zooms, record its size */
Jul 25, 2011
Jul 25, 2011
246
247
if( !_prev_frame )
_prev_frame = new BRect(Frame());
Jul 12, 2011
Jul 12, 2011
248
249
250
251
252
253
254
/* Perform normal hook operations */
BDirectWindow::Zoom(origin, width, height);
}
/* Member functions */
virtual void Show() {
Jul 25, 2011
Jul 25, 2011
255
256
257
while(IsHidden()) {
BDirectWindow::Show();
}
Jul 12, 2011
Jul 12, 2011
258
_shown = true;
Jul 25, 2011
Jul 25, 2011
259
Jul 12, 2011
Jul 12, 2011
260
261
262
263
264
265
266
BMessage msg(BAPP_SHOW);
_PostWindowEvent(msg);
}
virtual void Hide() {
BDirectWindow::Hide();
_shown = false;
Jul 25, 2011
Jul 25, 2011
267
Jul 12, 2011
Jul 12, 2011
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
BMessage msg(BAPP_HIDE);
_PostWindowEvent(msg);
}
virtual void Minimize(bool minimize) {
BDirectWindow::Minimize(minimize);
int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE);
BMessage msg(minState);
_PostWindowEvent(msg);
}
/* BView message interruption */
virtual void DispatchMessage(BMessage * msg, BHandler * target)
Jul 10, 2006
Jul 10, 2006
283
{
Jul 12, 2011
Jul 12, 2011
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
BPoint where; /* Used by mouse moved */
int32 buttons; /* Used for mouse button events */
int32 key; /* Used for key events */
switch (msg->what) {
case B_MOUSE_MOVED:
where;
int32 transit;
if (msg->FindPoint("where", &where) == B_OK
&& msg->FindInt32("be:transit", &transit) == B_OK) {
_MouseMotionEvent(where, transit);
}
/* FIXME: Apparently a button press/release event might be dropped
if made before before a different button is released. Does
B_MOUSE_MOVED have the data needed to check if a mouse button
state has changed? */
if (msg->FindInt32("buttons", &buttons) == B_OK) {
_MouseButtonEvent(buttons);
}
break;
case B_MOUSE_DOWN:
case B_MOUSE_UP:
/* _MouseButtonEvent() detects any and all buttons that may have
changed state, as well as that button's new state */
if (msg->FindInt32("buttons", &buttons) == B_OK) {
_MouseButtonEvent(buttons);
}
break;
case B_MOUSE_WHEEL_CHANGED:
float x, y;
if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK
&& msg->FindFloat("be:wheel_delta_y", &y) == B_OK) {
_MouseWheelEvent((int)x, (int)y);
}
break;
case B_KEY_DOWN:
case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */
if (msg->FindInt32("key", &key) == B_OK) {
_KeyEvent((SDL_Scancode)key, SDL_PRESSED);
}
break;
case B_KEY_UP:
case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */
if (msg->FindInt32("key", &key) == B_OK) {
_KeyEvent(key, SDL_RELEASED);
}
break;
default:
/* move it after switch{} so it's always handled
that way we keep BeOS feautures like:
- CTRL+Q to close window (and other shortcuts)
- PrintScreen to make screenshot into /boot/home
- etc.. */
//BDirectWindow::DispatchMessage(msg, target);
break;
}
Jul 25, 2011
Jul 25, 2011
346
Jul 12, 2011
Jul 12, 2011
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
BDirectWindow::DispatchMessage(msg, target);
}
/* Handle command messages */
virtual void MessageReceived(BMessage* message) {
switch (message->what) {
/* Handle commands from SDL */
case BWIN_SET_TITLE:
_SetTitle(message);
break;
case BWIN_MOVE_WINDOW:
_MoveTo(message);
break;
case BWIN_RESIZE_WINDOW:
_ResizeTo(message);
break;
case BWIN_SHOW_WINDOW:
Show();
break;
case BWIN_HIDE_WINDOW:
Hide();
break;
case BWIN_MAXIMIZE_WINDOW:
BWindow::Zoom();
break;
case BWIN_MINIMIZE_WINDOW:
Minimize(true);
break;
case BWIN_RESTORE_WINDOW:
_Restore();
break;
case BWIN_FULLSCREEN:
_SetFullScreen(message);
break;
default:
/* Perform normal message handling */
BDirectWindow::MessageReceived(message);
break;
}
Jul 10, 2006
Jul 10, 2006
387
}
Jul 12, 2011
Jul 12, 2011
388
389
390
391
392
393
/* Accessor methods */
bool IsShown() { return _shown; }
int32 GetID() { return _id; }
Jul 25, 2011
Jul 25, 2011
394
uint32 GetRowBytes() { return _row_bytes; }
Jul 22, 2011
Jul 22, 2011
395
396
int32 GetFbX() { return _bounds.left; }
int32 GetFbY() { return _bounds.top; }
Aug 3, 2011
Aug 3, 2011
397
398
// int32 GetFbHeight() { return _bounds.bottom - _bounds.top + 1; }
// int32 GetFbWidth() { return _bounds.right - _bounds.left + 1; }
Jul 25, 2011
Jul 25, 2011
399
bool ConnectionEnabled() { return !_connection_disabled; }
Jul 22, 2011
Jul 22, 2011
400
401
bool Connected() { return _connected; }
clipping_rect *GetClips() { return _clips; }
Jul 25, 2011
Jul 25, 2011
402
int32 GetNumClips() { return _num_clips; }
Jul 22, 2011
Jul 22, 2011
403
uint8* GetBufferPx() { return _bits; }
Jul 25, 2011
Jul 25, 2011
404
int32 GetBytesPerPx() { return _bytes_per_px; }
Aug 3, 2011
Aug 3, 2011
405
// uint8* GetWindowFramebuffer() { return _window_buffer; }
Jul 28, 2011
Jul 28, 2011
406
bool CanTrashWindowBuffer() { return _trash_window_buffer; }
Jul 27, 2011
Jul 27, 2011
407
408
bool BufferExists() { return _buffer_created; }
bool BufferIsDirty() { return _buffer_dirty; }
Aug 3, 2011
Aug 3, 2011
409
BBitmap *GetBitmap() { return _bitmap; }
Jul 12, 2011
Jul 12, 2011
410
411
412
/* Setter methods */
void SetID(int32 id) { _id = id; }
Jul 28, 2011
Jul 28, 2011
413
void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; }
Aug 3, 2011
Aug 3, 2011
414
// void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
Jul 27, 2011
Jul 27, 2011
415
416
417
void LockBuffer() { _buffer_locker->Lock(); }
void UnlockBuffer() { _buffer_locker->Unlock(); }
void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; }
Jul 28, 2011
Jul 28, 2011
418
void SetTrashBuffer(bool trash) { _trash_window_buffer = trash; }
Aug 3, 2011
Aug 3, 2011
419
void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; }
Jul 12, 2011
Jul 12, 2011
420
421
422
423
424
425
426
private:
/* Event redirection */
void _MouseMotionEvent(BPoint &where, int32 transit) {
if(transit == B_EXITED_VIEW) {
/* Change mouse focus */
Jul 25, 2011
Jul 25, 2011
427
if(_mouse_focused) {
Jul 12, 2011
Jul 12, 2011
428
429
430
431
432
_MouseFocusEvent(false);
}
} else {
static int x = 0, y = 0;
/* Change mouse focus */
Jul 25, 2011
Jul 25, 2011
433
if (!_mouse_focused) {
Jul 12, 2011
Jul 12, 2011
434
435
436
_MouseFocusEvent(true);
}
BMessage msg(BAPP_MOUSE_MOVED);
Jul 26, 2011
Jul 26, 2011
437
438
439
msg.AddInt32("x", (int)where.x);
msg.AddInt32("y", (int)where.y);
Jul 12, 2011
Jul 12, 2011
440
441
_PostWindowEvent(msg);
}
Jul 10, 2006
Jul 10, 2006
442
}
Jul 12, 2011
Jul 12, 2011
443
444
void _MouseFocusEvent(bool focusGained) {
Jul 25, 2011
Jul 25, 2011
445
_mouse_focused = focusGained;
Jul 12, 2011
Jul 12, 2011
446
447
448
449
450
451
452
BMessage msg(BAPP_MOUSE_FOCUS);
msg.AddBool("focusGained", focusGained);
_PostWindowEvent(msg);
//FIXME: Why were these here?
// if false: be_app->SetCursor(B_HAND_CURSOR);
// if true: SDL_SetCursor(NULL);
Jul 10, 2006
Jul 10, 2006
453
}
Jul 12, 2011
Jul 12, 2011
454
455
void _MouseButtonEvent(int32 buttons) {
Jul 25, 2011
Jul 25, 2011
456
int32 buttonStateChange = buttons ^ _last_buttons;
Jul 12, 2011
Jul 12, 2011
457
458
459
460
461
462
463
464
/* Make sure at least one button has changed state */
if( !(buttonStateChange) ) {
return;
}
/* Add any mouse button events */
if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) {
Jul 20, 2011
Jul 20, 2011
465
466
_SendMouseButton(SDL_BUTTON_LEFT, buttons &
B_PRIMARY_MOUSE_BUTTON);
Jul 12, 2011
Jul 12, 2011
467
468
}
if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) {
Jul 20, 2011
Jul 20, 2011
469
470
_SendMouseButton(SDL_BUTTON_RIGHT, buttons &
B_PRIMARY_MOUSE_BUTTON);
Jul 12, 2011
Jul 12, 2011
471
472
}
if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) {
Jul 20, 2011
Jul 20, 2011
473
474
_SendMouseButton(SDL_BUTTON_MIDDLE, buttons &
B_PRIMARY_MOUSE_BUTTON);
Jul 12, 2011
Jul 12, 2011
475
476
}
Jul 25, 2011
Jul 25, 2011
477
_last_buttons = buttons;
Jul 10, 2006
Jul 10, 2006
478
}
Jul 12, 2011
Jul 12, 2011
479
480
481
482
483
484
void _SendMouseButton(int32 button, int32 state) {
BMessage msg(BAPP_MOUSE_BUTTON);
msg.AddInt32("button-id", button);
msg.AddInt32("button-state", state);
_PostWindowEvent(msg);
Jul 10, 2006
Jul 10, 2006
485
}
Jul 12, 2011
Jul 12, 2011
486
487
488
489
490
491
492
void _MouseWheelEvent(int32 x, int32 y) {
/* Create a message to pass along to the BeApp thread */
BMessage msg(BAPP_MOUSE_WHEEL);
msg.AddInt32("xticks", x);
msg.AddInt32("yticks", y);
_PostWindowEvent(msg);
Jul 10, 2006
Jul 10, 2006
493
}
Jul 12, 2011
Jul 12, 2011
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
void _KeyEvent(int32 keyCode, int32 keyState) {
/* Create a message to pass along to the BeApp thread */
BMessage msg(BAPP_KEY);
msg.AddInt32("key-state", keyState);
msg.AddInt32("key-scancode", keyCode);
be_app->PostMessage(&msg);
/* Apparently SDL only uses the scancode */
}
void _RepaintEvent() {
/* Force a repaint: Call the SDL exposed event */
BMessage msg(BAPP_REPAINT);
_PostWindowEvent(msg);
}
void _PostWindowEvent(BMessage &msg) {
msg.AddInt32("window-id", _id);
be_app->PostMessage(&msg);
}
/* Command methods (functions called upon by SDL) */
void _SetTitle(BMessage *msg) {
const char *title;
if(
msg->FindString("window-title", &title) != B_OK
) {
return;
}
SetTitle(title);
}
void _MoveTo(BMessage *msg) {
int32 x, y;
if(
msg->FindInt32("window-x", &x) != B_OK ||
msg->FindInt32("window-y", &y) != B_OK
) {
return;
}
MoveTo(x, y);
}
void _ResizeTo(BMessage *msg) {
int32 w, h;
if(
msg->FindInt32("window-w", &w) != B_OK ||
msg->FindInt32("window-h", &h) != B_OK
) {
return;
}
ResizeTo(w, h);
}
void _Restore() {
if(IsMinimized()) {
Minimize(false);
} else if(IsHidden()) {
Show();
Jul 25, 2011
Jul 25, 2011
552
553
554
} else if(_prev_frame != NULL) { /* Zoomed */
MoveTo(_prev_frame->left, _prev_frame->top);
ResizeTo(_prev_frame->Width(), _prev_frame->Height());
Jul 12, 2011
Jul 12, 2011
555
}
Jul 10, 2006
Jul 10, 2006
556
557
}
Jul 12, 2011
Jul 12, 2011
558
559
560
561
562
563
564
565
566
567
568
void _SetFullScreen(BMessage *msg) {
bool fullscreen;
if(
msg->FindBool("fullscreen", &fullscreen) != B_OK
) {
return;
}
SetFullScreen(fullscreen);
}
/* Members */
Feb 16, 2006
Feb 16, 2006
569
#if SDL_VIDEO_OPENGL
Jul 25, 2011
Jul 25, 2011
570
BGLView * _SDL_GLView;
Apr 26, 2001
Apr 26, 2001
571
#endif
Jul 12, 2011
Jul 12, 2011
572
Jul 25, 2011
Jul 25, 2011
573
int32 _last_buttons;
Jul 12, 2011
Jul 12, 2011
574
int32 _id; /* Window id used by SDL_BApp */
Jul 25, 2011
Jul 25, 2011
575
576
577
bool _mouse_focused; /* Does this window have mouse focus? */
bool _shown;
bool _inhibit_resize;
Jun 24, 2011
Jun 24, 2011
578
Jul 25, 2011
Jul 25, 2011
579
BRect *_prev_frame; /* Previous position and size of the window */
Jul 22, 2011
Jul 22, 2011
580
581
/* Framebuffer members */
Jul 27, 2011
Jul 27, 2011
582
583
584
585
bool _connected,
_connection_disabled,
_buffer_created,
_buffer_dirty;
Jul 25, 2011
Jul 25, 2011
586
587
uint8 *_bits;
uint32 _row_bytes;
Jul 22, 2011
Jul 22, 2011
588
clipping_rect _bounds;
Jul 25, 2011
Jul 25, 2011
589
590
591
592
BLocker *_buffer_locker;
clipping_rect *_clips;
int32 _num_clips;
int32 _bytes_per_px;
Aug 3, 2011
Aug 3, 2011
593
// uint8 *_window_buffer; /* A copy of the window buffer */
Jul 28, 2011
Jul 28, 2011
594
bool _trash_window_buffer;
Jul 27, 2011
Jul 27, 2011
595
thread_id _draw_thread_id;
Aug 3, 2011
Aug 3, 2011
596
597
BBitmap *_bitmap;
Apr 26, 2001
Apr 26, 2001
598
599
};
Jul 12, 2011
Jul 12, 2011
600
#endif