pub(super) unsafe extern "system" fn public_window_callback<T: 'static>(
    window: HWND,
    msg: u32,
    wparam: WPARAM,
    lparam: LPARAM,
) -> LRESULT {
    let userdata = super::get_window_long(window, GWL_USERDATA);

    let userdata_ptr = match (userdata, msg) {
        (0, WM_NCCREATE) => {
            let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
            let initdata = &mut *(createstruct.lpCreateParams as *mut InitData<'_, T>);

            let result = match initdata.on_nccreate(window) {
                Some(userdata) => {
                    super::set_window_long(window, GWL_USERDATA, userdata as _);
                    DefWindowProcW(window, msg, wparam, lparam)
                }
                None => -1, // failed to create the window
            };

            return result;
        }
        // Getting here should quite frankly be impossible,
        // but we'll make window creation fail here just in case.
        (0, WM_CREATE) => return -1,
        (_, WM_CREATE) => {
            let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
            let initdata = createstruct.lpCreateParams;
            let initdata = &mut *(initdata as *mut InitData<'_, T>);

            initdata.on_create();
            return DefWindowProcW(window, msg, wparam, lparam);
        }
        (0, _) => return DefWindowProcW(window, msg, wparam, lparam),
        _ => userdata as *mut WindowData<T>,
    };

    let (result, userdata_removed, recurse_depth) = {
        let userdata = &*(userdata_ptr);

        userdata.recurse_depth.set(userdata.recurse_depth.get() + 1);

        let result = public_window_callback_inner(window, msg, wparam, lparam, userdata);

        let userdata_removed = userdata.userdata_removed.get();
        let recurse_depth = userdata.recurse_depth.get() - 1;
        userdata.recurse_depth.set(recurse_depth);

        (result, userdata_removed, recurse_depth)
    };

    if userdata_removed && recurse_depth == 0 {
        Box::from_raw(userdata_ptr);
    }

    result
}
/// Any window whose callback is configured to this function will have its events propagated
/// through the events loop of the thread the window was created in.
//
// This is the callback that is called by `DispatchMessage` in the events loop.
//
// Returning 0 tells the Win32 API that the message has been processed.
// FIXME: detect WM_DWMCOMPOSITIONCHANGED and call DwmEnableBlurBehindWindow if necessary
Any window whose callback is configured to this function will have its events propagated
through the events loop of the thread the window was created in.

This is the callback that is called by `DispatchMessage` in the events loop.

Returning 0 tells the Win32 API that the message has been processed.
FIXME: detect WM_DWMCOMPOSITIONCHANGED and call DwmEnableBlurBehindWindow if necessary
Any window whose callback is configured to this function will have its events propagated through the events loop of the thread the window was created in . This is the callback that is called by ` DispatchMessage ` in the events loop . Returning 0 tells the Win32 API that the message has been processed . FIXME : detect WM_DWMCOMPOSITIONCHANGED and call DwmEnableBlurBehindWindow if necessary
pub(super) unsafe extern "system" fn public_window_callback<T: 'static>(
    window: HWND,
    msg: u32,
    wparam: WPARAM,
    lparam: LPARAM,
) -> LRESULT {
    let userdata = super::get_window_long(window, GWL_USERDATA);
    let userdata_ptr = match (userdata, msg) {
        (0, WM_NCCREATE) => {
            let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
            let initdata = &mut *(createstruct.lpCreateParams as *mut InitData<'_, T>);
            let result = match initdata.on_nccreate(window) {
                Some(userdata) => {
                    super::set_window_long(window, GWL_USERDATA, userdata as _);
                    DefWindowProcW(window, msg, wparam, lparam)
                }
                None => -1, // failed to create the window
            };
            return result;
        }
        // Getting here should quite frankly be impossible,
        // but we'll make window creation fail here just in case.
        (0, WM_CREATE) => return -1,
        (_, WM_CREATE) => {
            let createstruct = &mut *(lparam as *mut CREATESTRUCTW);
            let initdata = createstruct.lpCreateParams;
            let initdata = &mut *(initdata as *mut InitData<'_, T>);
            initdata.on_create();
            return DefWindowProcW(window, msg, wparam, lparam);
        }
        (0, _) => return DefWindowProcW(window, msg, wparam, lparam),
        _ => userdata as *mut WindowData<T>,
    };
    let (result, userdata_removed, recurse_depth) = {
        let userdata = &*(userdata_ptr);
        userdata.recurse_depth.set(userdata.recurse_depth.get() + 1);
        let result = public_window_callback_inner(window, msg, wparam, lparam, userdata);
        let userdata_removed = userdata.userdata_removed.get();
        let recurse_depth = userdata.recurse_depth.get() - 1;
        userdata.recurse_depth.set(recurse_depth);
        (result, userdata_removed, recurse_depth)
    };
    if userdata_removed && recurse_depth == 0 {
        Box::from_raw(userdata_ptr);
    }
    result
}
pub ( super ) unsafe extern " " fn public_window_callback < T : ' static > ( window : HWND , msg : u32 , wparam : WPARAM , lparam : LPARAM , ) -> LRESULT { let userdata = super :: get_window_long ( window , GWL_USERDATA ) ; let userdata_ptr = match ( userdata , msg ) { ( 0 , WM_NCCREATE ) => { let createstruct = & mut * ( lparam as * mut CREATESTRUCTW ) ; let initdata = & mut * ( createstruct . lpCreateParams as * mut InitData < ' _ , T > ) ; let result = match initdata . on_nccreate ( window ) { Some ( userdata ) => { super :: set_window_long ( window , GWL_USERDATA , userdata as _ ) ; DefWindowProcW ( window , msg , wparam , lparam ) } None => - 1 , // failed to create the window } ; return result ; } // Getting here should quite frankly be impossible, // but we'll make window creation fail here just in case. ( 0 , WM_CREATE ) => return - 1 , ( _ , WM_CREATE ) => { let createstruct = & mut * ( lparam as * mut CREATESTRUCTW ) ; let initdata = createstruct . lpCreateParams ; let initdata = & mut * ( initdata as * mut InitData < ' _ , T > ) ; initdata . on_create ( ) ; return DefWindowProcW ( window , msg , wparam , lparam ) ; } ( 0 , _ ) => return DefWindowProcW ( window , msg , wparam , lparam ) , _ => userdata as * mut WindowData < T > , } ; let ( result , userdata_removed , recurse_depth ) = { let userdata = & * ( userdata_ptr ) ; userdata . recurse_depth . set ( userdata . recurse_depth . get ( ) + 1 ) ; let result = public_window_callback_inner ( window , msg , wparam , lparam , userdata ) ; let userdata_removed = userdata . userdata_removed . get ( ) ; let recurse_depth = userdata . recurse_depth . get ( ) - 1 ; userdata . recurse_depth . set ( recurse_depth ) ; ( result , userdata_removed , recurse_depth ) } ; if userdata_removed && recurse_depth == 0 { Box :: from_raw ( userdata_ptr ) ; } result }
Any window whose callback is configured to this function will have its events propagated
through the events loop of the thread the window was created in.
Any window whose callback is configured to this function will have its events propagated through the events loop of the thread the window was created in .
window
HWND
msg
u32
wparam
WPARAM
lparam
LPARAM