From c994407673785cf715268fc873bf2e98f57ca585 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 26 Jan 2020 20:13:36 +0000 Subject: Fix [dccd82bdc7]: ttk fonts are absolute on x11, which is very undesirable for hidpi displays --- library/ttk/fonts.tcl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/library/ttk/fonts.tcl b/library/ttk/fonts.tcl index a2781c6..d819973 100644 --- a/library/ttk/fonts.tcl +++ b/library/ttk/fonts.tcl @@ -53,10 +53,6 @@ # Most other toolkits use medium weight for all UI elements, # which is what we do now. # -# Font size specified in pixels on X11, not points. -# This is Theoretically Wrong, but in practice works better; using -# points leads to huge inconsistencies across different servers. -# namespace eval ttk { @@ -131,10 +127,10 @@ switch -- [tk windowingsystem] { set F(family) "Helvetica" set F(fixed) "courier" } - set F(size) -12 - set F(ttsize) -10 - set F(capsize) -14 - set F(fixedsize) -12 + set F(size) 10 + set F(ttsize) 9 + set F(capsize) 12 + set F(fixedsize) 10 font configure TkDefaultFont -family $F(family) -size $F(size) font configure TkTextFont -family $F(family) -size $F(size) -- cgit v0.12 From ff08eb67d0553702103f0b726742ce3de044d30f Mon Sep 17 00:00:00 2001 From: oehhar Date: Sun, 2 Feb 2020 15:37:45 +0000 Subject: Implementation for TIP 563: "scrollwheel on horizontal scrollbar scrolls without shift too" --- library/scrlbar.tcl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index bce8391..510713a 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -131,16 +131,16 @@ bind Scrollbar <> { if {[tk windowingsystem] eq "aqua"} { bind Scrollbar { - tk::ScrollByUnits %W v [expr {-(%D)}] + tk::ScrollByUnits %W hv [expr {-(%D)}] } bind Scrollbar { - tk::ScrollByUnits %W v [expr {-10 * (%D)}] + tk::ScrollByUnits %W hv [expr {-10 * (%D)}] } bind Scrollbar { - tk::ScrollByUnits %W h [expr {-(%D)}] + tk::ScrollByUnits %W v [expr {-(%D)}] } bind Scrollbar { - tk::ScrollByUnits %W h [expr {-10 * (%D)}] + tk::ScrollByUnits %W v [expr {-10 * (%D)}] } } else { # We must make sure that positive and negative movements are rounded @@ -151,9 +151,9 @@ if {[tk windowingsystem] eq "aqua"} { # The following code ensure equal +/- behaviour. bind Scrollbar { if {%D >= 0} { - tk::ScrollByUnits %W v [expr {-%D/30}] + tk::ScrollByUnits %W hv [expr {-%D/30}] } else { - tk::ScrollByUnits %W v [expr {(29-%D)/30}] + tk::ScrollByUnits %W hv [expr {(29-%D)/30}] } } bind Scrollbar { @@ -166,8 +166,8 @@ if {[tk windowingsystem] eq "aqua"} { } if {[tk windowingsystem] eq "x11"} { - bind Scrollbar {tk::ScrollByUnits %W v -5} - bind Scrollbar {tk::ScrollByUnits %W v 5} + bind Scrollbar {tk::ScrollByUnits %W hv -5} + bind Scrollbar {tk::ScrollByUnits %W hv 5} bind Scrollbar {tk::ScrollByUnits %W h -5} bind Scrollbar {tk::ScrollByUnits %W h 5} bind Scrollbar {tk::ScrollByUnits %W h -5} -- cgit v0.12 From 8132e24b6019dd64947f1c9c1f98ebc8b00711ab Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 9 Feb 2020 18:31:59 +0000 Subject: When Shift-bindings are equal to the non-shift ones, they can be eliminated: The non-shift one will do this work already. --- library/scrlbar.tcl | 19 ++----------------- library/ttk/scrollbar.tcl | 7 +++---- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/library/scrlbar.tcl b/library/scrlbar.tcl index 510713a..8106b3d 100644 --- a/library/scrlbar.tcl +++ b/library/scrlbar.tcl @@ -136,12 +136,6 @@ if {[tk windowingsystem] eq "aqua"} { bind Scrollbar { tk::ScrollByUnits %W hv [expr {-10 * (%D)}] } - bind Scrollbar { - tk::ScrollByUnits %W v [expr {-(%D)}] - } - bind Scrollbar { - tk::ScrollByUnits %W v [expr {-10 * (%D)}] - } } else { # We must make sure that positive and negative movements are rounded # equally to integers, avoiding the problem that @@ -156,22 +150,13 @@ if {[tk windowingsystem] eq "aqua"} { tk::ScrollByUnits %W hv [expr {(29-%D)/30}] } } - bind Scrollbar { - if {%D >= 0} { - tk::ScrollByUnits %W h [expr {-%D/30}] - } else { - tk::ScrollByUnits %W h [expr {(29-%D)/30}] - } - } } if {[tk windowingsystem] eq "x11"} { bind Scrollbar {tk::ScrollByUnits %W hv -5} bind Scrollbar {tk::ScrollByUnits %W hv 5} - bind Scrollbar {tk::ScrollByUnits %W h -5} - bind Scrollbar {tk::ScrollByUnits %W h 5} - bind Scrollbar {tk::ScrollByUnits %W h -5} - bind Scrollbar {tk::ScrollByUnits %W h 5} + bind Scrollbar {tk::ScrollByUnits %W hv -5} + bind Scrollbar {tk::ScrollByUnits %W hv 5} } # tk::ScrollButtonDown -- diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl index 15f9cde..7537491 100644 --- a/library/ttk/scrollbar.tcl +++ b/library/ttk/scrollbar.tcl @@ -21,14 +21,13 @@ bind TScrollbar { ttk::scrollbar::Release %W %x %y } # # The shift-bindings scroll left/right (not up/down) # if a widget has both possibilities -set eventList [list ] +set eventList [list ] switch [tk windowingsystem] { aqua { - lappend eventList + lappend eventList } x11 { - lappend eventList \ - + lappend eventList } } foreach event $eventList { -- cgit v0.12 From 9ec507e25b633e1418c3026687ca64c66472a0f1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 10 Feb 2020 21:31:42 +0000 Subject: Add non-regression test canvas-2.5: CanvasWidgetCmd, raise/lower option, no error on non-existing tags --- tests/canvas.test | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/canvas.test b/tests/canvas.test index 1386208..5086389 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -227,6 +227,16 @@ test canvas-2.4 {CanvasWidgetCmd, xview option} -constraints nonPortable -body { update lappend x [.c xview] } -result {{0.6 0.9} {0.66 0.96}} +test canvas-2.5 {CanvasWidgetCmd, raise/lower option, no error on non-existing tags} -setup { + .c create line 0 0 10 10 -tags aline +} -body { + .c raise aline noline + .c raise bline aline + .c lower aline noline + .c lower bline aline +} -cleanup { + .c delete aline +} -result {} catch {destroy .c} # Canvas used in 3.* test cases -- cgit v0.12 From 332ff2c72b47f5e0bc0df3f98f286b1b58ffc06a Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 10 Feb 2020 21:33:29 +0000 Subject: Fix [3552805fff]: Make '.canvas lower' work with non-exitent belowThis tag --- generic/tkCanvas.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 688fa0b..424dcf1 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -1681,11 +1681,6 @@ CanvasWidgetCmd( } else { FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done); if (itemPtr == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "tagOrId \"%s\" doesn't match any items", - Tcl_GetString(objv[3]))); - Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL); - result = TCL_ERROR; goto done; } itemPtr = itemPtr->prevPtr; @@ -1808,11 +1803,6 @@ CanvasWidgetCmd( prevPtr = itemPtr; } if (prevPtr == NULL) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "tagOrId \"%s\" doesn't match any items", - Tcl_GetString(objv[3]))); - Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL); - result = TCL_ERROR; goto done; } } -- cgit v0.12 From e020f123dd78dcc7057325fd9ceb975a5cbb0e7e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 18 Feb 2020 15:54:13 +0000 Subject: Clamp "listbox index" values between -1 and (maximum) end+1, as done in other GUI elements too (like menu). --- generic/tkListbox.c | 8 +++----- tests/listbox.test | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/generic/tkListbox.c b/generic/tkListbox.c index e66f3f6..546ae98 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -2753,11 +2753,7 @@ GetListboxIndex( break; case INDEX_END: /* "end" index */ - if (endIsSize) { - *indexPtr = listPtr->nElements; - } else { - *indexPtr = listPtr->nElements - 1; - } + *indexPtr = listPtr->nElements - (endIsSize ? 0 : 1); break; } return TCL_OK; @@ -2799,6 +2795,8 @@ GetListboxIndex( if (Tcl_GetIntFromObj(NULL, indexObj, indexPtr) == TCL_OK) { if (*indexPtr < -1) { *indexPtr = -1; + } else if (*indexPtr > listPtr->nElements) { + *indexPtr = listPtr->nElements + (endIsSize ? 1 : 0); } return TCL_OK; } diff --git a/tests/listbox.test b/tests/listbox.test index e9a2f28..f994e45 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -724,7 +724,7 @@ test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body { } -result 18 test listbox-3.63 {ListboxWidgetCmd procedure, "index" option} -body { .l index 34 -} -result 34 +} -result 19 test listbox-3.64 {ListboxWidgetCmd procedure, "insert" option} -body { .l insert } -returnCodes error -result {wrong # args: should be ".l insert index ?element ...?"} @@ -2112,7 +2112,7 @@ test listbox-10.17 {GetListboxIndex procedure} -setup { .l index 20 } -cleanup { destroy .l -} -result {20} +} -result {13} test listbox-10.18 {GetListboxIndex procedure} -setup { destroy .l } -body { -- cgit v0.12 From 4613eded586af72ff2cbcb0d92be41a178dad2af Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 19 Feb 2020 16:48:41 +0000 Subject: Fix 2 gcc warnings in win/ttkWinXPTheme.c due to the recent addition of "const". Also add type-casts (while on it), helping C++ compatibility. Use more internal size_t in ttk. And use some more Tcl_GetWideIntFromObj() in stead of Tcl_GetIntFromObj() --- generic/ttk/ttkEntry.c | 4 ++-- generic/ttk/ttkFrame.c | 4 ++-- generic/ttk/ttkManager.c | 20 ++++++++--------- generic/ttk/ttkManager.h | 22 +++++++++---------- generic/ttk/ttkNotebook.c | 51 ++++++++++++++++++++++---------------------- generic/ttk/ttkPanedwindow.c | 28 ++++++++++++------------ win/ttkWinXPTheme.c | 48 +++++++++++++++++++++++------------------ 7 files changed, 92 insertions(+), 85 deletions(-) diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index d9b3c8d3..1660107 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1553,7 +1553,7 @@ EntryIndexCommand( if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); return TCL_OK; } @@ -1853,7 +1853,7 @@ static int ComboboxCurrentCommand( } } cbPtr->combobox.currentIndex = currentIndex; - Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(currentIndex)); return TCL_OK; } else if (objc == 3) { int result, index; diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c index 978f47f..e623409 100644 --- a/generic/ttk/ttkFrame.c +++ b/generic/ttk/ttkFrame.c @@ -487,7 +487,7 @@ static void LabelframePlaceSlaves(void *recordPtr) } } -static int LabelRequest(void *managerData, int index, int width, int height) +static int LabelRequest(void *managerData, TkSizeT index, int width, int height) { return 1; } @@ -499,7 +499,7 @@ static int LabelRequest(void *managerData, int index, int width, int height) * This routine is also called when the widget voluntarily forgets * the slave in LabelframeConfigure. */ -static void LabelRemoved(void *managerData, int slaveIndex) +static void LabelRemoved(void *managerData, TkSizeT slaveIndex) { Labelframe *lframe = managerData; lframe->label.labelWidget = 0; diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index bf93699..caf452c 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -342,7 +342,7 @@ void Ttk_LostSlaveProc(ClientData clientData, Tk_Window slaveWindow) * Add a new slave window at the specified index. */ void Ttk_InsertSlave( - Ttk_Manager *mgr, int index, Tk_Window tkwin, void *slaveData) + Ttk_Manager *mgr, TkSizeT index, Tk_Window tkwin, void *slaveData) { Ttk_Slave *slave = NewSlave(mgr, tkwin, slaveData); InsertSlave(mgr, slave, index); @@ -351,7 +351,7 @@ void Ttk_InsertSlave( /* ++ Ttk_ForgetSlave -- * Unmanage the specified slave. */ -void Ttk_ForgetSlave(Ttk_Manager *mgr, int slaveIndex) +void Ttk_ForgetSlave(Ttk_Manager *mgr, TkSizeT slaveIndex) { Tk_Window slaveWindow = mgr->slaves[slaveIndex]->slaveWindow; RemoveSlave(mgr, slaveIndex); @@ -366,7 +366,7 @@ void Ttk_ForgetSlave(Ttk_Manager *mgr, int slaveIndex) * map the slave. */ void Ttk_PlaceSlave( - Ttk_Manager *mgr, int slaveIndex, int x, int y, int width, int height) + Ttk_Manager *mgr, TkSizeT slaveIndex, int x, int y, int width, int height) { Ttk_Slave *slave = mgr->slaves[slaveIndex]; Tk_MaintainGeometry(slave->slaveWindow,mgr->masterWindow,x,y,width,height); @@ -379,7 +379,7 @@ void Ttk_PlaceSlave( /* ++ Ttk_UnmapSlave -- * Unmap the specified slave, but leave it managed. */ -void Ttk_UnmapSlave(Ttk_Manager *mgr, int slaveIndex) +void Ttk_UnmapSlave(Ttk_Manager *mgr, TkSizeT slaveIndex) { Ttk_Slave *slave = mgr->slaves[slaveIndex]; Tk_UnmaintainGeometry(slave->slaveWindow, mgr->masterWindow); @@ -405,15 +405,15 @@ void Ttk_ManagerSizeChanged(Ttk_Manager *mgr) /* +++ Accessors. */ -int Ttk_NumberSlaves(Ttk_Manager *mgr) +TkSizeT Ttk_NumberSlaves(Ttk_Manager *mgr) { return mgr->nSlaves; } -void *Ttk_SlaveData(Ttk_Manager *mgr, int slaveIndex) +void *Ttk_SlaveData(Ttk_Manager *mgr, TkSizeT slaveIndex) { return mgr->slaves[slaveIndex]->slaveData; } -Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, int slaveIndex) +Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, TkSizeT slaveIndex) { return mgr->slaves[slaveIndex]->slaveWindow; } @@ -425,13 +425,13 @@ Tk_Window Ttk_SlaveWindow(Ttk_Manager *mgr, int slaveIndex) /* ++ Ttk_SlaveIndex -- * Returns the index of specified slave window, -1 if not found. */ -int Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow) +TkSizeT Ttk_SlaveIndex(Ttk_Manager *mgr, Tk_Window slaveWindow) { int index; for (index = 0; index < mgr->nSlaves; ++index) if (mgr->slaves[index]->slaveWindow == slaveWindow) return index; - return -1; + return TCL_INDEX_NONE; } /* ++ Ttk_GetSlaveIndexFromObj(interp, mgr, objPtr, indexPtr) -- @@ -488,7 +488,7 @@ int Ttk_GetSlaveIndexFromObj( /* ++ Ttk_ReorderSlave(mgr, fromIndex, toIndex) -- * Change slave order. */ -void Ttk_ReorderSlave(Ttk_Manager *mgr, int fromIndex, int toIndex) +void Ttk_ReorderSlave(Ttk_Manager *mgr, TkSizeT fromIndex, TkSizeT toIndex) { Ttk_Slave *moved = mgr->slaves[fromIndex]; diff --git a/generic/ttk/ttkManager.h b/generic/ttk/ttkManager.h index 07fcea1..365a080 100644 --- a/generic/ttk/ttkManager.h +++ b/generic/ttk/ttkManager.h @@ -31,8 +31,8 @@ typedef struct { /* Manager hooks */ int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr); void (*PlaceSlaves)(void *managerData); - int (*SlaveRequest)(void *managerData, int slaveIndex, int w, int h); - void (*SlaveRemoved)(void *managerData, int slaveIndex); + int (*SlaveRequest)(void *managerData, TkSizeT slaveIndex, int w, int h); + void (*SlaveRemoved)(void *managerData, TkSizeT slaveIndex); } Ttk_ManagerSpec; /* @@ -49,18 +49,18 @@ MODULE_SCOPE Ttk_Manager *Ttk_CreateManager( MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *); MODULE_SCOPE void Ttk_InsertSlave( - Ttk_Manager *, int position, Tk_Window, void *slaveData); + Ttk_Manager *, TkSizeT position, Tk_Window, void *slaveData); -MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, int slaveIndex); +MODULE_SCOPE void Ttk_ForgetSlave(Ttk_Manager *, TkSizeT slaveIndex); -MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, int fromIndex, int toIndex); +MODULE_SCOPE void Ttk_ReorderSlave(Ttk_Manager *, TkSizeT fromIndex, TkSizeT toIndex); /* Rearrange slave positions */ MODULE_SCOPE void Ttk_PlaceSlave( - Ttk_Manager *, int slaveIndex, int x, int y, int width, int height); + Ttk_Manager *, TkSizeT slaveIndex, int x, int y, int width, int height); /* Position and map the slave */ -MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, int slaveIndex); +MODULE_SCOPE void Ttk_UnmapSlave(Ttk_Manager *, TkSizeT slaveIndex); /* Unmap the slave */ MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *); @@ -69,7 +69,7 @@ MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *); /* Utilities: */ -MODULE_SCOPE int Ttk_SlaveIndex(Ttk_Manager *, Tk_Window); +MODULE_SCOPE TkSizeT Ttk_SlaveIndex(Ttk_Manager *, Tk_Window); /* Returns: index in slave array of specified window, -1 if not found */ MODULE_SCOPE int Ttk_GetSlaveIndexFromObj( @@ -77,13 +77,13 @@ MODULE_SCOPE int Ttk_GetSlaveIndexFromObj( /* Accessor functions: */ -MODULE_SCOPE int Ttk_NumberSlaves(Ttk_Manager *); +MODULE_SCOPE TkSizeT Ttk_NumberSlaves(Ttk_Manager *); /* Returns: number of managed slaves */ -MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, int slaveIndex); +MODULE_SCOPE void *Ttk_SlaveData(Ttk_Manager *, TkSizeT slaveIndex); /* Returns: client data associated with slave */ -MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, int slaveIndex); +MODULE_SCOPE Tk_Window Ttk_SlaveWindow(Ttk_Manager *, TkSizeT slaveIndex); /* Returns: slave window */ MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window slave, Tk_Window master); diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 03d3695..4b0a16c 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -254,9 +254,9 @@ error: * Return the index of the tab at point x,y, * or -1 if no tab at that point. */ -static int IdentifyTab(Notebook *nb, int x, int y) +static TkSizeT IdentifyTab(Notebook *nb, int x, int y) { - int index; + TkSizeT index; for (index = 0; index < Ttk_NumberSlaves(nb->notebook.mgr); ++index) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr,index); if ( tab->state != TAB_STATE_HIDDEN @@ -265,7 +265,7 @@ static int IdentifyTab(Notebook *nb, int x, int y) return index; } } - return -1; + return TCL_INDEX_NONE; } /* @@ -287,19 +287,19 @@ static void ActivateTab(Notebook *nb, int index) * The USER1 bit is set for the leftmost visible tab, and USER2 * is set for the rightmost visible tab. */ -static Ttk_State TabState(Notebook *nb, int index) +static Ttk_State TabState(Notebook *nb, TkSizeT index) { Ttk_State state = nb->core.state; Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); - int i = 0; + TkSizeT i = 0; - if (index == nb->notebook.currentIndex) { + if ((int)index == nb->notebook.currentIndex) { state |= TTK_STATE_SELECTED; } else { state &= ~TTK_STATE_FOCUS; } - if (index == nb->notebook.activeIndex) { + if ((int)index == nb->notebook.activeIndex) { state |= TTK_STATE_ACTIVE; } for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { @@ -312,7 +312,7 @@ static Ttk_State TabState(Notebook *nb, int index) } break; } - for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) { + for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i != TCL_INDEX_NONE; --i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); if (tab->state == TAB_STATE_HIDDEN) { continue; @@ -351,7 +351,7 @@ static void TabrowSize( { Ttk_Layout tabLayout = nb->notebook.tabLayout; int tabrowWidth = 0, tabrowHeight = 0; - int i; + TkSizeT i; for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); @@ -391,7 +391,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) int clientWidth = 0, clientHeight = 0, reqWidth = 0, reqHeight = 0, tabrowWidth = 0, tabrowHeight = 0; - int i; + TkSizeT i; NotebookStyleOptions(nb, &nbstyle); @@ -695,16 +695,16 @@ static void SelectNearestTab(Notebook *nb) * Select the next tab if the current one is being removed. * Adjust currentIndex to account for removed slave. */ -static void TabRemoved(void *managerData, int index) +static void TabRemoved(void *managerData, TkSizeT index) { Notebook *nb = managerData; Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); - if (index == nb->notebook.currentIndex) { + if ((int)index == nb->notebook.currentIndex) { SelectNearestTab(nb); } - if (index < nb->notebook.currentIndex) { + if ((int)index < nb->notebook.currentIndex) { --nb->notebook.currentIndex; } @@ -713,7 +713,7 @@ static void TabRemoved(void *managerData, int index) TtkRedisplayWidget(&nb->core); } -static int TabRequest(void *managerData, int index, int width, int height) +static int TabRequest(void *managerData, TkSizeT index, int width, int height) { return 1; } @@ -731,7 +731,7 @@ static int AddTab( return TCL_ERROR; } #if 0 /* can't happen */ - if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) >= 0) { + if (Ttk_SlaveIndex(nb->notebook.mgr, slaveWindow) != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added", Tk_PathName(slaveWindow))); Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL); @@ -791,7 +791,7 @@ static void NotebookEventHandler(ClientData clientData, XEvent *eventPtr) Tk_DeleteEventHandler(nb->core.tkwin, NotebookEventMask, NotebookEventHandler, clientData); } else if (eventPtr->type == MotionNotify) { - int index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y); + TkSizeT index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y); ActivateTab(nb, index); } else if (eventPtr->type == LeaveNotify) { ActivateTab(nb, -1); @@ -1054,7 +1054,8 @@ static int NotebookIdentifyCommand( int what = IDENTIFY_ELEMENT; Notebook *nb = recordPtr; Ttk_Element element = NULL; - int x, y, tabIndex; + int x, y; + TkSizeT tabIndex; if (objc < 4 || objc > 5) { Tcl_WrongNumArgs(interp, 2,objv, "?what? x y"); @@ -1070,7 +1071,7 @@ static int NotebookIdentifyCommand( } tabIndex = IdentifyTab(nb, x, y); - if (tabIndex >= 0) { + if (tabIndex != TCL_INDEX_NONE) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr, tabIndex); Ttk_State state = TabState(nb, tabIndex); Ttk_Layout tabLayout = nb->notebook.tabLayout; @@ -1090,8 +1091,8 @@ static int NotebookIdentifyCommand( } break; case IDENTIFY_TAB: - if (tabIndex >= 0) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(tabIndex)); + if (tabIndex != TCL_INDEX_NONE) { + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(tabIndex)); } break; } @@ -1118,14 +1119,14 @@ static int NotebookIndexCommand( * Special-case for "end": */ if (!strcmp("end", Tcl_GetString(objv[2]))) { - int nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); - Tcl_SetObjResult(interp, Tcl_NewIntObj(nSlaves)); + TkSizeT nSlaves = Ttk_NumberSlaves(nb->notebook.mgr); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(nSlaves)); return TCL_OK; } status = FindTabIndex(interp, nb, objv[2], &index); - if (status == TCL_OK && index >= 0) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); + if (status == TCL_OK && index != -1) { + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); } return status; @@ -1167,7 +1168,7 @@ static int NotebookTabsCommand( Notebook *nb = recordPtr; Ttk_Manager *mgr = nb->notebook.mgr; Tcl_Obj *result; - int i; + TkSizeT i; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, ""); diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 227642d..1b12d50 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -206,7 +206,7 @@ static int ShoveUp(Paned *pw, int i, int pos) * Same as ShoveUp, but going in the opposite direction * and stopping at the sentinel sash. */ -static int ShoveDown(Paned *pw, int i, int pos) +static int ShoveDown(Paned *pw, TkSizeT i, int pos) { Pane *pane = Ttk_SlaveData(pw->paned.mgr,i); int sashThickness = pw->paned.sashThickness; @@ -275,7 +275,7 @@ static void AdjustPanes(Paned *pw) { int sashThickness = pw->paned.sashThickness; int pos = 0; - int index; + TkSizeT index; for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) { Pane *pane = Ttk_SlaveData(pw->paned.mgr, index); @@ -372,7 +372,7 @@ static void PlacePanes(Paned *pw) int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin); int sashThickness = pw->paned.sashThickness; int pos = 0; - int index; + TkSizeT index; for (index = 0; index < Ttk_NumberSlaves(pw->paned.mgr); ++index) { Pane *pane = Ttk_SlaveData(pw->paned.mgr, index); @@ -403,7 +403,7 @@ static void PanedPlaceSlaves(void *managerData) PlacePanes(pw); } -static void PaneRemoved(void *managerData, int index) +static void PaneRemoved(void *managerData, TkSizeT index) { Paned *pw = managerData; Pane *pane = Ttk_SlaveData(pw->paned.mgr, index); @@ -419,7 +419,7 @@ static int AddPane( if (!Ttk_Maintainable(interp, slaveWindow, pw->core.tkwin)) { return TCL_ERROR; } - if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) >= 0) { + if (Ttk_SlaveIndex(pw->paned.mgr, slaveWindow) != TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "%s already added", Tk_PathName(slaveWindow))); Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL); @@ -445,7 +445,7 @@ static int AddPane( * in order to avoid unexpected pane resizes (esp. while the * user is dragging a sash [#1325286]). */ -static int PaneRequest(void *managerData, int index, int width, int height) +static int PaneRequest(void *managerData, TkSizeT index, int width, int height) { Paned *pw = managerData; Pane *pane = Ttk_SlaveData(pw->paned.mgr, index); @@ -603,11 +603,11 @@ static void DrawSash(Paned *pw, int index, Drawable d) static void PanedDisplay(void *recordPtr, Drawable d) { Paned *pw = recordPtr; - int i, nSashes = Ttk_NumberSlaves(pw->paned.mgr) - 1; + TkSizeT i, nSlaves = Ttk_NumberSlaves(pw->paned.mgr); TtkWidgetDisplay(recordPtr, d); - for (i = 0; i < nSashes; ++i) { - DrawSash(pw, i, d); + for (i = 1; i < nSlaves; ++i) { + DrawSash(pw, i - 1, d); } } @@ -743,7 +743,7 @@ static int PanedIdentifyCommand( /* Found it. */ switch (what) { case IDENTIFY_SASH: - Tcl_SetObjResult(interp, Tcl_NewIntObj(index)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); return TCL_OK; case IDENTIFY_ELEMENT: { @@ -808,7 +808,7 @@ static int PanedPanesCommand( Paned *pw = recordPtr; Ttk_Manager *mgr = pw->paned.mgr; Tcl_Obj *panes; - int i; + TkSizeT i; if (objc != 2) { Tcl_WrongNumArgs(interp, 2, objv, ""); @@ -843,7 +843,7 @@ static int PanedSashposCommand( if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) { return TCL_ERROR; } - if (sashIndex < 0 || sashIndex >= Ttk_NumberSlaves(pw->paned.mgr) - 1) { + if (sashIndex < 0 || (TkSizeT)(sashIndex + 1) >= Ttk_NumberSlaves(pw->paned.mgr)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "sash index %d out of range", sashIndex)); Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL); @@ -853,7 +853,7 @@ static int PanedSashposCommand( pane = Ttk_SlaveData(pw->paned.mgr, sashIndex); if (objc == 3) { - Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos)); return TCL_OK; } /* else -- set new sash position */ @@ -871,7 +871,7 @@ static int PanedSashposCommand( AdjustPanes(pw); Ttk_ManagerLayoutChanged(pw->paned.mgr); - Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos)); return TCL_OK; } diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index e63b5fe..1ec961f 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -102,7 +102,7 @@ LoadXPThemeProcs(HINSTANCE *phlib) * We have successfully loaded the library. Proceed in storing the * addresses of the functions we want to use. */ - XPThemeProcs *procs = ckalloc(sizeof(XPThemeProcs)); + XPThemeProcs *procs = (XPThemeProcs *)ckalloc(sizeof(XPThemeProcs)); #define LOADPROC(name) \ (0 != (procs->name = (name ## Proc *)GetProcAddress(handle, #name) )) @@ -134,7 +134,7 @@ LoadXPThemeProcs(HINSTANCE *phlib) static void XPThemeDeleteProc(void *clientData) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; FreeLibrary(themeData->hlibrary); ckfree(clientData); } @@ -142,9 +142,11 @@ XPThemeDeleteProc(void *clientData) static int XPThemeEnabled(Ttk_Theme theme, void *clientData) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; int active = themeData->procs->IsThemeActive(); int themed = themeData->procs->IsAppThemed(); + (void)theme; + return (active && themed); } @@ -409,7 +411,7 @@ typedef struct static ElementData * NewElementData(XPThemeProcs *procs, const ElementInfo *info) { - ElementData *elementData = ckalloc(sizeof(ElementData)); + ElementData *elementData = (ElementData *)ckalloc(sizeof(ElementData)); elementData->procs = procs; elementData->info = info; @@ -425,12 +427,12 @@ NewElementData(XPThemeProcs *procs, const ElementInfo *info) */ static void DestroyElementData(void *clientData) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (elementData->info->flags & HEAP_ELEMENT) { - ckfree(elementData->info->statemap); + ckfree((char *)elementData->info->statemap); ckfree((char *)elementData->info->className); ckfree((char *)elementData->info->elementName); - ckfree(elementData->info); + ckfree((char *)elementData->info); } ckfree(clientData); } @@ -493,9 +495,10 @@ static void GenericElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; HRESULT result; SIZE size; + (void)elementRecord; if (!InitElementData(elementData, tkwin, 0)) return; @@ -529,8 +532,9 @@ static void GenericElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; RECT rc; + (void)elementRecord; if (!InitElementData(elementData, tkwin, d)) { return; @@ -574,7 +578,7 @@ GenericSizedElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (!InitElementData(elementData, tkwin, 0)) return; @@ -610,7 +614,7 @@ SpinboxArrowElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; if (!InitElementData(elementData, tkwin, 0)) return; @@ -639,9 +643,10 @@ static void ThumbElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; unsigned stateId = Ttk_StateTableLookup(elementData->info->statemap, state); RECT rc = BoxToRect(b); + (void)elementRecord; /* * Don't draw the thumb if we are disabled. @@ -678,7 +683,7 @@ static void PbarElementSize( void *clientData, void *elementRecord, Tk_Window tkwin, int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; int nBars = 3; GenericElementSize(clientData, elementRecord, tkwin, @@ -718,9 +723,10 @@ static void TabElementDraw( void *clientData, void *elementRecord, Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state) { - ElementData *elementData = clientData; + ElementData *elementData = (ElementData *)clientData; int partId = elementData->info->partId; RECT rc = BoxToRect(b); + (void)elementRecord; if (!InitElementData(elementData, tkwin, d)) return; @@ -1108,7 +1114,7 @@ Ttk_CreateVsapiElement( int objc, Tcl_Obj *const objv[]) { - XPThemeData *themeData = clientData; + XPThemeData *themeData = (XPThemeData *)clientData; ElementInfo *elementPtr = NULL; ClientData elementData; LPCWSTR className; @@ -1215,7 +1221,7 @@ Ttk_CreateVsapiElement( if (Tcl_ListObjGetElements(interp, objv[2], &count, &specs) != TCL_OK) goto retErr; /* we over-allocate to ensure there is a terminating entry */ - stateTable = ckalloc(sizeof(Ttk_StateTable) * (count + 1)); + stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable) * (count + 1)); memset(stateTable, 0, sizeof(Ttk_StateTable) * (count + 1)); for (n = 0, j = 0; status == TCL_OK && n < count; n += 2, ++j) { Ttk_StateSpec spec = {0,0}; @@ -1233,11 +1239,11 @@ Ttk_CreateVsapiElement( return status; } } else { - stateTable = ckalloc(sizeof(Ttk_StateTable)); + stateTable = (Ttk_StateTable *)ckalloc(sizeof(Ttk_StateTable)); memset(stateTable, 0, sizeof(Ttk_StateTable)); } - elementPtr = ckalloc(sizeof(ElementInfo)); + elementPtr = (ElementInfo *)ckalloc(sizeof(ElementInfo)); elementPtr->elementSpec = elementSpec; elementPtr->partId = partId; elementPtr->statemap = stateTable; @@ -1245,12 +1251,12 @@ Ttk_CreateVsapiElement( elementPtr->flags = HEAP_ELEMENT | flags; /* set the element name to an allocated copy */ - name = ckalloc(strlen(elementName) + 1); + name = (char *)ckalloc(strlen(elementName) + 1); strcpy(name, elementName); elementPtr->elementName = name; /* set the class name to an allocated copy */ - wname = ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR)); + wname = (LPWSTR)ckalloc(Tcl_DStringLength(&classBuf) + sizeof(WCHAR)); wcscpy(wname, className); elementPtr->className = wname; @@ -1302,7 +1308,7 @@ MODULE_SCOPE int TtkXPTheme_Init(Tcl_Interp *interp, HWND hwnd) * Set theme data and cleanup proc */ - themeData = ckalloc(sizeof(XPThemeData)); + themeData = (XPThemeData *)ckalloc(sizeof(XPThemeData)); themeData->procs = procs; themeData->hlibrary = hlibrary; -- cgit v0.12 From a6dabf17584dfeb18cb9c16a66e6a10a4b2ac071 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 21 Feb 2020 14:26:23 +0000 Subject: Rename (static) function TkMenuCleanup() to MenuCleanup(). Make TkGetMenuIndex() a static function (is used in one file only). Remove "registry" keywork in tkMenu.c. Add "const" modifier to ttkWinXPTheme.c --- generic/tkMenu.c | 69 ++++++++++++++++++++++++++++++----------------------- generic/tkMenu.h | 2 -- win/ttkWinXPTheme.c | 2 +- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 1d7039c..faadc81 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -368,7 +368,9 @@ static void MenuWorldChanged(ClientData instanceData); static int PostProcessEntry(TkMenuEntry *mePtr); static void RecursivelyDeleteMenu(TkMenu *menuPtr); static void UnhookCascadeEntry(TkMenuEntry *mePtr); -static void TkMenuCleanup(ClientData unused); +static void MenuCleanup(ClientData unused); +static int GetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr, + Tcl_Obj *objPtr, int lastOK, TkSizeT *indexPtr); /* * The structure below is a list of procs that respond to certain window @@ -409,7 +411,7 @@ Tk_MenuObjCmd( { Tk_Window tkwin = clientData; Tk_Window newWin; - register TkMenu *menuPtr; + TkMenu *menuPtr; TkMenuReferences *menuRefPtr; int i, index, toplevel; const char *windowName; @@ -620,8 +622,8 @@ MenuWidgetObjCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument strings. */ { - register TkMenu *menuPtr = clientData; - register TkMenuEntry *mePtr; + TkMenu *menuPtr = clientData; + TkMenuEntry *mePtr; int result = TCL_OK; int option; ThreadSpecificData *tsdPtr = @@ -645,7 +647,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (menuPtr->active == index) { @@ -742,12 +744,12 @@ MenuWidgetObjCmd( if (first >= menuPtr->numEntries) { goto done; } - } else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){ + } else if (GetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){ goto error; } if (objc == 3) { last = first; - } else if (TkGetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) { + } else if (GetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) { goto error; } @@ -773,7 +775,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index option"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { @@ -798,7 +800,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index ?-option value ...?"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { @@ -838,7 +840,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "string"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { @@ -865,7 +867,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { @@ -887,7 +889,7 @@ MenuWidgetObjCmd( goto error; } if (objc == 5) { - if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) { goto error; } } @@ -918,7 +920,7 @@ MenuWidgetObjCmd( goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if ((index == TCL_INDEX_NONE) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) { @@ -936,7 +938,7 @@ MenuWidgetObjCmd( Tcl_WrongNumArgs(interp, 2, objv, "index"); goto error; } - if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) { goto error; } if (index == TCL_INDEX_NONE) { @@ -1391,7 +1393,7 @@ static void DestroyMenuEntry( void *memPtr) /* Pointer to entry to be freed. */ { - register TkMenuEntry *mePtr = memPtr; + TkMenuEntry *mePtr = memPtr; TkMenu *menuPtr = mePtr->menuPtr; if (menuPtr->postedCascade == mePtr) { @@ -1525,7 +1527,7 @@ MenuWorldChanged( static int ConfigureMenu( Tcl_Interp *interp, /* Used for error reporting. */ - register TkMenu *menuPtr, /* Information about widget; may or may not + TkMenu *menuPtr, /* Information about widget; may or may not * already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[]) /* Arguments. */ @@ -1908,7 +1910,7 @@ PostProcessEntry( static int ConfigureMenuEntry( - register TkMenuEntry *mePtr,/* Information about menu entry; may or may + TkMenuEntry *mePtr,/* Information about menu entry; may or may * not already have values for some fields. */ int objc, /* Number of valid entries in argv. */ Tcl_Obj *const objv[]) /* Arguments. */ @@ -1972,7 +1974,7 @@ ConfigureMenuEntry( static int ConfigureMenuCloneEntries( - Tcl_Interp *interp, /* Used for error reporting. */ + Tcl_Interp *dummy, /* Used for error reporting. */ TkMenu *menuPtr, /* Information about whole menu. */ int index, /* Index of mePtr within menuPtr's entries. */ int objc, /* Number of valid entries in argv. */ @@ -1984,6 +1986,7 @@ ConfigureMenuCloneEntries( TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL; Tcl_Obj *oldCascadePtr = NULL; const char *newCascadeName; + (void)dummy; /* * Cascades are kind of tricky here. This is special case #3 in the @@ -2094,7 +2097,7 @@ ConfigureMenuCloneEntries( /* *-------------------------------------------------------------- * - * TkGetMenuIndex -- + * GetMenuIndex -- * * Parse a textual index into a menu and return the numerical index of * the indicated entry. @@ -2112,7 +2115,7 @@ ConfigureMenuCloneEntries( */ int -TkGetMenuIndex( +GetMenuIndex( Tcl_Interp *interp, /* For error messages. */ TkMenu *menuPtr, /* Menu for which the index is being * specified. */ @@ -2356,7 +2359,7 @@ MenuAddOrInsert( TkMenu *menuListPtr; if (indexPtr != NULL) { - if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) { return TCL_ERROR; } } else { @@ -2494,6 +2497,8 @@ MenuVarProc( TkMenu *menuPtr; const char *value; const char *name, *onValue; + (void)name1; + (void)name2; if (Tcl_InterpDeleted(interp) || (mePtr->namePtr == NULL)) { /* @@ -2595,11 +2600,11 @@ MenuVarProc( int TkActivateMenuEntry( - register TkMenu *menuPtr, /* Menu in which to activate. */ + TkMenu *menuPtr, /* Menu in which to activate. */ TkSizeT index) /* Index of entry to activate, or * TCL_INDEX_NONE to deactivate all entries. */ { - register TkMenuEntry *mePtr; + TkMenuEntry *mePtr; int result = TCL_OK; if (menuPtr->active != TCL_INDEX_NONE) { @@ -2874,7 +2879,7 @@ MenuDoXPosition( TkSizeT index; TkRecomputeMenu(menuPtr); - if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) { return TCL_ERROR; } Tcl_ResetResult(interp); @@ -2911,7 +2916,7 @@ MenuDoYPosition( TkSizeT index; TkRecomputeMenu(menuPtr); - if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) { + if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) { goto error; } Tcl_ResetResult(interp); @@ -3315,8 +3320,10 @@ TkSetWindowMenuBar( static void DestroyMenuHashTable( ClientData clientData, /* The menu hash table we are destroying. */ - Tcl_Interp *interp) /* The interpreter we are destroying. */ + Tcl_Interp *dummy) /* The interpreter we are destroying. */ { + (void)dummy; + Tcl_DeleteHashTable(clientData); ckfree(clientData); } @@ -3556,7 +3563,7 @@ DeleteMenuCloneEntries( /* *---------------------------------------------------------------------- * - * TkMenuCleanup -- + * MenuCleanup -- * * Resets menusInitialized to allow Tk to be finalized and reused without * the DLL being unloaded. @@ -3571,9 +3578,11 @@ DeleteMenuCloneEntries( */ static void -TkMenuCleanup( - ClientData unused) +MenuCleanup( + ClientData dummy) { + (void)dummy; + menusInitialized = 0; } @@ -3611,7 +3620,7 @@ TkMenuInit(void) * Make sure we cleanup on finalize. */ - TkCreateExitHandler((Tcl_ExitProc *) TkMenuCleanup, NULL); + TkCreateExitHandler((Tcl_ExitProc *) MenuCleanup, NULL); Tcl_MutexUnlock(&menuMutex); } if (!tsdPtr->menusInitialized) { diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 0b261e5..ecb6fac 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -491,8 +491,6 @@ MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp, Tcl_Obj *namePtr); MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr); MODULE_SCOPE Tcl_HashTable *TkGetMenuHashTable(Tcl_Interp *interp); -MODULE_SCOPE int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr, - Tcl_Obj *objPtr, int lastOK, TkSizeT *indexPtr); MODULE_SCOPE void TkMenuInitializeDrawingFields(TkMenu *menuPtr); MODULE_SCOPE void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr); MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr, diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 1ec961f..7f20ed1 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -1060,7 +1060,7 @@ static const ElementInfo ElementInfoTable[] = { static int GetSysFlagFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr) { - static const char *names[] = { + static const char *const names[] = { "SM_CXBORDER", "SM_CYBORDER", "SM_CXVSCROLL", "SM_CYVSCROLL", "SM_CXHSCROLL", "SM_CYHSCROLL", "SM_CXMENUCHECK", "SM_CYMENUCHECK", "SM_CXMENUSIZE", "SM_CYMENUSIZE", "SM_CXSIZE", "SM_CYSIZE", "SM_CXSMSIZE", -- cgit v0.12 From fed281550bb47d459300b6168ecee7bad8d9d730 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 23 Feb 2020 14:38:44 +0000 Subject: Prevent some textTag tests from triggering hot spots of the Linux KDE/Plasma desktop. What is needed in these tests is to move the mouse out of the test window when the test starts, so that the events expected by the test can be observed. We don't need to move the mouse exactly at the upper-left corner of the screen, we only have to make sure the mouse pointer is outside the test window. --- tests/textTag.test | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/textTag.test b/tests/textTag.test index 5761abc..d85037a 100644 --- a/tests/textTag.test +++ b/tests/textTag.test @@ -1488,7 +1488,8 @@ set y3 [expr {[lindex $c 1] + [lindex $c 3]/2}] test textTag-15.1 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { bind .t {lappend x up} .t tag bind x {lappend x x-up} @@ -1513,7 +1514,8 @@ test textTag-15.1 {TkTextBindProc} -constraints haveCourier12 -setup { test textTag-15.2 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag bind x {lappend x x-enter} .t tag bind x {lappend x x-down} @@ -1541,7 +1543,8 @@ test textTag-15.2 {TkTextBindProc} -constraints haveCourier12 -setup { test textTag-15.3 {TkTextBindProc} -constraints haveCourier12 -setup { .t tag delete x y - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag bind x {lappend x x-enter} .t tag bind x {lappend x x-down} @@ -1576,7 +1579,8 @@ test textTag-16.1 {TkTextPickCurrent procedure} -constraints { haveCourier12 } -setup { .t tag delete {*}[.t tag names] - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { event gen .t -state 0x100 -x $x1 -y $y1 set x [.t index current] @@ -1598,7 +1602,8 @@ test textTag-16.2 {TkTextPickCurrent procedure} -constraints { haveCourier12 } -setup { .t tag delete {*}[.t tag names] - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag configure big -font $bigFont event gen .t -state 0x100 -x $x1 -y $y1 @@ -1617,7 +1622,8 @@ test textTag-16.3 {TkTextPickCurrent procedure} -constraints { foreach i {a b c d} { .t tag remove $i 1.0 end } - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { foreach i {a b c d} { .t tag bind $i "lappend x enter-$i" @@ -1646,7 +1652,8 @@ test textTag-16.4 {TkTextPickCurrent procedure} -constraints { foreach i {a b c d} { .t tag remove $i 1.0 end } - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { foreach i {a b c d} { .t tag bind $i "lappend x enter-$i" @@ -1674,7 +1681,8 @@ test textTag-16.5 {TkTextPickCurrent procedure} -constraints { foreach i {big a b c d} { .t tag remove $i 1.0 end } - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag configure big -font $bigFont event gen .t -x $x1 -y $y1 @@ -1692,7 +1700,8 @@ test textTag-16.6 {TkTextPickCurrent procedure} -constraints { foreach i {big a b c d} { .t tag remove $i 1.0 end } - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag configure big -font $bigFont event gen .t -x $x1 -y $y1 @@ -1711,7 +1720,8 @@ test textTag-16.7 {TkTextPickCurrent procedure} -constraints { foreach i {big a b c d} { .t tag remove $i 1.0 end } - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { .t tag configure big -font $bigFont .t tag bind a {.t tag add big 3.0 3.2} @@ -1741,7 +1751,8 @@ test textTag-17.1 {insert procedure inserts tags} -setup { test textTag-18.1 {TkTextPickCurrent tag bindings} -setup { destroy .t - event generate {} -warp 1 -x -1 -y -1; update + wm geometry . +200+200 ; update + event generate {} -warp 1 -x 5 -y 5 ; update idletasks ; after 50 } -body { text .t -width 30 -height 4 -relief sunken -borderwidth 10 \ -highlightthickness 10 -pady 2 -- cgit v0.12 From a8ea4815643347a53204e6667ee4ac9aefcb6a14 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 23 Feb 2020 21:19:38 +0000 Subject: Fix 2 compiler warnings (gcc-9) --- generic/tkImgListFormat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c index 2b23699..0c261f7 100644 --- a/generic/tkImgListFormat.c +++ b/generic/tkImgListFormat.c @@ -864,7 +864,7 @@ ParseColorAsList( * To avoid that, avance the pointer to the next non-blank char. */ - while(isspace(*curPos)) { + while(isspace(UCHAR(*curPos))) { ++curPos; } while (i < 4 && *curPos != '\0') { @@ -872,7 +872,7 @@ ParseColorAsList( if (values[i] < 0 || values[i] > 255) { return TCL_ERROR; } - while(isspace(*curPos)) { + while(isspace(UCHAR(*curPos))) { ++curPos; } ++i; -- cgit v0.12 From 52ba73c674ceaf6939d1161e615216ca96ba0f64 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 24 Feb 2020 01:11:17 +0000 Subject: Fix for utility/floating windows on macOS not displaying completely on initial creation --- macosx/tkMacOSXWindowEvent.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 6c0f335..be3439f 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -906,10 +906,11 @@ RedisplayView( /* * Make sure that we are not trying to displaying a view that no longer - * exists. + * exists. Must call [NSApp windows] because [NSApp orderedWindows] excludes + * floating/utility windows and other window panels. */ - for (NSWindow *w in [NSApp orderedWindows]) { + for (NSWindow *w in [NSApp windows]) { if ([w contentView] == view) { [view setNeedsDisplay:YES]; break; -- cgit v0.12 From 6caccdc166b91ff4f36ca8b5c0d02654ad98a413 Mon Sep 17 00:00:00 2001 From: Kevin Walzer Date: Mon, 24 Feb 2020 01:12:55 +0000 Subject: Fix for utility/floating windows on macOS not displaying completely on initial creation --- macosx/tkMacOSXWindowEvent.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index fe6981d..d9ad52f 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -903,13 +903,14 @@ RedisplayView( ClientData clientdata) { NSView *view = (NSView *) clientdata; - + /* * Make sure that we are not trying to displaying a view that no longer - * exists. + * exists. Must call [NSApp windows] because [NSApp orderedWindows] excludes + * floating/utility windows and other window panels. */ - for (NSWindow *w in [NSApp orderedWindows]) { + for (NSWindow *w in [NSApp windows]) { if ([w contentView] == view) { [view setNeedsDisplay:YES]; break; -- cgit v0.12 From d100137ea90e888dac02a31e3bb934d81b69c224 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Feb 2020 08:57:14 +0000 Subject: Add internal function TkGetIntForIndex(), which handles integer indexes and "end" using Tcl_GetIntForIndex() (TIP #544). For now, only used in menu's. --- generic/tkInt.h | 2 ++ generic/tkMenu.c | 32 ++++++++++-------------- generic/tkObj.c | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 20 deletions(-) diff --git a/generic/tkInt.h b/generic/tkInt.h index 7ef7862..e797d29 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1331,6 +1331,8 @@ MODULE_SCOPE int TkListCreateFrame(ClientData clientData, MODULE_SCOPE void TkRotatePoint(double originX, double originY, double sine, double cosine, double *xPtr, double *yPtr); +MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, TkSizeT, TkSizeT*); + #ifdef _WIN32 #define TkParseColor XParseColor diff --git a/generic/tkMenu.c b/generic/tkMenu.c index faadc81..ed434e9 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -2126,15 +2126,25 @@ GetMenuIndex( TkSizeT *indexPtr) /* Where to store converted index. */ { int i; - const char *string = Tcl_GetString(objPtr); + const char *string; + + if (TkGetIntForIndex(objPtr, menuPtr->numEntries - ((lastOK) ? 0 : 1), indexPtr) == TCL_OK) { + if (*indexPtr != TCL_INDEX_NONE) { + if (*indexPtr >= menuPtr->numEntries) { + *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1); + } + return TCL_OK; + } + } + + string = Tcl_GetString(objPtr); if ((string[0] == 'a') && (strcmp(string, "active") == 0)) { *indexPtr = menuPtr->active; goto success; } - if (((string[0] == 'l') && (strcmp(string, "last") == 0)) - || ((string[0] == 'e') && (strcmp(string, "end") == 0))) { + if ((string[0] == 'l') && (strcmp(string, "last") == 0)) { *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1); goto success; } @@ -2151,22 +2161,6 @@ GetMenuIndex( } } - if (isdigit(UCHAR(string[0]))) { - if (Tcl_GetIntFromObj(NULL, objPtr, &i) == TCL_OK) { - if (i >= (int)menuPtr->numEntries) { - if (lastOK) { - i = menuPtr->numEntries; - } else { - i = menuPtr->numEntries-1; - } - } else if (i < 0) { - i = -1; - } - *indexPtr = i; - goto success; - } - } - for (i = 0; i < (int)menuPtr->numEntries; i++) { Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr; const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr); diff --git a/generic/tkObj.c b/generic/tkObj.c index 1a98db6..bbd331c 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -50,6 +50,7 @@ typedef struct PixelRep { typedef struct { const Tcl_ObjType *doubleTypePtr; const Tcl_ObjType *intTypePtr; + const Tcl_ObjType *endTypePtr; } ThreadSpecificData; static Tcl_ThreadDataKey dataKey; @@ -97,6 +98,29 @@ static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr); +#if TCL_MAJOR_VERSION < 9 +#if defined(USE_TCL_STUBS) +/* Little hack to eliminate the need for "tclInt.h" here: + Just copy a small portion of TclIntStubs, just + enough to make it work */ +typedef struct TclIntStubs { + int magic; + void *hooks; + void (*dummy[34]) (void); /* dummy entries 0-33, not used */ + int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */ +} TclIntStubs; +extern const struct TclIntStubs *tclIntStubsPtr; + +# undef Tcl_GetIntForIndex +# define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \ + ((int (*)(Tcl_Interp*, Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \ + tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr))) +#elif TCL_MINOR_VERSION < 7 +extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*); +# define Tcl_GetIntForIndex TclGetIntForIndex +#endif +#endif + /* * The following structure defines the implementation of the "pixel" Tcl * object, used for measuring distances. The pixel object remembers its @@ -160,12 +184,17 @@ GetTypeCache(void) /* Smart initialization of doubleTypePtr/intTypePtr without * hash-table lookup or creating complete Tcl_Obj's */ Tcl_Obj obj; + obj.bytes = (char *)"end"; obj.length = 3; + obj.typePtr = NULL; + Tcl_GetIntForIndex(NULL, &obj, TCL_INDEX_NONE, (TkSizeT *)&obj.internalRep.doubleValue); + tsdPtr->endTypePtr = obj.typePtr; obj.bytes = (char *)"0.0"; + obj.length = 3; obj.typePtr = NULL; Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue); tsdPtr->doubleTypePtr = obj.typePtr; - obj.bytes += 2; + obj.bytes = (char *)"0"; obj.length = 1; obj.typePtr = NULL; Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue); @@ -177,6 +206,51 @@ GetTypeCache(void) /* *---------------------------------------------------------------------- * + * TkGetIntForIndex -- + * + * Almost the same as Tcl_GetIntForIndex, but it return an int, and it is + * more restricted. For example it only accepts "end", not "end-1", and + * only "2", not "1+1" + * + * Results: + * The return value is a standard Tcl object result. + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +int +TkGetIntForIndex(Tcl_Obj *indexObj, TkSizeT end, TkSizeT *indexPtr) { + ThreadSpecificData *tsdPtr = (ThreadSpecificData *) + Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); + + if (Tcl_GetIntForIndex(NULL, indexObj, end, indexPtr) != TCL_OK) { + return TCL_ERROR; + } + if (indexObj->typePtr == tsdPtr->endTypePtr) { + /* check for "end", but not "end-??" or "end+??" */ + return (*indexPtr == end) ? TCL_OK : TCL_ERROR; + } + if (indexObj->typePtr != tsdPtr->intTypePtr) { + /* Neither do we accept "??-??" or "??+??" */ + return TCL_ERROR; + } +#if TCL_MAJOR_VERSION < 9 + if (*indexPtr < -1) { + *indexPtr = TCL_INDEX_NONE; + } +#endif + if ((*indexPtr != TCL_INDEX_NONE) && (*indexPtr > end)) { + *indexPtr = end + 1; + } + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * * GetPixelsFromObjEx -- * * Attempt to return a pixel value from the Tcl object "objPtr". If the -- cgit v0.12 From 008b8ba0fb46d4fa8108df83ec96e4e59667e3bf Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Feb 2020 09:09:56 +0000 Subject: Work around a few new gcc(-9) warnings. --- generic/tkCanvUtil.c | 5 +++-- generic/tkImgPhoto.c | 4 ++-- generic/tkUtil.c | 1 + generic/tkWindow.c | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index ca3af8f..c2ff2bf 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -28,15 +28,16 @@ const Tk_SmoothMethod tkBezierSmoothMethod = { "true", TkMakeBezierCurve, (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, - int numPoints, int numSteps)) TkMakeBezierPostscript, + int numPoints, int numSteps))(void *)TkMakeBezierPostscript, }; static const Tk_SmoothMethod tkRawSmoothMethod = { "raw", TkMakeRawCurve, (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, - int numPoints, int numSteps)) TkMakeRawCurvePostscript, + int numPoints, int numSteps))(void *)TkMakeRawCurvePostscript, }; + /* * Function forward-declarations. */ diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 03b3731..96c3743 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -768,7 +768,7 @@ ImgPhotoCmd( Tk_PhotoImageBlock *blockPtr); Tcl_DStringInit(&buffer); - result = ((OldStringWriteProc) stringWriteProc)(interp, &buffer, + result = ((OldStringWriteProc)(void *)stringWriteProc)(interp, &buffer, Tcl_GetString(options.format), &block); if (result == TCL_OK) { Tcl_DStringResult(interp, &buffer); @@ -780,7 +780,7 @@ ImgPhotoCmd( Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr, void *dummy); - result = ((NewStringWriteProc) stringWriteProc)(interp, + result = ((NewStringWriteProc)(void *)stringWriteProc)(interp, options.format, &block, NULL); } if (options.background) { diff --git a/generic/tkUtil.c b/generic/tkUtil.c index e32fdf3..cac3dc8 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -299,6 +299,7 @@ TkOffsetParseProc( tsoffset.flags = INT_MAX; goto goodTSOffset; } + break; case 'w': if (value[1] != '\0') {goto badTSOffset;} tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 00fb344..ec99717 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -124,7 +124,7 @@ static const TkCmd commands[] = { {"place", Tk_PlaceObjCmd, PASSMAINWINDOW|ISSAFE}, {"raise", Tk_RaiseObjCmd, PASSMAINWINDOW|ISSAFE}, {"selection", Tk_SelectionObjCmd, PASSMAINWINDOW}, - {"tk", (Tcl_ObjCmdProc *) TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, + {"tk", (Tcl_ObjCmdProc *)(void *)TkInitTkCmd, USEINITPROC|PASSMAINWINDOW|ISSAFE}, {"tkwait", Tk_TkwaitObjCmd, PASSMAINWINDOW|ISSAFE}, {"update", Tk_UpdateObjCmd, PASSMAINWINDOW|ISSAFE}, {"winfo", Tk_WinfoObjCmd, PASSMAINWINDOW|ISSAFE}, @@ -939,7 +939,7 @@ TkCreateMainWindow( clientData = NULL; } if (cmdPtr->flags & USEINITPROC) { - ((TkInitProc *) cmdPtr->objProc)(interp, clientData); + ((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); -- cgit v0.12 From 96ef4a384e7c31836cbfbb9165122bc5e937333e Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Feb 2020 09:46:08 +0000 Subject: (cherry-pick): Work around a few new gcc(-9) warnings. Also fix static build against Tcl 8.6 headers, so we (finally) add a static build of Tk 8.5 to Travis. --- .travis.yml | 7 +++++++ generic/tkCanvUtil.c | 5 +++-- generic/tkImgPhoto.c | 4 ++-- generic/tkUtil.c | 1 + generic/tkWindow.c | 4 ++-- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f603442..5f01fb0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,13 @@ matrix: compiler: gcc env: - BUILD_DIR=unix + - name: "Linux/GCC/Static" + os: linux + dist: bionic + compiler: gcc + env: + - CFGOPT="--disable-shared" + - BUILD_DIR=unix - name: "Linux/GCC 7/Shared" os: linux dist: bionic diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index d051e27..bbf8bea 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -29,15 +29,16 @@ Tk_SmoothMethod tkBezierSmoothMethod = { "true", TkMakeBezierCurve, (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, - int numPoints, int numSteps)) TkMakeBezierPostscript, + int numPoints, int numSteps))(void *)TkMakeBezierPostscript, }; static Tk_SmoothMethod tkRawSmoothMethod = { "raw", TkMakeRawCurve, (void (*) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, - int numPoints, int numSteps)) TkMakeRawCurvePostscript, + int numPoints, int numSteps))(void *)TkMakeRawCurvePostscript, }; + /* * Function forward-declarations. */ diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 56217c4..3976e8b 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -984,7 +984,7 @@ ImgPhotoCmd( Tcl_DStringInit(&buffer); result = ((int (*) (Tcl_Interp *interp, Tcl_DString *dataPtr, char *formatString, - Tk_PhotoImageBlock *blockPtr)) stringWriteProc) + Tk_PhotoImageBlock *blockPtr))(void *)stringWriteProc) (interp, &buffer, Tcl_GetString(options.format), &block); if (result == TCL_OK) { Tcl_DStringResult(interp, &buffer); @@ -995,7 +995,7 @@ ImgPhotoCmd( result = ((int (*) (Tcl_Interp *interp, Tcl_Obj *formatString, Tk_PhotoImageBlock *blockPtr, - void *dummy)) stringWriteProc) + void *dummy))(void *)stringWriteProc) (interp, options.format, &block, NULL); } if (options.background) { diff --git a/generic/tkUtil.c b/generic/tkUtil.c index bfa5d5c..b1d99e0 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -293,6 +293,7 @@ TkOffsetParseProc( tsoffset.flags = INT_MAX; goto goodTSOffset; } + break; case 'w': if (value[1] != '\0') {goto badTSOffset;} tsoffset.flags = TK_OFFSET_LEFT|TK_OFFSET_MIDDLE; diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 1257e22..3de2105 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -963,7 +963,7 @@ TkCreateMainWindow( } if (cmdPtr->flags & NOOBJPROC) { Tcl_CreateCommand(interp, cmdPtr->name, - (Tcl_CmdProc *) cmdPtr->objProc, clientData, NULL); + (Tcl_CmdProc *)(void *)cmdPtr->objProc, clientData, NULL); } else { Tcl_CreateObjCommand(interp, cmdPtr->name, cmdPtr->objProc, clientData, NULL); @@ -3275,7 +3275,7 @@ Initialize( Tcl_SetMainLoop(Tk_MainLoop); -#ifndef _WIN32 +#if !defined(_WIN32) && !defined(STATIC_BUILD) /* On Windows, this has no added value. */ # undef Tk_InitStubs Tk_InitStubs(interp, TK_VERSION, 1); -- cgit v0.12 From e89bfca44403750e0e1b9f7f36ed67cd244ab73f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 24 Feb 2020 13:11:47 +0000 Subject: Fix [4b5deacc70]: undefined reference to `Tcl_SetStartupScript'. Also fix some ANSI prototypes. Sync tcl.m4 with Tcl. --- generic/tkButton.h | 2 +- generic/tkMain.c | 4 +++- generic/tkWindow.c | 10 +++++----- generic/ttk/ttkTheme.c | 2 +- unix/configure | 2 +- unix/tcl.m4 | 2 +- unix/tkUnixEvent.c | 4 ++-- win/configure | 46 ++++++++++++++++++++++------------------------ win/tcl.m4 | 44 +++++++++++++++++++------------------------- 9 files changed, 55 insertions(+), 61 deletions(-) diff --git a/generic/tkButton.h b/generic/tkButton.h index d669b02..3859d78 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -306,7 +306,7 @@ MODULE_SCOPE char tkDefLabelPady[TCL_INTEGER_SPACE]; */ #ifndef TkpButtonSetDefaults -MODULE_SCOPE void TkpButtonSetDefaults(); +MODULE_SCOPE void TkpButtonSetDefaults(void); #endif MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData); MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr); diff --git a/generic/tkMain.c b/generic/tkMain.c index e8aa08b..d62dd72 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -15,7 +15,9 @@ */ #include "tkInt.h" -#ifdef _WIN32 +#if TCL_MINOR_VERSION < 6 +#include "tclInt.h" +#elif defined(_WIN32) /* Little hack to eliminate the need for "tclInt.h" here: Just copy a small portion of TclIntPlatStubs, just enough to make it work. See [600b72bfbc] */ diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 3de2105..01ed94a 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -2843,14 +2843,14 @@ static HMODULE tkcygwindll = NULL; * so we don't have to do any encoding conversions. */ int -TkCygwinMainEx(argc, argv, appInitProc, interp) - int argc; /* Number of arguments. */ - char **argv; /* Array of argument strings. */ - Tcl_AppInitProc *appInitProc; /* Application-specific initialization +TkCygwinMainEx( + int argc, /* Number of arguments. */ + char **argv, /* Array of argument strings. */ + Tcl_AppInitProc *appInitProc, /* Application-specific initialization * procedure to call after most * initialization but before starting * to execute commands. */ - Tcl_Interp *interp; + Tcl_Interp *interp) { char name[MAX_PATH]; int len; diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c index a2c51c0..393c5fa 100644 --- a/generic/ttk/ttkTheme.c +++ b/generic/ttk/ttkTheme.c @@ -38,7 +38,7 @@ typedef struct Ttk_Style_ Ttk_ResourceCache cache; /* Back-pointer to resource cache */ } Style; -static Style *NewStyle() +static Style *NewStyle(void) { Style *stylePtr = (Style*)ckalloc(sizeof(Style)); diff --git a/unix/configure b/unix/configure index 1d8bc0d..c5c8f67 100755 --- a/unix/configure +++ b/unix/configure @@ -4864,7 +4864,7 @@ fi CFLAGS_OPTIMIZE=-O if test "$GCC" = yes; then - CFLAGS_WARNING="-Wall" + CFLAGS_WARNING="-Wall -Wpointer-arith" else CFLAGS_WARNING="" diff --git a/unix/tcl.m4 b/unix/tcl.m4 index f4503f4..399215e 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1142,7 +1142,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE=-O AS_IF([test "$GCC" = yes], [ - CFLAGS_WARNING="-Wall" + CFLAGS_WARNING="-Wall -Wpointer-arith" ], [CFLAGS_WARNING=""]) AC_CHECK_TOOL(AR, ar) STLIB_LD='${AR} cr' diff --git a/unix/tkUnixEvent.c b/unix/tkUnixEvent.c index eb83474..1cfa3ba 100644 --- a/unix/tkUnixEvent.c +++ b/unix/tkUnixEvent.c @@ -457,9 +457,9 @@ DisplayFileProc( * nice (?!) message. */ - void (*oldHandler)(); + void (*oldHandler)(int); - oldHandler = (void (*)()) signal(SIGPIPE, SIG_IGN); + oldHandler = (void (*)(int)) signal(SIGPIPE, SIG_IGN); XNoOp(display); XFlush(display); (void) signal(SIGPIPE, oldHandler); diff --git a/win/configure b/win/configure index a33d8f0..650e46c 100755 --- a/win/configure +++ b/win/configure @@ -3338,6 +3338,11 @@ echo "${ECHO_T}$CELIB_DIR" >&6 # Set some defaults (may get changed below) EXTRA_CFLAGS="" +cat >>confdefs.h <<\_ACEOF +#define MODULE_SCOPE extern +_ACEOF + + # Extract the first word of "cygpath", so it can be a program name with args. set dummy cygpath; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 @@ -3395,7 +3400,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - #ifndef __WIN32__ + #ifndef _WIN32 #error cross-compiler #endif @@ -3518,7 +3523,7 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ - #ifdef __WIN32__ + #ifdef _WIN32 #error win32 #endif @@ -3575,7 +3580,7 @@ echo "$as_me: error: ${CC} cannot produce win32 executables." >&2;} echo $ECHO_N "checking compiler flags... $ECHO_C" >&6 if test "${GCC}" = "yes" ; then SHLIB_LD="" - SHLIB_LD_LIBS="" + SHLIB_LD_LIBS='${LIBS}' LIBS="-lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" @@ -3596,9 +3601,6 @@ echo $ECHO_N "checking compiler flags... $ECHO_C" >&6 echo "$as_me:$LINENO: result: using static flags" >&5 echo "${ECHO_T}using static flags" >&6 runtime= - MAKE_DLL="echo " - LIBSUFFIX="s\${DBGX}.a" - LIBFLAGSUFFIX="s\${DBGX}" LIBRARIES="\${STATIC_LIBRARIES}" EXESUFFIX="s\${DBGX}.exe" else @@ -3616,29 +3618,29 @@ echo "$as_me: error: ${CC} does not support the -shared option. fi runtime= - # Link with gcc since ld does not link to default libs like - # -luser32 and -lmsvcrt by default. - SHLIB_LD='${CC} -shared' - SHLIB_LD_LIBS='${LIBS}' # Add SHLIB_LD_LIBS to the Make rule, not here. - MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \$@ ${extra_ldflags} \ - -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\$@)" - LIBSUFFIX="\${DBGX}.a" - LIBFLAGSUFFIX="\${DBGX}" EXESUFFIX="\${DBGX}.exe" LIBRARIES="\${SHARED_LIBRARIES}" fi + # Link with gcc since ld does not link to default libs like + # -luser32 and -lmsvcrt by default. + SHLIB_LD='${CC} -shared' + SHLIB_LD_LIBS='${LIBS}' + MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \$@ ${extra_ldflags} \ + -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\$@)" # DLLSUFFIX is separate because it is the building block for # users of tclConfig.sh that may build shared or static. DLLSUFFIX="\${DBGX}.dll" + LIBSUFFIX="\${DBGX}.a" + LIBFLAGSUFFIX="\${DBGX}" SHLIB_SUFFIX=.dll EXTRA_CFLAGS="${extra_cflags}" CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall" + CFLAGS_WARNING="-Wall -Wdeclaration-after-statement -Wpointer-arith" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= @@ -3739,24 +3741,16 @@ echo "${ECHO_T} Using 64-bit $MACHINE mode" >&6 echo "$as_me:$LINENO: result: using static flags" >&5 echo "${ECHO_T}using static flags" >&6 runtime=-MT - MAKE_DLL="echo " - LIBSUFFIX="s\${DBGX}.lib" - LIBFLAGSUFFIX="s\${DBGX}" LIBRARIES="\${STATIC_LIBRARIES}" EXESUFFIX="s\${DBGX}.exe" - SHLIB_LD_LIBS="" else # dynamic echo "$as_me:$LINENO: result: using shared flags" >&5 echo "${ECHO_T}using shared flags" >&6 runtime=-MD # Add SHLIB_LD_LIBS to the Make rule, not here. - MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\$@" - LIBSUFFIX="\${DBGX}.lib" - LIBFLAGSUFFIX="\${DBGX}" - EXESUFFIX="\${DBGX}.exe" LIBRARIES="\${SHARED_LIBRARIES}" - SHLIB_LD_LIBS='${LIBS}' + EXESUFFIX="\${DBGX}.exe" case "x`echo \${VisualStudioVersion}`" in x1[4-9]*) lflags="${lflags} -nodefaultlib:libucrt.lib" @@ -3765,9 +3759,12 @@ echo "${ECHO_T}using shared flags" >&6 ;; esac fi + MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\$@" # DLLSUFFIX is separate because it is the building block for # users of tclConfig.sh that may build shared or static. DLLSUFFIX="\${DBGX}.dll" + LIBSUFFIX="\${DBGX}.lib" + LIBFLAGSUFFIX="\${DBGX}" if test "$do64bit" != "no" ; then case "$do64bit" in @@ -3920,6 +3917,7 @@ _ACEOF fi SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}" + SHLIB_LD_LIBS='${LIBS}' # link -lib only works when -lib is the first arg STLIB_LD="${LINKBIN} -lib ${lflags}" RC_OUT=-fo diff --git a/win/tcl.m4 b/win/tcl.m4 index 9703a9a..5abc0e6 100644 --- a/win/tcl.m4 +++ b/win/tcl.m4 @@ -247,7 +247,7 @@ AC_DEFUN([SC_PATH_TKCONFIG], [ # # Results: # -# Subst the following vars: +# Substitutes the following vars: # TCL_BIN_DIR # TCL_SRC_DIR # TCL_LIB_FILE @@ -557,6 +557,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ # Set some defaults (may get changed below) EXTRA_CFLAGS="" + AC_DEFINE(MODULE_SCOPE, [extern], [No need to mark inidividual symbols as hidden]) AC_CHECK_PROG(CYGPATH, cygpath, cygpath -m, echo) @@ -571,7 +572,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK(for cross-compile version of gcc, ac_cv_cross, AC_TRY_COMPILE([ - #ifndef __WIN32__ + #ifndef _WIN32 #error cross-compiler #endif ], [], @@ -638,7 +639,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_CACHE_CHECK(for mingw32 version of gcc, ac_cv_win32, AC_TRY_COMPILE([ - #ifdef __WIN32__ + #ifdef _WIN32 #error win32 #endif ], [], @@ -653,7 +654,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ AC_MSG_CHECKING([compiler flags]) if test "${GCC}" = "yes" ; then SHLIB_LD="" - SHLIB_LD_LIBS="" + SHLIB_LD_LIBS='${LIBS}' LIBS="-lws2_32" # mingw needs to link ole32 and oleaut32 for [send], but MSVC doesn't LIBS_GUI="-lgdi32 -lcomdlg32 -limm32 -lcomctl32 -lshell32 -luuid -lole32 -loleaut32" @@ -673,9 +674,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ # static AC_MSG_RESULT([using static flags]) runtime= - MAKE_DLL="echo " - LIBSUFFIX="s\${DBGX}.a" - LIBFLAGSUFFIX="s\${DBGX}" LIBRARIES="\${STATIC_LIBRARIES}" EXESUFFIX="s\${DBGX}.exe" else @@ -689,29 +687,29 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ fi runtime= - # Link with gcc since ld does not link to default libs like - # -luser32 and -lmsvcrt by default. - SHLIB_LD='${CC} -shared' - SHLIB_LD_LIBS='${LIBS}' # Add SHLIB_LD_LIBS to the Make rule, not here. - MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \ - -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)" - LIBSUFFIX="\${DBGX}.a" - LIBFLAGSUFFIX="\${DBGX}" EXESUFFIX="\${DBGX}.exe" LIBRARIES="\${SHARED_LIBRARIES}" fi + # Link with gcc since ld does not link to default libs like + # -luser32 and -lmsvcrt by default. + SHLIB_LD='${CC} -shared' + SHLIB_LD_LIBS='${LIBS}' + MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -o \[$]@ ${extra_ldflags} \ + -Wl,--out-implib,\$(patsubst %.dll,lib%.a,\[$]@)" # DLLSUFFIX is separate because it is the building block for # users of tclConfig.sh that may build shared or static. DLLSUFFIX="\${DBGX}.dll" + LIBSUFFIX="\${DBGX}.a" + LIBFLAGSUFFIX="\${DBGX}" SHLIB_SUFFIX=.dll EXTRA_CFLAGS="${extra_cflags}" CFLAGS_DEBUG=-g CFLAGS_OPTIMIZE="-O2 -fomit-frame-pointer" - CFLAGS_WARNING="-Wall" + CFLAGS_WARNING="-Wall -Wdeclaration-after-statement -Wpointer-arith" LDFLAGS_DEBUG= LDFLAGS_OPTIMIZE= @@ -766,23 +764,15 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ # static AC_MSG_RESULT([using static flags]) runtime=-MT - MAKE_DLL="echo " - LIBSUFFIX="s\${DBGX}.lib" - LIBFLAGSUFFIX="s\${DBGX}" LIBRARIES="\${STATIC_LIBRARIES}" EXESUFFIX="s\${DBGX}.exe" - SHLIB_LD_LIBS="" else # dynamic AC_MSG_RESULT([using shared flags]) runtime=-MD # Add SHLIB_LD_LIBS to the Make rule, not here. - MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@" - LIBSUFFIX="\${DBGX}.lib" - LIBFLAGSUFFIX="\${DBGX}" - EXESUFFIX="\${DBGX}.exe" LIBRARIES="\${SHARED_LIBRARIES}" - SHLIB_LD_LIBS='${LIBS}' + EXESUFFIX="\${DBGX}.exe" case "x`echo \${VisualStudioVersion}`" in x1[[4-9]]*) lflags="${lflags} -nodefaultlib:libucrt.lib" @@ -791,9 +781,12 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ ;; esac fi + MAKE_DLL="\${SHLIB_LD} \$(LDFLAGS) -out:\[$]@" # DLLSUFFIX is separate because it is the building block for # users of tclConfig.sh that may build shared or static. DLLSUFFIX="\${DBGX}.dll" + LIBSUFFIX="\${DBGX}.lib" + LIBFLAGSUFFIX="\${DBGX}" if test "$do64bit" != "no" ; then case "$do64bit" in @@ -932,6 +925,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ fi SHLIB_LD="${LINKBIN} -dll -incremental:no ${lflags}" + SHLIB_LD_LIBS='${LIBS}' # link -lib only works when -lib is the first arg STLIB_LD="${LINKBIN} -lib ${lflags}" RC_OUT=-fo -- cgit v0.12 From 8038544e96a3e88afb75ad072c8f9a1c6e900c61 Mon Sep 17 00:00:00 2001 From: oehhar Date: Mon, 24 Feb 2020 20:28:32 +0000 Subject: Add tests for scrollwheel on scrollbar: no shift horizontal and for ttk::scrollbar --- tests/scrollbar.test | 32 ++++++++++++++++-- tests/ttk/scrollbar.test | 86 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 8a9d2c4..e02e3a8 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -714,7 +714,7 @@ test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -set destroy .t .s } -result {5.0} -test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} -setup { +test scrollbar-10.2.1 { event on horizontal scrollbar} -constraints {notAqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top @@ -728,7 +728,7 @@ test scrollbar-10.2.1 { event on scrollbar} -constraints {notAqua} - } -cleanup { destroy .t .s } -result {1.4} -test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -setup { +test scrollbar-10.2.2 { event on horizontal scrollbar} -constraints {aqua} -setup { destroy .t .s } -body { pack [text .t -xscrollcommand {.s set} -wrap none] -side top @@ -742,6 +742,34 @@ test scrollbar-10.2.2 { event on scrollbar} -constraints {aqua} -set } -cleanup { destroy .t .s } -result {1.4} +test scrollbar-10.2.3 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.4 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} test scrollbar-11.1 {bug fix: [011706ec42] Scrollbar unsafe wrt widget destruction} -body { proc destroy_scrollbar {} { diff --git a/tests/ttk/scrollbar.test b/tests/ttk/scrollbar.test index 0743def..443687a 100644 --- a/tests/ttk/scrollbar.test +++ b/tests/ttk/scrollbar.test @@ -70,6 +70,92 @@ test scrollbar-1.3 "Change orientation" -body { expr {$h < $w} } -result 1 +test scrollbar-10.1.1 { event on scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} +test scrollbar-10.1.2 { event on scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -yscrollcommand {.s set}] -side left + for {set i 1} {$i < 100} {incr i} {.t insert end "Line $i\n"} + pack [ttk::scrollbar .s -command {.t yview}] -fill y -expand 1 -side left + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {5.0} + +test scrollbar-10.2.1 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.2 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.3 { event on horizontal scrollbar} -constraints {notAqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -120 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} +test scrollbar-10.2.4 { event on horizontal scrollbar} -constraints {aqua} -setup { + destroy .t .s +} -body { + pack [text .t -xscrollcommand {.s set} -wrap none] -side top + for {set i 1} {$i < 100} {incr i} {.t insert end "Char $i "} + pack [ttk::scrollbar .s -command {.t xview} -orient horizontal] -fill x -expand 1 -side top + update + focus -force .s + event generate .s -delta -4 + after 200 {set eventprocessed 1} ; vwait eventprocessed + .t index @0,0 +} -cleanup { + destroy .t .s +} -result {1.4} + # # Scale tests: # -- cgit v0.12 From 23ab6e5cf377104cf3eb9c6b9ccefb860cdf36aa Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Tue, 25 Feb 2020 16:20:04 +0000 Subject: Upgrade console channel type to TCL_CHANNEL_VERSION_5. --- generic/tkConsole.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/generic/tkConsole.c b/generic/tkConsole.c index a6a8cbf..e8f5920 100644 --- a/generic/tkConsole.c +++ b/generic/tkConsole.c @@ -44,6 +44,7 @@ typedef struct ChannelData { */ static int ConsoleClose(ClientData instanceData, Tcl_Interp *interp); +static int Console2Close(ClientData instanceData, Tcl_Interp *interp, int flags); static void ConsoleDeleteProc(ClientData clientData); static void ConsoleEventProc(ClientData clientData, XEvent *eventPtr); static int ConsoleHandle(ClientData instanceData, int direction, @@ -66,7 +67,7 @@ static int InterpreterObjCmd(ClientData clientData, Tcl_Interp *interp, static const Tcl_ChannelType consoleChannelType = { "console", /* Type name. */ - TCL_CHANNEL_VERSION_4, /* v4 channel */ + TCL_CHANNEL_VERSION_5, /* v4 channel */ ConsoleClose, /* Close proc. */ ConsoleInput, /* Input proc. */ ConsoleOutput, /* Output proc. */ @@ -75,7 +76,7 @@ static const Tcl_ChannelType consoleChannelType = { NULL, /* Get option proc. */ ConsoleWatch, /* Watch for events on console. */ ConsoleHandle, /* Get a handle from the device. */ - NULL, /* close2proc. */ + Console2Close, /* close2proc. */ NULL, /* Always non-blocking.*/ NULL, /* flush proc. */ NULL, /* handler proc. */ @@ -573,7 +574,7 @@ ConsoleInput( /* *---------------------------------------------------------------------- * - * ConsoleClose -- + * ConsoleClose/Console2Close -- * * Closes the IO channel. * @@ -607,6 +608,18 @@ ConsoleClose( ckfree(data); return 0; } + +static int +Console2Close( + ClientData instanceData, /* Unused. */ + Tcl_Interp *interp, /* Unused. */ + int flags) +{ + if ((flags&(TCL_CLOSE_READ|TCL_CLOSE_WRITE))==0) { + return ConsoleClose(instanceData, interp); + } + return EINVAL; +} /* *---------------------------------------------------------------------- -- cgit v0.12 From fab5a5002310262db827d5f035d7287b859a4336 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Feb 2020 09:09:16 +0000 Subject: Add errno.h include to tkMacOSXPort.h and tkUnixPort.h: now needed in tkConsole.c --- macosx/tkMacOSXPort.h | 13 +++++++------ unix/tkUnixPort.h | 15 ++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/macosx/tkMacOSXPort.h b/macosx/tkMacOSXPort.h index ba6e329..71797b0 100644 --- a/macosx/tkMacOSXPort.h +++ b/macosx/tkMacOSXPort.h @@ -1,7 +1,7 @@ /* * tkMacOSXPort.h -- * - * This file is included by all of the Tk C files. It contains + * This file is included by all of the Tk C files. It contains * information that may be configuration-dependent, such as * #includes for system include files and a few other things. * @@ -17,14 +17,15 @@ #define _TKMACPORT #include -#include -#include -#include -#include #include -#include #include +#include +#include +#include +#include #include +#include +#include #include #include #ifdef HAVE_SYS_SELECT_H diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index b6a35d8..09ff558 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -18,18 +18,19 @@ #define __UNIX__ 1 #include -#include +#include +#include +#include #include -#include +#include #include -#include +#include +#include #ifdef NO_STDLIB_H # include "../compat/stdlib.h" #else # include #endif -#include -#include #include #include #ifdef HAVE_SYS_SELECT_H @@ -44,9 +45,9 @@ # include #else # if HAVE_SYS_TIME_H -# include +# include # else -# include +# include # endif #endif #if HAVE_INTTYPES_H -- cgit v0.12