I have the following basic setup
const St = imports.gi.St;
const Webkit = imports.gi.WebKit2;
const Gtk = imports.gi.Gtk;
let window, webView;
function _handleclick(){
window = new Gtk.Window({
type: Gtk.WindowType.TOPLEVEL
decorated: false,
skip_taskbar_hint: true,
skip_pager_hint: true,
resizable: false,
});
window.set_default_size(400, 600);
webView = new Webkit.WebView();
webView.load_uri(https://www.example.com);
window.add(webView);
window.set_position(Gtk.WindowPosition.MOUSE);
window.show_all();
}
The function is called when the user clicks a St.Bin object, defined like this
button = new St.Bin({
style_class: 'panel-button',
reactive: true,
can_focus: true,
x_expand: true,
y_expand: false,
track_hover: true
});
when this function is called, the Gtk.Window containing the WebView is drawn successfully, and the website displayed can be focused and interacted with using the keyboard (tab
, enter
, alt+tab
, etc.) but it doesn't appear to pick up any mouse events. Even though clicking on the window will allow it to grab focus, the elements of the displayed website do not respond to any mouse interaction, be it clicking or scrolling.
I've been going over the documentation for both WebView and Window, according to the former, "WebKitWebView is scrollable by itself", which seems to imply that it should already be listening for mouse events, and from my spotty understanding of this article on Gtk event propagation, since the window has focus, it should be propagating the events to the GtkWidget; clearly there's something I'm failing to understand here or perhaps the mouse event is being picked up by something else? The website show in the webview seems to receive an event when the mouse pointer enters or exits the webview area, but no button presses or other movement.
I have tried fumbling around with a bunch of direrent attibutes and functions I've found in the documentation but every resource online would seem to indicate that the basic setup of a webview inside a gtk window should work without further tweaking.
It looks like you might be trying to create a GTK window inside the GNOME Shell process; that's not supported. You'll have to spawn a new process if you want to use GTK.