changeset 433:706de3956894

Added initial support for PicoGUI (thanks Micah!)
author Sam Lantinga <slouken@libsdl.org>
date Thu, 01 Aug 2002 23:24:13 +0000
parents 80a35d43a58f
children ed58b98c0d9d
files Makefile.am README.PicoGUI configure.in docs.html src/video/Makefile.am src/video/SDL_sysvideo.h src/video/SDL_video.c src/video/picogui/.cvsignore src/video/picogui/Makefile.am src/video/picogui/SDL_pgevents.c src/video/picogui/SDL_pgevents_c.h src/video/picogui/SDL_pgvideo.c src/video/picogui/SDL_pgvideo.h
diffstat 13 files changed, 692 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.am	Thu Aug 01 23:08:41 2002 +0000
+++ b/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
@@ -30,6 +30,7 @@
 	README.MacOSX	\
 	README.MiNT	\
 	README.NanoX	\
+	README.PicoGUI	\
 	README.QNX	\
 	README.Qtopia	\
 	README.WinCE	\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.PicoGUI	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,50 @@
+ ========================
+  Using SDL with PicoGUI
+ ========================
+
+- Originally contributed by Micah Dowty <micahjd@users.sourceforge.net>
+
+PicoGUI is a scalable GUI system with a unique architecture, primarily focused
+on scalability to various embedded systems. You can find more information
+including a FAQ at http://picogui.org
+
+To use the patch:
+
+  1. When compiling, add the "--enable-video-picogui" switch to ./configure
+
+  2. When running your program, ensure that the picogui driver for SDL
+     is in use by setting the SDL_VIDEODRIVER environment variable 
+     to "picogui".
+
+  3. The program must also be linked to the C client library for PicoGUI
+     (libpgui.so). If the program is being compiled with a patched SDL 
+     installed this should be done automatically. If you want to use an
+     existing binary with PicoGUI, you can set the LD_PRELOAD environment
+     variable to the path of your libpgui.so file.
+
+Capabilities:
+
+  So far only basic functionality is provided on true color (linear16/24/32)
+  devices. Accessing a memory mapped bitmap, updating the display, and handling
+  mouse/keyboard input. This functionality has been tested with several
+  applications, including mplayer, Xine, sldroids, and Abuse.
+
+TODO list:
+
+  - YUV overlays will be helpful for watching video on set top boxes or other
+    embedded devices that have some graphics acceleration hardware
+
+  - Account for rotated bitmap storage in pgserver
+
+  - Support for hiding or changing the cursor
+
+  - The display should be centered when the SDL application is smaller
+    than the PicoGUI panel
+
+  - Fullscreen or any other special modes
+
+  - Support for indexed and grayscale modes
+
+  - Probably much more...
+
+--- The End ---
--- a/configure.in	Thu Aug 01 23:08:41 2002 +0000
+++ b/configure.in	Thu Aug 01 23:24:13 2002 +0000
@@ -1470,6 +1470,32 @@
     fi
 }
 
+dnl Set up the PicoGUI video driver if enabled
+CheckPicoGUI()
+{
+    AC_ARG_ENABLE(video-picogui,
+[  --enable-video-picogui  use PicoGUI video driver [default=no]],
+                  , enable_video_picogui=no)
+    if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
+        AC_MSG_CHECKING(for PicoGUI support)
+        video_picogui=no
+        AC_TRY_COMPILE([
+         #include <picogui.h>
+        ],[
+        ],[
+        video_picogui=yes
+        ])
+        AC_MSG_RESULT($video_picogui)
+        if test x$video_picogui = xyes; then
+	    SDL_LIBS="$SDL_LIBS -lpgui"
+            CFLAGS="$CFLAGS -DENABLE_PICOGUI"
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS picogui"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS picogui/libvideo_picogui.la"
+        fi
+        AC_LANG_C
+    fi
+}
+
 dnl Set up the Mac toolbox video driver for Mac OS 7-9
 CheckTOOLBOX()
 {
@@ -1676,6 +1702,7 @@
         CheckSVGA
         CheckAAlib
         CheckQtopia
+        CheckPicoGUI
         CheckOpenGL
         CheckInputEvents
         CheckPTHREAD
@@ -2602,6 +2629,7 @@
 src/video/xbios/Makefile
 src/video/gem/Makefile
 src/video/qtopia/Makefile
+src/video/picogui/Makefile
 src/events/Makefile
 src/joystick/Makefile
 src/joystick/amigaos/Makefile
--- a/docs.html	Thu Aug 01 23:08:41 2002 +0000
+++ b/docs.html	Thu Aug 01 23:24:13 2002 +0000
@@ -16,6 +16,7 @@
 Major changes since SDL 1.0.0:
 </H2>
 <UL>
+	<LI> 1.2.5: Added initial support for PicoGUI (thanks Micah!)
 	<LI> 1.2.5: Fixed SDL_DisplayFormatAlpha() on RGB surfaces with alpha
 	<LI> 1.2.5: Fixed setting OpenGL mode multiple times on Windows
 	<LI> 1.2.5: Added support for Qtopia on embedded systems (thanks David!)
--- a/src/video/Makefile.am	Thu Aug 01 23:08:41 2002 +0000
+++ b/src/video/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
@@ -8,7 +8,7 @@
 DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
                wincommon windib windx5 \
                maccommon macdsp macrom quartz \
-               bwindow ps2gs photon cybergfx epoc \
+               bwindow ps2gs photon cybergfx epoc picogui \
                ataricommon xbios gem XFree86
 
 DRIVERS = @VIDEO_DRIVERS@
--- a/src/video/SDL_sysvideo.h	Thu Aug 01 23:08:41 2002 +0000
+++ b/src/video/SDL_sysvideo.h	Thu Aug 01 23:24:13 2002 +0000
@@ -401,6 +401,9 @@
 #ifdef ENABLE_QTOPIA
 extern VideoBootStrap Qtopia_bootstrap;
 #endif
+#ifdef ENABLE_PICOGUI
+extern VideoBootStrap PG_bootstrap;
+#endif
 /* This is the current video device */
 extern SDL_VideoDevice *current_video;
 
--- a/src/video/SDL_video.c	Thu Aug 01 23:08:41 2002 +0000
+++ b/src/video/SDL_video.c	Thu Aug 01 23:24:13 2002 +0000
@@ -114,6 +114,9 @@
 #ifdef ENABLE_QTOPIA
 	&Qtopia_bootstrap,
 #endif
+#ifdef ENABLE_PICOGUI
+	&PG_bootstrap,
+#endif
 	NULL
 };
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/.cvsignore	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/Makefile.am	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,13 @@
+
+## Makefile.am for SDL using the PicoGUI video driver
+
+noinst_LTLIBRARIES = libvideo_picogui.la
+libvideo_picogui_la_SOURCES = $(PICOGUI_SRCS)
+
+# The SDL PicoGUI video driver sources
+PICOGUI_SRCS = 			\
+	SDL_pgevents.c		\
+	SDL_pgevents_c.h	\
+	SDL_pgvideo.c		\
+	SDL_pgvideo.h
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/SDL_pgevents.c	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,121 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+
+    Micah Dowty
+    micahjd@users.sourceforge.net
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_pgvideo.h"
+#include "SDL_pgevents_c.h"
+
+int PG_HandleClose(struct pgEvent *evt)
+{
+        SDL_PrivateQuit();
+	return 1;               /* Intercept the event's normal quit handling */
+}
+
+int PG_HandleResize(struct pgEvent *evt)
+{
+        SDL_PrivateResize(evt->e.size.w, evt->e.size.h);
+	return 0;
+}
+
+int PG_HandleKey(struct pgEvent *evt)
+{
+        SDL_keysym sym;
+	memset(&sym,0,sizeof(sym));
+	sym.sym = evt->e.kbd.key;
+	sym.mod = evt->e.kbd.mods;
+        SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
+	return 0;
+}
+
+int PG_HandleChar(struct pgEvent *evt)
+{
+        SDL_keysym sym;
+	memset(&sym,0,sizeof(sym));
+	sym.unicode = evt->e.kbd.key;
+	sym.mod = evt->e.kbd.mods;
+        SDL_PrivateKeyboard(evt->type == PG_WE_KBD_KEYDOWN, &sym);
+	return 0;
+}
+
+int PG_HandleMouseButton(struct pgEvent *evt)
+{        
+        /* We need to focus the canvas when it's clicked */
+        if (evt->extra) {
+	        SDL_VideoDevice *this = (SDL_VideoDevice *) evt->extra;
+		pgFocus(this->hidden->wCanvas);
+	}
+        SDL_PrivateMouseButton(evt->type == PG_WE_PNTR_DOWN, evt->e.pntr.chbtn,
+			       evt->e.pntr.x, evt->e.pntr.y);
+	return 0;
+}
+
+int PG_HandleMouseMotion(struct pgEvent *evt)
+{
+        SDL_PrivateMouseMotion(evt->e.pntr.btn,0,evt->e.pntr.x, evt->e.pntr.y);
+	return 0;
+}
+
+void PG_PumpEvents(_THIS)
+{
+        /* Process all pending events */
+        pgEventPoll();
+}
+
+void PG_InitOSKeymap(_THIS)
+{
+        /* We need no keymap */
+}
+
+void PG_InitEvents(_THIS)
+{
+        /* Turn on all the mouse and keyboard triggers for our canvas, normally less important
+	 * events like mouse movement are ignored to save bandwidth. */
+        pgSetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK, 
+		    pgGetWidget(this->hidden->wCanvas, PG_WP_TRIGGERMASK) |
+		    PG_TRIGGER_UP | PG_TRIGGER_DOWN | PG_TRIGGER_MOVE |
+		    PG_TRIGGER_KEYUP | PG_TRIGGER_KEYDOWN | PG_TRIGGER_CHAR,0);
+
+	/* Start our canvas out focused, so we get keyboard input */
+	pgFocus(this->hidden->wCanvas);
+
+        /* Set up bindings for all the above event handlers */
+        pgBind(this->hidden->wApp,    PG_WE_CLOSE, &PG_HandleClose, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_BUILD, &PG_HandleResize, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_KBD_CHAR, &PG_HandleChar, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYUP, &PG_HandleKey, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_KBD_KEYDOWN, &PG_HandleKey, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_PNTR_MOVE, &PG_HandleMouseMotion, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_PNTR_UP, &PG_HandleMouseButton, NULL);
+        pgBind(this->hidden->wCanvas, PG_WE_PNTR_DOWN, &PG_HandleMouseButton, this);
+}
+
+/* end of SDL_pgevents.c ... */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/SDL_pgevents_c.h	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+
+    Micah Dowty
+    micahjd@users.sourceforge.net
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_pgvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern void PG_PumpEvents(_THIS);
+extern void PG_InitEvents(_THIS);
+extern void PG_InitOSKeymap(_THIS);
+
+/* end of SDL_pgevents_c.h ... */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/SDL_pgvideo.c	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,370 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+
+    Micah Dowty
+    micahjd@users.sourceforge.net
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+
+#include "SDL_pgvideo.h"
+#include "SDL_pgevents_c.h"
+
+#define PGVID_DRIVER_NAME "picogui"
+
+/* Initialization/Query functions */
+static int PG_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void PG_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int PG_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int PG_LockHWSurface(_THIS, SDL_Surface *surface);
+static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void PG_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* etc. */
+static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
+
+// The implementation dependent data for the window manager cursor
+struct WMcursor {
+  /* Our cursor is a PicoGUI theme */
+  pghandle theme;
+} ;
+
+/* WM functions */
+void PG_SetCaption(_THIS, const char *title, const char *icon);
+WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask, 
+			      int w, int h, int hot_x, int hot_y);
+void PG_FreeWMCursor (_THIS, WMcursor * cursor);
+void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+int PG_ShowWMCursor (_THIS, WMcursor * cursor);
+
+/* PicoGUI driver bootstrap functions */
+
+static int PG_Available(void)
+{
+        /* FIXME: The current client lib doesn't give a way to see if the picogui
+	 *        server is reachable without causing a fatal error if it isn't.
+	 *        This should be fixed in cli_c2, but until then assume we can
+	 *        connect. Since more common drivers like X11 are probed first anyway,
+	 *        this shouldn't be a huge problem.
+	 */
+	return(1);
+}
+
+static void PG_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *PG_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = PG_VideoInit;
+	device->ListModes = PG_ListModes;
+	device->SetVideoMode = PG_SetVideoMode;
+	device->CreateYUVOverlay = NULL;
+	device->SetColors = PG_SetColors;
+	device->UpdateRects = PG_UpdateRects;
+	device->VideoQuit = PG_VideoQuit;
+	device->AllocHWSurface = PG_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = PG_LockHWSurface;
+	device->UnlockHWSurface = PG_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = PG_FreeHWSurface;
+	device->SetCaption = PG_SetCaption;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+
+	device->PumpEvents = PG_PumpEvents;
+	device->InitOSKeymap = PG_InitOSKeymap;
+
+	device->ShowWMCursor = PG_ShowWMCursor;
+	device->CreateWMCursor = PG_CreateWMCursor;
+	device->FreeWMCursor = PG_FreeWMCursor;
+	device->WarpWMCursor = PG_WarpWMCursor;
+
+	device->free = PG_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap PG_bootstrap = {
+	PGVID_DRIVER_NAME, "PicoGUI SDL driver",
+	PG_Available, PG_CreateDevice
+};
+
+
+int PG_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+        /* Connect to the PicoGUI server. No way to process command line args yet,
+	 * but since this is based on SHM it's not important to be able to specify
+	 * a remote PicoGUI server.
+	 *
+	 * FIXME: Another nitpick about the current client lib is there's no
+	 *        clean way to indicate that command line args are not available.
+	 */
+        pgInit(0,(char**)"");
+	this->hidden->mi = *pgGetVideoMode();
+
+	/* Create a picogui application and canvas. We'll populate the canvas later. */
+	this->hidden->wApp = pgRegisterApp(PG_APP_NORMAL,"SDL",0);
+	this->hidden->wCanvas = pgNewWidget(PG_WIDGET_CANVAS,0,0);
+	pgSetWidget(PGDEFAULT,
+		    PG_WP_SIDE, PG_S_ALL,
+		    0);
+
+	PG_InitEvents(this);
+
+	/* Determine the screen depth.
+	 * We change this during the SDL_SetVideoMode implementation... 
+	 * Round up to the nearest Bytes per pixel
+	 */
+	vformat->BitsPerPixel = this->hidden->mi.bpp;
+	vformat->BytesPerPixel = this->hidden->mi.bpp >> 3;
+	if (this->hidden->mi.bpp & 7)
+	  vformat->BytesPerPixel++;
+
+	/* We're done! */
+	return(0);
+}
+
+SDL_Rect **PG_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+   	 return (SDL_Rect **) -1;
+}
+
+SDL_Surface *PG_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	if ( this->hidden->bitmap ) {
+	  /* Free old bitmap */
+	  if (current->pixels) {
+	    shmdt(current->pixels);
+	    current->pixels = NULL;
+	  }
+	  pgDelete(this->hidden->bitmap);
+	}
+
+	/* Allocate the new pixel format for the screen */
+	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
+		SDL_SetError("Couldn't allocate new pixel format for requested mode");
+		return(NULL);
+	}
+
+	/* Create a new picogui bitmap */
+	this->hidden->bitmap = pgCreateBitmap(width,height);
+	this->hidden->shm = *pgMakeSHMBitmap(this->hidden->bitmap);
+	current->pixels = shmat(shmget(this->hidden->shm.shm_key,
+				       this->hidden->shm.shm_length,0),NULL,0);
+
+	/* Reset the canvas, and draw persistent and incremental grops.
+	 * Use mapping and offsets to center it.
+	 */
+
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_NUKE, 0);
+
+	/* 0. Set the source position during incremental rendering
+	 */
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 5, PG_GROP_SETSRC,0,0,0,0);
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
+
+	/* 1. Incremental bitmap rendering
+	 */
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
+		   0,0,0,0,this->hidden->bitmap);
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROPFLAGS, 1, PG_GROPF_INCREMENTAL);
+
+	/* 2. Normal bitmap rendering
+	 */
+	pgWriteCmd(this->hidden->wCanvas, PGCANVAS_GROP, 6, PG_GROP_BITMAP,
+		   0,0,this->hidden->shm.width,this->hidden->shm.height,this->hidden->bitmap);
+     
+	/* Set up the new mode framebuffer */
+	current->flags = 0;
+	current->w = this->hidden->shm.width;
+	current->h = this->hidden->shm.height;
+	current->pitch = this->hidden->shm.pitch;
+
+	/* Set up pixel format */
+	current->format->BitsPerPixel = this->hidden->shm.bpp;
+	current->format->BytesPerPixel = this->hidden->shm.bpp >> 3;
+	if (this->hidden->shm.bpp & 7)
+	  current->format->BytesPerPixel++;
+	current->format->palette = NULL;
+	current->format->Rmask = this->hidden->shm.red_mask;
+	current->format->Gmask = this->hidden->shm.green_mask;
+	current->format->Bmask = this->hidden->shm.blue_mask;
+	current->format->Amask = this->hidden->shm.alpha_mask;
+	current->format->Rshift = this->hidden->shm.red_shift;
+	current->format->Gshift = this->hidden->shm.green_shift;
+	current->format->Bshift = this->hidden->shm.blue_shift;
+	current->format->Ashift = this->hidden->shm.alpha_shift;
+	current->format->Rloss = 8 - this->hidden->shm.red_length;
+	current->format->Gloss = 8 - this->hidden->shm.green_length;
+	current->format->Bloss = 8 - this->hidden->shm.blue_length;
+	current->format->Aloss = 8 - this->hidden->shm.alpha_length;
+
+	/* Draw the app */
+	pgUpdate();
+
+	/* We're done */
+	return(current);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int PG_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void PG_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int PG_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+
+static void PG_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+static void PG_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
+{
+        int i;
+	
+	for (i = 0; i < numrects; i++) {
+	        if (rects[i].w <= 0 || rects[i].h <= 0)
+		  continue;
+
+		/* Schedule an incremental update for this rectangle, using
+		 * the canvas gropnodes we've loaded beforehand.
+		 */
+		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 0);
+		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
+			   rects[i].x, rects[i].y,
+			   rects[i].w, rects[i].h);
+		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_FINDGROP, 1, 1);
+		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_MOVEGROP, 4, 
+			   rects[i].x, rects[i].y,
+			   rects[i].w, rects[i].h);
+		
+		/* Go perform the update */
+		pgWriteCmd(this->hidden->wCanvas, PGCANVAS_INCREMENTAL, 0);
+		pgSubUpdate(this->hidden->wCanvas);
+	}
+}
+
+int PG_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	/* do nothing of note. */
+	return(1);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+void PG_VideoQuit(_THIS)
+{
+	if (this->screen->pixels != NULL)
+	{
+		shmdt(this->screen->pixels);
+		this->screen->pixels = NULL;
+		pgDelete(this->hidden->bitmap);
+	}
+	pgDelete(this->hidden->wCanvas);
+	pgDelete(this->hidden->wApp);
+}
+
+void PG_SetCaption(_THIS, const char *title, const char *icon)
+{
+        if (title != NULL)
+	  pgReplaceText(this->hidden->wApp, title);
+	pgUpdate();
+}
+
+/* FIXME: The cursor stuff isn't implemented yet! */
+
+WMcursor * PG_CreateWMCursor (_THIS,Uint8 * data, Uint8 * mask, 
+			      int w, int h, int hot_x, int hot_y)
+{
+        static WMcursor dummy;
+        return &dummy;
+}
+
+void PG_FreeWMCursor (_THIS, WMcursor * cursor)
+{
+}
+
+void PG_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+}
+
+int PG_ShowWMCursor (_THIS, WMcursor * cursor)
+{
+        return 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/picogui/SDL_pgvideo.h	Thu Aug 01 23:24:13 2002 +0000
@@ -0,0 +1,54 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+
+    Micah Dowty
+    micahjd@users.sourceforge.net
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_pgvideo_h
+#define _SDL_pgvideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_mutex.h"
+
+#include <picogui.h>
+#include <sys/shm.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+
+/* Private display data */
+
+struct SDL_PrivateVideoData {
+  pghandle wApp, wCanvas;        /* PicoGUI widgets */
+  pghandle bitmap;
+  struct pgshmbitmap shm;        /* shared memory info */
+  struct pgmodeinfo mi;          /* PicoGUI video mode info structure */
+};
+
+#endif /* _SDL_pgvideo_h */