1

I've recently switched to using dwm and have been bumping up against a weird behaviour in Firefox, when clicking the right mouse button.

Placement of context menu under i3

Above is Firefox opening a context menu under most window managers. (This particular shot is taken in i3, but it's the same in Gnome and other window managers and desktop environments). Notice that the context menu appears a couple of pixels down and to the right of the cursor's hotspot, so that releasing the mouse button won't activate anything from the menu; the menu remains open and you may select something from it with a subsequent click.

Placement of context menu under dwm

By contrast, the above shot is of Firefox opening the context menu under dwm. Notice that the context menu has appeared directly under the cursor's hotspot, so pressing and releasing the mouse button instantly triggers the 'Open Link in New Tab' item and closes the menu. (This same thing also happens with the 'Back' option, if you do a right-click that's not over a link)

This only seems to happen in Firefox; Chrome's context menu appears in the correct place, as do the ones in Gnome Terminal and Gimp. Has anybody else bumped into this and know of a fix?

1

This appears to be a bug either in dwm (version 6.1) or in Firefox (version 57.04), but here's what lead to this misbehaviour:

In dwm's configuration file config.h, there is the following line:

static const unsigned int borderpx  = 2;        /* border pixel of windows */

This value specifies how large dwm's window borders are. By default, this value is set to 2. I had increased this value to 4, to make it easier to tell which window currently had the focus. (by default, dwm draws non-focused window borders in medium grey, and focused window borders in medium blue, which I personally find a little hard to distinguish in very narrow lines when glimpsed from the corner of the eye)

That's all fine, but the borderpx unexpectedly also seems to affect the placement of Firefox's context menu (and only Firefox's context menu; context menus in other programs appear not to be affected); when it's opened, the menu is placed one pixel further toward the top and one pixel toward the left, for each integral value above 2.

For example, here's where Firefox's context menu opens relative to the cursor if you set borderpx to 30:

weird placement!

Any value above '2' will result in Firefox's context menu opening up with an active part of the menu appearing directly beneath the cursor's hotspot, and thus automatically being activated if you do a single right-click. So to work around this issue, you need to reduce borderpx to a value of 2 or lower. (Or, I guess, increase it to over 268, if you'd like to make the context menu appear entirely to the left of where you click, and are okay with absurdly thick borders around all your windows)

Moral of the story: If you want to make dwm's focused windows more quickly identifiable, do it by changing the color of the borders, not by changing the width of the borders.

  • Can't replicate. I'd say it is a bug in your theme. – jasonwryan Jan 31 '18 at 20:15
  • @jasonwryan I'm not using a theme; just the default Firefox with uBlock Origin and nothing else. Edit: er.. and I guess I had LastPass on one of the computers where I had the problem, since I can see it in one of the screenshots. Not on the one I'm using right now, though. – Trevor Powell Feb 1 '18 at 6:29
  • Firefox is a GTK app; you are using a theme... – jasonwryan Feb 1 '18 at 6:39
  • @jasonwryan It's just set to Ambiance, one of the standard themes that comes with GTK under Ubuntu. I did mention in the original question that I don't get the same misbehaviour in Gnome-Terminal or Gimp or Chrome, which I understand all use GTK. If it was a GTK theme bug as you're saying, then wouldn't it affect all GTK applications? It also doesn't affect Thunar or Nautilus. Firefox is the only place where it seems to happen, for me. – Trevor Powell Feb 2 '18 at 3:36
  • And incidentally, when you said "a bug in your theme", I assumed you meant a Firefox theme, since I was talking about Firefox, and Firefox supports themes. That's an entirely fair thing for me to have assumed you meant, based upon the tiny throwaway comment you wrote. – Trevor Powell Feb 2 '18 at 3:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.