Gtk4 EventController GestureClick returns incorrect state- Gdk.ModifierType on mouse button press in X11

,

Gesture click works correctly in Wayland and returns the correct Gdk.ModifierType in integers on logging.

The methods fail under X11 and return incorrect Hex numbers.

Example program is attached. Left mouse click in the window will log the errors to the console on X11, correct state is reported on running the same program on Wayland.

Again, a problem with Gjs or Gtk4?

Addendum: Just checked on Manjaro everthing works fine even under X11, it fails in latest Fedora and Ubuntu 22.04. So probably a problem in latest Gtk4 for these distributions?

#!/usr/bin/env gjs

imports.gi.versions.Gtk = "4.0";
const { Gio, Gtk } = imports.gi;

class ImageViewerWindow {
    constructor(app) {
        this._app = app;
        this._window = null;
    }

    _buildUI() {
        this._window = new Gtk.ApplicationWindow({
            application: this._app,
            defaultHeight: 600,
            defaultWidth: 800
        });
        
        this._buttonClick = Gtk.GestureClick.new();
        this._buttonClick.set_button(0);
        this._buttonClick.set_propagation_phase(Gtk.PropagationPhase.BUBBLE);
        this._window.add_controller(this._buttonClick);
        this._buttonClick.connect('pressed', (actor, n_press, x, y) => {
            let button = actor.get_current_button();
            let state = this._buttonClick.get_current_event().get_modifier_state();
            let anotherstate = this._buttonClick.get_current_event_state();
            log(state);
            log(anotherstate);
        });
    }

    getWidget() {
        this._buildUI();
        return this._window;
    }
}

const application = new Gtk.Application({
    application_id: 'org.gnome.Sandbox.MenuExample',
    flags: Gio.ApplicationFlags.FLAGS_NONE
});

application.connect('activate', app => {
    let activeWindow = app.activeWindow;

    if (!activeWindow) {
        let imageViewerWindow = new ImageViewerWindow(app);
        activeWindow = imageViewerWindow.getWidget();
    }

    activeWindow.present();
});

application.run(null);

I’ve been doing some tests under Debian SID, both in Wayland and X11.

In Wayland, both calls return 0x00 if no modifier key is pressed; 0x01 if SHIFT key is pressed; 0x04 if CTRL key is pressed, and 0x08 if ALT key is pressed.

In X11 I receive an error:

Gjs-CRITICAL: JS ERROR: 0x1n is not a valid value for flags GdkModifierType_buildUI

being ‘n’ the same value than in Wayland; this is: under X11, the state has the bit 4 set, making it an invalid value.