Hi all I've been working on a new window manager for directfb based on metacity.
And also looked deeply at the current implementation. My conclusion
was that we needed to
add the concept of insets to make it easy to support borders. This
approach seems far simpler
to the current ones. Also in the case that the wm does not want to use
insets it has little impact on the implementation.
? core/windows.c.modified
? core/wm.c.modified
? core/wm.h.modified
? core/wm_module.h.modified
? display/idirectfbsurface_window.c.modified
Index: core/windows.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/windows.c,v
retrieving revision 1.219
diff -u -r1.219 windows.c
--- core/windows.c	29 Oct 2005 00:41:00 -0000	1.219
+++ core/windows.c	9 Jun 2006 20:00:20 -0000
@@ -270,6 +270,46 @@
      context = stack->context;
      layer   = dfb_layer_at( context->layer_id );
 
+     memset( &config, 0, sizeof(CoreWindowConfig) );
+
+     config.bounds.x = x;
+     config.bounds.y = y;
+     config.bounds.w = width;
+     config.bounds.h = height;
+
+     config.events   = DWET_ALL;
+
+
+     /* Create the window object. */
+     window = dfb_core_create_window( layer->core );
+
+     window->id     = ++stack->id_pool;
+     window->caps   = caps;
+     window->stack  = stack;
+     window->config = config;
+
+	 ret = dfb_wm_preconfigure_window(stack,window);
+
+	 if(ret) {
+          fusion_object_destroy( &window->object );
+          dfb_windowstack_unlock( stack );
+          return ret;
+	 }
+
+	 /*wm may have changed values */
+	 config = window->config;
+     x = config.bounds.x;
+     y = config.bounds.y;
+     width = config.bounds.w;
+     height = config.bounds.h;
+	 caps = window->caps;
+
+     /* Auto enable blending for ARGB only, not LUT8. */
+     if ((caps & DWCAPS_ALPHACHANNEL) &&
+         DFB_PIXELFORMAT_HAS_ALPHA(pixelformat) && pixelformat != DSPF_LUT8)
+          config.options |= DWOP_ALPHACHANNEL;
+
+
      surface_caps &= DSCAPS_INTERLACED | DSCAPS_SEPARATED | DSCAPS_PREMULTIPLIED |
                      DSCAPS_DEPTH | DSCAPS_STATIC_ALLOC | DSCAPS_SYSTEMONLY | DSCAPS_VIDEOONLY;
 
@@ -347,28 +387,6 @@
      if (caps & DWCAPS_DOUBLEBUFFER)
           surface_caps |= DSCAPS_DOUBLE;
 
-     memset( &config, 0, sizeof(CoreWindowConfig) );
-
-     config.bounds.x = x;
-     config.bounds.y = y;
-     config.bounds.w = width;
-     config.bounds.h = height;
-
-     config.events   = DWET_ALL;
-
-     /* Auto enable blending for ARGB only, not LUT8. */
-     if ((caps & DWCAPS_ALPHACHANNEL) &&
-         DFB_PIXELFORMAT_HAS_ALPHA(pixelformat) && pixelformat != DSPF_LUT8)
-          config.options |= DWOP_ALPHACHANNEL;
-
-     /* Create the window object. */
-     window = dfb_core_create_window( layer->core );
-
-     window->id     = ++stack->id_pool;
-     window->caps   = caps;
-     window->stack  = stack;
-     window->config = config;
-
      /* Create the window's surface using the layer's palette if possible. */
      if (! (caps & DWCAPS_INPUTONLY)) {
           if (context->config.buffermode == DLBM_WINDOWS) {
Index: core/wm.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/wm.c,v
retrieving revision 1.9
diff -u -r1.9 wm.c
--- core/wm.c	9 Dec 2005 14:59:31 -0000	1.9
+++ core/wm.c	9 Jun 2006 20:00:21 -0000
@@ -547,21 +547,37 @@
      return wm_local->funcs->WarpCursor( stack, wm_local->data, stack->stack_data, x, y );
 }
 
+
+/**
+ * Give the wm a chance to specifiy a border
+ */
 DFBResult
-dfb_wm_add_window( CoreWindowStack *stack,
-                   CoreWindow      *window )
+dfb_wm_get_insets( CoreWindowStack  *stack,
+					CoreWindow      *window,
+                    DFBInsets       *insets)
+{
+     D_ASSERT( wm_local != NULL );
+     D_ASSERT( wm_local->funcs != NULL );
+     D_ASSERT( wm_local->funcs->GetInsets != NULL );
+
+     D_ASSERT( stack != NULL );
+
+     return wm_local->funcs->GetInsets(stack,window,insets);
+}
+/**
+ Give the wm a chance to override the windows configuration 
+**/
+DFBResult
+dfb_wm_preconfigure_window( CoreWindowStack *stack,CoreWindow *window )
 {
      DFBResult  ret;
      void      *window_data = NULL;
 
      D_ASSERT( wm_local != NULL );
      D_ASSERT( wm_local->funcs != NULL );
-     D_ASSERT( wm_local->funcs->AddWindow != NULL );
      D_ASSERT( wm_shared != NULL );
-
-     D_ASSERT( stack != NULL );
-
      D_ASSERT( window != NULL );
+	 D_ASSERT( wm_local->funcs->PreConfigureWindow != NULL );
 
      /* Allocate shared window data. */
      if (wm_shared->info.window_data_size) {
@@ -571,9 +587,8 @@
                return D_OOSHM();
           }
      }
-
      /* Tell window manager about the new window. */
-     ret = wm_local->funcs->AddWindow( stack, wm_local->data,
+     ret = wm_local->funcs->PreConfigureWindow( stack, wm_local->data,
                                        stack->stack_data, window, window_data );
      if (ret) {
           if (window_data)
@@ -588,6 +603,32 @@
 }
 
 DFBResult
+dfb_wm_add_window( CoreWindowStack *stack,
+                   CoreWindow      *window )
+{
+     DFBResult  ret;
+     D_ASSERT( wm_local != NULL );
+     D_ASSERT( wm_local->funcs != NULL );
+     D_ASSERT( wm_local->funcs->AddWindow != NULL );
+     D_ASSERT( wm_shared != NULL );
+
+     D_ASSERT( stack != NULL );
+
+     D_ASSERT( window != NULL );
+
+
+     /* Tell window manager about the new window. */
+     ret = wm_local->funcs->AddWindow( stack, wm_local->data,
+                                       stack->stack_data, window, window->window_data );
+     if (ret) {
+          if (window->window_data)
+               SHFREE( wm_shared->shmpool, window->window_data );
+          return ret;
+     }
+     return DFB_OK;
+}
+
+DFBResult
 dfb_wm_remove_window( CoreWindowStack *stack,
                       CoreWindow      *window )
 {
Index: core/wm.h
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/wm.h,v
retrieving revision 1.8
diff -u -r1.8 wm.h
--- core/wm.h	9 Nov 2004 04:47:40 -0000	1.8
+++ core/wm.h	9 Jun 2006 20:00:21 -0000
@@ -174,6 +174,15 @@
 
 
    /** Window **/
+     DFBResult (*GetInsets)   ( CoreWindowStack        *stack,
+                                     CoreWindow        *window,
+                                     DFBInsets         *insets );
+
+     DFBResult (*PreConfigureWindow)   ( CoreWindowStack        *stack,
+                                     void                   *wm_data,
+                                     void                   *stack_data,
+                                     CoreWindow             *window,
+                                     void                   *window_data );
 
      DFBResult (*AddWindow)        ( CoreWindowStack        *stack,
                                      void                   *wm_data,
@@ -268,6 +277,11 @@
                                  int                     x,
                                  int                     y );
 
+DFBResult dfb_wm_preconfigure_window    ( CoreWindowStack        *stack,
+                                 CoreWindow             *window );
+
+DFBResult dfb_wm_get_insets ( CoreWindowStack        *stack,
+                                 CoreWindow             *window,DFBInsets *insets );
 
 DFBResult dfb_wm_add_window    ( CoreWindowStack        *stack,
                                  CoreWindow             *window );
Index: core/wm_module.h
===================================================================
RCS file: /cvs/directfb/DirectFB/src/core/wm_module.h,v
retrieving revision 1.6
diff -u -r1.6 wm_module.h
--- core/wm_module.h	7 Nov 2004 09:15:21 -0000	1.6
+++ core/wm_module.h	9 Jun 2006 20:00:21 -0000
@@ -115,6 +115,16 @@
 
 /** Window **/
 
+static DFBResult wm_get_insets     ( CoreWindowStack        *stack,
+                                     CoreWindow             *window,
+                                     DFBInsets              *insets );
+
+static DFBResult wm_preconfigure_window     ( CoreWindowStack        *stack,
+                                     void                   *wm_data,
+                                     void                   *stack_data,
+                                     CoreWindow             *window,
+                                     void                   *window_data );
+
 static DFBResult wm_add_window     ( CoreWindowStack        *stack,
                                      void                   *wm_data,
                                      void                   *stack_data,
@@ -190,6 +200,8 @@
      EnumWindows:         wm_enum_windows,
      WarpCursor:          wm_warp_cursor,
 
+     GetInsets:     	  wm_get_insets,
+     PreConfigureWindow:     wm_preconfigure_window,
      AddWindow:           wm_add_window,
      RemoveWindow:        wm_remove_window,
      SetWindowConfig:     wm_set_window_config,
Index: display/idirectfbsurface_window.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/display/idirectfbsurface_window.c,v
retrieving revision 1.51
diff -u -r1.51 idirectfbsurface_window.c
--- display/idirectfbsurface_window.c	28 Dec 2005 02:23:55 -0000	1.51
+++ display/idirectfbsurface_window.c	9 Jun 2006 20:00:21 -0000
@@ -44,6 +44,7 @@
 #include "core/state.h"
 #include "core/surfaces.h"
 #include "core/windows.h"
+#include "core/wm.h"
 #include "core/windows_internal.h" /* FIXME */
 
 #include "idirectfbsurface.h"
@@ -235,11 +236,30 @@
                                    DFBSurfaceCapabilities  caps )
 {
      DFBResult ret;
+	 DFBInsets insets;
+	 CoreWindowStack *stack;
+
+	 dfb_wm_get_insets(window->stack,window,&insets);
+
+	 if( insets.l != 0 || insets.t != 0 || insets.r != 0  || insets.b != 0 ) {
+		if ( !wanted ) {
+			DFBRectangle rect = { 0, 0, window->surface->width, 
+									window->surface->height };
+			wanted =▭
+		    wanted->w -=insets.l+insets.r;
+		    wanted->h -=insets.t+insets.b;
+
+		}
+		wanted->x +=insets.l;
+		wanted->y +=insets.t;
+		if( granted )
+			*granted = *wanted;
+		caps |= DSCAPS_SUBSURFACE;
+	 }
 
      DIRECT_ALLOCATE_INTERFACE_DATA(thiz, IDirectFBSurface_Window)
 
      D_DEBUG_AT( Surface, "%s( %p )\n", __FUNCTION__, thiz );
-
      ret = IDirectFBSurface_Construct( thiz, wanted, granted,
                                        window->surface, caps );
      if (ret)
@@ -265,7 +285,6 @@
      thiz->Release = IDirectFBSurface_Window_Release;
      thiz->Flip = IDirectFBSurface_Window_Flip;
      thiz->GetSubSurface = IDirectFBSurface_Window_GetSubSurface;
-
      return DFB_OK;
 }
 
Index: windows/idirectfbwindow.c
===================================================================
RCS file: /cvs/directfb/DirectFB/src/windows/idirectfbwindow.c,v
retrieving revision 1.84
diff -u -r1.84 idirectfbwindow.c
--- windows/idirectfbwindow.c	18 Mar 2005 23:30:31 -0000	1.84
+++ windows/idirectfbwindow.c	9 Jun 2006 20:00:22 -0000
@@ -52,6 +52,7 @@
 #include <core/state.h>
 #include <core/surfaces.h>
 #include <core/windows.h>
+#include <core/wm.h>
 #include <core/windowstack.h>
 #include <core/windows_internal.h> /* FIXME */
 
@@ -249,19 +250,23 @@
                              int             *x,
                              int             *y )
 {
+     DFBInsets insets;
      DIRECT_INTERFACE_GET_DATA(IDirectFBWindow)
 
+
      if (data->destroyed)
           return DFB_DESTROYED;
 
      if (!x && !y)
           return DFB_INVARG;
 
+     dfb_wm_get_insets(data->window->stack,data->window,&insets);
+
      if (x)
-          *x = data->window->config.bounds.x;
+          *x = data->window->config.bounds.x-insets.l;
 
      if (y)
-          *y = data->window->config.bounds.y;
+          *y = data->window->config.bounds.y-insets.t;
 
      return DFB_OK;
 }
@@ -271,6 +276,7 @@
                          int             *width,
                          int             *height )
 {
+     DFBInsets insets;
      DIRECT_INTERFACE_GET_DATA(IDirectFBWindow)
 
      if (data->destroyed)
@@ -278,12 +284,13 @@
 
      if (!width && !height)
           return DFB_INVARG;
+     dfb_wm_get_insets(data->window->stack,data->window,&insets);
 
      if (width)
-          *width = data->window->config.bounds.w;
+          *width = data->window->config.bounds.w-insets.l-insets.r;
 
      if (height)
-          *height = data->window->config.bounds.h;
+          *height = data->window->config.bounds.h-insets.t-insets.b;
 
      return DFB_OK;
 }
@@ -610,11 +617,15 @@
 static DFBResult
 IDirectFBWindow_MoveTo( IDirectFBWindow *thiz, int x, int y )
 {
+     DFBInsets insets;
      DIRECT_INTERFACE_GET_DATA(IDirectFBWindow)
 
      if (data->destroyed)
           return DFB_DESTROYED;
 
+     dfb_wm_get_insets(data->window->stack,data->window,&insets);
+     x +=insets.l;
+     y +=insets.t;
      return dfb_window_move( data->window, x, y, false );
 }
 
@@ -623,6 +634,7 @@
                         int              width,
                         int              height )
 {
+     DFBInsets insets;
      DIRECT_INTERFACE_GET_DATA(IDirectFBWindow)
 
      if (data->destroyed)
@@ -630,7 +642,9 @@
 
      if (width < 1 || width > 4096 || height < 1 || height > 4096)
           return DFB_INVARG;
-
+     dfb_wm_get_insets(data->window->stack,data->window,&insets);
+     width  +=insets.l+insets.r;
+     height +=insets.t+insets.b;
      return dfb_window_resize( data->window, width, height );
 }
 
_______________________________________________
directfb-dev mailing list
[email protected]
http://mail.directfb.org/cgi-bin/mailman/listinfo/directfb-dev

Reply via email to