diff --git a/include/webui.h b/include/webui.h index ceb365eed..3ac286305 100644 --- a/include/webui.h +++ b/include/webui.h @@ -192,6 +192,19 @@ WEBUI_EXPORT size_t webui_get_new_window_id(void); */ WEBUI_EXPORT size_t webui_bind(size_t window, const char* element, void (*func)(webui_event_t* e)); +/** + * @brief Get the "best" browser to be used. If running "webui::show()" + * or passing AnyBrowser to "webui::show_browser()", this function will + * return the same browser that will be used. + * + * @param window The window number + * + * @return Returns the best browser to be used. + * + * @example size_t browser = webui_get_best_browser(myWindow); + */ +WEBUI_EXPORT size_t webui_get_best_browser(size_t window); + /** * @brief Show a window using embedded HTML, or a file. If the window is already * open, it will be refreshed. diff --git a/include/webui.hpp b/include/webui.hpp index fb6103015..dd3fe719a 100644 --- a/include/webui.hpp +++ b/include/webui.hpp @@ -181,6 +181,8 @@ class window { // Get the ID of the last child process spawned by the browser. size_t get_child_process_id() const { return webui_get_child_process_id(webui_window); } + size_t get_best_browser() const { return webui_get_best_browser(webui_window); } + // Set the web-server root folder path for this specific window. bool set_root_folder(const std::string_view path) const { return webui_set_root_folder(webui_window, path.data()); diff --git a/src/webui.c b/src/webui.c index 76c46c290..e2e08db6c 100644 --- a/src/webui.c +++ b/src/webui.c @@ -1167,6 +1167,12 @@ size_t webui_bind(size_t window, const char* element, void( * func)(webui_event_ return cb_index; } +size_t webui_get_best_browser(size_t window) { + // This just exposes the existing function + _webui_window_t * win = _webui_core.wins[window]; + return _webui_find_the_best_browser(win); +} + const char* webui_get_string_at(webui_event_t* e, size_t index) { #ifdef WEBUI_LOG