SDL 如何检查 window 是最大化还是最小化

SDL How to check if window is maximized or minimized

我正在尝试制作一个可以最大化和最小化的无边框 window,但我无法获得有关如何获取 window 当前状态的任何信息(如果它是最小化或最大化)以及如何使用它。

(编辑)代码的粗略片段:


SDL_Rect minimize_area = {0,0,20,20};
Button minimize_window_button = Button(minimize_area);

SDL_Rect maximize_area = {0,0,20,20};
Button maximize_window_button = Button(maximize_area);

SDL_Rect close_area = {0,0,20,20};
Button close_window_button = Button(close_area);

// Program loop
while ( SDL_PollEvent( &event ) ) {
    case SDL_MOUSEBUTTONDOWN:
        if (event.button.button == SDL_BUTTON_LEFT) {
            mouse.updateMousePosition();
            if (close_window_button.mouseInDstRect(mouse.pos.x, mouse.pos.y)) running = false;
            if (maximize_window_button.mouseInDstRect(mouse.pos.x, mouse.pos.y)) {
                if (/* WAY TO KNOW IF THE WINDOW IS MAXIMIZED */) {
                    SDL_MaximizeWindow(window);
                } else {
                    SDL_RestoreWindow(window);
                }
            }
            if (minimize_window_button.mouseInDstRect(mouse.pos.x, mouse.pos.y)) {
                if (/* WAY TO KNOW IF WINDOW IS MINIMIZED or UNMINIMIZED */) {
                    SDL_MinimizeWindow(window);
                } else {
                    SDL_RestoreWindow(window);
                }
            }

        }

        SDL_Log("click!");
        break;
}



SDL_GetWindowFlags(),检查 SDL_WINDOW_MINIMIZEDSDL_WINDOW_MAXIMIZED 位。