5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-01 13:31:25 +08:00

Make calls thread safe

This commit is contained in:
Lea Anthony 2025-02-08 10:37:58 +11:00
parent 89db2ad082
commit 347d8cf861
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405

View File

@ -14,9 +14,6 @@ static float xroot = 0.0f;
static float yroot = 0.0f;
static int dragTime = -1;
static uint mouseButton = 0;
static int wmIsWayland = -1;
static int decoratorWidth = -1;
static int decoratorHeight = -1;
// casts
void ExecuteOnMainThread(void *f, gpointer jscallback)
@ -73,23 +70,13 @@ static bool isNULLRectangle(GdkRectangle input)
static gboolean onWayland()
{
switch (wmIsWayland)
const char *gdkBackend = getenv("XDG_SESSION_TYPE");
if(gdkBackend != NULL && strcmp(gdkBackend, "wayland") == 0)
{
case -1:
char *gdkBackend = getenv("XDG_SESSION_TYPE");
if(gdkBackend != NULL && strcmp(gdkBackend, "wayland") == 0)
{
wmIsWayland = 1;
return TRUE;
}
wmIsWayland = 0;
return FALSE;
case 1:
return TRUE;
default:
return FALSE;
}
return FALSE;
}
static GdkMonitor *getCurrentMonitor(GtkWindow *window)
@ -270,24 +257,18 @@ void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_wid
size.min_height = min_height;
size.min_width = min_width;
// On Wayland window manager get the decorators and calculate the differences from the windows' size.
// On Wayland window manager get the decorators and calculate the differences from the window size.
if(onWayland())
{
if(decoratorWidth == -1 && decoratorHeight == -1)
{
int windowWidth, windowHeight;
gtk_window_get_size(window, &windowWidth, &windowHeight);
int windowWidth, windowHeight;
gtk_window_get_size(window, &windowWidth, &windowHeight);
GtkAllocation windowAllocation;
gtk_widget_get_allocation(GTK_WIDGET(window), &windowAllocation);
GtkAllocation windowAllocation;
gtk_widget_get_allocation(GTK_WIDGET(window), &windowAllocation);
decoratorWidth = (windowAllocation.width-windowWidth);
decoratorHeight = (windowAllocation.height-windowHeight);
}
// Add the decorator difference to the window so fullscreen and maximise can fill the window.
size.max_height = decoratorHeight+size.max_height;
size.max_width = decoratorWidth+size.max_width;
size.max_height = (windowAllocation.height-windowHeight)+size.max_height;
size.max_width = (windowAllocation.width-windowWidth)+size.max_width;
}
gtk_window_set_geometry_hints(window, NULL, &size, flags);