Alexandre Julliard : winex11: Apply the existing window region (if any) when creating the whole window.

Alexandre Julliard julliard at winehq.org
Wed Jan 23 14:36:45 CST 2008


Module: wine
Branch: master
Commit: 395928dfb17a1e73a1d11acbdd27deecd48655d6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=395928dfb17a1e73a1d11acbdd27deecd48655d6

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Jan 23 16:30:18 2008 +0100

winex11: Apply the existing window region (if any) when creating the whole window.

Move X11DRV_SetWindowRgn to window.c.

---

 dlls/winex11.drv/window.c |   71 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/winex11.drv/winpos.c |   56 -----------------------------------
 2 files changed, 71 insertions(+), 56 deletions(-)

diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 015a57b..fd05cc9 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -32,6 +32,9 @@
 #include <X11/Xlib.h>
 #include <X11/Xresource.h>
 #include <X11/Xutil.h>
+#ifdef HAVE_LIBXSHAPE
+#include <X11/extensions/shape.h>
+#endif /* HAVE_LIBXSHAPE */
 
 #include "windef.h"
 #include "winbase.h"
@@ -222,6 +225,41 @@ void X11DRV_sync_window_style( Display *display, struct x11drv_win_data *data )
 
 
 /***********************************************************************
+ *              sync_window_region
+ *
+ * Update the X11 window region.
+ */
+static void sync_window_region( Display *display, struct x11drv_win_data *data, HRGN hrgn )
+{
+#ifdef HAVE_LIBXSHAPE
+    if (!data->whole_window) return;
+
+    if (!hrgn)
+    {
+        wine_tsx11_lock();
+        XShapeCombineMask( display, data->whole_window, ShapeBounding, 0, 0, None, ShapeSet );
+        wine_tsx11_unlock();
+    }
+    else
+    {
+        RGNDATA *pRegionData = X11DRV_GetRegionData( hrgn, 0 );
+        if (pRegionData)
+        {
+            wine_tsx11_lock();
+            XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
+                                     data->window_rect.left - data->whole_rect.left,
+                                     data->window_rect.top - data->whole_rect.top,
+                                     (XRectangle *)pRegionData->Buffer,
+                                     pRegionData->rdh.nCount, ShapeSet, YXBanded );
+            wine_tsx11_unlock();
+            HeapFree(GetProcessHeap(), 0, pRegionData);
+        }
+    }
+#endif  /* HAVE_LIBXSHAPE */
+}
+
+
+/***********************************************************************
  *              X11DRV_set_win_format
  */
 BOOL X11DRV_set_win_format( HWND hwnd, XID fbconfig_id )
@@ -1013,6 +1051,7 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
     int cx, cy, mask;
     XSetWindowAttributes attr;
     XIM xim;
+    HRGN hrgn;
 
     if (!(cx = data->window_rect.right - data->window_rect.left)) cx = 1;
     if (!(cy = data->window_rect.bottom - data->window_rect.top)) cy = 1;
@@ -1051,6 +1090,13 @@ static Window create_whole_window( Display *display, struct x11drv_win_data *dat
     X11DRV_set_wm_hints( display, data );
 
     SetPropA( data->hwnd, whole_window_prop, (HANDLE)data->whole_window );
+
+    /* set the window region */
+    if ((hrgn = CreateRectRgn( 0, 0, 0, 0 )))
+    {
+        if (GetWindowRgn( data->hwnd, hrgn ) != ERROR) sync_window_region( display, data, hrgn );
+        DeleteObject( hrgn );
+    }
     return data->whole_window;
 }
 
@@ -1619,3 +1665,28 @@ void X11DRV_SetWindowIcon( HWND hwnd, UINT type, HICON icon )
         wine_tsx11_unlock();
     }
 }
+
+
+/***********************************************************************
+ *		SetWindowRgn  (X11DRV.@)
+ *
+ * Assign specified region to window (for non-rectangular windows)
+ */
+int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
+{
+    struct x11drv_win_data *data;
+
+    if ((data = X11DRV_get_win_data( hwnd )))
+    {
+        sync_window_region( thread_display(), data, hrgn );
+        invalidate_dce( hwnd, &data->window_rect );
+    }
+    else if (GetWindowThreadProcessId( hwnd, NULL ) != GetCurrentThreadId())
+    {
+        FIXME( "not supported on other thread window %p\n", hwnd );
+        SetLastError( ERROR_INVALID_WINDOW_HANDLE );
+        return FALSE;
+    }
+
+    return TRUE;
+}
diff --git a/dlls/winex11.drv/winpos.c b/dlls/winex11.drv/winpos.c
index 36cab19..08baa65 100644
--- a/dlls/winex11.drv/winpos.c
+++ b/dlls/winex11.drv/winpos.c
@@ -23,9 +23,6 @@
 
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
-#ifdef HAVE_LIBXSHAPE
-#include <X11/extensions/shape.h>
-#endif /* HAVE_LIBXSHAPE */
 #include <stdarg.h>
 
 #include "windef.h"
@@ -1029,59 +1026,6 @@ void X11DRV_ConfigureNotify( HWND hwnd, XEvent *xev )
 
 
 /***********************************************************************
- *		SetWindowRgn  (X11DRV.@)
- *
- * Assign specified region to window (for non-rectangular windows)
- */
-int X11DRV_SetWindowRgn( HWND hwnd, HRGN hrgn, BOOL redraw )
-{
-    struct x11drv_win_data *data;
-
-    if (!(data = X11DRV_get_win_data( hwnd )))
-    {
-        if (IsWindow( hwnd ))
-            FIXME( "not supported on other thread window %p\n", hwnd );
-        SetLastError( ERROR_INVALID_WINDOW_HANDLE );
-        return FALSE;
-    }
-
-#ifdef HAVE_LIBXSHAPE
-    if (data->whole_window)
-    {
-        Display *display = thread_display();
-
-        if (!hrgn)
-        {
-            wine_tsx11_lock();
-            XShapeCombineMask( display, data->whole_window,
-                               ShapeBounding, 0, 0, None, ShapeSet );
-            wine_tsx11_unlock();
-        }
-        else
-        {
-            RGNDATA *pRegionData = X11DRV_GetRegionData( hrgn, 0 );
-            if (pRegionData)
-            {
-                wine_tsx11_lock();
-                XShapeCombineRectangles( display, data->whole_window, ShapeBounding,
-                                         data->window_rect.left - data->whole_rect.left,
-                                         data->window_rect.top - data->whole_rect.top,
-                                         (XRectangle *)pRegionData->Buffer,
-                                         pRegionData->rdh.nCount,
-                                         ShapeSet, YXBanded );
-                wine_tsx11_unlock();
-                HeapFree(GetProcessHeap(), 0, pRegionData);
-            }
-        }
-    }
-#endif  /* HAVE_LIBXSHAPE */
-
-    invalidate_dce( hwnd, &data->window_rect );
-    return TRUE;
-}
-
-
-/***********************************************************************
  *           draw_moving_frame
  *
  * Draw the frame used when moving or resizing window.




More information about the wine-cvs mailing list