sulami / FrankenWM

🖼️ Fast dynamic tiling X11 window manager
https://bbs.archlinux.org/viewtopic.php?id=189060
Other
263 stars 34 forks source link

Some windows don't play nicely with xcb_ewmh #117

Open qsmodo opened 3 years ago

qsmodo commented 3 years ago

I've set #define OUTPUT_TITLE True in my config.h, recompiled, but still no title is output.

I added a debugging fprintf(stderr, "%s\n", wtitle.strings); statement inside this test:

https://github.com/sulami/FrankenWM/blob/0eb3d54b0cf7cac958408826f1d434d8867f3a6b/frankenwm.c#L1385-L1388

and found out that the output is (null). It seems something is wrong with handling that string.

qsmodo commented 3 years ago

Okay, it turns out this is a more over-reaching issue. Not all windows respond to xcb_ewmh_get_wm_name, especially old ones as xterm, xmessage, gvim, and probably many others. This also means that rules[] also fails for matching those windows. Indeed,

https://github.com/sulami/FrankenWM/blob/0eb3d54b0cf7cac958408826f1d434d8867f3a6b/frankenwm.c#L2063-L2064

prints garbage or is skipped altogether for such windows.

Spectrwm works correctly in this regard, and it uses xcb_icccm functions, not xcb_ewmh, so probably that's the problem.

qsmodo commented 3 years ago

So, with the PR merge the largest problem is gone. Now there is the output title issue left.

What I have managed to do is in this branch. At first sight it seems to work well, the title is output for all windows. But if the title contains non-ASCII characters, it may get cropped or mangled. As it turns out, the Xlib uses some obscure COMPOUND_TEXT and converting it to UTF-8 is as obscure and tricky (see this thread).

The options, as I see it, are

  1. Leave this thing alone and allow OUTPUT_TITLE not to work.
  2. Merge that branch, and now OUTPUT_TITLE more or less works, but the window title may get mangled.
  3. Delete OUTPUT_TITLE altogether and use xdotool getactivewindow getwindowname.

Honestly option 3 looks the best to me. I have been using it for a couple of months in my Dzen bar and it works flawlessly. It also avoids duplicating code.