Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some windows don't play nicely with xcb_ewmh #117

Open
qsmodo opened this issue Jun 8, 2021 · 2 comments
Open

Some windows don't play nicely with xcb_ewmh #117

qsmodo opened this issue Jun 8, 2021 · 2 comments

Comments

@qsmodo
Copy link
Contributor

qsmodo commented Jun 8, 2021

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:

FrankenWM/frankenwm.c

Lines 1385 to 1388 in 0eb3d54

if (M_CURRENT) {
cookie = xcb_ewmh_get_wm_name_unchecked(ewmh, M_CURRENT->win);
xcb_ewmh_get_wm_name_reply(ewmh, cookie, &wtitle, (void *)0);
}

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

@qsmodo
Copy link
Contributor Author

qsmodo commented Jun 8, 2021

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,

FrankenWM/frankenwm.c

Lines 2063 to 2064 in 0eb3d54

if (xcb_ewmh_get_wm_name_reply(ewmh, cookie, &wtitle, (void *)0)) {
DEBUGP("EWMH window title: %s\n", wtitle.strings);

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 qsmodo changed the title OUTPUT_TITLE doesn't work Some windows don't play nicely with xcb_ewmh Jun 8, 2021
@qsmodo
Copy link
Contributor Author

qsmodo commented Jul 7, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant