SDL 2.0
SDL_bwindow.cc
Go to the documentation of this file.
1/*
2 Simple DirectMedia Layer
3 Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21#include "../../SDL_internal.h"
22
23#if SDL_VIDEO_DRIVER_HAIKU
24#include "../SDL_sysvideo.h"
25
26#include "SDL_BWin.h"
27#include <new>
28
29/* Define a path to window's BWIN data */
30#ifdef __cplusplus
31extern "C" {
32#endif
33
34static SDL_INLINE SDL_BWin *_ToBeWin(SDL_Window *window) {
35 return ((SDL_BWin*)(window->driverdata));
36}
37
38static SDL_INLINE SDL_BApp *_GetBeApp() {
39 return ((SDL_BApp*)be_app);
40}
41
42static int _InitWindow(_THIS, SDL_Window *window) {
43 uint32 flags = 0;
44 window_look look = B_TITLED_WINDOW_LOOK;
45
46 BRect bounds(
47 window->x,
48 window->y,
49 window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing
50 window->y + window->h - 1
51 );
52
53 if(window->flags & SDL_WINDOW_FULLSCREEN) {
54 /* TODO: Add support for this flag */
55 printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__);
56 }
57 if(window->flags & SDL_WINDOW_OPENGL) {
58 /* TODO: Add support for this flag */
59 }
60 if(!(window->flags & SDL_WINDOW_RESIZABLE)) {
61 flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE;
62 }
63 if(window->flags & SDL_WINDOW_BORDERLESS) {
64 look = B_NO_BORDER_WINDOW_LOOK;
65 }
66
67 SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags);
68 if(bwin == NULL)
69 return -1;
70
71 window->driverdata = bwin;
72 int32 winID = _GetBeApp()->GetID(window);
73 bwin->SetID(winID);
74
75 return 0;
76}
77
79 if (_InitWindow(_this, window) < 0) {
80 return -1;
81 }
82
83 /* Start window loop */
84 _ToBeWin(window)->Show();
85 return 0;
86}
87
89
90 SDL_BWin *otherBWin = (SDL_BWin*)data;
91 if(!otherBWin->LockLooper())
92 return -1;
93
94 /* Create the new window and initialize its members */
95 window->x = (int)otherBWin->Frame().left;
96 window->y = (int)otherBWin->Frame().top;
97 window->w = (int)otherBWin->Frame().Width();
98 window->h = (int)otherBWin->Frame().Height();
99
100 /* Set SDL flags */
101 if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) {
103 }
104
105 /* If we are out of memory, return the error code */
106 if (_InitWindow(_this, window) < 0) {
107 return -1;
108 }
109
110 /* TODO: Add any other SDL-supported window attributes here */
111 _ToBeWin(window)->SetTitle(otherBWin->Title());
112
113 /* Start window loop and unlock the other window */
114 _ToBeWin(window)->Show();
115
116 otherBWin->UnlockLooper();
117 return 0;
118}
119
121 BMessage msg(BWIN_SET_TITLE);
122 msg.AddString("window-title", window->title);
123 _ToBeWin(window)->PostMessage(&msg);
124}
125
127 /* FIXME: Icons not supported by Haiku */
128}
129
131 BMessage msg(BWIN_MOVE_WINDOW);
132 msg.AddInt32("window-x", window->x);
133 msg.AddInt32("window-y", window->y);
134 _ToBeWin(window)->PostMessage(&msg);
135}
136
138 BMessage msg(BWIN_RESIZE_WINDOW);
139 msg.AddInt32("window-w", window->w - 1);
140 msg.AddInt32("window-h", window->h - 1);
141 _ToBeWin(window)->PostMessage(&msg);
142}
143
145 BMessage msg(BWIN_SET_BORDERED);
146 msg.AddBool("window-border", bordered != SDL_FALSE);
147 _ToBeWin(window)->PostMessage(&msg);
148}
149
151 BMessage msg(BWIN_SET_RESIZABLE);
152 msg.AddBool("window-resizable", resizable != SDL_FALSE);
153 _ToBeWin(window)->PostMessage(&msg);
154}
155
157 BMessage msg(BWIN_SHOW_WINDOW);
158 _ToBeWin(window)->PostMessage(&msg);
159}
160
162 BMessage msg(BWIN_HIDE_WINDOW);
163 _ToBeWin(window)->PostMessage(&msg);
164}
165
167 BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */
168 _ToBeWin(window)->PostMessage(&msg);
169}
170
172 BMessage msg(BWIN_MAXIMIZE_WINDOW);
173 _ToBeWin(window)->PostMessage(&msg);
174}
175
177 BMessage msg(BWIN_MINIMIZE_WINDOW);
178 _ToBeWin(window)->PostMessage(&msg);
179}
180
182 BMessage msg(BWIN_RESTORE_WINDOW);
183 _ToBeWin(window)->PostMessage(&msg);
184}
185
187 SDL_VideoDisplay * display, SDL_bool fullscreen) {
188 /* Haiku tracks all video display information */
189 BMessage msg(BWIN_FULLSCREEN);
190 msg.AddBool("fullscreen", fullscreen);
191 _ToBeWin(window)->PostMessage(&msg);
192
193}
194
196 /* FIXME: Not Haiku supported */
197 return -1;
198}
199
201 /* FIXME: Not Haiku supported */
202 return -1;
203}
204
205
207 /* TODO: Implement this! */
208}
209
211 _ToBeWin(window)->LockLooper(); /* This MUST be locked */
212 _GetBeApp()->ClearID(_ToBeWin(window));
213 _ToBeWin(window)->Quit();
214 window->driverdata = NULL;
215}
216
218 struct SDL_SysWMinfo *info) {
219 /* FIXME: What is the point of this? What information should be included? */
220 return SDL_FALSE;
221}
222
223
224
225
226
227#ifdef __cplusplus
228}
229#endif
230
231#endif /* SDL_VIDEO_DRIVER_HAIKU */
232
233/* vi: set ts=4 sw=4 expandtab: */
@ BWIN_SET_BORDERED
Definition: SDL_BWin.h:58
@ BWIN_SET_RESIZABLE
Definition: SDL_BWin.h:59
@ BWIN_SHOW_WINDOW
Definition: SDL_BWin.h:52
@ BWIN_MOVE_WINDOW
Definition: SDL_BWin.h:50
@ BWIN_MAXIMIZE_WINDOW
Definition: SDL_BWin.h:54
@ BWIN_FULLSCREEN
Definition: SDL_BWin.h:60
@ BWIN_HIDE_WINDOW
Definition: SDL_BWin.h:53
@ BWIN_MINIMIZE_WINDOW
Definition: SDL_BWin.h:55
@ BWIN_RESTORE_WINDOW
Definition: SDL_BWin.h:56
@ BWIN_SET_TITLE
Definition: SDL_BWin.h:57
@ BWIN_RESIZE_WINDOW
Definition: SDL_BWin.h:51
#define _THIS
void HAIKU_SetWindowIcon(_THIS, SDL_Window *window, SDL_Surface *icon)
SDL_bool HAIKU_GetWindowWMInfo(_THIS, SDL_Window *window, struct SDL_SysWMinfo *info)
void HAIKU_SetWindowGrab(_THIS, SDL_Window *window, SDL_bool grabbed)
void HAIKU_ShowWindow(_THIS, SDL_Window *window)
void HAIKU_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *display, SDL_bool fullscreen)
int HAIKU_CreateWindowFrom(_THIS, SDL_Window *window, const void *data)
void HAIKU_SetWindowSize(_THIS, SDL_Window *window)
int HAIKU_CreateWindow(_THIS, SDL_Window *window)
void HAIKU_RestoreWindow(_THIS, SDL_Window *window)
int HAIKU_GetWindowGammaRamp(_THIS, SDL_Window *window, Uint16 *ramp)
int HAIKU_SetWindowGammaRamp(_THIS, SDL_Window *window, const Uint16 *ramp)
void HAIKU_HideWindow(_THIS, SDL_Window *window)
void HAIKU_SetWindowPosition(_THIS, SDL_Window *window)
void HAIKU_DestroyWindow(_THIS, SDL_Window *window)
void HAIKU_RaiseWindow(_THIS, SDL_Window *window)
void HAIKU_SetWindowTitle(_THIS, SDL_Window *window)
void HAIKU_SetWindowBordered(_THIS, SDL_Window *window, SDL_bool bordered)
void HAIKU_MaximizeWindow(_THIS, SDL_Window *window)
void HAIKU_MinimizeWindow(_THIS, SDL_Window *window)
void HAIKU_SetWindowResizable(_THIS, SDL_Window *window, SDL_bool resizable)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: SDL_opengl.h:1974
GLbitfield flags
SDL_bool
Definition: SDL_stdinc.h:162
@ SDL_FALSE
Definition: SDL_stdinc.h:163
uint16_t Uint16
Definition: SDL_stdinc.h:191
static SDL_VideoDevice * _this
Definition: SDL_video.c:118
@ SDL_WINDOW_OPENGL
Definition: SDL_video.h:101
@ SDL_WINDOW_RESIZABLE
Definition: SDL_video.h:105
@ SDL_WINDOW_FULLSCREEN
Definition: SDL_video.h:100
@ SDL_WINDOW_BORDERLESS
Definition: SDL_video.h:104
#define NULL
Definition: begin_code.h:167
#define SDL_INLINE
Definition: begin_code.h:134
int32 GetID()
Definition: SDL_BWin.h:434
void SetID(int32 id)
Definition: SDL_BWin.h:454
EGLSurface EGLNativeWindowType * window
Definition: eglext.h:1025
A collection of pixels used in software blitting.
Definition: SDL_surface.h:71
The type used to identify a window.
Definition: SDL_sysvideo.h:74