fix win size bug on linux.

This commit is contained in:
alves
2026-03-04 17:48:36 +08:00
parent 1dc0e3dda8
commit f004e9194b
2 changed files with 14 additions and 4 deletions

View File

@@ -504,6 +504,12 @@ std::deque<wxDialog*> dialogStack;
void fit_in_display(wxTopLevelWindow& window, wxSize desired_size)
{
// GTK requires width >= -1 and height > 0 for gtk_window_resize/set_size_request
if (desired_size.GetWidth() < WINDOW_MIN_WIDTH)
desired_size.SetWidth(WINDOW_MIN_WIDTH);
if (desired_size.GetHeight() < WINDOW_MIN_HEIGHT)
desired_size.SetHeight(WINDOW_MIN_HEIGHT);
const auto display_size = wxDisplay(window.GetParent()).GetClientArea();
if (desired_size.GetWidth() > display_size.GetWidth()) {
desired_size.SetWidth(display_size.GetWidth() * 4 / 5);

View File

@@ -17,6 +17,11 @@
#endif
#include "sentry_wrapper/SentryWrapper.hpp"
#if defined(__linux__)
#include <mutex>
#endif
#ifdef __WIN32__
#include <WebView2.h>
#include <Shellapi.h>
@@ -278,12 +283,11 @@ wxWebView* WebView::CreateWebView(wxWindow * parent, wxString const & url)
// Handlers must be registered before Create(). Linux (WebKit2): scheme is process-global, register once to avoid "Cannot register URI scheme ... more than once".
// macOS (WKWebView): scheme is per-view, each WebView needs its own handlers.
#if defined(__linux__)
static bool s_wxfs_memory_handlers_registered = false;
if (!s_wxfs_memory_handlers_registered) {
static std::once_flag s_wxfs_memory_handlers_once;
std::call_once(s_wxfs_memory_handlers_once, [webView]() {
webView->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
webView->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));
s_wxfs_memory_handlers_registered = true;
}
});
#else
webView->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewArchiveHandler("wxfs")));
webView->RegisterHandler(wxSharedPtr<wxWebViewHandler>(new wxWebViewFSHandler("memory")));