phillbush / xmenu

a x11 menu utility
Other
296 stars 26 forks source link

Dividers not working anymore #45

Closed jzbor closed 1 year ago

jzbor commented 1 year ago

So if I remember correctly this used to work and produce a menu with a divider in the middle:

printf "hello\n\nworld" | xmenu

Now I just get the following X error:

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  53 (X_CreatePixmap)
  Value in failed request:  0x0
  Serial number of failed request:  78
  Current serial number in output stream:  106

I am using NixOS unstable, which is on the latest version (4.5.5) if that helps.

Edit: I have also tried the sample script provided by this repository, which does not work either...

z0noxz commented 1 year ago

I just tried this on VoidLinux, and it works fine. I've read that others have had similar issues due to nvidia drivers (https://github.com/jgmenu/jgmenu/issues/139). It sounds like the issue is with your computer and not xmenu. Have you tried running the same command on anther computer?

jzbor commented 1 year ago

Hm I have a AMD graphics card (RX580) and I think I also tried on my laptop (Intel integrated), so I doubt it has something to do with the gpu directly. It might be something up with the dependencies/the packaging of those dependencies...

EDIT: Note that the issue that you linked does not refer to any sorts of (Nvidia) graphics driver issues, but rather the author of that issue looking it up and seeing mostly Nvidia problems (no wonder, when you search for something like that). It seems as though that issue kind of fixed itself which might again be to a dependency getting updated or something like that

jzbor commented 1 year ago

I think I have somewhat tracked down the issue to this line. The error results from item->h being 0 which is not a valid input according to XCreatePixmap(3).

z0noxz commented 1 year ago

What makes it zero then? The separator should have a height of 3 pixels.

What does the lines .separator_pixels = ... and .height_pixels = ... say in the config.h file if you compile it from source?

Add fprintf(stderr, "h:%d\n", item->h); at line 1183 above the XCreatePixmap, what doas that print? I get: h:25 h:3 h:25

jzbor commented 1 year ago

I don't have my PC available right now, but I compiled from the master branch of this repo and tried printing the parameter before each XCreatePixmap call, which led me to that line, which called the function with a 0 parameter.

z0noxz commented 1 year ago

Please try to determine why the value is not set to another value than 0. There are three lines of code that should result in a value higher than 0 (once the item is allocated). The first line sets the height of the separator with item->h = config.separator_pixels; (this seems most likely to be the issue if the error only occurs when using separators). The second line sets the height of items with a label to item->h = config.height_pixels; and the last line resets the height based on the condition if (menu->h + config.height_pixels * 2 < maxh - config.border_pixels * 2) where menu->h = menuh;. All three of these lines are located in the setupitems function.

I have attempted to replicate the error on my machine by compiling from the master branch, but I was unable to reproduce the error.

Have you asked other NixOS users if they are experiencing the same issue?

Edit: Correction, I was able to replicate the error by forcefully setting item->h = 0;. This gives the same error message as you get, so you are probably correct that is has to do with the height being 0. The question is why.

You could always try to debug using gdb and step through the program from when the items are allocated to see if the height is ever set and to what value.

phillbush commented 1 year ago

I could also not replicate the error without changing the code. I have even git-checkout'd to the last version (4.5.5) and the error did not occurred. item->h is initialized to zero by the allocating function, but it is then set to a positive value by the function that compute the menu size from its icons.

In any case, I have bumped the version to 4.6.0.

jzbor commented 1 year ago

Hey guys, Sorry for the troubles. I think I found the issue - this line somehow ended up in my Xresources:

xmenu.separatorWidth: 0

Setting it to a proper setting fixed the issue. Maybe it is worth mentioning that 0 is an invalid value for this setting or add a check, when the config is loaded. Probably depends on your preference though.

Thanks for the support!