annotate src/video/bwindow/SDL_BWin.h @ 3878:678576473849 SDL-1.2

Fixed bug #286 Date: Thu, 9 Feb 2006 17:06:51 +0300 From: "Oleg K [BeSman]" Subject: BeOS SDL patches Hello all. My name is Oleg K. [BeSman], Im a BeOS user from Russia.This mail contain a BeOs-specific patches to SDL (implementation of InputGrabbing and mouse_relative mode). See the source in attached file for details.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 24 Sep 2006 15:31:42 +0000
parents 6162b8d921ce
children 4e29535b821b
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1013
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 1
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #ifndef _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #define _SDL_BWin_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
1367
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
26 #include "SDL_config.h"
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
27
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include <stdio.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include <AppKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include <InterfaceKit.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 #include <be/game/DirectWindow.h>
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
32 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 #include <be/opengl/GLView.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 #endif
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
35 #include <support/UTF8.h>
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
36
1367
e440d5c488c1 Fixes for BeOS and Solaris builds
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
37 #include "../../main/beos/SDL_BeApp.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #include "SDL_events.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #include "SDL_BView.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41 extern "C" {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
42 #include "../../events/SDL_events_c.h"
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
43
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
44 extern int mouse_relative;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
45 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 class SDL_BWin : public BDirectWindow
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 public:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 SDL_BWin(BRect bounds) :
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 BDirectWindow(bounds, "Untitled", B_TITLED_WINDOW, 0) {
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
52 last_buttons = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 the_view = NULL;
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
54 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 SDL_GLView = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 SDL_View = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 shown = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60 inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 }
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
62
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 virtual ~SDL_BWin() {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
66 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67 if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
70 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 the_view = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 Unlock();
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
75 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 if ( SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77 delete SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 if ( SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 delete SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 }
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
84
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 /* Override the Show() method so we can tell when we've been shown */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 virtual void Show(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 BWindow::Show();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 shown = true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 virtual bool Shown(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92 return (shown);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 /* If called, the next resize event will not be forwarded to SDL. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 virtual void InhibitResize(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 inhibit_resize=true;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 /* Handle resizing of the window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 virtual void FrameResized(float width, float height) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 if(inhibit_resize)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 inhibit_resize = false;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 SDL_PrivateResize((int)width, (int)height);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 }
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
105 virtual int CreateView(Uint32 flags, Uint32 gl_flags) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 int retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 Lock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 if ( flags & SDL_OPENGL ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
111 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 if ( SDL_GLView == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 SDL_GLView = new BGLView(Bounds(), "SDL GLView",
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
114 B_FOLLOW_ALL_SIDES, (B_WILL_DRAW|B_FRAME_EVENTS),
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
115 gl_flags);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 if ( the_view != SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 if ( the_view ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 AddChild(SDL_GLView);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 the_view = SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 SDL_SetError("OpenGL support not enabled");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130 if ( SDL_View == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 SDL_View = new SDL_BView(Bounds());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
132 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
133 if ( the_view != SDL_View ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 if ( the_view ) {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
135 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 if ( the_view == SDL_GLView ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140 RemoveChild(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 AddChild(SDL_View);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 the_view = SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 virtual void SetBitmap(BBitmap *bitmap) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 SDL_View->SetBitmap(bitmap);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 virtual bool BeginDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 return(Lock());
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 virtual void DrawAsync(BRect updateRect) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 SDL_View->DrawAsync(updateRect);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 virtual void EndDraw(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 SDL_View->Sync();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 Unlock();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 }
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
162 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 virtual void SwapBuffers(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
164 SDL_GLView->UnlockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 SDL_GLView->LockGL();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 SDL_GLView->SwapBuffers();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 virtual BView *View(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 return(the_view);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 /* Hook functions -- overridden */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 virtual void Minimize(bool minimize) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 /* This is only called when mimimized, not when restored */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 //SDL_PrivateAppActive(minimize, SDL_APPACTIVE);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 BWindow::Minimize(minimize);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 virtual void WindowActivated(bool active) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 virtual bool QuitRequested(void) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 if ( SDL_BeAppActive > 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 SDL_PrivateQuit();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 /* We don't ever actually close the window here because
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 the application should respond to the quit request,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 or ignore it as desired.
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 return(false);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 return(true); /* Close the app window */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 }
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
193 virtual void Quit() {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
194 if (!IsLocked())
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
195 Lock();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
196 BDirectWindow::Quit();
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
197 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
199 virtual int16 Translate2Unicode(const char *buf) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
200 int32 state, srclen, dstlen;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
201 unsigned char destbuf[2];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
202 Uint16 unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
203
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
204 if ((uchar)buf[0] > 127) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
205 state = 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
206 srclen = SDL_strlen(buf);
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
207 dstlen = sizeof(destbuf);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
208 convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, (char *)destbuf, &dstlen, &state);
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
209 unicode = destbuf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
210 unicode <<= 8;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
211 unicode |= destbuf[1];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
212 } else
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
213 unicode = buf[0];
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
214
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
215 /* For some reason function keys map to control characters */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
216 # define CTRL(X) ((X)-'@')
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
217 switch (unicode) {
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
218 case CTRL('A'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
219 case CTRL('B'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
220 case CTRL('C'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
221 case CTRL('D'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
222 case CTRL('E'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
223 case CTRL('K'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
224 case CTRL('L'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
225 case CTRL('P'):
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
226 if ( ! (SDL_GetModState() & KMOD_CTRL) )
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
227 unicode = 0;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
228 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
229 /* Keyboard input maps newline to carriage return */
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
230 case '\n':
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
231 unicode = '\r';
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
232 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
233 default:
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
234 break;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
235 }
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
236
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
237 return unicode;
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
238 }
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
239
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1614
diff changeset
240 virtual void DispatchMessage(BMessage *msg, BHandler *target);
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
241
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 private:
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1336
diff changeset
243 #if SDL_VIDEO_OPENGL
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 BGLView *SDL_GLView;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 SDL_BView *SDL_View;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 BView *the_view;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 bool shown;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 bool inhibit_resize;
907
3bd4d7a1ee04 Date: Mon, 21 Jun 2004 16:52:47 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 906
diff changeset
250 int32 last_buttons;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 #endif /* _SDL_BWin_h */