Repeatedly making a window fullscreen from a shortcut key leaves an indelible mess on the screen(GTK4 + macOS)
which version of GTK are you using?
GTK4(b27a1692) meson_options.txt
which operating system are you using?
- ProductName: macOS
- ProductVersion: 11.6.4
- BuildVersion: 20G417
the necessary steps to reproduce the issue
This problem occurs when the following code is compiled and executed and the window is continuously fullscreen and unfullscreen from the shortcut keys.
- Run
gtk4-demo
- Run
Video Player
- Hit the F11 key repeatedly.
the expected outcome
It is desirable that no trash be left behind.
a description of the behavior
a small, self-contained example exhibiting the behavior
Sorry for the Rust code.
#include <gtk/gtk.h>
static gboolean toggle_fullscreen(GtkWidget *widget, GVariant *args,
gpointer data) {
GdkSurface *surface;
GdkToplevelState state;
surface = gtk_native_get_surface(GTK_NATIVE(widget));
state = gdk_toplevel_get_state(GDK_TOPLEVEL(surface));
if (state & GDK_TOPLEVEL_STATE_FULLSCREEN)
gtk_window_unfullscreen(GTK_WINDOW(widget));
else
gtk_window_fullscreen(GTK_WINDOW(widget));
return TRUE;
}
static void activate(GtkApplication *app, gpointer user_data) {
GtkWidget *window;
GtkEventController *controller;
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Window");
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
controller = gtk_shortcut_controller_new();
gtk_widget_add_controller(window, controller);
gtk_shortcut_controller_add_shortcut(
GTK_SHORTCUT_CONTROLLER(controller),
gtk_shortcut_new(gtk_keyval_trigger_new(GDK_KEY_F11, 0),
gtk_callback_action_new(toggle_fullscreen, NULL, NULL)));
gtk_widget_show(window);
}
int main(int argc, char **argv) {
GtkApplication *app;
int status;
app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
Edited by sumibi-yakitori