| Ticket UUID: | 1510538 | |||
| Title: | Wrong initial scrollbar width | |||
| Type: | Bug | Version: | obsolete: 8.4.13 | |
| Submitter: | tombert | Created on: | 2006-06-22 11:08:13 | |
| Subsystem: | 16. [scrollbar] | Assigned To: | fvogel | |
| Priority: | 6 | Severity: | Minor | |
| Status: | Closed | Last Modified: | 2016-01-08 14:32:11 | |
| Resolution: | Fixed | Closed By: | fvogel | |
| Closed on: | 2016-01-08 14:32:11 | |||
| Description: |
The following sample shows a text and a scrollbar with not default width. The width of the scrollbar is not updated accordingly before packing = the widgets are overlapping. thx, regards, thomas ############# package require Tk toplevel .t text .t.text scrollbar .t.scroll -orient vertical -width 11 .t.text configure -yscrollcommand [list .t.scroll set] .t.scroll configure -command [list .t.text yview] pack .t.text -fill both -expand yes -side left pack .t.scroll -fill y -side left ############# tested on XP | |||
| User Comments: |
fvogel added on 2016-01-08 14:32:11:
Merged (by Jan Nijtmans) to trunk, and cherrypicked to core-8-5-branch. fvogel added on 2016-01-07 14:19:01: I wanted to add a test in the test suite for this ticket. The bug is that the OS ignored the given width of the scrollbar when rendering it on screen. The width known by Tk is correct (and always was, with and without the fix), therefore [.s identify $x $y] cannot allow any check of the fix presence. AFAIK there is no way from Tk script level to check that the OS now draws the scrollbar using its requested width instead of the default width, thus no new test case. fvogel added on 2016-01-04 17:35:11: More digging shows that the issue is different.
On Windows, the scrollbar widget is implemented as a native scrollbar window (which is different from the case of the scale widget for instance).
In tkWinScrlbr.c, the CreateProc creates the scrollbar window through CreateWindow using a style (e.g. for a vertical scrollbar):
style = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS
| SBS_VERT | SBS_RIGHTALIGN;
scrollPtr->hwnd = CreateWindow("SCROLLBAR", NULL, style,
Tk_X(tkwin), Tk_Y(tkwin), Tk_Width(tkwin), Tk_Height(tkwin),
parent, NULL, Tk_GetHINSTANCE(), NULL);
According to MSDN, if neither the SBS_RIGHTALIGN nor SBS_LEFTALIGN style is specified, the scrollbar has the height, width, and position specified by the x, y, nWidth, and nHeight parameters of CreateWindow. Otherwise, the scrollbar has the has the default width for system scroll bars.
The fix consists then in removing SBS_RIGHTALIGN (and SBS_BOTTOMALIGN for the horizontal scrollbar).
See branch bug-1510538.
fvogel added on 2016-01-03 11:39:58: Another observation: using a scale widget instead of a scrollbar does not show any problem: package require Tk scale .s -width 110 pack .s This works as expected (the scale has the requested large width), contrary to with a scrollbar. Further analysis of the events suite processed in both cases is: - Events in TkScrollbarEventProc: 22 (ConfigureNotify), then 19 (MapNoptify) - Events in ScaleEventProc: 22 (ConfigureNotify), then 19 (MapNoptify) , then 12 (Expose) Therefore the Expose event is indeed not sent to the scrollbar. Looks quite like [1305128], but what puzzles me is that sending the event manually: event generate .s <Expose> ; # or even <Configure> does not fix the scrollbar geometry. fvogel added on 2016-01-03 11:02:56: The patch below forcing Tk_MoveResizeWindow seems to work because:
Tk_MoveResizeWindow calls XMoveResizeWindow,
which calls (on Windows) MoveWindow,
which has the effect of sending a WM_PAINT message in the TkWinChildProc callback,
which in turn generates an Expose event
This Expose event should be processed in TkScrollbarEventProc through TkScrollbarEventuallyRedraw, but at this point the debugger does not enter TkScrollbarEventProc. How strange...
Also, the patch works only the first packing time. Running:
package require Tk
destroy .s
scrollbar .s -width 110
pack .s
update
after 100 {scrollbar .s -width 110 ; pack .s}
triggers the bug again, even with the patch.
fvogel added on 2016-01-03 10:23:04: This bug does not happen on Linux (Debian 6.0). No idea about Max OS (can't test), but I tend to believe this is a Windows-only bug. fvogel added on 2016-01-03 10:21:21: Patch apparently fixing the issue consists, in tkPack.c / ArrangePacking, in forcing XMoveResizeWindow even if no coordinates or size changed:
--- generic/tkPack.c
+++ generic/tkPack.c
@@ -797,16 +797,17 @@
if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
if ((width <= 0) || (height <= 0)) {
Tk_UnmapWindow(slavePtr->tkwin);
} else {
- if ((x != Tk_X(slavePtr->tkwin))
- || (y != Tk_Y(slavePtr->tkwin))
- || (width != Tk_Width(slavePtr->tkwin))
- || (height != Tk_Height(slavePtr->tkwin))) {
- Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
- }
+// if ((x != Tk_X(slavePtr->tkwin))
+// || (y != Tk_Y(slavePtr->tkwin))
+// || (width != Tk_Width(slavePtr->tkwin))
+// || (height != Tk_Height(slavePtr->tkwin))) {
+// Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
+// }
+ Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
if (abort) {
goto done;
}
/*
This should then be propagated to grid and place as well.
Not fond of changing this though.
fvogel added on 2016-01-02 22:04:25: Minimal script showing the issue: package require Tk scrollbar .s -width 110 pack .s # the scrollbar still occupies much less than the required 110 pixels width # change toplevel size by mouse --> it becomes 110 pixels width fvogel added on 2016-01-02 20:17:15: Workaround: don't set -width at scrollbar creation time, and run update ; .t.scroll configure -width 11 after having packed the scrollbar. [email protected] added on 2007-12-18 04:35:52: Logged In: NO Any update on this bug, please. We really appreciate it if this bug can be fixed because our tcl/tk base application have a theme, and the scrollbar is not adjusting according to the width during initializing. hobbs added on 2006-07-04 02:54:03: Logged In: YES user_id=72656 bug confirmed in 8.4.13 on XP | |||
Home
Timeline
Branches
Tags
Forum
Tickets
Download
Wiki