webui-dev / webui

Use any web browser or WebView as GUI, with your preferred language in the backend and modern web technologies in the frontend, all in a lightweight portable library.
https://webui.me
MIT License
2.9k stars 164 forks source link

The position of the window to open at startup (Windows) #189

Closed delphius closed 11 months ago

delphius commented 1 year ago

It's not the first time I've encountered it, when you run a program from a folder, the program window (browser) itself opens BEHIND this folder, and not in front of it, as it would be logical.

Is it the same for everyone and what is the reason?

hassandraga commented 1 year ago

Yes, that's happen in some specific scenarios/OS. We can fix this by using OS APIs to get the window ID and bring it to the front, but this is low priority for now.

Please keep this open until gets implemented.

fibodevy commented 1 year ago

It would be useful if there was function to return actual OS window handle, then it would be possible to set the focus to this window, and also do more useful things. For example show & hide window if tray icon clicked.

hassandraga commented 11 months ago

Unfortunately, we can't control the behavior of the web browser. I added two new APIs to get the process ID, but for now, those APIs are "useless" because the web browser create many child process for the window and dispatch the main parent process ID. I will close this as a won't fix.

printf("Child process: %lld\n", webui_get_child_process_id(my_window));
printf("Parent process: %lld\n", webui_get_parent_process_id(my_window));

If anyone have a solution/suggestion we will re-open this issue.

hassandraga commented 11 months ago

New update https://github.com/webui-dev/webui/commit/a616991ca679f0646bf35d580443e101369273ce.

Now webui_get_child_process_id() will return the correct web browser's last child process ID.