x11awesome-wmxcbxembed

Would I be able to use the XEmbed extension to implement titlebars, and arbitrary embedding of clients in my window manager?


I'm writing a window manager that is similar to AwesomeWM in that it will be configurable with lua, will have a UI system to awesome's wibox, but with some additional niceties like built-in animation support, among other things.

I know AwesomeWM uses client properties like "client.titlebar_top" to implement titlebars, but what I would like to do is allow users to do two things:

Upon seeing this, my thought was that this could be simplified: if you can embed a client inside a wibox in an arbitrary way, you could create a titlebar by just automatically embedding a client in a wibox whenever it gets managed by the WM:

clients = {}

root.connect_signal("managed", function(client) {
    table.insert(clients, wibox({
        x = 20, y = 20, width = 200, height = 200,
        layout = wibox.layout.vertical,
        {}, -- titlebar would be here
        client
    }))
})

(forgive me if the syntax is not exactly correct, it's been a long time since I used awesome's wibox syntax.)

But if this feature existed, a user would also be able to, for example, implement a widget that would show a horizontal list of all the currently active clients. For example, the way Windows 7 had it where you would hover over the icon of a client, and it would show you a smaller preview of the contents of that client.

My question is: would it be possible to arbitrarily embed a client like this in a wibox window by using the xembed extension?

Also, by "arbitrarily embedded" I mean that you would be able to treat the embedded client as just another "element" that is part of that wibox layout. Meaning you can have multiple embedded windows in a wibox, and the embedded client window could be occluded by other elements drawn by cairo, it could be shaped arbitrarily, it can be rotated, scaled, translated, and become transparent.

Essentially, I would like to be able to treat the embedded client as if I was drawing an image with cairo.


Solution

  • For example, the way Windows 7 had it where you would hover over the icon of a client, and it would show you a smaller preview of the contents of that client.

    The key word here is smaller. What makes the preview smaller? If the WM shows the "real window" here, the app will update its layout to the new size, but would not make its content smaller.

    My question is: would it be possible to arbitrarily embed a client like this in a wibox window by using the xembed extension?

    Nope. The xembed specification is a special protocol that defines how the window that is being embedded and the window that it is embedded into have to behave. These rules are quite different to the rules from ICCCM (which is the specification that describes "normal" WM behaviour.

    and the embedded client window could be occluded by other elements drawn by cairo, it could be shaped arbitrarily,

    Nope. You could use the SHAPE extension to do arbitrary shapes, but you cannot just use normal drawing to define shapes. With "normal drawing" to a window, whatever draws last wins and draws over anything that was there before. If you send your cairo drawing to a different window than the window that you want to embed, then the shape of the window decides which of your drawing just disappears into nothingness.

    it can be rotated, scaled, translated, and become transparent.

    All of these are not actually possible with X11. There is the composite extension which makes compositing managers (e.g. xcompmgr or picom) possible.

    With this extension, it is not the X11 server that decides what is actually shown on the screen. Instead, the compositing manager gets all window contents as images and draws them however it likes.

    However, this only allows rotating, ... windows in screen. Event processing still works as normal. So, for "clicking things", the window is not actually rotated.

    Essentially, I would like to be able to treat the embedded client as if I was drawing an image with cairo.

    However, this is a window and not an image. Sorry.