Skip to content

Commit

Permalink
Better fix for [4d0a6f32b7]: Unique behavior of some options in the m…
Browse files Browse the repository at this point in the history
…essage widget in 8.7/9.0. No longer cache PIXEL values in button's and message. With testcases
  • Loading branch information
jan.nijtmans committed Jun 14, 2024
2 parents 4c2383b + b990e1d commit 032de5d
Show file tree
Hide file tree
Showing 7 changed files with 248 additions and 111 deletions.
30 changes: 30 additions & 0 deletions generic/tkButton.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,17 +1097,45 @@ ConfigureButton(
} else {
Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder);
}
if (butPtr->wrapLength < 0) {
butPtr->wrapLength = 0;
if (butPtr->wrapLengthPtr) {
Tcl_DecrRefCount(butPtr->wrapLengthPtr);
}
butPtr->wrapLengthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->wrapLengthPtr);
}
if (butPtr->borderWidth < 0) {
butPtr->borderWidth = 0;
if (butPtr->borderWidthPtr) {
Tcl_DecrRefCount(butPtr->borderWidthPtr);
}
butPtr->borderWidthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->borderWidthPtr);
}
if (butPtr->highlightWidth < 0) {
butPtr->highlightWidth = 0;
if (butPtr->highlightWidthPtr) {
Tcl_DecrRefCount(butPtr->highlightWidthPtr);
}
butPtr->highlightWidthPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->highlightWidthPtr);
}
if (butPtr->padX < 0) {
butPtr->padX = 0;
if (butPtr->padXPtr) {
Tcl_DecrRefCount(butPtr->padXPtr);
}
butPtr->padXPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->padXPtr);
}
if (butPtr->padY < 0) {
butPtr->padY = 0;
if (butPtr->padYPtr) {
Tcl_DecrRefCount(butPtr->padYPtr);
}
butPtr->padYPtr = Tcl_NewIntObj(0);
Tcl_IncrRefCount(butPtr->padYPtr);
}

if (butPtr->type >= TYPE_CHECK_BUTTON) {
Expand Down Expand Up @@ -1463,13 +1491,15 @@ ButtonEventProc(
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
butPtr->flags |= GOT_FOCUS;
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth);
if (butPtr->highlightWidth > 0) {
goto redraw;
}
}
} else if (eventPtr->type == FocusOut) {
if (eventPtr->xfocus.detail != NotifyInferior) {
butPtr->flags &= ~GOT_FOCUS;
Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth);
if (butPtr->highlightWidth > 0) {
goto redraw;
}
Expand Down
Loading

0 comments on commit 032de5d

Please sign in to comment.