summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcsaba <csaba>2024-05-15 16:24:34 (GMT)
committercsaba <csaba>2024-05-15 16:24:34 (GMT)
commitd1b06d589cc039ff7f4bcf911333401f713991b4 (patch)
treede47373827e28fad4b95ad869d9ff7fc9b520166
parentece2290f0f187d183557c32e6c8834d1c965a349 (diff)
downloadtk-d1b06d589cc039ff7f4bcf911333401f713991b4.zip
tk-d1b06d589cc039ff7f4bcf911333401f713991b4.tar.gz
tk-d1b06d589cc039ff7f4bcf911333401f713991b4.tar.bz2
Using the application's TkMainInfo struct for sharing the data of the trough's inner box in a thread-safe manner when drawing the ttk::scale widget of the "default" theme.
-rw-r--r--generic/tkInt.h2
-rw-r--r--generic/ttk/ttkElements.c41
2 files changed, 27 insertions, 16 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 2130649..a9da4ec 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -753,6 +753,8 @@ typedef struct TkMainInfo {
#endif
unsigned int ttkNbTabsStickBit;
/* Information used by ttk::notebook. */
+ int troughInnerX, troughInnerY, troughInnerWidth, troughInnerHeight;
+ /* Information used by ttk::scale. */
} TkMainInfo;
/*
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 7ebc453..4506ecb 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -1212,8 +1212,6 @@ static void TroughElementSize(
}
}
-static Ttk_Box troughInnerBox;
-
static void TroughElementDraw(
TCL_UNUSED(void *), /* clientData */
void *elementRecord, Tk_Window tkwin,
@@ -1224,6 +1222,7 @@ static void TroughElementDraw(
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
int borderWidth = 1, grooveWidth = -1, relief = TK_RELIEF_SUNKEN;
Ttk_Orient orient;
+ TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
@@ -1239,10 +1238,15 @@ static void TroughElementDraw(
b.width = grooveWidth;
}
- troughInnerBox.x = b.x + borderWidth;
- troughInnerBox.y = b.y + borderWidth;
- troughInnerBox.width = b.width - 2*borderWidth;
- troughInnerBox.height = b.height - 2*borderWidth;
+ /*
+ * Save the data of the trough's inner box for later
+ */
+ if (mainInfoPtr != NULL) {
+ mainInfoPtr->troughInnerX = b.x + borderWidth;
+ mainInfoPtr->troughInnerY = b.y + borderWidth;
+ mainInfoPtr->troughInnerWidth = b.width - 2*borderWidth;
+ mainInfoPtr->troughInnerHeight = b.height - 2*borderWidth;
+ }
}
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
@@ -1385,6 +1389,7 @@ static void SliderElementDraw(
{
double scalingLevel = TkScalingLevel(tkwin);
int dim = SLIDER_DIM * scalingLevel;
+ TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr;
SliderElement *slider = (SliderElement *)elementRecord;
Ttk_Orient orient;
@@ -1426,16 +1431,20 @@ static void SliderElementDraw(
* Fill the thin trough area preceding the
* slider's center with the inner color
*/
- TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
- switch (orient) {
- case TTK_ORIENT_HORIZONTAL:
- XFillRectangle(disp, d, gc, troughInnerBox.x, troughInnerBox.y,
- b.x + dim/2 - 1, troughInnerBox.height);
- break;
- case TTK_ORIENT_VERTICAL:
- XFillRectangle(disp, d, gc, troughInnerBox.x, troughInnerBox.y,
- troughInnerBox.width, b.y + dim/2 - 1);
- break;
+ if (mainInfoPtr != NULL) {
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+ switch (orient) {
+ case TTK_ORIENT_HORIZONTAL:
+ XFillRectangle(disp, d, gc,
+ mainInfoPtr->troughInnerX, mainInfoPtr->troughInnerY,
+ b.x + dim/2 - 1, mainInfoPtr->troughInnerHeight);
+ break;
+ case TTK_ORIENT_VERTICAL:
+ XFillRectangle(disp, d, gc,
+ mainInfoPtr->troughInnerX, mainInfoPtr->troughInnerY,
+ mainInfoPtr->troughInnerWidth, b.y + dim/2 - 1);
+ break;
+ }
}
/*