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);