third_party/cairo/src/cairo-os2-surface.c
void
cairo_os2_surface_set_hwnd (cairo_surface_t *surface,
                            HWND             hwnd_client_window)
{
    cairo_os2_surface_t *local_os2_surface;

    local_os2_surface = (cairo_os2_surface_t *) surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return;
    }

    if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
        != NO_ERROR)
    {
        /* Could not get mutex! */
        return;
    }

    local_os2_surface->hwnd_client_window = hwnd_client_window;

    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
}
/**
 * cairo_os2_surface_set_hwnd:
 * @surface: the cairo surface to associate with the window handle
 * @hwnd_client_window: the window handle of the client window
 *
 * Sets window handle for surface; the caller retains ownership of the window.
 * If Cairo wants to blit into the window because it is set to blit as the
 * surface changes (see cairo_os2_surface_set_manual_window_refresh()), then
 * there are two ways it can choose:
 * If it knows the HWND of the surface, then it invalidates that area, so the
 * application will get a WM_PAINT message and it can call
 * cairo_os2_surface_refresh_window() to redraw that area. Otherwise cairo itself
 * will use the HPS it got at surface creation time, and blit the pixels itself.
 * It's also a solution, but experience shows that if this happens from a non-PM
 * thread, then it can screw up PM internals.
 *
 * So, best solution is to set the HWND for the surface after the surface
 * creation, so every blit will be done from application's message processing
 * loop, which is the safest way to do.
 *
 * Since: 1.4
 **/
@surface: the cairo surface to associate with the window handle
@hwnd_client_window: the window handle of the client window

Sets window handle for surface; the caller retains ownership of the window.
If Cairo wants to blit into the window because it is set to blit as the
surface changes ), then
there are two ways it can choose:
If it knows the HWND of the surface, then it invalidates that area, so the
application will get a WM_PAINT message and it can call
cairo_os2_surface_refresh_window() to redraw that area. Otherwise cairo itself
will use the HPS it got at surface creation time, and blit the pixels itself.
It's also a solution, but experience shows that if this happens from a non-PM
thread, then it can screw up PM internals.

So, best solution is to set the HWND for the surface after the surface
creation, so every blit will be done from application's message processing
loop, which is the safest way to do.


@surface : the cairo surface to associate with the window handle @hwnd_client_window : the window handle of the client window Sets window handle for surface ; the caller retains ownership of the window . If Cairo wants to blit into the window because it is set to blit as the surface changes ) then there are two ways it can choose : If it knows the HWND of the surface then it invalidates that area so the application will get a WM_PAINT message and it can call cairo_os2_surface_refresh_window () to redraw that area . Otherwise cairo itself will use the HPS it got at surface creation time and blit the pixels itself . It ' s also a solution but experience shows that if this happens from a non - PM thread then it can screw up PM internals . So best solution is to set the HWND for the surface after the surface creation so every blit will be done from application ' s message processing loop which is the safest way to do .
void
cairo_os2_surface_set_hwnd (cairo_surface_t *surface,
                            HWND             hwnd_client_window)
{
    cairo_os2_surface_t *local_os2_surface;
    local_os2_surface = (cairo_os2_surface_t *) surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        return;
    }
    if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
        != NO_ERROR)
    {
        return;
    }
    local_os2_surface->hwnd_client_window = hwnd_client_window;
    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
}
void cairo_os2_surface_set_hwnd ( cairo_surface_t * surface , HWND hwnd_client_window ) { cairo_os2_surface_t * local_os2_surface ; local_os2_surface = ( cairo_os2_surface_t * ) surface ; if ( ( ! local_os2_surface ) || ( local_os2_surface -> base . backend != & cairo_os2_surface_backend ) ) { return ; } if ( DosRequestMutexSem ( local_os2_surface -> hmtx_use_private_fields , SEM_INDEFINITE_WAIT ) != NO_ERROR ) { return ; } local_os2_surface -> hwnd_client_window = hwnd_client_window ; DosReleaseMutexSem ( local_os2_surface -> hmtx_use_private_fields ) ; }
cairo_os2_surface_set_hwnd:
 @surface: the cairo surface to associate with the window handle
 @hwnd_client_window: the window handle of the client window
cairo_os2_surface_set_hwnd : @surface : the cairo surface to associate with the window handle @hwnd_client_window : the window handle of the client window
/* Invalid parameter (wrong surface)! */ /* Could not get mutex! */