Is there a reason why there is no complete kwin API for c++?

Let’s say I want to get the list of all windows. In kwin scripts, I can just do workspace.windowList() (in kwin6, workspace.clientList() in kwin5), regardless if on X11 or Wayland. In C++ instead this can be done only on X11 using KX11Extras, while on Wayland there is no way at all (AFAIK). Are there reasons there is not an official API with the same exact functionalities of the scripting console? what I’m currently doing is saving a new kwin script to a temporary file, installing it, running it, reading its output from the journalctl, uninstalling it and removing it. This seems a crazy way to get a simple list of windows

KX11Extras and KWin scripts are very different things.

KX11Extras is for applications to interact with X11 and do various things. It is not really specific to KWin and limited by what X11 allows applications to do.

KWin scripts are running as part of KWin. That means they have more direct access to what happens inside of KWin.

It is possible to write KWin plugins with C++ that directly interact with KWins internal C++ APIs. However that API is not stable, so third-party extensions should prefer the scripting API


Thank you very much for the reply! I understand now, I’ll better stick to classical kwin scripts. I wanted to use c++ because I wanted to be able to run the script with a command, passing parameters to the script (window name and class). Do you know of any way to achieve this?