yequake
yequake copied to clipboard
behaviour on multi-monitor
On my one multi-monitor setup, yequake
always seems to open on the left-most monitor, no matter which screen has focus (i.e. no matter which screen has an active window and/or the mouse pointer). I only have access to one multi-monitor setup at the moment, so it could be something specific to that set-up, or something about how KDE Plasma handles things.
Thanks for the report. You might compare to how equake
works, as it has a lot of code related to monitors. If you have any suggestions for how to support multiple monitors in a good way, let me know.
I'm pretty certain the trouble with yequake
is that in the yequake--toggle-frame
function, ((_monitor-x _monitor-y monitor-width monitor-height) (mapcar #'floor (alist-get 'geometry (frame-monitor-attributes)))
just throws away the x,y information from (frame-monitor-attributes)
, and the x value is important in order to open on a screen other than the leftmost (and for vertically-stacked multiple screen, the y value would of course be important).
In theory, this shouldn't matter, since (-let* (((&alist '_x '_y 'width 'height 'left 'top 'buffer-fns 'alpha 'frame-parameters) frame)...
should get the relevant x value, but (I think) since the frame is not yet created, the x value (=left
) will always be 'nil
, and so
(frame-x (or left
(floor (/ (- monitor-width frame-width)
2))))
will always use the latter value. Though I may be off on what's going on in yequake
.
To be honest, figuring out multi-monitor stuff in equake
has been 90% of my time invested, and I was actually hoping maybe yequake
had a simpler solution.
@emacsomancer Please try that branch and see if it works. If it does, it's a very simple fix. If not, it shouldn't take much more to make it work properly, I think. With your help, it should be possible. :)
@alphapapa , yes, that fixes the issue I referred to. Now its behaviour is: open the yequake frame on whatever screen had the last focussed Emacs frame, which is what we would expect it to do.
Now, this isn't necessarily what the user might expect though, because the user would expect the yequake
frame to open on whatever screen is active / whatever screen has the mouse cursor on it.
This is something I struggled with for equake
too. My solution is to have a second way of 'toggling' the equake
frame with emacsclient -n -c -e '(equake-invoke)' -F '((title . "*transient*") (alpha . (0 . 0)) (width . (text-pixels . 0)) (height . (text-pixels . 0)) (left . 0) (top . 0))'
, which creates a 'sacrificial' emacs frame on whatever screen the user is active on (whether or not that was the screen with the last active Emacs frame, or indeed whether or not that screen contains any Emacs frames), grab the monitor information, then delete-frame
for all frames with title *transient*
and proceed as usual. It is of course a sort of hack; but I'm not sure how else to figure out what screen the user 'is on' otherwise and it's only very slightly slower then the simpler emacsclient -n -e '(equake-invoke)'
(which is sufficient for single-screen set-ups).
@alphapapa tried it as well on my machine and worked nicely. yequake
displays nicely on the primary screen instead between the two (swapped primary back and forth and it always picked the correct screen).
@emacsomancer I think the final problem can probably be solved by using the function x-mouse-absolute-pixel-position
to get the mouse cursor position, then figuring out which monitor (or X "screen") it's on, and then using make-frame-on-display
to make the new frame on that screen. I don't have multiple monitors here, so I'm not sure how much help I can be. Whatever the final solution, it should probably also allow the Yequake config to specify screen selection either automatically by mouse cursor position, automatically by the screen with the most recently active Emacs frame, or manually by either screen number or raw X/Y position.
Since you've both said that this branch is an improvement, I'll merge it to master now, and then leave this issue open until a better solution is implemented. Thanks for your help.
x-mouse-absolute-pixel-position
is a great tip. I haven't figured out how to use make-frame-on-display
to open frames on anything other than the primary screen though, so that may or may not work.
The other issue is that these are all X11-centric solutions, as far as I know.