0

I'm writing a reparenting window manager for X11 (and have asked a number of questions about it here already). Right now, the issue I'm having isn't so much a bug to fix as much as a question on how to implement something.

Applications can request transparency, and if a compositor like xcompmgr or picom is running, they will provide it. However, this doesn't seem to work when I reparent the window; in this case the client window's background just shows a black background behind (maybe the frame window? but the background of that isn't black). I do indicate I have a frame by setting _NET_FRAME_EXTENTS.

What I've tried:

  • It looks like awesomewm's code for opacity listens to a property notify with a _NET_WM_OPACITY. I don't get any PropertyNotify event when I change opacity of a window, despite selecting SubstructureRedirect|SubstructureNotify|PropertyChange on the root window.
gsb
  • 67
  • 2
  • 9
  • I think I might have figured it out. Setting PropertyNotify on the actual client window and I receive events. Now I can try to figure out how to forward the net wm opacity to the frame window, like awesome does. awesome! (pun intended ;)) – gsb Oct 08 '21 at 22:03
  • Hmm. I recieve events, but it is really interesting because they don't seem to be in EWMH; I was looking for _NET_WM_WINDOW_OPACITY – gsb Oct 08 '21 at 22:54
  • `Got atom 322, expected one of EWMH: [241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 304, 268, 269, 270, 271, 272, 273]`; 304 is net wm window opacity. It looks like it's not actually part of the EWMH specification, but I do get the atom with xcb_intern_atom. What should I try now? – gsb Oct 08 '21 at 22:55
  • Guess I could just get trans of window and apply that to frame, might work, but feels unclean. I don't understand why this wouldn't work if it works in awesomewm. – gsb Oct 08 '21 at 23:01
  • Actually not so fast; this happens on any button press. So I have no clue :( – gsb Oct 08 '21 at 23:20

1 Answers1

1

You need to create your frame window with reparenting with depth=32 (i.e.: Made to work with transparency). Since you are already looking at AwesomeWM: It finds the right visual for this at startup and then creates all of its windows this way. That is only necessary since Lua code might want transparency. AFAIR, other WMs look at the program's window bit depth and create their frame window based on that.

Uli Schlachter
  • 9,337
  • 1
  • 23
  • 39
  • Thanks. However if I do `self.conn.create_window(32, ...` the window never shows up, but w/ COPY_DEPTH_FROM_PARENT it does. – gsb Oct 09 '21 at 15:23
  • If I use geom.depth it works on some windows like Chromium, but not on others; and once that window is unmapped then it doesn't let other windows be mapped. ?? – gsb Oct 09 '21 at 15:28
  • ah, it looks like chromium's depth is 24. windows with a depth of 24 work, but not with a depth of 32. hardcoding the depth to 24 and I don't get any transparency. – gsb Oct 09 '21 at 15:29
  • Setting the colormap from attr.colormap does not work either – gsb Oct 09 '21 at 15:53
  • See https://stackoverflow.com/questions/3645632/how-to-create-a-window-with-a-bit-depth-of-32 – Uli Schlachter Oct 09 '21 at 16:01
  • but border_pixel is set: this is how I create the frame window (using x11rb, with &win_aux as last parameter): https://hastebin.com/uladadifuv.rust – gsb Oct 09 '21 at 16:36
  • Perhaps I have to create my own colormap. – gsb Oct 09 '21 at 16:51
  • trying to create my own: https://hastebin.com/degezuvuro.rust has no effect either. so I have no idea why the window is not mapped when bit depth is 32. – gsb Oct 09 '21 at 17:00
  • 1
    Ok, so I had to use the colormap *and* visual provided by attributes. Now transparency works! But the issue I have is that now it makes the titlebar transparent too on windows with depth 32. How do I work around *that*? I just set the background to something and depth=32. would it work if I drew a rectangle instead? – gsb Oct 09 '21 at 19:25
  • Marked this as solved, because the core concept (opacity) this answer is fine; followup question @ https://stackoverflow.com/questions/69510499/how-to-set-an-opaque-background-for-window-with-depth-32 – gsb Oct 09 '21 at 20:53