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

Unable to size window dimensions with setSize #13

Closed
alecstein opened this issue Jan 3, 2024 · 9 comments
Closed

Unable to size window dimensions with setSize #13

alecstein opened this issue Jan 3, 2024 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@alecstein
Copy link

alecstein commented Jan 3, 2024

For a minimal repro, try this:

zig-webui/src/examples/call_js_from_zig

pub fn main() !void {
    var nwin = webui.newWindow();

    _ = nwin.setSize(10, 10);     // try resize before show

    _ = nwin.show(html);

   _ = nwin.setSize(10, 10);     // resize after .show

    _ = nwin.bind("MyButton1", my_function_count);
    _ = nwin.bind("MyButton2", my_function_exit);

    webui.wait();


    webui.clean();
}

In neither case does nwin.setSize(...) actually change the window size.

I'm not sure if this is a bug with this library (which essentially wraps WebUI) or with WebUI itself, but I'm posting it here just in case.

@hassandraga
Copy link
Member

I tested it using the C example, and it's working for me. We should use the debug version of WebUI to see what's going on in the logs.

On the other hand, WebUI only passes the window size using the command line if the web browser supports it. Otherwise, WebUI simply runs window.resizeTo(x, y);, so I suggest you use window.resizeTo in your UI using JavaScript while we debug the Zig wrapper.

@alecstein
Copy link
Author

alecstein commented Jan 4, 2024

@hassandraga Honestly it might be browser related. After window.resizeTo failed even in the console, I found this discussion:

https://stackoverflow.com/questions/65260529/how-to-resize-a-html-browser-window-with-javascript-using-chrome

Apparently you're (in many cases) only allowed to modify windows the size of windows opened with window.open(), as a security measure.

When you say it's working, what browser did you try it on? I'm using Firefox on MacOS Monterey.

@hassandraga
Copy link
Member

I test it using Chrome in Linux.

@jinzhongjia jinzhongjia self-assigned this Jan 4, 2024
@jinzhongjia
Copy link
Collaborator

em.. linux chrome is available with zig

@jinzhongjia
Copy link
Collaborator

I will still test it using other browser.
To be honest, this function doesn't even do wrapping, it just converts the integer type

@jinzhongjia
Copy link
Collaborator

jinzhongjia commented Jan 4, 2024

weird, zig setsize is not available with firefox
@hassandraga maye we should test it with C on firefox

@jinzhongjia jinzhongjia added the bug Something isn't working label Jan 4, 2024
@jinzhongjia
Copy link
Collaborator

I have test it with C on firefox, it really doesn't work

@jinzhongjia
Copy link
Collaborator

I will open an new issue in webui repository.

@hassandraga
Copy link
Member

The WebUIFirefoxProfile folder was already deleted in my system, so webui_set_size() worked when I test it. But starting from the second run, Firefox remember the last manually changed size and position, so it ignores the values setting by WebUI command lines.

A quick workaround is by deleting the Firefox profile on exist:

webui.deleteAllProfiles(); /// Delete all window object's web-browser profiles
webui.clean(); /// Clean all memory resources

Let's then figure out a better solution for Firefox in webui-dev/webui#296.

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

No branches or pull requests

3 participants