mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 06:20:48 +08:00
change ifdef to function
This commit is contained in:
parent
bed3ec4163
commit
d04fd9a35f
@ -14,6 +14,9 @@ static float xroot = 0.0f;
|
|||||||
static float yroot = 0.0f;
|
static float yroot = 0.0f;
|
||||||
static int dragTime = -1;
|
static int dragTime = -1;
|
||||||
static uint mouseButton = 0;
|
static uint mouseButton = 0;
|
||||||
|
static int wmIsWayland = -1;
|
||||||
|
static int decoratorWidth = -1;
|
||||||
|
static int decoratorHeight = -1;
|
||||||
|
|
||||||
// casts
|
// casts
|
||||||
void ExecuteOnMainThread(void *f, gpointer jscallback)
|
void ExecuteOnMainThread(void *f, gpointer jscallback)
|
||||||
@ -68,6 +71,27 @@ static bool isNULLRectangle(GdkRectangle input)
|
|||||||
return input.x == -1 && input.y == -1 && input.width == -1 && input.height == -1;
|
return input.x == -1 && input.y == -1 && input.width == -1 && input.height == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean onWayland()
|
||||||
|
{
|
||||||
|
switch (wmIsWayland)
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static GdkMonitor *getCurrentMonitor(GtkWindow *window)
|
static GdkMonitor *getCurrentMonitor(GtkWindow *window)
|
||||||
{
|
{
|
||||||
// Get the monitor that the window is currently on
|
// Get the monitor that the window is currently on
|
||||||
@ -228,9 +252,6 @@ void SetPosition(void *window, int x, int y)
|
|||||||
ExecuteOnMainThread(setPosition, (gpointer)args);
|
ExecuteOnMainThread(setPosition, (gpointer)args);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decoratorWidth = 0;
|
|
||||||
static int decoratorHeight = 0;
|
|
||||||
|
|
||||||
void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_width, int max_height)
|
void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_width, int max_height)
|
||||||
{
|
{
|
||||||
GdkGeometry size;
|
GdkGeometry size;
|
||||||
@ -249,10 +270,10 @@ void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_wid
|
|||||||
size.min_height = min_height;
|
size.min_height = min_height;
|
||||||
size.min_width = min_width;
|
size.min_width = min_width;
|
||||||
|
|
||||||
# ifdef GDK_WINDOWING_WAYLAND
|
if(onWayland())
|
||||||
if (decoratorWidth == 0 && decoratorHeight == 0) {
|
{
|
||||||
char *gdkBackend = getenv("XDG_SESSION_TYPE");
|
if(decoratorWidth == -1 && decoratorHeight == -1)
|
||||||
if(gdkBackend != NULL && strcmp(gdkBackend, "wayland") == 0 && gtk_window_get_decorated(window)) {
|
{
|
||||||
int windowWidth, windowHeight;
|
int windowWidth, windowHeight;
|
||||||
gtk_window_get_size(window, &windowWidth, &windowHeight);
|
gtk_window_get_size(window, &windowWidth, &windowHeight);
|
||||||
|
|
||||||
@ -262,11 +283,10 @@ void SetMinMaxSize(GtkWindow *window, int min_width, int min_height, int max_wid
|
|||||||
decoratorWidth = (windowAllocation.width-windowWidth);
|
decoratorWidth = (windowAllocation.width-windowWidth);
|
||||||
decoratorHeight = (windowAllocation.height-windowHeight);
|
decoratorHeight = (windowAllocation.height-windowHeight);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
size.max_height = decoratorHeight+size.max_height;
|
size.max_height = decoratorHeight+size.max_height;
|
||||||
size.max_width = decoratorWidth+size.max_width;
|
size.max_width = decoratorWidth+size.max_width;
|
||||||
#endif
|
}
|
||||||
|
|
||||||
gtk_window_set_geometry_hints(window, NULL, &size, flags);
|
gtk_window_set_geometry_hints(window, NULL, &size, flags);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user