Closed immjs closed 2 years ago
On Linux like suggested here https://stackoverflow.com/questions/14732838/how-to-get-xwindow-id-in-gtk3
const gi = require('node-gtk')
const Gtk = gi.require('Gtk', '3.0')
// Importing 'GdkX11' adds .getXid()
gi.require('GdkX11')
gi.startLoop()
Gtk.init()
const win = new Gtk.Window({title: 'Hello', window_position: Gtk.WindowPosition.CENTER})
win.on('show', () => {
const xid = win.getWindow().getXid();
console.log(`xid: 0x${Number(xid).toString(16)}`)
Gtk.main()
})
win.on('destroy', Gtk.mainQuit)
win.showAll()
$ node index.js
xid: 0x6200003
$ xwininfo -name Hello
xwininfo: Window id: 0x6200003 "Hello"
...
Oh, I have to wait for it to show. Alright, thanks !
Hello, How can I get the XWindow ID of a GTK window? I can only seem to find information about getting the XWindow ID of a GDK window.