annotate src/video/gtk/SDL_gtkvideo.c @ 4404:b8de86ee2ad6 SDL-1.2-olpc

First shot at GTK+ video target for the OLPC laptops. Seriously incomplete, but it's enough to get some bits to a window...
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 19 Apr 2007 07:12:30 +0000
parents
children
rev   line source
4404
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Lesser General Public License for more details.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22 #include "SDL_config.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 /*
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 * GTK+ SDL video driver implementation; this is a little like a pared-down
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 * version of the X11 driver. You almost certainly do NOT want this target
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27 * on a desktop machine. This was written for the One Laptop Per Child
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 * project so they wouldn't need to use the SDL_WINDOWID hack with the X11
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 * driver and compete for the event queue.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30 *
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 * of this was cut-and-pasted from the dummy video target just to have a
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 * starting point for the bare minimum to fill in, and some was lifted from
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34 * the x11 target.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 #include "SDL_video.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 #include "SDL_mouse.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39 #include "../SDL_sysvideo.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 #include "../SDL_pixels_c.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 #include "../../events/SDL_events_c.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43 #include "SDL_gtkvideo.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 #include "SDL_gtkevents_c.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 #include "SDL_gtkmouse_c.h"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47 #define GTKPLUSVID_DRIVER_NAME "gtk"
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 /* Initialization/Query functions */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 static int GTKPLUS_VideoInit(_THIS, SDL_PixelFormat *vformat);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 static SDL_Rect **GTKPLUS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 static SDL_Surface *GTKPLUS_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 static int GTKPLUS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 static void GTKPLUS_VideoQuit(_THIS);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 /* Hardware surface functions */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57 static int GTKPLUS_AllocHWSurface(_THIS, SDL_Surface *surface);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 static int GTKPLUS_LockHWSurface(_THIS, SDL_Surface *surface);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 static void GTKPLUS_UnlockHWSurface(_THIS, SDL_Surface *surface);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 static void GTKPLUS_FreeHWSurface(_THIS, SDL_Surface *surface);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 static void GTKPLUS_SetCaption(_THIS, const char *title, const char *icon);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 /* etc. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 static void GTKPLUS_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 /* GTKPLUS driver bootstrap functions */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 static int do_gtk_init(void)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 static int initted = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 if (!initted) { /* !!! FIXME: I can't see a way to deinit gtk... */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 int tmpargc = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 char *args[] = { NULL, NULL };
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74 char **tmpargv = args;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
75 initted = (gtk_init_check(&tmpargc, &tmpargv));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
76 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
77 return initted;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
78 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
79
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
80
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
81 static int GTKPLUS_Available(void)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
82 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
83 return 1; /* !!! FIXME */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
84 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
85
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
86 static void GTKPLUS_DeleteDevice(SDL_VideoDevice *device)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
87 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
88 SDL_free(device->hidden);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
89 SDL_free(device);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
90 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
91
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
92 static SDL_VideoDevice *GTKPLUS_CreateDevice(int devindex)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
93 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
94 SDL_VideoDevice *device;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
95
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
96 /* Initialize all variables that we clean on shutdown */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
97 device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
98 if ( device ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
99 SDL_memset(device, 0, (sizeof *device));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
100 device->hidden = (struct SDL_PrivateVideoData *)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
101 SDL_malloc((sizeof *device->hidden));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
102 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
103 if ( (device == NULL) || (device->hidden == NULL) ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
104 SDL_OutOfMemory();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
105 if ( device ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
106 SDL_free(device);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
107 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
108 return(0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
109 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
110 SDL_memset(device->hidden, 0, (sizeof *device->hidden));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
111
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
112 device->handles_any_size = 1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
113
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
114 /* Set the function pointers */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
115 device->VideoInit = GTKPLUS_VideoInit;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
116 device->ListModes = GTKPLUS_ListModes;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
117 device->SetVideoMode = GTKPLUS_SetVideoMode;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
118 device->CreateYUVOverlay = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
119 device->SetColors = GTKPLUS_SetColors;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
120 device->UpdateRects = GTKPLUS_UpdateRects;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
121 device->VideoQuit = GTKPLUS_VideoQuit;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
122 device->AllocHWSurface = GTKPLUS_AllocHWSurface;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
123 device->CheckHWBlit = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
124 device->FillHWRect = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
125 device->SetHWColorKey = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
126 device->SetHWAlpha = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
127 device->LockHWSurface = GTKPLUS_LockHWSurface;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
128 device->UnlockHWSurface = GTKPLUS_UnlockHWSurface;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
129 device->FlipHWSurface = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
130 device->FreeHWSurface = GTKPLUS_FreeHWSurface;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
131 device->SetCaption = GTKPLUS_SetCaption;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
132 device->SetIcon = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
133 device->IconifyWindow = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
134 device->GrabInput = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
135 device->GetWMInfo = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
136 device->InitOSKeymap = GTKPLUS_InitOSKeymap;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
137 device->PumpEvents = GTKPLUS_PumpEvents;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
138
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
139 device->free = GTKPLUS_DeleteDevice;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
140
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
141 return device;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
142 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
143
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
144 VideoBootStrap GTKPLUS_bootstrap = {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
145 GTKPLUSVID_DRIVER_NAME, "SDL GTK+ video driver",
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
146 GTKPLUS_Available, GTKPLUS_CreateDevice
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
147 };
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
148
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
149
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
150 static int add_visual(_THIS, int depth, GdkVisualType vistype)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
151 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
152 GdkVisual *vi = gdk_visual_get_best_with_both(depth, vistype);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
153 if(vi != NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
154 g_object_ref(vi);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
155 this->hidden->visuals[this->hidden->nvisuals++] = vi;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
156 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
157 return(this->hidden->nvisuals);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
158 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
159
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
160 static int GTKPLUS_GetVideoModes(_THIS)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
161 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
162 const gint screen_w = gdk_screen_width();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
163 const gint screen_h = gdk_screen_height();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
164 int i, n;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
165
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
166 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
167 /* It's interesting to note that if we allow 32 bit depths (on X11),
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
168 we get a visual with an alpha mask on composite servers.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
169 static int depth_list[] = { 32, 24, 16, 15, 8 };
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
170 */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
171 static int depth_list[] = { 24, 16, 15, 8 };
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
172 int use_directcolor = 1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
173
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
174 /* Search for the visuals in deepest-first order, so that the first
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
175 will be the richest one */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
176 if ( SDL_getenv("SDL_VIDEO_GTK_NODIRECTCOLOR") ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
177 use_directcolor = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
178 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
179 this->hidden->nvisuals = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
180 for ( i=0; i<SDL_arraysize(depth_list); ++i ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
181 if ( depth_list[i] > 8 ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
182 if ( use_directcolor ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
183 add_visual(this, depth_list[i], GDK_VISUAL_DIRECT_COLOR);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
184 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
185 add_visual(this, depth_list[i], GDK_VISUAL_TRUE_COLOR);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
186 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
187 add_visual(this, depth_list[i], GDK_VISUAL_PSEUDO_COLOR);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
188 add_visual(this, depth_list[i], GDK_VISUAL_STATIC_COLOR);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
189 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
190 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
191 if ( this->hidden->nvisuals == 0 ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
192 SDL_SetError("Found no sufficiently capable GTK+ visuals");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
193 return -1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
194 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
195 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
196
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
197 return 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
198 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
199
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
200
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
201 int GTKPLUS_VideoInit(_THIS, SDL_PixelFormat *vformat)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
202 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
203 GdkVisual *sysvis = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
204 int i;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
205
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
206 if (!do_gtk_init()) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
207 return -1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
208 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
209
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
210 /* Get the available video modes */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
211 if(GTKPLUS_GetVideoModes(this) < 0)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
212 return -1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
213
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
214 /* Determine the current screen size */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
215 this->info.current_w = gdk_screen_width();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
216 this->info.current_h = gdk_screen_height();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
217
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
218 /* Determine the default screen depth:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
219 Use the default visual (or at least one with the same depth) */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
220 this->hidden->display_colormap = gdk_colormap_get_system(); /* !!! FIXME: refcount? */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
221 sysvis = gdk_visual_get_system(); /* !!! FIXME: refcount? */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
222
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
223 for(i = 0; i < this->hidden->nvisuals; i++) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
224 if(this->hidden->visuals[i]->depth == sysvis->depth)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
225 break;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
226 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
227
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
228 if(i == this->hidden->nvisuals) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
229 /* default visual was useless, take the deepest one instead */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
230 i = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
231 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
232
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
233 this->hidden->visual = this->hidden->visuals[i];
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
234 if ( this->hidden->visual == sysvis ) { /* !!! FIXME: same pointer? */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
235 this->hidden->colormap = this->hidden->display_colormap;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
236 g_object_ref(this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
237 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
238 this->hidden->colormap = gdk_colormap_new(this->hidden->visual, FALSE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
239 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
240
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
241 // !!! FIXME: this is not a public GDK symbol!!
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
242 vformat->BitsPerPixel = _gdk_windowing_get_bits_for_depth(
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
243 gdk_display_get_default(),
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
244 this->hidden->visuals[i]->depth);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
245 this->hidden->depth = vformat->BitsPerPixel;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
246
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
247 if ( vformat->BitsPerPixel > 8 ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
248 vformat->Rmask = this->hidden->visual->red_mask;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
249 vformat->Gmask = this->hidden->visual->green_mask;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
250 vformat->Bmask = this->hidden->visual->blue_mask;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
251 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
252 if ( this->hidden->depth == 32 ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
253 vformat->Amask = (0xFFFFFFFF & ~(vformat->Rmask|vformat->Gmask|vformat->Bmask));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
254 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
255
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
256 #if 0
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
257 /* Create the fullscreen and managed windows */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
258 create_aux_windows(this);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
259
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
260 /* Create the blank cursor */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
261 SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
262 BLANK_CWIDTH, BLANK_CHEIGHT,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
263 BLANK_CHOTX, BLANK_CHOTY);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
264
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
265 /* Allow environment override of screensaver disable. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
266 env = SDL_getenv("SDL_VIDEO_ALLOW_SCREENSAVER");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
267 this->hidden->allow_screensaver = ( (env && SDL_atoi(env)) ? 1 : 0 );
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
268 #endif
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
269
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
270 /* We're done! */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
271 gdk_flush(); /* just in case. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
272
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
273 /* Fill in some window manager capabilities */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
274 this->info.wm_available = 1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
275
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
276 return(0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
277 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
278
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
279
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
280 static GdkVisual *find_visual(_THIS, int bpp)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
281 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
282 GdkDisplay *display = gdk_display_get_default();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
283 int i;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
284 for ( i = 0; i < this->hidden->nvisuals; i++ ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
285 const int videpth = this->hidden->visuals[i]->depth;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
286 // !!! FIXME: this is not a public GDK symbol!!
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
287 const int depth = _gdk_windowing_get_bits_for_depth(display, videpth);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
288 if ( depth == bpp )
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
289 break;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
290 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
291
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
292 if ( i == this->hidden->nvisuals ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
293 SDL_SetError("No matching visual for requested depth");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
294 return NULL; /* should never happen */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
295 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
296 return this->hidden->visuals[i];
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
297 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
298
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
299
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
300 SDL_Rect **GTKPLUS_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
301 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
302 if ((flags & SDL_OPENGL) == 0) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
303 if (find_visual(this, format->BitsPerPixel) != NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
304 return (SDL_Rect **) -1; /* !!! FIXME: maybe not right. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
305 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
306 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
307 return NULL; /* unsupported. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
308 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
309
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
310
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
311 SDL_Surface *GTKPLUS_SetVideoMode(_THIS, SDL_Surface *current,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
312 int width, int height, int bpp, Uint32 flags)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
313 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
314 Uint32 Amask = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
315 int vis_change = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
316 GtkWindow *win = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
317 GdkImage *img = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
318 GdkVisual *sysvis = gdk_visual_get_system(); /* !!! FIXME: refcount? */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
319 GdkVisual *vis = find_visual(this, bpp);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
320 if (vis == NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
321 return(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
322 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
323
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
324 if (flags & SDL_OPENGL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
325 SDL_SetError("No OpenGL support in the GTK+ target");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
326 return(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
327 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
328
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
329 /* These are the only flags we allow here... */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
330 flags &= /*SDL_FULLSCREEN |*/ SDL_RESIZABLE | SDL_NOFRAME | SDL_HWPALETTE;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
331
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
332 vis_change = (vis != this->hidden->visual);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
333 this->hidden->visual = vis;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
334 this->hidden->depth = vis->depth;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
335
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
336 /* Allocate the new pixel format for this video mode */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
337 if ( this->hidden->depth == 32 ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
338 Amask = (0xFFFFFFFF & ~(vis->red_mask|vis->green_mask|vis->blue_mask));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
339 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
340 Amask = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
341 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
342 if ( ! SDL_ReallocFormat(current, bpp,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
343 vis->red_mask, vis->green_mask, vis->blue_mask, Amask) ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
344 return NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
345 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
346
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
347 /* Create the appropriate colormap */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
348 g_object_unref(this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
349 this->hidden->colormap = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
350
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
351 if ( this->hidden->visual->type == GDK_VISUAL_PSEUDO_COLOR ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
352 int ncolors;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
353
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
354 /* Allocate the pixel flags */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
355 ncolors = this->hidden->visual->colormap_size;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
356
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
357 #if 0
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
358 SDL_XPixels = SDL_malloc(ncolors * sizeof(int));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
359 if(SDL_XPixels == NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
360 SDL_OutOfMemory();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
361 return -1;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
362 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
363 SDL_memset(SDL_XPixels, 0, ncolors * sizeof(*SDL_XPixels));
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
364 #endif
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
365
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
366 /* always allocate a private colormap on non-default visuals */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
367 if ( this->hidden->visual != sysvis ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
368 flags |= SDL_HWPALETTE;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
369 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
370 if ( flags & SDL_HWPALETTE ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
371 current->flags |= SDL_HWPALETTE;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
372 this->hidden->colormap = gdk_colormap_new(this->hidden->visual, TRUE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
373 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
374 this->hidden->colormap = this->hidden->display_colormap;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
375 g_object_ref(this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
376 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
377 } else if ( this->hidden->visual->type == GDK_VISUAL_DIRECT_COLOR ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
378
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
379 /* Create a colormap which we can manipulate for gamma */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
380 this->hidden->colormap = gdk_colormap_new(this->hidden->visual, TRUE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
381 gdk_flush();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
382
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
383 /* Initialize the colormap to the identity mapping */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
384 SDL_GetGammaRamp(0, 0, 0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
385 this->screen = current;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
386 #if 0 // !!! FIXME
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
387 GTKPLUS_SetGammaRamp(this, this->gamma);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
388 #endif
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
389 this->screen = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
390 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
391 /* Create a read-only colormap for our window */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
392 this->hidden->colormap = gdk_colormap_new(this->hidden->visual, FALSE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
393 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
394
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
395 #if 0 // !!! FIXME
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
396 /* Recreate the auxiliary windows, if needed (required for GL) */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
397 if ( vis_change )
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
398 create_aux_windows(this);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
399
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
400 if(current->flags & SDL_HWPALETTE) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
401 /* Since the full-screen window might have got a nonzero background
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
402 colour (0 is white on some displays), we should reset the
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
403 background to 0 here since that is what the user expects
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
404 with a private colormap */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
405 XSetWindowBackground(SDL_Display, FSwindow, 0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
406 XClearWindow(SDL_Display, FSwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
407 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
408
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
409 /* resize the (possibly new) window manager window */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
410 if( !SDL_windowid ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
411 X11_SetSizeHints(this, w, h, flags);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
412 window_w = w;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
413 window_h = h;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
414 XResizeWindow(SDL_Display, WMwindow, w, h);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
415 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
416 #endif
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
417
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
418 if ( this->hidden->gdkimage ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
419 g_object_unref(this->hidden->gdkimage);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
420 this->hidden->gdkimage = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
421 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
422
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
423 img = this->hidden->gdkimage = gdk_image_new(GDK_IMAGE_FASTEST,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
424 vis, width, height);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
425 if (img == NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
426 SDL_SetError("Couldn't allocate buffer for requested mode");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
427 return(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
428 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
429 gdk_image_set_colormap(this->hidden->gdkimage, this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
430
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
431 SDL_memset(img->mem, 0, height * img->bpl);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
432
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
433 if ( this->hidden->gtkwindow == NULL ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
434 this->hidden->gtkdrawingarea = gtk_drawing_area_new();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
435 if ( this->hidden->gtkdrawingarea == NULL ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
436 SDL_SetError("Couldn't create drawing area for requested mode");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
437 g_object_unref(this->hidden->gdkimage);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
438 this->hidden->gdkimage = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
439 return(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
440 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
441
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
442 this->hidden->gtkwindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
443 if ( this->hidden->gtkwindow == NULL ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
444 SDL_SetError("Couldn't create window for requested mode");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
445 g_object_unref(this->hidden->gdkimage);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
446 g_object_unref(this->hidden->gtkdrawingarea);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
447 this->hidden->gdkimage = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
448 this->hidden->gtkdrawingarea = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
449 return(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
450 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
451
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
452 gtk_window_set_title(GTK_WINDOW(this->hidden->gtkwindow), "");
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
453 gtk_widget_set_app_paintable(this->hidden->gtkwindow, TRUE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
454 gtk_widget_set_app_paintable(this->hidden->gtkdrawingarea, TRUE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
455 gtk_widget_set_double_buffered(this->hidden->gtkwindow, FALSE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
456 gtk_widget_set_double_buffered(this->hidden->gtkdrawingarea, FALSE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
457
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
458 GTKPLUS_ConnectSignals(this);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
459
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
460 gtk_container_add(GTK_CONTAINER(this->hidden->gtkwindow),
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
461 this->hidden->gtkdrawingarea);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
462 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
463
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
464 win = GTK_WINDOW(this->hidden->gtkwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
465 gtk_widget_set_colormap(this->hidden->gtkdrawingarea, this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
466
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
467 // !!! FIXME
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
468 #if 0
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
469 /* Cache the window in the server, when possible */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
470 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
471 Screen *xscreen;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
472 XSetWindowAttributes a;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
473
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
474 xscreen = ScreenOfDisplay(SDL_Display, SDL_Screen);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
475 a.backing_store = DoesBackingStore(xscreen);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
476 if ( a.backing_store != NotUseful ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
477 XChangeWindowAttributes(SDL_Display, SDL_Window,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
478 CWBackingStore, &a);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
479 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
480 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
481
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
482 /* Update the internal keyboard state */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
483 X11_SetKeyboardState(SDL_Display, NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
484
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
485 /* When the window is first mapped, ignore non-modifier keys */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
486 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
487 Uint8 *keys = SDL_GetKeyState(NULL);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
488 for ( i = 0; i < SDLK_LAST; ++i ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
489 switch (i) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
490 case SDLK_NUMLOCK:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
491 case SDLK_CAPSLOCK:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
492 case SDLK_LCTRL:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
493 case SDLK_RCTRL:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
494 case SDLK_LSHIFT:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
495 case SDLK_RSHIFT:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
496 case SDLK_LALT:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
497 case SDLK_RALT:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
498 case SDLK_LMETA:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
499 case SDLK_RMETA:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
500 case SDLK_MODE:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
501 break;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
502 default:
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
503 keys[i] = SDL_RELEASED;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
504 break;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
505 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
506 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
507 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
508
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
509 /* Map them both and go fullscreen, if requested */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
510 if ( ! SDL_windowid ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
511 XMapWindow(SDL_Display, SDL_Window);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
512 XMapWindow(SDL_Display, WMwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
513 X11_WaitMapped(this, WMwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
514 if ( flags & SDL_FULLSCREEN ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
515 current->flags |= SDL_FULLSCREEN;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
516 X11_EnterFullScreen(this);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
517 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
518 current->flags &= ~SDL_FULLSCREEN;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
519 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
520 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
521 #endif
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
522
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
523 if ((flags & SDL_FULLSCREEN) == 0) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
524 gtk_window_unfullscreen(win);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
525 } else {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
526 gtk_window_fullscreen(win);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
527 flags &= ~SDL_RESIZABLE;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
528 flags |= SDL_NOFRAME;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
529 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
530
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
531 gtk_window_set_resizable(win, (flags & SDL_RESIZABLE) ? TRUE : FALSE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
532 gtk_window_set_decorated(win, (flags & SDL_NOFRAME) ? FALSE : TRUE);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
533 gtk_window_resize(win, width, height);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
534 gtk_widget_set_size_request(this->hidden->gtkdrawingarea, width, height);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
535 gtk_widget_show(this->hidden->gtkdrawingarea);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
536 gtk_widget_show(this->hidden->gtkwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
537
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
538 /* Set up the new mode framebuffer */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
539 current->w = width;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
540 current->h = height;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
541 //current->format->depth = vis->bits_per_rgb;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
542 current->flags = flags | SDL_PREALLOC;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
543 current->pitch = img->bpl;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
544 current->pixels = this->hidden->gdkimage->mem;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
545
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
546 /* We're done */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
547 return(current);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
548 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
549
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
550 static void GTKPLUS_SetCaption(_THIS, const char *title, const char *icon)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
551 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
552 gtk_window_set_title(GTK_WINDOW(this->hidden->gtkwindow),
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
553 (const gchar *) title);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
554 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
555
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
556 /* We don't actually allow hardware surfaces. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
557 static int GTKPLUS_AllocHWSurface(_THIS, SDL_Surface *surface)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
558 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
559 return(-1);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
560 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
561
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
562 static void GTKPLUS_FreeHWSurface(_THIS, SDL_Surface *surface)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
563 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
564 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
565
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
566 /* We need to wait for vertical retrace on page flipped displays */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
567 static int GTKPLUS_LockHWSurface(_THIS, SDL_Surface *surface)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
568 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
569 return(0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
570 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
571
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
572 static void GTKPLUS_UnlockHWSurface(_THIS, SDL_Surface *surface)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
573 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
574 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
575
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
576 static void GTKPLUS_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
577 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
578 if ( (this->hidden->gtkdrawingarea != NULL) &&
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
579 (GTK_WIDGET_DRAWABLE(this->hidden->gtkdrawingarea)) &&
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
580 (numrects > 0) ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
581 GdkDrawable *draw = GDK_DRAWABLE(this->hidden->gtkdrawingarea->window);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
582 if (this->hidden->gc == NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
583 this->hidden->gc = gdk_gc_new(draw);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
584 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
585
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
586 if (this->hidden->gc != NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
587 GdkImage *img = this->hidden->gdkimage;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
588 const SDL_Rect *r = rects;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
589 int i;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
590 for (i = 0; i < numrects; i++, r++) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
591 const gint x = r->x;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
592 const gint y = r->y;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
593 gdk_draw_image(draw, this->hidden->gc, img,
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
594 x, y, x, y, r->w, r->h);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
595 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
596 gdk_flush(); /* transfer the GdkImage so we can make changes. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
597 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
598 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
599 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
600
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
601 int GTKPLUS_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
602 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
603 /* !!! FIXME */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
604 return(0);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
605 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
606
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
607 /* Note: If we are terminated, this could be called in the middle of
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
608 another SDL video routine -- notably UpdateRects.
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
609 */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
610 void GTKPLUS_VideoQuit(_THIS)
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
611 {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
612 int i;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
613
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
614 gdk_flush();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
615
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
616 if (this->hidden->gc != NULL) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
617 g_object_unref(this->hidden->gc);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
618 this->hidden->gc = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
619 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
620
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
621 if ( this->hidden->gtkwindow ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
622 /* this deletes the drawing area widget, too. */
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
623 gtk_widget_destroy(this->hidden->gtkwindow);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
624 this->hidden->gtkwindow = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
625 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
626
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
627 if ( this->hidden->gdkimage ) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
628 g_object_unref(this->hidden->gdkimage);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
629 this->hidden->gdkimage = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
630 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
631
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
632 for (i = 0; i < this->hidden->nvisuals; i++) {
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
633 g_object_unref(this->hidden->visuals[i]);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
634 this->hidden->visuals[i] = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
635 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
636 this->hidden->nvisuals = 0;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
637
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
638 g_object_unref(this->hidden->colormap);
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
639 this->hidden->colormap = NULL;
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
640
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
641 gdk_flush();
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
642 }
b8de86ee2ad6 First shot at GTK+ video target for the OLPC laptops. Seriously incomplete,
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
643