# HG changeset patch
# User Sam Lantinga <slouken@libsdl.org>
# Date 1014734333 0
# Node ID 3ea69fd0b095ea9f80f7b6f3e53e863ac01709b6
# Parent  e5a489f0288c48abbff59201349f0f598800b145
Updated for DirectFB 0.9.9

diff -r e5a489f0288c -r 3ea69fd0b095 configure.in
--- a/configure.in	Fri Feb 22 17:39:11 2002 +0000
+++ b/configure.in	Tue Feb 26 14:38:53 2002 +0000
@@ -748,7 +748,7 @@
                 AC_MSG_ERROR([*** pkg-config too old; version 0.5 or better required.])
             fi
 
-            DIRECTFB_REQUIRED_VERSION=0.9.8
+            DIRECTFB_REQUIRED_VERSION=0.9.9
 
             if $PKG_CONFIG --atleast-version $DIRECTFB_REQUIRED_VERSION directfb ; then
                 DIRECTFB_CFLAGS=`$PKG_CONFIG --cflags directfb`
diff -r e5a489f0288c -r 3ea69fd0b095 src/video/directfb/SDL_DirectFB_events.c
--- a/src/video/directfb/SDL_DirectFB_events.c	Fri Feb 22 17:39:11 2002 +0000
+++ b/src/video/directfb/SDL_DirectFB_events.c	Tue Feb 26 14:38:53 2002 +0000
@@ -56,7 +56,8 @@
 {
   DFBInputEvent evt;
 
-  while (HIDDEN->inputbuffer->GetEvent (HIDDEN->inputbuffer, &evt) == DFB_OK)
+  while (HIDDEN->eventbuffer->GetEvent (HIDDEN->eventbuffer,
+                                        DFB_EVENT (&evt)) == DFB_OK)
     {
       SDL_keysym keysym;
 
diff -r e5a489f0288c -r 3ea69fd0b095 src/video/directfb/SDL_DirectFB_video.c
--- a/src/video/directfb/SDL_DirectFB_video.c	Fri Feb 22 17:39:11 2002 +0000
+++ b/src/video/directfb/SDL_DirectFB_video.c	Tue Feb 26 14:38:53 2002 +0000
@@ -304,7 +304,7 @@
   DFBCardCapabilities    caps;
   IDirectFBDisplayLayer *layer;
   DFBDisplayLayerConfig  dlc;
-  IDirectFBInputBuffer  *inputbuffer;
+  IDirectFBEventBuffer  *eventbuffer;
 
 
   ret = DirectFBInit (NULL, NULL);
@@ -329,11 +329,10 @@
       return -1;
     }
 
-  ret = dfb->CreateInputBuffer (dfb, DICAPS_BUTTONS | DICAPS_AXIS | DICAPS_KEYS,
-                                &inputbuffer);
+  ret = dfb->CreateEventBuffer (dfb, DICAPS_ALL, &eventbuffer);
   if (ret)
     {
-      SetDirectFBerror ("dfb->CreateInputBuffer", ret);
+      SetDirectFBerror ("dfb->CreateEventBuffer", ret);
       layer->Release (layer);
       dfb->Release (dfb);
       return -1;
@@ -395,7 +394,7 @@
   HIDDEN->initialized = 1;
   HIDDEN->dfb         = dfb;
   HIDDEN->layer       = layer;
-  HIDDEN->inputbuffer = inputbuffer;
+  HIDDEN->eventbuffer = eventbuffer;
 
   return 0;
 }
@@ -691,34 +690,48 @@
 
 static void DirectFB_WindowedUpdate(_THIS, int numrects, SDL_Rect *rects)
 {
+  DFBRegion         region;
+  int               i;
+  int               region_valid = 0;
   IDirectFBSurface *surface = this->screen->hwdata->surface;
-  DFBRegion region = { rects->x, rects->y,
-                       rects->x + rects->w - 1,
-                       rects->y + rects->h - 1 };
 
-  while (--numrects)
+  for (i=0; i<numrects; ++i)
     {
       int x2, y2;
 
-      rects++;
+      if ( ! rects[i].w ) /* Clipped? */
+        continue;
+
+      x2 = rects[i].x + rects[i].w - 1;
+      y2 = rects[i].y + rects[i].h - 1;
 
-      if (rects->x < region.x1)
-        region.x1 = rects->x;
+      if (region_valid)
+        {
+          if (rects[i].x < region.x1)
+            region.x1 = rects[i].x;
 
-      if (rects->y < region.y1)
-        region.y1 = rects->y;
+          if (rects[i].y < region.y1)
+            region.y1 = rects[i].y;
 
-      x2 = rects->x + rects->w - 1;
-      y2 = rects->y + rects->h - 1;
+          if (x2 > region.x2)
+            region.x2 = x2;
 
-      if (x2 > region.x2)
-        region.x2 = x2;
+          if (y2 > region.y2)
+            region.y2 = y2;
+        }
+      else
+        {
+            region.x1 = rects[i].x;
+            region.y1 = rects[i].y;
+            region.x2 = x2;
+            region.y2 = y2;
 
-      if (y2 > region.y2)
-        region.y2 = y2;
+            region_valid = 1;
+        }
     }
 
-  surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
+  if (region_valid)
+    surface->Flip (surface, &region, DSFLIP_WAITFORSYNC);
 }
 
 int DirectFB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
@@ -731,7 +744,7 @@
 {
   int i, j;
 
-  HIDDEN->inputbuffer->Release (HIDDEN->inputbuffer);
+  HIDDEN->eventbuffer->Release (HIDDEN->eventbuffer);
   HIDDEN->layer->Release (HIDDEN->layer);
   HIDDEN->dfb->Release (HIDDEN->dfb);
 
diff -r e5a489f0288c -r 3ea69fd0b095 src/video/directfb/SDL_DirectFB_video.h
--- a/src/video/directfb/SDL_DirectFB_video.h	Fri Feb 22 17:39:11 2002 +0000
+++ b/src/video/directfb/SDL_DirectFB_video.h	Tue Feb 26 14:38:53 2002 +0000
@@ -43,7 +43,7 @@
 
   IDirectFB             *dfb;
   IDirectFBDisplayLayer *layer;
-  IDirectFBInputBuffer  *inputbuffer;
+  IDirectFBEventBuffer  *eventbuffer;
 
 #define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
   int SDL_nummodes[NUM_MODELISTS];