Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't resize window on X11 #395

Open
alters-mit opened this issue Jul 25, 2023 · 3 comments
Open

Can't resize window on X11 #395

alters-mit opened this issue Jul 25, 2023 · 3 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@alters-mit
Copy link

On Linux X11, request_screen_size doesn't panic (an improvement from 0.3) but it doesn't actually do anything.

@not-fl3
Copy link
Owner

not-fl3 commented Jul 25, 2023

resize.mp4
use macroquad::prelude::*;

async fn test1() {
    while !is_key_pressed(KeyCode::Space) {
        clear_background(RED);
        draw_text("Press space for next test", 20.0, 20.0, 16., BLACK);
        next_frame().await;
    }
    next_frame().await;
}

async fn test2() {
    set_fullscreen(true);
    while !is_key_pressed(KeyCode::Space) {
        clear_background(WHITE);
        draw_text("Should be fullscreen", 20.0, 20.0, 16., BLACK);
        next_frame().await;
    }
    set_fullscreen(false);
    next_frame().await;
    while !is_key_pressed(KeyCode::Space) {
        clear_background(WHITE);
        draw_text("Should be windowed again", 20.0, 20.0, 16., BLACK);
        next_frame().await;
    }
    next_frame().await;
}

async fn test3() {
    request_new_screen_size(350., 50.);
    while !is_key_pressed(KeyCode::Space) {
        clear_background(WHITE);
        draw_text("Should be a 350, 50 window", 20.0, 20.0, 16., BLACK);
        next_frame().await;
    }
    request_new_screen_size(800., 600.);
    next_frame().await;
    while !is_key_pressed(KeyCode::Space) {
        clear_background(WHITE);
        draw_text("Should be a 800, 600 window", 20.0, 20.0, 16., BLACK);
        next_frame().await;
    }
}

#[macroquad::main("test")]
async fn main() {
    test1().await;
    //test2().await;
    test3().await;
}

works on my machine :(

@not-fl3 not-fl3 added bug Something isn't working help wanted Extra attention is needed labels Jul 25, 2023
@alters-mit
Copy link
Author

I found the source of the bug. In Conf, window_resizable needs to be set to true, otherwise the window won't resize at all. The bug also goes away if there is no Conf function.

On Windows and MacOS, my Conf function, and subsequent request_new_screen_size() call, works as expected, even with window_resizable: false

@joseluis
Copy link

joseluis commented Feb 3, 2025

In Conf, window_resizable needs to be set to true, otherwise the window won't resize at all.

I've been playing a little at this. The core issue seems to be that that X11 window managers interpret equal min/max size as a strict, non-negotiable constraint. If the library sets those size hints, the WM obeys them and that blocks all resizing (from both user and program).

I also tried setting _NET_WM_ALLOWED_ACTIONS to disallow resizing (and others, and maximizing but it seems to be ignored by the openbox WM I'm using, and apparently many others even if they claim compatibility so...

The only workaround I found in order to be able to resize from the app while disabling user resizes is to save the desired window dimensions in the state, and in resize_event if the new size is not equal to the saved one resize it back immediately. It's an ugly hack but seems to work enough. Although that doesn't preclude the user from maximizing the window, and we can't detect that event either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants