Skip to content

Fit Table Tooltip in a single monitor #62 #2241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

amartya4256
Copy link
Contributor

This PR contributes to the fitting of the table tooltip inside a
single monitor if it spans over multiple monitor to avoid any
infinite loop because of rescaling triggered by any DPI_CHANGED events.

Adapted from #2142

contributes to
#62 and
#128

How to test

First we need to create a table with narrow columns.

  • Go to this method: org.eclipse.swt.examples.controlexample.TableTab.packColumns()
  • Change it with this:
void packColumns () {
		int columnCount = table1.getColumnCount();
		for (int i = 0; i < columnCount; i++) {
			TableColumn tableColumn = table1.getColumn(i);
			tableColumn.setWidth(8);
//			tableColumn.pack();
		}
	}
  • Launch ControlExample and go to table tab and position the shell in such a way that the table columns overlap on multiple monitors.
  • Hover over the overlappting columns and the tooltip must be positioned in the monitor where the cursor is contained, as shown in the picture.
image

Copy link
Contributor

github-actions bot commented Jun 16, 2025

Test Results

   545 files  + 6     545 suites  +6   34m 46s ⏱️ -27s
 4 403 tests +37   4 385 ✅ +35   18 💤 +3  0 ❌ ±0 
16 733 runs  +37  16 593 ✅ +35  140 💤 +3  0 ❌ ±0 

Results for commit 70ef650. ± Comparison against base commit edc5529.

♻️ This comment has been updated with latest results.

@amartya4256 amartya4256 force-pushed the amartya4256/table_tooltip branch 3 times, most recently from 5a97f16 to 8106e43 Compare June 17, 2025 07:42
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems to work fine. But I have to admit that I don't know what the actual changes are supposed to do. I see the expected coordinates adjustment for the tooltip, but there are some further changes around, which I do not understand at all (I have added comments to those lines). Can you please elaborate on why these changes are necessary and what they do?

Comment on lines -7161 to -7163
if (hdr.code != OS.TTN_SHOW) tipRequested = true;
long code = callWindowProc (handle, OS.WM_NOTIFY, wParam, lParam);
if (hdr.code != OS.TTN_SHOW) tipRequested = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why can this code be removed? It will also result in the code returned by this method to usually be null (in case we are not in the customToolTip case with TTN_SHOW.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was made corresponding to this bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=178044
Commit id: ec9593c
This was made for rollovers in 2007 but seems to have been fixed for the newer versions of windows. With the block present, the code goes in an infinite loop at 7162 and gets infinite TTN_GETDISPINFO messages, when the tooltip is by default over 2 monitors.
Thus, this could be removed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current windows works fine with rollover tooltips withut this block as well, however this block makes it worse when the tooltip is in the middle of 2 screens. You can try running the code with this block present and try to position your tooltip in the middle of 2 monitors.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have to admit that I do not fully understand the assessment. The code was not introduced for the mentioned bug and in the mentioned commit. The commit only moved that code to a different place, such that it is also executed for the TTN_SHOW event. The commit that originally introduced the code is from 2005: dd05f31. So the question remains why the code is now completely unnecessary (not only for TTN_SHOW but only for the TTN_GETDISPINFO event).

Just wondering: is the reaction to the TTN_GETDISPINFO still necessary at all? I tested with the ControlExample and there it does not make any difference whether I keep the switch-case for TTN_GETDISPINFO or whether I remove it (even though those events are actually fired). But since I don't know what this is necessary for, I cannot assess if there are remaining cases (maybe with very specific configurations) where it is needed.

In general, I currently still lack understanding of what exactly happens here. I can confirm that the change works as expected in all cases I have tested, but likely I don't know about all the use cases this complex code has been written for. So I am bit concerned that we break something when just removing some code. On the other hand, the code obviously leads to an issue (namely an inifite execution loop), which we definitely need to resolve. So it might lead to the trade-off that we need to accept that we might miss some use case here that we do not understand but therefor resolve a known bug.

Thus, my proposal:

  • Please check again what this code is used for (as, like I said above, the existing assessment is not comprehensible for me)
  • Have the change reviewed and tested by @fedejeanne, such that he can hopefully merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no explanation in the commit dd05f31, however it relates to the bug report mentioned I suppose. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=82739)

There's a snippet in the report and I tried that out and found no issues. I believe the block of code:

tipRequested = true;Add commentMore actions
int code = callWindowProc (handle, OS.WM_NOTIFY, wParam, lParam);
tipRequested = false;

Doesn't have any visual effect anymore.

Anyway it's hard to assess what it was introduced for but I gathered that the tooltip works similar to how it is implemented for Tree. Without having much changes in the original implementation, I tried to bring it as close as possible to Tree. However, I assessed the bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=82739 and the other bug report which was its duplicate (https://bugs.eclipse.org/bugs/show_bug.cgi?id=83703) and it doesn't seem to hamper the table tooltips in externalize stings view, the custom tooltip on the table in the control which comes using (ctrl+3) and also the snippets. These fixes were done for XP and Vista as it seems but I have tested them with the current windows 11 and my PR doesn't change any behaviour at all for them.

@amartya4256 amartya4256 force-pushed the amartya4256/table_tooltip branch 3 times, most recently from 7a66ca6 to 18da1d6 Compare June 20, 2025 12:22
This commit contributes to the fitting of the table tooltip inside a
single monitor if it spans over multiple monitor to avoid any
infinite loop because of rescaling triggered by any DPI_CHANGED events.

contributes to
eclipse-platform#62 and
eclipse-platform#128
@fedejeanne fedejeanne force-pushed the amartya4256/table_tooltip branch from 18da1d6 to 70ef650 Compare June 26, 2025 14:39
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.

Tooltip of Table freezing on spanning across multiple monitors
2 participants