annotate src/video/bwindow/SDL_syswm.cc @ 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 376665398b25
children cb7b118b400a
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: 906
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: 906
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: 906
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: 906
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: 906
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: 906
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: 906
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: 0
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1403
376665398b25 Catch the C++ and Objective C sources too...
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #include "SDL_BWin.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 extern "C" {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_syswm_c.h"
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
28 #include "SDL_error.h"
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
29 #include "../SDL_cursor_c.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 void BE_SetWMCaption(_THIS, const char *title, const char *icon)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
32 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33 SDL_Win->SetTitle(title);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
34 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
35
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
36 int BE_IconifyWindow(_THIS)
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
37 {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
38 SDL_Win->Minimize(true);
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
39 }
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
40
3878
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
41 SDL_GrabMode BE_GrabInput(_THIS, SDL_GrabMode mode)
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
42 {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
43 if ( mode == SDL_GRAB_OFF ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
44 // be_app->ShowCursor();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
45 if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
46 /* BeSman: Jan 2, 2006
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
47 must be leaving relative mode, move mouse from
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
48 center of window to where it belongs ... */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
49 BPoint pt;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
50 int x, y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
51 SDL_GetMouseState(&x,&y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
52 pt.x = x;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
53 pt.y = y;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
54 SDL_Win->Lock();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
55 SDL_Win->ConvertToScreen(&pt);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
56 SDL_Win->Unlock();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
57 set_mouse_position((int)pt.x, (int)pt.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
58 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
59 } else {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
60 // be_app->HideCursor();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
61 if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
62 /* BeSman: Jan 2, 2006
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
63 must be entering relative mode, get ready by
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
64 moving mouse to center of window ... */
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
65 BPoint pt;
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
66 pt.x = (SDL_VideoSurface->w/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
67 pt.y = (SDL_VideoSurface->h/2);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
68 SDL_Win->Lock();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
69 SDL_Win->ConvertToScreen(&pt);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
70 SDL_Win->Unlock();
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
71 set_mouse_position((int)pt.x, (int)pt.y);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
72 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
73 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
74 return(mode);
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
75 }
678576473849 Fixed bug #286
Sam Lantinga <slouken@libsdl.org>
parents: 1403
diff changeset
76
906
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
77 int BE_GetWMInfo(_THIS, SDL_SysWMinfo *info)
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
78 {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
79 if (info->version.major <= SDL_MAJOR_VERSION)
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
80 {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
81 return 1;
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
82 }
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
83 else
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
84 {
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
85 SDL_SetError("Application not compiled with SDL %d.%d\n",
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
86 SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
87 return -1;
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
88 }
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
89 }
a48acf6ee48f Date: Sat, 03 Jul 2004 02:23:48 +0200
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
90
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 }; /* Extern C */