[Win32] GTK partially freezes the desktop under specific circumstances in a mixed-DPI setup
Steps to reproduce
- Compile the provided MVE and ensure it is linked with the provided manifest.
- Set two adjacent monitors up. Set one to 200% scale and the other to 100% scale.
- Slowly drag the window from one monitor to the other.
- Your desktop should partially freeze, blocking some types of user input. You can unfreeze it by closing the app through Task Manager.
MVE
gtk-scaling-mve.c
(Main source code)
#include <gtk/gtk.h>
#include <windows.h>
static void activate(GtkApplication* app, gpointer user_data)
{
GtkWidget* window;
GtkWidget* button;
button = gtk_button_new_with_label("click me!");
gtk_widget_set_margin_top(button, 12);
gtk_widget_set_margin_bottom(button, 12);
gtk_widget_set_margin_start(button, 12);
gtk_widget_set_margin_end(button, 12);
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Window");
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_window_set_child(GTK_WINDOW(window), button);
gtk_window_present(GTK_WINDOW(window));
}
int main(int argc, char** argv)
{
GtkApplication* app;
int status;
SetEnvironmentVariableA("GTK_CSD", "0");
app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
app.manifest
(This is needed to enable per-monitor DPI scaling)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
Current behavior
The window remains frozen in place. Certain inputs are blocked on other windows or register incorrectly (for example, attempting to open a dropdown in Task Manager doesn't work).
Expected outcome
GTK should not freeze.
Version information
- GTK version: 4.16.5 (current version provided by
gvsbuild
)- configuration:
debug-optimized
- configuration:
Additional information
Here's what the desktop looks like when I trigger the freeze:
Nothing of interest is printed to the terminal before the crash, even if I set G_MESSAGES_DEBUG=1
.
System information
- OS: Windows 11 Home (23H2, OS Build 22631.4460)
- Graphics: Intel UHD Graphics
- Monitors: I have two monitors:
- Laptop screen: 2256x1024, 200% scaling
- Monitor: 1920x1080, 100% scaling