Fix file-info tooltip on wrong monitor#2752
Open
ermingol23 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.