annotate src/video/gem/SDL_gemwm.c @ 1555:780fd5b61df1

Fixed bug #89 Date: Sun, 23 Oct 2005 16:39:03 +0200 From: "A. Schmid" <sahib@phreaker.net> Subject: [SDL] no software surfaces with svgalib driver? Hi, I noticed that the SDL (1.2.9) svgalib driver only makes use of linear addressable (framebuffer) video modes. On older systems (like one of mine), linear addressable modes are often not available. Especially for cards with VESA VBE < 2.0 the svgalib vesa driver is unusable, since VESA only supports framebuffering for VBE 2.0 and later. The changes necessary to add support for software surfaces seem to be relatively small. I only had to hack src/video/svga/SDL_svgavideo.c (see attached patch). The code worked fine for me, but it is no more than a proof of concept and should be reviewed (probably has a memory leak when switching modes). It also uses the vgagl library (included in the svgalib package) and needs to be linked against it. -Alex
author Sam Lantinga <slouken@libsdl.org>
date Sun, 19 Mar 2006 12:05:16 +0000
parents d910939febfa
children 782fd950bd46 c121d94672cb 5d14acfdf84d
rev   line source
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
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: 1080
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
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: 1080
diff changeset
6 modify it under the terms of the GNU Lesser General Public
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
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: 1080
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
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: 1080
diff changeset
13 Lesser General Public License for more details.
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1080
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: 1080
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: 1080
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
22 #include "SDL_config.h"
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /*
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
25 GEM SDL video driver
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
26 Window manager functions
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
27
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
28 Patrice Mandin
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
29 */
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 /* Mint includes */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #include <gem.h>
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #include "SDL_gemwm_c.h"
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 /* Defines */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #define ICONWIDTH 64
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #define ICONHEIGHT 64
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 /* Functions */
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
43 void GEM_SetCaption(_THIS, const char *title, const char *icon)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
44 {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
45 if (title) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 GEM_title_name = title;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
47 GEM_refresh_name = SDL_TRUE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
50 if (icon) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
51 GEM_icon_name = icon;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
52 GEM_refresh_name = SDL_TRUE;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 void GEM_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 {
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
58 SDL_Surface *sicon;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
59 SDL_Rect bounds;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
60
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
61 #if 0
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
62 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
63 return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
64 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
65 #endif
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
66
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
67 if (icon == NULL) {
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 return;
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
69 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
70
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
71 /* Convert icon to the screen format */
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
72 sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
73 VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask, 0);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
74 if ( sicon == NULL ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
75 return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
76 }
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
78 bounds.x = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
79 bounds.y = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
80 bounds.w = icon->w;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
81 bounds.h = icon->h;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
82 if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 ) {
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
83 SDL_FreeSurface(sicon);
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
84 return;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
85 }
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
86
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
87 GEM_icon = sicon;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 int GEM_IconifyWindow(_THIS)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 {
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 if ((GEM_wfeatures & (1<<WF_ICONIFY))==0)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 return 0;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
95 GEM_message[0] = WM_ICONIFY;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
96 GEM_message[1] = gl_apid;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
97 GEM_message[2] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
98 GEM_message[3] = GEM_handle;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
99 GEM_message[4] = 0;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
100 GEM_message[5] = GEM_desk_h-ICONHEIGHT;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
101 GEM_message[6] = ICONWIDTH;
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
102 GEM_message[7] = ICONHEIGHT;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103
736
028e03e273c8 Use new C2P routine + corrections for iconification window
Patrice Mandin <patmandin@gmail.com>
parents: 557
diff changeset
104 appl_write(gl_apid, sizeof(GEM_message), GEM_message);
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 return 1;
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 }
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 SDL_GrabMode GEM_GrabInput(_THIS, SDL_GrabMode mode)
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 {
1068
adb547913775 Can not grab mouse
Patrice Mandin <patmandin@gmail.com>
parents: 769
diff changeset
111 return SDL_GRAB_OFF;
281
c5010ab8ba35 Added initial support for Atari (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 }