Skip to content

Fix file-info tooltip on wrong monitor#2752

Open
ermingol23 wants to merge 1 commit into
emacs-helm:masterfrom
ermingol23:fix-fileinfo-popup
Open

Fix file-info tooltip on wrong monitor#2752
ermingol23 wants to merge 1 commit into
emacs-helm:masterfrom
ermingol23:fix-fileinfo-popup

Conversation

@ermingol23

Copy link
Copy Markdown
Contributor

Fix file-info tooltip always rendered on the leftmost (and perhaps also topmost) monitor in a multi-monitor setup. For instance, when having a multi-monitor setup (LEFT and RIGHT) where Emacs is running on the RIGHT monitor and you press 'M-i' in helm-find-files for a file, the toolip window is displayed on the LEFT monitor instead of the RIGHT monitor.

This is due to that the function posn-at-point always return an XY-coordinate in the local monitor and frame coordinate system and the function tooltip-show always render in the global coordinate system that spans across all monitors in the multi-monitor setup.

To correct this the frames left and top coordinates need to be added to the corresponding values returned from posn-at-point.

In addition to this, Gnome (at least as it is configured in stock Ubuntu 24.04) adds a thick border around the tooltip that is rendered outside of the actual tooltip area (to the left and above of the left and top coordinates given to tooltip-show indirectly via tooltip-frame-parameters). Emacs is not aware of this extra border around the tooltip (not sure if it is even theoretically possible for Emacs to find out the size of any such border-padding) and thus it can not compensate for it. The effect is that the extra border-padding covers the end of the file-name the tooltip shows meta-information about (couple of characters). To give the user a chance to compensate for any such window system behavior a new custom variable is introduced in this commit (helm-ff-tooltip-horizontal-padding) with default value 0. This variable is added to the x-coordinate of the tooltip in an attempt to allow the user to compensate for the possible padding employed by the window system.

Finally when the tooltip-content is prepared the last entry adds an extra new-line character that inserts an extra blank line at the end of the tooltip when it is rendered. This last new-line is removed by this commit.

Fix file-info tooltip always rendered on the leftmost (and perhaps
also topmost) monitor in a multi-monitor setup. For instance, when
having a multi-monitor setup (LEFT and RIGHT) where Emacs is running
on the RIGHT monitor and you press 'M-i' in helm-find-files for a
file, the toolip window is displayed on the LEFT monitor instead of
the RIGHT monitor.

This is due to that the function posn-at-point always return an
XY-coordinate in the *local* monitor and frame coordinate system and
the function tooltip-show always render in the *global* coordinate
system that spans across all monitors in the multi-monitor setup.

To correct this the frames left and top coordinates need to be added
to the corresponding values returned from posn-at-point.

In addition to this, Gnome (at least as it is configured in stock
Ubuntu 24.04) adds a thick border around the tooltip that is
rendered *outside* of the actual tooltip area (to the left and above
of the left and top coordinates given to tooltip-show indirectly via
tooltip-frame-parameters). Emacs is not aware of this extra border
around the tooltip (not sure if it is even theoretically possible for
Emacs to find out the size of any such border-padding) and thus it can
not compensate for it. The effect is that the extra border-padding
covers the end of the file-name the tooltip shows meta-information
about (couple of characters). To give the user a chance to compensate
for any such window system behavior a new custom variable is
introduced in this commit (helm-ff-tooltip-horizontal-padding) with
default value 0. This variable is added to the x-coordinate of the
tooltip in an attempt to allow the user to compensate for the possible
padding employed by the window system.

Finally when the tooltip-content is prepared the last entry adds an
extra new-line character that inserts an extra blank line at the end
of the tooltip when it is rendered. This last new-line is removed by
this commit.
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

Successfully merging this pull request may close these issues.

1 participant