phillbush / xmenu

a x11 menu utility
Other
296 stars 26 forks source link

coordinates on multi monitor #8

Closed GideonWolfe closed 4 years ago

GideonWolfe commented 4 years ago

So this is a nitpick but I figured I would ask anyways.

Currently I have a button on my bar that triggers xmenu to my cursor location. This works great because I have three monitors, and no matter which bar I click on, I will get the menu by my mouse.

The only problem I have with this is that since it goes to my cursor position, it overlaps and obscures the bar when the menu is open.

I have tries setting the coordinates as per the docs, but I suspect that this works differently for multi monitors because I used the coordinate 0x0 assuming that would be in the top left, but I could not see where it launched to at all.

So is there a way I can tell xmenu to spawn at a specific location on every monitor? Basically in the top left but with enough top padding not to obscure my bar.

phillbush commented 4 years ago

For X, all monitors make up a single rectangular screen. So the coordinates 0x0 is the top left corner of this virtual screen, not the top left of a monitor. Some regions of this virtual screen are not assigned to any monitor. You can use a software like slop to get the coordinates of a particular region on the screen.

For now, xmenu is unaware of the existence of monitors, its coordinates are based on this virtual screen.

But I'm going to add support to multi monitors (just wait an hour and a half). I'll add the option -m NUMBER that makes the position be relative to the monitor NUMBER, not to the virtual screen. I'll also make -m -1 (with negative NUMBER, or some other argument) to make the position be relative to the monitor the mouse is currently in.

Edit: I didn't added the -m option, instead I made the choice of the monitor be specified as another argument of -p, since specifying the monitor only makes sense when also specifying a position with -p.

GideonWolfe commented 4 years ago

Wow, this is fantastic. I can easily have three almost identical xmenu scripts that launch on a specific monitor. Thanks again for keeping these features rolling out!

phillbush commented 4 years ago

Done (it took more time than I imagined).

I embedded the monitor information within the -p option , if you run xmenu -p 0x0:0 it will open at position 0x0 of the monitor 0 (Monitor counts from 0 to number of monitors - 1). And if you run xmenu -p 0x0:cursor it will open at position 0x0 of the monitor where the cursor is in.

Can you test to see if the changes work for you? (I don't have a spare monitor rn).

GideonWolfe commented 4 years ago

I'll give it a shot!

GideonWolfe commented 4 years ago

Remembering to git pull this time, I switched my menu to invoke xmenu with xmenu -i -p 1x1:0.

The output of that is

xmenu: improper position: 1x1:0

GideonWolfe commented 4 years ago

Ok, this time I forgot to recompile... The compiler is giving me

/usr/bin/ld: xmenu.o: in function `initmonitor':
xmenu.c:(.text+0x7bf): undefined reference to `XineramaQueryScreens'
collect2: error: ld returned 1 exit status
make: *** [Makefile:9: xmenu] Error 1
phillbush commented 4 years ago

I forgot to git add config.mk.
Now it should compile.

GideonWolfe commented 4 years ago

Works fantastic! I'll finish getting working on all three monitors and let you know if I run into anything else!

GideonWolfe commented 4 years ago

2020-07-29-143047_5560x1920_scrot

The fruits of your labors have paid off, this is looking slick.

phillbush commented 4 years ago

Looks awesome!

Spuxy commented 2 years ago

how about oposite side ? I mean in the right top corner instead of left top corner :) ?

phillbush commented 2 years ago

how about oposite side ? I mean in the right top corner instead of left top corner :) ?

Then you should write a script to do some math with the output of xrandr(1) or other program to get the width of the monitor.