Hello.
Working on Qt/DirectFB code suggested me a couple of things about
DirectFB ( the port is beginning to work pretty well! give a look
at the latest screenshot at qt-directfb.sf.net ).
First, it could be nice if an app could find a window at (x,y), or could use
some window-manager like policies about size, etc ...
Some time ago someone was speaking about a window manager, isn't it?
Second, in DirectFB 0.9.19 there is a bug in the generic fbdev driver that
makes unusable the multi-app core.The bug does not affect the sdl
backend either the matrox driver. I will give a look as soon as i can...
Third, it could be nice that a window with alpha channel could decide of not
receiving mouse event where alpha = 0, with this shaped window can be
implemented in Qt and receive selected events. Al that can be realized with
the attached patch, that add the "DWOP_SHAPED" flag (to be used with
DWOP_ALPHACHANNEL)
Thanx
Maurizio Monge
diff -uNr DirectFB-0.9.19/include/directfb.h DirectFB-0.9.19-shaped/include/directfb.h
--- DirectFB-0.9.19/include/directfb.h 2003-07-14 18:04:24.000000000 +0200
+++ DirectFB-0.9.19-shaped/include/directfb.h 2003-07-28 07:06:45.000000000 +0200
@@ -2974,6 +2974,8 @@
window's alpha channel */
DWOP_OPAQUE_REGION = 0x00000004, /* overrides DWOP_ALPHACHANNEL for the
region set by SetOpaqueRegion() */
+ DWOP_SHAPED = 0x00000008, /* Do not send events if alpha==0, must
+ be used with DWOP_ALPHACHANNEL */
DWOP_KEEP_POSITION = 0x00000010, /* window can't be moved
with the mouse */
DWOP_KEEP_SIZE = 0x00000020, /* window can't be resized
@@ -2985,7 +2987,7 @@
implies DWOP_KEEP... */
DWOP_INDESTRUCTIBLE = 0x00002000, /* window can't be destroyed
by internal shortcut */
- DWOP_ALL = 0x00003077 /* all possible options */
+ DWOP_ALL = 0x0000307f /* all possible options */
} DFBWindowOptions;
/*
diff -uNr DirectFB-0.9.19/src/core/windows.c DirectFB-0.9.19-shaped/src/core/windows.c
--- DirectFB-0.9.19/src/core/windows.c 2003-07-11 16:56:31.000000000 +0200
+++ DirectFB-0.9.19-shaped/src/core/windows.c 2003-07-28 07:07:03.000000000 +0200
@@ -45,6 +45,7 @@
#include <core/state.h>
#include <core/system.h>
#include <core/windows.h>
+#include <core/palette.h>
#include <misc/conf.h>
#include <misc/util.h>
@@ -1666,7 +1667,63 @@
if (!(w->options & DWOP_GHOST) && w->opacity &&
x >= w->x && x < w->x+w->width &&
y >= w->y && y < w->y+w->height)
- return w;
+ {
+ if( ((w->options & (DWOP_ALPHACHANNEL|DWOP_SHAPED)) !=
+ (DWOP_ALPHACHANNEL|DWOP_SHAPED) )
+ || !w->surface || ( (w->options & DWOP_OPAQUE_REGION)
+ && x-w->x >= w->opaque.x1 && x-w->x <= w->opaque.x2 &&
+ y-w->y >= w->opaque.y1 && y-w->y <= w->opaque.y2 ) )
+ return w;
+
+ else
+ {
+ void *data = NULL;
+ int pitch;
+
+ if(dfb_surface_soft_lock(
+ w->surface, DSLF_READ, &data, &pitch, 0 ) == 0);
+ {
+ int alpha = 1;
+ switch(w->surface->format)
+ {
+ case DSPF_ARGB:
+ alpha = *(int*)((char*)data+
+ pitch*(y-w->y)+4*(x-w->x))
+ & 0xff000000;
+ break;
+ case DSPF_ARGB1555:
+ alpha = (int)(*(short*)((char*)data+
+ pitch*(y-w->y)+2*(x-w->x))
+ & 0x8000);
+ break;
+ case DSPF_ALUT44:
+ alpha = (int)(*((unsigned char*)data+
+ pitch*(y-w->y)+(x-w->x))
+ & 0xf0);
+ break;
+ case DSPF_LUT8:
+ {
+ unsigned char pix =
+ *((unsigned char*)data +
+ pitch*(y-w->y)+(x-w->x));
+ if( w->surface->palette &&
+ pix < w->surface->palette->num_entries)
+ alpha = 0xff000000 &
+ ((int*)w->surface->palette->entries)[pix];
+ }
+ break;
+ default:
+ break;
+ }
+ if( alpha )// alpha = 1 on error
+ {
+ dfb_surface_unlock( w->surface, 0 );
+ return w;
+ }
+ dfb_surface_unlock( w->surface, 0 );
+ }
+ }
+ }
}
return NULL;