Get window id of a Window object (Window.get_xwindow() doesn't exist)

Hi,

I’m using an extension that started failing after an upgrade.

The extension relied on Window.get_xwindow() to get the window id of a given window, but that function is not available anymore (at least is not showing in Meta 7 API documentation).

Fetching Meta.MAJOR_VERSION & Meta.MINOR_VERSION & Meta.MICRO_VERSION yields: v 5.4.6

Any ideas how to get a window id (i.e. the id returned by a utility like xwininfo) using the API?

Thanks

That’s quite surprising, given that the function was marked as non-introspectable more than 10 years ago, before the 3.0 release.

Any ideas how to get a window id

If you really have to mess with (legacy) X11-specific APIs, you can look at window.get_description(). If the returned string starts with 0x, then it is the (hexadecimal) XID of the client window.

1 Like

Thanks Florian, I tried the get_description() workaround and it seems to work.

Out of curiosity (I have very little knowledge of gnome development), what would be the proper way to do this without legacy APIs?

The extension essentially binds to maximize/unmaximize events and then calls xprop to un/decorate the window in response to those events, so currently for xprop to work it needs the window id which was previously fetched using get_xwindow().

Thanks

what would be the proper way to do this without legacy APIs?

You didn’t mention before what “this” was :wink:

For wayland clients, window decorations are handled by the client as regular part of the window, so it’s not possible to remove them behind the app’s back.

That is, what you are doing is inherently tied to X11, so using an X11-specific hack is acceptable (well, really all you can do anyway).

1 Like