-- v2: winewayland: Move window surface creation functions to window_surface.c. winemac: Move window surface creation functions to surface.c. winex11: Move window surface creation functions to bitblt.c.
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winex11.drv/bitblt.c | 100 +++++++++++++++++++++++++++++++++++++- dlls/winex11.drv/window.c | 96 ------------------------------------ dlls/winex11.drv/x11drv.h | 3 +- 3 files changed, 99 insertions(+), 100 deletions(-)
diff --git a/dlls/winex11.drv/bitblt.c b/dlls/winex11.drv/bitblt.c index 11ba34739c3..c4ae4dd522e 100644 --- a/dlls/winex11.drv/bitblt.c +++ b/dlls/winex11.drv/bitblt.c @@ -2054,8 +2054,8 @@ static const struct window_surface_funcs x11drv_surface_funcs = /*********************************************************************** * create_surface */ -struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect, - COLORREF color_key, BOOL use_alpha ) +static struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect, + COLORREF color_key, BOOL use_alpha ) { const XPixmapFormatValues *format = pixmap_formats[vis->depth]; char buffer[FIELD_OFFSET( BITMAPINFO, bmiColors[256] )]; @@ -2182,3 +2182,99 @@ HRGN expose_surface( struct window_surface *window_surface, const RECT *rect ) window_surface_unlock( window_surface ); return region; } + + +BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect ) +{ + *surface_rect = NtUserGetVirtualScreenRect(); + + if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE; + OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top ); + surface_rect->left &= ~31; + surface_rect->top &= ~31; + surface_rect->right = max( surface_rect->left + 32, (surface_rect->right + 31) & ~31 ); + surface_rect->bottom = max( surface_rect->top + 32, (surface_rect->bottom + 31) & ~31 ); + return TRUE; +} + + +/*********************************************************************** + * CreateWindowSurface (X11DRV.@) + */ +BOOL X11DRV_CreateWindowSurface( HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface ) +{ + struct x11drv_win_data *data; + RECT surface_rect; + DWORD flags; + COLORREF key; + BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED; + + TRACE( "hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect( visible_rect ), surface ); + + if (!(data = get_win_data( hwnd ))) return TRUE; /* use default surface */ + + if (*surface) window_surface_release( *surface ); + *surface = NULL; /* indicate that we want to draw directly to the window */ + + if (data->embedded) goto done; /* draw directly to the window */ + if (data->whole_window == root_window) goto done; /* draw directly to the window */ + if (data->client_window) goto done; /* draw directly to the window */ + if (!client_side_graphics && !layered) goto done; /* draw directly to the window */ + + if (!get_surface_rect( visible_rect, &surface_rect )) goto done; + if (data->surface) + { + if (EqualRect( &data->surface->rect, &surface_rect )) + { + /* existing surface is good enough */ + window_surface_add_ref( data->surface ); + *surface = data->surface; + goto done; + } + } + else if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done; + + if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY)) + key = CLR_INVALID; + + *surface = create_surface( data->hwnd, data->whole_window, &data->vis, &surface_rect, key, FALSE ); + +done: + release_win_data( data ); + return TRUE; +} + + +/***************************************************************************** + * CreateLayeredWindow (X11DRV.@) + */ +BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key, + struct window_surface **window_surface ) +{ + struct window_surface *surface; + struct x11drv_win_data *data; + RECT rect; + + if (!(data = get_win_data( hwnd ))) return FALSE; + + data->layered = TRUE; + if (!data->embedded && argb_visual.visualid) set_window_visual( data, &argb_visual, TRUE ); + + rect = *window_rect; + OffsetRect( &rect, -window_rect->left, -window_rect->top ); + + surface = data->surface; + if (!surface || !EqualRect( &surface->rect, &rect )) + { + data->surface = create_surface( data->hwnd, data->whole_window, &data->vis, &rect, + color_key, data->use_alpha ); + if (surface) window_surface_release( surface ); + surface = data->surface; + } + else set_surface_color_key( surface, color_key ); + + if ((*window_surface = surface)) window_surface_add_ref( surface ); + release_win_data( data ); + + return TRUE; +} diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c index 74a9a4f6d68..bdf5d2a3b7b 100644 --- a/dlls/winex11.drv/window.c +++ b/dlls/winex11.drv/window.c @@ -2576,20 +2576,6 @@ done: }
-static inline BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect ) -{ - *surface_rect = NtUserGetVirtualScreenRect(); - - if (!intersect_rect( surface_rect, surface_rect, visible_rect )) return FALSE; - OffsetRect( surface_rect, -visible_rect->left, -visible_rect->top ); - surface_rect->left &= ~31; - surface_rect->top &= ~31; - surface_rect->right = max( surface_rect->left + 32, (surface_rect->right + 31) & ~31 ); - surface_rect->bottom = max( surface_rect->top + 32, (surface_rect->bottom + 31) & ~31 ); - return TRUE; -} - - /*********************************************************************** * WindowPosChanging (X11DRV.@) */ @@ -2626,53 +2612,6 @@ done: }
-/*********************************************************************** - * CreateWindowSurface (X11DRV.@) - */ -BOOL X11DRV_CreateWindowSurface( HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface ) -{ - struct x11drv_win_data *data; - RECT surface_rect; - DWORD flags; - COLORREF key; - BOOL layered = NtUserGetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_LAYERED; - - TRACE( "hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect( visible_rect ), surface ); - - if (!(data = get_win_data( hwnd ))) return TRUE; /* use default surface */ - - if (*surface) window_surface_release( *surface ); - *surface = NULL; /* indicate that we want to draw directly to the window */ - - if (data->embedded) goto done; /* draw directly to the window */ - if (data->whole_window == root_window) goto done; /* draw directly to the window */ - if (data->client_window) goto done; /* draw directly to the window */ - if (!client_side_graphics && !layered) goto done; /* draw directly to the window */ - - if (!get_surface_rect( visible_rect, &surface_rect )) goto done; - if (data->surface) - { - if (EqualRect( &data->surface->rect, &surface_rect )) - { - /* existing surface is good enough */ - window_surface_add_ref( data->surface ); - *surface = data->surface; - goto done; - } - } - else if (!(swp_flags & SWP_SHOWWINDOW) && !(NtUserGetWindowLongW( hwnd, GWL_STYLE ) & WS_VISIBLE)) goto done; - - if (!layered || !NtUserGetLayeredWindowAttributes( hwnd, &key, NULL, &flags ) || !(flags & LWA_COLORKEY)) - key = CLR_INVALID; - - *surface = create_surface( data->hwnd, data->whole_window, &data->vis, &surface_rect, key, FALSE ); - -done: - release_win_data( data ); - return TRUE; -} - - /*********************************************************************** * WindowPosChanged (X11DRV.@) */ @@ -2983,41 +2922,6 @@ void X11DRV_SetLayeredWindowAttributes( HWND hwnd, COLORREF key, BYTE alpha, DWO }
-/***************************************************************************** - * CreateLayeredWindow (X11DRV.@) - */ -BOOL X11DRV_CreateLayeredWindow( HWND hwnd, const RECT *window_rect, COLORREF color_key, - struct window_surface **window_surface ) -{ - struct window_surface *surface; - struct x11drv_win_data *data; - RECT rect; - - if (!(data = get_win_data( hwnd ))) return FALSE; - - data->layered = TRUE; - if (!data->embedded && argb_visual.visualid) set_window_visual( data, &argb_visual, TRUE ); - - rect = *window_rect; - OffsetRect( &rect, -window_rect->left, -window_rect->top ); - - surface = data->surface; - if (!surface || !EqualRect( &surface->rect, &rect )) - { - data->surface = create_surface( data->hwnd, data->whole_window, &data->vis, &rect, - color_key, data->use_alpha ); - if (surface) window_surface_release( surface ); - surface = data->surface; - } - else set_surface_color_key( surface, color_key ); - - if ((*window_surface = surface)) window_surface_add_ref( surface ); - release_win_data( data ); - - return TRUE; -} - - /*********************************************************************** * UpdateLayeredWindow (X11DRV.@) */ diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 49fb17fc7cd..3ac86d32669 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -266,8 +266,6 @@ extern Pixmap create_pixmap_from_image( HDC hdc, const XVisualInfo *vis, const B const struct gdi_image_bits *bits, UINT coloruse ); extern DWORD get_pixmap_image( Pixmap pixmap, int width, int height, const XVisualInfo *vis, BITMAPINFO *info, struct gdi_image_bits *bits ); -extern struct window_surface *create_surface( HWND hwnd, Window window, const XVisualInfo *vis, const RECT *rect, - COLORREF color_key, BOOL use_alpha ); extern void set_surface_color_key( struct window_surface *window_surface, COLORREF color_key ); extern HRGN expose_surface( struct window_surface *window_surface, const RECT *rect );
@@ -687,6 +685,7 @@ typedef int (*x11drv_error_callback)( Display *display, XErrorEvent *event, void
extern void X11DRV_expect_error( Display *display, x11drv_error_callback callback, void *arg ); extern int X11DRV_check_error(void); +extern BOOL get_surface_rect( const RECT *visible_rect, RECT *surface_rect ); extern void X11DRV_X_to_window_rect( struct x11drv_win_data *data, RECT *rect, int x, int y, int cx, int cy ); extern POINT virtual_screen_to_root( INT x, INT y ); extern POINT root_to_virtual_screen( INT x, INT y );
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winemac.drv/macdrv.h | 3 -- dlls/winemac.drv/surface.c | 98 ++++++++++++++++++++++++++++++++++++-- dlls/winemac.drv/window.c | 91 ----------------------------------- 3 files changed, 95 insertions(+), 97 deletions(-)
diff --git a/dlls/winemac.drv/macdrv.h b/dlls/winemac.drv/macdrv.h index 31835164e71..811947f723c 100644 --- a/dlls/winemac.drv/macdrv.h +++ b/dlls/winemac.drv/macdrv.h @@ -207,10 +207,7 @@ extern BOOL macdrv_SystemParametersInfo(UINT action, UINT int_param, void *ptr_p extern macdrv_window macdrv_get_cocoa_window(HWND hwnd, BOOL require_on_screen); extern RGNDATA *get_region_data(HRGN hrgn, HDC hdc_lptodp); extern void activate_on_following_focus(void); -extern struct window_surface *create_surface(HWND hwnd, macdrv_window window, const RECT *rect, - struct window_surface *old_surface, BOOL use_alpha); extern void set_surface_use_alpha(struct window_surface *window_surface, BOOL use_alpha); -extern void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect);
extern void macdrv_handle_event(const macdrv_event *event);
diff --git a/dlls/winemac.drv/surface.c b/dlls/winemac.drv/surface.c index 37e2c466926..bd40a2a2db2 100644 --- a/dlls/winemac.drv/surface.c +++ b/dlls/winemac.drv/surface.c @@ -127,8 +127,8 @@ static struct macdrv_window_surface *get_mac_surface(struct window_surface *surf /*********************************************************************** * create_surface */ -struct window_surface *create_surface(HWND hwnd, macdrv_window window, const RECT *rect, - struct window_surface *old_surface, BOOL use_alpha) +static struct window_surface *create_surface(HWND hwnd, macdrv_window window, const RECT *rect, + struct window_surface *old_surface, BOOL use_alpha) { struct macdrv_window_surface *surface; int width = rect->right - rect->left, height = rect->bottom - rect->top; @@ -265,7 +265,7 @@ done: * Intersect the accumulated drawn region with a new visible rect, * effectively discarding stale drawing in the surface slack area. */ -void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect) +static void surface_clip_to_visible_rect(struct window_surface *window_surface, const RECT *visible_rect) { struct macdrv_window_surface *surface = get_mac_surface(window_surface); RECT rect = *visible_rect; @@ -277,3 +277,95 @@ void surface_clip_to_visible_rect(struct window_surface *window_surface, const R intersect_rect(&window_surface->bounds, &window_surface->bounds, &rect); window_surface_unlock(window_surface); } + + +static inline RECT get_surface_rect(const RECT *visible_rect) +{ + RECT rect = *visible_rect; + + OffsetRect(&rect, -visible_rect->left, -visible_rect->top); + rect.left &= ~127; + rect.top &= ~127; + rect.right = max(rect.left + 128, (rect.right + 127) & ~127); + rect.bottom = max(rect.top + 128, (rect.bottom + 127) & ~127); + return rect; +} + + +/*********************************************************************** + * CreateWindowSurface (MACDRV.@) + */ +BOOL macdrv_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface) +{ + struct macdrv_win_data *data; + DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); + RECT surface_rect; + + TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface); + + if (!(data = get_win_data(hwnd))) return TRUE; /* use default surface */ + + if (*surface) window_surface_release(*surface); + *surface = NULL; + + surface_rect = get_surface_rect(visible_rect); + if (data->surface) + { + if (EqualRect(&data->surface->rect, &surface_rect)) + { + /* existing surface is good enough */ + surface_clip_to_visible_rect(data->surface, visible_rect); + window_surface_add_ref(data->surface); + *surface = data->surface; + goto done; + } + } + else if (!(swp_flags & SWP_SHOWWINDOW) && !(style & WS_VISIBLE)) goto done; + + *surface = create_surface(data->hwnd, data->cocoa_window, &surface_rect, data->surface, FALSE); + +done: + release_win_data(data); + return TRUE; +} + + +/*********************************************************************** + * CreateLayeredWindow (MACDRV.@) + */ +BOOL macdrv_CreateLayeredWindow(HWND hwnd, const RECT *window_rect, COLORREF color_key, + struct window_surface **window_surface) +{ + struct window_surface *surface; + struct macdrv_win_data *data; + RECT rect; + + if (!(data = get_win_data(hwnd))) return FALSE; + + data->layered = TRUE; + data->ulw_layered = TRUE; + + rect = *window_rect; + OffsetRect(&rect, -window_rect->left, -window_rect->top); + + surface = data->surface; + if (!surface || !EqualRect(&surface->rect, &rect)) + { + data->surface = create_surface(data->hwnd, data->cocoa_window, &rect, NULL, TRUE); + macdrv_set_window_surface(data->cocoa_window, data->surface); + if (surface) window_surface_release(surface); + surface = data->surface; + if (data->unminimized_surface) + { + window_surface_release(data->unminimized_surface); + data->unminimized_surface = NULL; + } + } + else set_surface_use_alpha(surface, TRUE); + + if ((*window_surface = surface)) window_surface_add_ref(surface); + + release_win_data(data); + + return TRUE; +} diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c index 012189249a4..35198f45607 100644 --- a/dlls/winemac.drv/window.c +++ b/dlls/winemac.drv/window.c @@ -1890,46 +1890,6 @@ done: }
-/*********************************************************************** - * CreateLayeredWindow (MACDRV.@) - */ -BOOL macdrv_CreateLayeredWindow(HWND hwnd, const RECT *window_rect, COLORREF color_key, - struct window_surface **window_surface) -{ - struct window_surface *surface; - struct macdrv_win_data *data; - RECT rect; - - if (!(data = get_win_data(hwnd))) return FALSE; - - data->layered = TRUE; - data->ulw_layered = TRUE; - - rect = *window_rect; - OffsetRect(&rect, -window_rect->left, -window_rect->top); - - surface = data->surface; - if (!surface || !EqualRect(&surface->rect, &rect)) - { - data->surface = create_surface(data->hwnd, data->cocoa_window, &rect, NULL, TRUE); - macdrv_set_window_surface(data->cocoa_window, data->surface); - if (surface) window_surface_release(surface); - surface = data->surface; - if (data->unminimized_surface) - { - window_surface_release(data->unminimized_surface); - data->unminimized_surface = NULL; - } - } - else set_surface_use_alpha(surface, TRUE); - - if ((*window_surface = surface)) window_surface_add_ref(surface); - - release_win_data(data); - - return TRUE; -} - /*********************************************************************** * UpdateLayeredWindow (MACDRV.@) */ @@ -1984,19 +1944,6 @@ LRESULT macdrv_WindowMessage(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) }
-static inline RECT get_surface_rect(const RECT *visible_rect) -{ - RECT rect = *visible_rect; - - OffsetRect(&rect, -visible_rect->left, -visible_rect->top); - rect.left &= ~127; - rect.top &= ~127; - rect.right = max(rect.left + 128, (rect.right + 127) & ~127); - rect.bottom = max(rect.top + 128, (rect.bottom + 127) & ~127); - return rect; -} - - /*********************************************************************** * WindowPosChanging (MACDRV.@) */ @@ -2028,44 +1975,6 @@ done: }
-/*********************************************************************** - * CreateWindowSurface (MACDRV.@) - */ -BOOL macdrv_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface) -{ - struct macdrv_win_data *data; - DWORD style = NtUserGetWindowLongW(hwnd, GWL_STYLE); - RECT surface_rect; - - TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface); - - if (!(data = get_win_data(hwnd))) return TRUE; /* use default surface */ - - if (*surface) window_surface_release(*surface); - *surface = NULL; - - surface_rect = get_surface_rect(visible_rect); - if (data->surface) - { - if (EqualRect(&data->surface->rect, &surface_rect)) - { - /* existing surface is good enough */ - surface_clip_to_visible_rect(data->surface, visible_rect); - window_surface_add_ref(data->surface); - *surface = data->surface; - goto done; - } - } - else if (!(swp_flags & SWP_SHOWWINDOW) && !(style & WS_VISIBLE)) goto done; - - *surface = create_surface(data->hwnd, data->cocoa_window, &surface_rect, data->surface, FALSE); - -done: - release_win_data(data); - return TRUE; -} - - /*********************************************************************** * WindowPosChanged (MACDRV.@) */
From: Rémi Bernon rbernon@codeweavers.com
--- dlls/winewayland.drv/waylanddrv.h | 25 +++++++++++- dlls/winewayland.drv/window.c | 57 +-------------------------- dlls/winewayland.drv/window_surface.c | 39 +++++++++++++++++- 3 files changed, 64 insertions(+), 57 deletions(-)
diff --git a/dlls/winewayland.drv/waylanddrv.h b/dlls/winewayland.drv/waylanddrv.h index 4b92c9bf1ba..d0a8977f887 100644 --- a/dlls/winewayland.drv/waylanddrv.h +++ b/dlls/winewayland.drv/waylanddrv.h @@ -272,11 +272,34 @@ void wayland_shm_buffer_unref(struct wayland_shm_buffer *shm_buffer); * Wayland window surface */
-struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect); void wayland_window_surface_update_wayland_surface(struct window_surface *surface, struct wayland_surface *wayland_surface); void wayland_window_flush(HWND hwnd);
+/********************************************************************** + * Wayland Window + */ + +/* private window data */ +struct wayland_win_data +{ + struct rb_entry entry; + /* hwnd that this private data belongs to */ + HWND hwnd; + /* wayland surface (if any) for this window */ + struct wayland_surface *wayland_surface; + /* wine window_surface backing this window */ + struct window_surface *window_surface; + /* USER window rectangle relative to win32 parent window client area */ + RECT window_rect; + /* USER client rectangle relative to win32 parent window client area */ + RECT client_rect; + BOOL managed; +}; + +struct wayland_win_data *wayland_win_data_get(HWND hwnd); +void wayland_win_data_release(struct wayland_win_data *data); + /********************************************************************** * Wayland Keyboard */ diff --git a/dlls/winewayland.drv/window.c b/dlls/winewayland.drv/window.c index c006505bc90..060a25d50c6 100644 --- a/dlls/winewayland.drv/window.c +++ b/dlls/winewayland.drv/window.c @@ -56,23 +56,6 @@ static BOOL set_window_pos(HWND hwnd, HWND after, INT x, INT y, INT cx, INT cy, }
-/* private window data */ -struct wayland_win_data -{ - struct rb_entry entry; - /* hwnd that this private data belongs to */ - HWND hwnd; - /* wayland surface (if any) for this window */ - struct wayland_surface *wayland_surface; - /* wine window_surface backing this window */ - struct window_surface *window_surface; - /* USER window rectangle relative to win32 parent window client area */ - RECT window_rect; - /* USER client rectangle relative to win32 parent window client area */ - RECT client_rect; - BOOL managed; -}; - static int wayland_win_data_cmp_rb(const void *key, const struct rb_entry *entry) { @@ -153,7 +136,7 @@ static void wayland_win_data_destroy(struct wayland_win_data *data) * * Lock and return the data structure associated with a window. */ -static struct wayland_win_data *wayland_win_data_get(HWND hwnd) +struct wayland_win_data *wayland_win_data_get(HWND hwnd) { struct rb_entry *rb_entry;
@@ -172,7 +155,7 @@ static struct wayland_win_data *wayland_win_data_get(HWND hwnd) * * Release the data returned by wayland_win_data_get. */ -static void wayland_win_data_release(struct wayland_win_data *data) +void wayland_win_data_release(struct wayland_win_data *data) { assert(data); pthread_mutex_unlock(&win_data_mutex); @@ -471,42 +454,6 @@ done: }
-/*********************************************************************** - * WAYLAND_CreateWindowSurface - */ -BOOL WAYLAND_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface) -{ - struct wayland_win_data *data; - RECT surface_rect; - - TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface); - - if (!(data = wayland_win_data_get(hwnd))) return TRUE; /* use default surface */ - - /* Release the dummy surface wine provides for toplevels. */ - if (*surface) window_surface_release(*surface); - *surface = NULL; - - surface_rect = *visible_rect; - OffsetRect(&surface_rect, -surface_rect.left, -surface_rect.top); - - /* Check if we can reuse our current window surface. */ - if (data->window_surface && - EqualRect(&data->window_surface->rect, &surface_rect)) - { - window_surface_add_ref(data->window_surface); - *surface = data->window_surface; - TRACE("reusing surface %p\n", *surface); - goto done; - } - - *surface = wayland_window_surface_create(data->hwnd, &surface_rect); - -done: - wayland_win_data_release(data); - return TRUE; -} - /*********************************************************************** * WAYLAND_WindowPosChanged */ diff --git a/dlls/winewayland.drv/window_surface.c b/dlls/winewayland.drv/window_surface.c index 888fa74c085..9377b05b4ce 100644 --- a/dlls/winewayland.drv/window_surface.c +++ b/dlls/winewayland.drv/window_surface.c @@ -449,7 +449,7 @@ static const struct window_surface_funcs wayland_window_surface_funcs = /*********************************************************************** * wayland_window_surface_create */ -struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect) +static struct window_surface *wayland_window_surface_create(HWND hwnd, const RECT *rect) { char buffer[FIELD_OFFSET(BITMAPINFO, bmiColors[256])]; BITMAPINFO *info = (BITMAPINFO *)buffer; @@ -516,3 +516,40 @@ void wayland_window_surface_update_wayland_surface(struct window_surface *window
window_surface_unlock(window_surface); } + + +/*********************************************************************** + * WAYLAND_CreateWindowSurface + */ +BOOL WAYLAND_CreateWindowSurface(HWND hwnd, UINT swp_flags, const RECT *visible_rect, struct window_surface **surface) +{ + struct wayland_win_data *data; + RECT surface_rect; + + TRACE("hwnd %p, swp_flags %08x, visible %s, surface %p\n", hwnd, swp_flags, wine_dbgstr_rect(visible_rect), surface); + + if (!(data = wayland_win_data_get(hwnd))) return TRUE; /* use default surface */ + + /* Release the dummy surface wine provides for toplevels. */ + if (*surface) window_surface_release(*surface); + *surface = NULL; + + surface_rect = *visible_rect; + OffsetRect(&surface_rect, -surface_rect.left, -surface_rect.top); + + /* Check if we can reuse our current window surface. */ + if (data->window_surface && + EqualRect(&data->window_surface->rect, &surface_rect)) + { + window_surface_add_ref(data->window_surface); + *surface = data->window_surface; + TRACE("reusing surface %p\n", *surface); + goto done; + } + + *surface = wayland_window_surface_create(data->hwnd, &surface_rect); + +done: + wayland_win_data_release(data); + return TRUE; +}
v2: Don't change `get_surface_rect` logic at the same time... I think it's probably what caused the test failures, otherwise it's just moving code around.