fn apply_diff(mut self, window: HWND, mut new: WindowFlags, set_client_rect: Option<RECT>) {
        self = self.mask();
        new = new.mask();

        let diff = self ^ new;
        if diff == WindowFlags::empty() {
            return;
        }

        if diff.contains(WindowFlags::VISIBLE) {
            unsafe {
                winuser::ShowWindow(
                    window,
                    match new.contains(WindowFlags::VISIBLE) {
                        true => winuser::SW_SHOW,
                        false => winuser::SW_HIDE,
                    },
                );
            }
        }
        if diff.contains(WindowFlags::ALWAYS_ON_TOP) {
            unsafe {
                winuser::SetWindowPos(
                    window,
                    match new.contains(WindowFlags::ALWAYS_ON_TOP) {
                        true => winuser::HWND_TOPMOST,
                        false => winuser::HWND_NOTOPMOST,
                    },
                    0,
                    0,
                    0,
                    0,
                    winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOMOVE | winuser::SWP_NOSIZE,
                );
                winuser::UpdateWindow(window);
            }
        }

        if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
            unsafe {
                winuser::ShowWindow(
                    window,
                    match new.contains(WindowFlags::MAXIMIZED) {
                        true => winuser::SW_MAXIMIZE,
                        false => winuser::SW_RESTORE,
                    },
                );
            }
        }

        if diff != WindowFlags::empty() {
            let (style, style_ex) = new.to_window_styles();

            unsafe {
                winuser::SendMessageW(window, *event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID, 1, 0);

                winuser::SetWindowLongW(window, winuser::GWL_STYLE, style as _);
                winuser::SetWindowLongW(window, winuser::GWL_EXSTYLE, style_ex as _);

                match set_client_rect
                    .and_then(|r| util::adjust_window_rect_with_styles(window, style, style_ex, r))
                {
                    Some(client_rect) => {
                        let (x, y, w, h) = (
                            client_rect.left,
                            client_rect.top,
                            client_rect.right - client_rect.left,
                            client_rect.bottom - client_rect.top,
                        );
                        winuser::SetWindowPos(
                            window,
                            ptr::null_mut(),
                            x,
                            y,
                            w,
                            h,
                            winuser::SWP_NOZORDER
                                | winuser::SWP_FRAMECHANGED
                                | winuser::SWP_NOACTIVATE,
                        );
                    }
                    None => {
                        // Refresh the window frame.
                        winuser::SetWindowPos(
                            window,
                            ptr::null_mut(),
                            0,
                            0,
                            0,
                            0,
                            winuser::SWP_NOZORDER
                                | winuser::SWP_NOMOVE
                                | winuser::SWP_NOSIZE
                                | winuser::SWP_FRAMECHANGED
                                | winuser::SWP_NOACTIVATE,
                        );
                    }
                }
                winuser::SendMessageW(window, *event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID, 0, 0);
            }
        }
    }
/// Adjust the window client rectangle to the return value, if present.
Adjust the window client rectangle to the return value, if present.
Adjust the window client rectangle to the return value if present .
fn apply_diff(mut self, window: HWND, mut new: WindowFlags, set_client_rect: Option<RECT>) {
        self = self.mask();
        new = new.mask();
        let diff = self ^ new;
        if diff == WindowFlags::empty() {
            return;
        }
        if diff.contains(WindowFlags::VISIBLE) {
            unsafe {
                winuser::ShowWindow(
                    window,
                    match new.contains(WindowFlags::VISIBLE) {
                        true => winuser::SW_SHOW,
                        false => winuser::SW_HIDE,
                    },
                );
            }
        }
        if diff.contains(WindowFlags::ALWAYS_ON_TOP) {
            unsafe {
                winuser::SetWindowPos(
                    window,
                    match new.contains(WindowFlags::ALWAYS_ON_TOP) {
                        true => winuser::HWND_TOPMOST,
                        false => winuser::HWND_NOTOPMOST,
                    },
                    0,
                    0,
                    0,
                    0,
                    winuser::SWP_ASYNCWINDOWPOS | winuser::SWP_NOMOVE | winuser::SWP_NOSIZE,
                );
                winuser::UpdateWindow(window);
            }
        }
        if diff.contains(WindowFlags::MAXIMIZED) || new.contains(WindowFlags::MAXIMIZED) {
            unsafe {
                winuser::ShowWindow(
                    window,
                    match new.contains(WindowFlags::MAXIMIZED) {
                        true => winuser::SW_MAXIMIZE,
                        false => winuser::SW_RESTORE,
                    },
                );
            }
        }
        if diff != WindowFlags::empty() {
            let (style, style_ex) = new.to_window_styles();
            unsafe {
                winuser::SendMessageW(window, *event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID, 1, 0);
                winuser::SetWindowLongW(window, winuser::GWL_STYLE, style as _);
                winuser::SetWindowLongW(window, winuser::GWL_EXSTYLE, style_ex as _);
                match set_client_rect
                    .and_then(|r| util::adjust_window_rect_with_styles(window, style, style_ex, r))
                {
                    Some(client_rect) => {
                        let (x, y, w, h) = (
                            client_rect.left,
                            client_rect.top,
                            client_rect.right - client_rect.left,
                            client_rect.bottom - client_rect.top,
                        );
                        winuser::SetWindowPos(
                            window,
                            ptr::null_mut(),
                            x,
                            y,
                            w,
                            h,
                            winuser::SWP_NOZORDER
                                | winuser::SWP_FRAMECHANGED
                                | winuser::SWP_NOACTIVATE,
                        );
                    }
                    None => {
                        // Refresh the window frame.
                        winuser::SetWindowPos(
                            window,
                            ptr::null_mut(),
                            0,
                            0,
                            0,
                            0,
                            winuser::SWP_NOZORDER
                                | winuser::SWP_NOMOVE
                                | winuser::SWP_NOSIZE
                                | winuser::SWP_FRAMECHANGED
                                | winuser::SWP_NOACTIVATE,
                        );
                    }
                }
                winuser::SendMessageW(window, *event_loop::SET_RETAIN_STATE_ON_SIZE_MSG_ID, 0, 0);
            }
        }
    }
fn apply_diff ( mut self , window : HWND , mut new : WindowFlags , set_client_rect : Option < RECT > ) { self = self . mask ( ) ; new = new . mask ( ) ; let diff = self ^ new ; if diff == WindowFlags :: empty ( ) { return ; } if diff . contains ( WindowFlags :: VISIBLE ) { unsafe { winuser :: ShowWindow ( window , match new . contains ( WindowFlags :: VISIBLE ) { true => winuser :: SW_SHOW , false => winuser :: SW_HIDE , } , ) ; } } if diff . contains ( WindowFlags :: ALWAYS_ON_TOP ) { unsafe { winuser :: SetWindowPos ( window , match new . contains ( WindowFlags :: ALWAYS_ON_TOP ) { true => winuser :: HWND_TOPMOST , false => winuser :: HWND_NOTOPMOST , } , 0 , 0 , 0 , 0 , winuser :: SWP_ASYNCWINDOWPOS | winuser :: SWP_NOMOVE | winuser :: SWP_NOSIZE , ) ; winuser :: UpdateWindow ( window ) ; } } if diff . contains ( WindowFlags :: MAXIMIZED ) || new . contains ( WindowFlags :: MAXIMIZED ) { unsafe { winuser :: ShowWindow ( window , match new . contains ( WindowFlags :: MAXIMIZED ) { true => winuser :: SW_MAXIMIZE , false => winuser :: SW_RESTORE , } , ) ; } } if diff != WindowFlags :: empty ( ) { let ( style , style_ex ) = new . to_window_styles ( ) ; unsafe { winuser :: SendMessageW ( window , * event_loop :: SET_RETAIN_STATE_ON_SIZE_MSG_ID , 1 , 0 ) ; winuser :: SetWindowLongW ( window , winuser :: GWL_STYLE , style as _ ) ; winuser :: SetWindowLongW ( window , winuser :: GWL_EXSTYLE , style_ex as _ ) ; match set_client_rect . and_then ( | r | util :: adjust_window_rect_with_styles ( window , style , style_ex , r ) ) { Some ( client_rect ) => { let ( x , y , w , h ) = ( client_rect . left , client_rect . top , client_rect . right - client_rect . left , client_rect . bottom - client_rect . top , ) ; winuser :: SetWindowPos ( window , ptr :: null_mut ( ) , x , y , w , h , winuser :: SWP_NOZORDER | winuser :: SWP_FRAMECHANGED | winuser :: SWP_NOACTIVATE , ) ; } None => { // Refresh the window frame. winuser :: SetWindowPos ( window , ptr :: null_mut ( ) , 0 , 0 , 0 , 0 , winuser :: SWP_NOZORDER | winuser :: SWP_NOMOVE | winuser :: SWP_NOSIZE | winuser :: SWP_FRAMECHANGED | winuser :: SWP_NOACTIVATE , ) ; } } winuser :: SendMessageW ( window , * event_loop :: SET_RETAIN_STATE_ON_SIZE_MSG_ID , 0 , 0 ) ; } } }
Adjust the window client rectangle to the return value, if present.
Adjust the window client rectangle to the return value if present .
mut self
window
HWND
new
WindowFlags
set_client_rect
Option<RECT>
mut self
window
HWND
new
WindowFlags
set_client_rect
Option<RECT>