Tk Source Code

View Ticket
Login
2022-06-07
21:21 • Closed ticket [94547cbe]: Revised text: borders not always redrawn plus 5 other changes artifact: e5f07337 user: fvogel
21:19
Fix [94547cbef7]: Revised [text]: borders not always redrawn. check-in: 95a8ce18 user: fvogel tags: revised_text, tip-466
2022-05-23
06:44 • Ticket [94547cbe] Revised text: borders not always redrawn status still Open with 3 other changes artifact: 5d150590 user: fvogel
00:19 • Ticket [94547cbe]: 3 changes artifact: 9e16d3dc user: griffin
2022-05-21
06:39 • Ticket [cb21f579] Embedded windows leak over border and highlight areas of text status still Open with 3 other changes artifact: 75da5c60 user: fvogel
2022-05-20
21:24 • Open ticket [94547cbe]: Revised text: borders not always redrawn plus 3 other changes artifact: bed4474d user: fvogel
21:19
Backout all three previous commits, and this time fix [94547cbef7]: Revised [text]: borders not always redrawn check-in: 1a49fd12 user: fvogel tags: bug-94547cbef7
2022-05-18
20:30 • Ticket [94547cbe] Revised text: borders not always redrawn status still Pending with 3 other changes artifact: 140b7159 user: griffin
06:32 • Ticket [94547cbe]: 3 changes artifact: 184c65a3 user: griffin
03:47 • Ticket [94547cbe]: 3 changes artifact: 540381eb user: fvogel
00:40 • Ticket [94547cbe]: 3 changes artifact: bc69083a user: griffin
2022-05-17
22:28 • Ticket [94547cbe]: 3 changes artifact: fe24de7b user: fvogel
16:28 • Ticket [94547cbe]: 3 changes artifact: 9824f01d user: griffin
11:46 • Ticket [94547cbe]: 3 changes artifact: 8dc7118d user: fvogel
05:55 • Ticket [94547cbe]: 4 changes artifact: 2ac06726 user: fvogel
03:01 • Pending ticket [94547cbe]. artifact: ea411e51 user: griffin
02:32
Fix bug [94547cbef7] - Compute correct test for border region. check-in: 632732f2 user: griffin tags: bug-94547cbef7
2021-09-09
19:48 • Ticket [94547cbe] Revised text: borders not always redrawn status still Open with 3 other changes artifact: 87948487 user: fvogel
2021-07-24
12:37
Remove notAqua constraint for textDisp-7.5 and textDisp-7.7. These tests fail on all platforms with the revised text widget, see [94547cbef7]. check-in: 80ad9d67 user: fvogel tags: less_test_constraints_revised_text
12:34 • Ticket [94547cbe] Revised text: borders not always redrawn status still Open with 3 other changes artifact: 473e4622 user: fvogel
2021-07-14
15:38 • New ticket [94547cbe]. artifact: 89f91cd6 user: fvogel

Ticket UUID: 94547cbef7a87a11323edd2e8dd56bc406877da3
Title: Revised [text]: borders not always redrawn
Type: Bug Version: revised_text
Submitter: fvogel Created on: 2021-07-14 15:38:58
Subsystem: 18. [text] Assigned To: fvogel
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2022-06-07 21:21:17
Resolution: Fixed Closed By: fvogel
    Closed on: 2022-06-07 21:21:17
Description:

package require Tk
pack [text .t]
.t configure -bd 15 -relief raised
.t insert 1.0 "Line 1"
frame .f2 -bg #ff0000
place .f2 -in .t -relx 0.4 -relwidth 0.2 -rely 1.0 -relheight 0.2 \
    -anchor s -bordermode ignore
update
destroy .f2
When executing this, a relic of the red frame is still visible in the text widget bottom border. This means that borders were erroneously not redrawn after destruction of frame .f2, while they should have been.

Further notes:

  • This happens with the revised text widget but not with the legacy version.
  • When the red frame overlaps the left or top border, i.e when the place command has -relx 0 -rely 0.5 or -relx 0.2 -rely 0.05, then there is NO such problem: borders are correctly redrawn.
  • When the red frame overlaps the right or bottom border, i.e. when the place command has -relx 1.0 -rely 0.5 or -relx 0.2 -rely 1.0 , then there IS a problem: borders are NOT redrawn.

User Comments: fvogel added on 2022-06-07 21:21:17:

All this now done. I have found bug [aad0231f07] in the process. Closing this one now.


fvogel added on 2022-05-23 06:44:26:

Oh, right! I didn't notice these tests because they were marked as 'nonPortable', meaning they normally don't run.

I'm now dealing with them in a specific test branch nonPortable_tests off core-8-6-branch, with the objective of removing this constraint when it is no longer needed. If no surprise shows up, I'll merge it up to trunk, then revised_text, and finally to bug-94547cbef7.


griffin added on 2022-05-23 00:19:35:

Yes, my mistake in the text region changes.

I am seeing textDisp-7.2 and -7.3 failing. Both of these tests expect the border to be drawn. From what I can tell, the test does not damage the border. It is what I see observationally and what is defined by the place command. Place defines -relx and -rely to be inside the border when -border is not present, i.e. when the default value is "inside".

I also note that a focus change will also cause the border to be redrawn. These tests make no assurance about the current state of focus for the text widget. Consequently, the place operation can potentially change focus. This can result in unstable results from these tests.

Regardless of what the original text widget produces for these tests, I still think the current expected results are incorrect. The test, as designed, should not redraw the border. Can you see anything that I may have missed in this analysis?


fvogel added on 2022-05-20 21:24:29:

Brian, sorry but I disagree. I had a deeper look at the problem and I have found that the width and height of the textRect were jsut wrongly calculated. I have fixed this in [1a49fd12].

Now the test script from my original report in the present ticket behaves correctly, and, very important, no test result needs to be changed compared to the legacy text widget.

For easy testing here is an interactive test:

package require Tk
proc doit {x y} {
  frame .f2 -bg #ff0000
  set inset [expr [.t cget -borderwidth] + [.t cget -highlightthickness]]
  set x [expr $x - $inset - [.t cget -padx]]
  set y [expr $y - $inset - [.t cget -pady]]
  place .f2 -in .t -x $x -width 50 -y $y -height 100
  update
  after 300
  destroy .f2
}
pack [text .t -insertofftime 0]
.t configure -bd 15 -relief raised
.t insert 1.0 "Line 1"
bind .t <Button-1> {doit %x %y}


griffin added on 2022-05-18 20:30:55:

After some deliberation, I've convinced myself that the RectContainsRect() is the wrong test completely. The text region and border are two independent (re)draw regions, and any test to determine damaged areas needs to be independent as well. For the border, there is actually 4 regions to examine, so any test limited to comparing two regions is insufficient.

Beyond that, I believe the cursor extent values potentially force an overlap between the text region and border/padding, which complicates any damage calculation. With respect to the border, anything dealing with the text region is immaterial.

Looking closely at test textDisp-7.2, I've determined that the border should not be drawn. The damaged area is completely contained within the text region by definition. So the current test results are wrong and indicate an unnecessary redraw of the border. I have not investigated other test discrepancies yet.

I've updated the changes to TextInvalidateRegion() and textDisp-7.2 as per my observations above. These changes are on the [bug-94547cbef7] branch.


griffin added on 2022-05-18 06:32:54:

Very impressive! Thank you!


fvogel added on 2022-05-18 03:47:48:

Yes I'm aware of this issue with test constraints. There is a third way to deal with this, which is to make the tests font agnostic. I have started the implementation work, see branches less_tests_constraints for 8.6 (legacy version) and less_test_constraints_revised_text for the revised_text branch.


griffin added on 2022-05-18 00:40:33:

Thanks for the explanation!

I determined that the reason the tests passed on Linux, at least for me locally, is because all of tests that should have failed were skipped due to the textfont constraint. This is a serious flaw in the regression system, making it pretty much useless for doing any development work.

There are 2 fixes for the general font problem that come to mind: 1) Assert the presence of a particular font so that no Tk test passes without that font present, or 2) build and release Tk with a specific set of default fonts.


fvogel added on 2022-05-17 22:28:57:
The rectangle provided in the expose event is clipped by the text area rectangle inside the text widget. The coordinates associated to this expose event are not what we would expect. The bug is not where you have changed the code, function RectContainsRect is totally correct and TextInvalidateRegion as well. It's the clipRect (obtained from the invalidated region) that is too small. And it's too small because the invalidated region vehiculated by the expose event is a rectangle unexpectedly clipped by the limits of the text widget area (inside the border).

griffin added on 2022-05-17 16:28:42:

I changed the computation done on expose events to determine if the border should be redrawn. I replaced the test with original test from text widget, which appeared correct to me since it actually included the border width info whereas the revised version did not.

On further inspection, it appears that the revised text combines the text area and border together before determining redraw regions. That could explain the extra border redraw with my change.


fvogel added on 2022-05-17 11:46:39:

Without having yet really looked at the proposed patch I'm observing many new failures at Github actions. These were not present before the patch.

They are probably all the same and reveal that borders are now redrawn in more than 30 newly failing tests while borders were not redrawn in those tests before the patch. Note that tese tests do pass with the legacy widget.

What I also find interesting is that whereas the patch is changing generic code, the tests fail on Windows and macOS but pass on Linux. I have no explanation about this fact so far, but digging in that direction could reveal something.


fvogel added on 2022-05-17 05:55:32:
I will have a look, yes thanks.

griffin added on 2022-05-17 03:01:21:

This problem should be fixed now with change [632732f2]. Francois: can you please confirm and close? Thanks.


fvogel added on 2021-07-24 12:34:04:
textDisp-7.5 and textDisp-7.7 show the issue as well.