[WayLand] GDK_FULLSCREEN_ON_ALL_MONITORS works only when the process is owned by root

Using the below snippet, works perfectly on X11, but it silently fails under WayLand when you have more than one monitor configured.

What it’s strange is that it works when the process creating the fullscreen is owned by root.

By silently I mean that we don’t see any error messages, but the windows go fullscreen on only one monitor.

I think it’s not a GTK bug, but probably a compositor issue, and we didn’t try to run on other compositors.

Where we should report this problem?

We tested on Fedora 35, and Ubuntu 21.10

#include <gtk/gtk.h>

static void
activate(GtkApplication *       app,
         gpointer user_data)
{
        GtkWidget *window;

        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_widget_show(window);
        gdk_window_set_fullscreen_mode(
                gtk_widget_get_window(window),
                GDK_FULLSCREEN_ON_ALL_MONITORS);
        gdk_window_fullscreen(GDK_WINDOW(gtk_widget_get_window(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;
}

There is no real way to do that in Wayland as of yet. The flag does nothing with the Wayland GTK backend, but also Mutter seems to lack the code to do it. Maybe some other compositors have another custom Wayland extension that supports it, if they did it would have to be added to GTK. You could put in a feature request, but I would say you just want to completely avoid doing that on Wayland. It is a bad idea. Stretching a single buffer across all monitors won’t work right when the displays have different refresh rates.

It seems likely that running the application as root is causing it to fall back to Xwayland which still preserves the old X11 behavior. You could try to test with a GDK_BACKEND=x11 environment variable to see if it also works that way.

Thanks for your answer

It all makes sense, but I have a use case where having a buffer spanning multiple monitors is a requirement.

The problem has been emerged when we added support for multiple monitors in Remmina for the RDP protocol. There’s no other way to implement it.

GNOME Connection, vinaigre, wlfreerdp and the like may suffer from the same issue.

Another missing feature is to have a buffer spanning only a limited number of monitors. Today is either one or all.

You can implement in your application using several windows that each pull from an offscreen buffer. This is technically what the wayland compositor would be doing anyway.

Otherwise, you would have to put in a feature request for a new Wayland extension that can fullscreen a window using a list of outputs. I don’t think that exists yet.

Thanks @jfrancis, I’ll evaluate pros and cons of each option and hope in some external support :-p

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.