From 19702c5a40b368d9d39834a373f4745782de16e3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 28 Jan 2017 15:41:45 +0000 Subject: Proposed fix for [499526180d]: Add support for windows multimedia virtual keys. Patch by ralfixx --- generic/ks_names.h | 7 +++++++ win/tkWinKey.c | 11 +++++++++-- xlib/X11/keysymdef.h | 12 ++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/generic/ks_names.h b/generic/ks_names.h index 22d9fc5..b939a51 100644 --- a/generic/ks_names.h +++ b/generic/ks_names.h @@ -920,3 +920,10 @@ { "hebrew_shin", 0xcf9 }, { "hebrew_taf", 0xcfa }, { "Hebrew_switch", 0xFF7E }, +{ "XF86AudioLowerVolume", 0x1008FF11 }, +{ "XF86AudioMute", 0x1008FF12 }, +{ "XF86AudioRaiseVolume", 0x1008FF13 }, +{ "XF86AudioPlay", 0x1008FF14 }, +{ "XF86AudioStop", 0x1008FF15 }, +{ "XF86AudioPrev", 0x1008FF16 }, +{ "XF86AudioNext", 0x1008FF17 }, diff --git a/win/tkWinKey.c b/win/tkWinKey.c index 1ebf312..357a804 100644 --- a/win/tkWinKey.c +++ b/win/tkWinKey.c @@ -21,7 +21,8 @@ * like a worthwhile improvement to use the table. */ -#define MAX_KEYCODE 145 /* VK_SCROLL is the last entry in our table below */ +#define MAX_KEYCODE 179 /* VK_MEDIA_PLAY_PAUSE is the last entry in our table below */ +/* cf. https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx */ static const KeySym keymap[] = { NoSymbol, NoSymbol, NoSymbol, XK_Cancel, NoSymbol, @@ -53,7 +54,13 @@ static const KeySym keymap[] = { XK_F19, XK_F20, XK_F21, XK_F22, XK_F23, XK_F24, NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, XK_Num_Lock, - XK_Scroll_Lock + XK_Scroll_Lock, NoSymbol, NoSymbol, NoSymbol, NoSymbol, + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*150 0x96*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*155 0x9b*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*160 0xa0*/ + NoSymbol, NoSymbol, NoSymbol, NoSymbol, NoSymbol, /*165 0xa5*/ + NoSymbol, NoSymbol, NoSymbol, XK_XF86AudioMute, XK_XF86AudioLowerVolume, /*170 0xaa*/ + XK_XF86AudioRaiseVolume, XK_XF86AudioNext, XK_XF86AudioPrev, XK_XF86AudioStop, XK_XF86AudioPlay /*175 0xaf*/ }; /* diff --git a/xlib/X11/keysymdef.h b/xlib/X11/keysymdef.h index b22d41b..a7c654d 100644 --- a/xlib/X11/keysymdef.h +++ b/xlib/X11/keysymdef.h @@ -1167,3 +1167,15 @@ SOFTWARE. #define XK_Hebrew_switch 0xFF7E /* Alias for mode_switch */ #endif /* XK_HEBREW */ +/* Multimedia keys, defined same as on Linux + * /usr/include/pkg/libxkbcommon/xkbcommon/xkbcommon-keysyms.h + */ + +#define XK_XF86AudioLowerVolume 0x1008FF11 /* Volume control down */ +#define XK_XF86AudioMute 0x1008FF12 /* Mute sound from the system */ +#define XK_XF86AudioRaiseVolume 0x1008FF13 /* Volume control up */ +#define XK_XF86AudioPlay 0x1008FF14 /* Start playing of audio > */ +#define XK_XF86AudioStop 0x1008FF15 /* Stop playing audio */ +#define XK_XF86AudioPrev 0x1008FF16 /* Previous track */ +#define XK_XF86AudioNext 0x1008FF17 /* Next track */ + -- cgit v0.12 From c39e643b30e956481203d8f38e1a396230368a57 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Jan 2017 15:01:36 +0000 Subject: Remove obsolete (and currently wrong) comment in generic/ks_names.h --- generic/ks_names.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/generic/ks_names.h b/generic/ks_names.h index b939a51..af73d3b 100644 --- a/generic/ks_names.h +++ b/generic/ks_names.h @@ -1,6 +1,3 @@ -/* - * This file is generated from $(INCLUDESRC)/keysymdef.h. Do not edit. - */ { "BackSpace", 0xFF08 }, { "Tab", 0xFF09 }, { "Linefeed", 0xFF0A }, -- cgit v0.12 From f802dd59b9fdec91f7178bfb7bcaa2ab2818739c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 29 Jan 2017 17:11:28 +0000 Subject: Add comment explaining that ks_names.h should be kept in sync with keysymdef.h, and explain why this needs to be done manually. --- generic/ks_names.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/generic/ks_names.h b/generic/ks_names.h index af73d3b..9f49130 100644 --- a/generic/ks_names.h +++ b/generic/ks_names.h @@ -1,3 +1,16 @@ +/* + * This file should be maintained in sync with xlib/X11/keysymdefs.h + * + * Note that this should be done manually only, because in some cases + * keysymdefs.h defines the same integer for multiple keysyms, e.g.: + * + * #define XK_Greek_LAMDA 0x7cb + * #define XK_Greek_LAMBDA 0x7cb + * + * #define XK_Cyrillic_DZHE 0x6bf + * #define XK_Serbian_DZE 0x6bf (deprecated) + * + */ { "BackSpace", 0xFF08 }, { "Tab", 0xFF09 }, { "Linefeed", 0xFF0A }, -- cgit v0.12 From 62ab7985dd7a7e82173c18ca3ff19ba49f152ed8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 6 Mar 2017 23:23:11 +0000 Subject: Added documentation for the new keysyms --- doc/keysyms.n | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/keysyms.n b/doc/keysyms.n index bf81440..84214ff 100644 --- a/doc/keysyms.n +++ b/doc/keysyms.n @@ -918,6 +918,13 @@ Super_R 65516 0xffec Hyper_L 65517 0xffed Hyper_R 65518 0xffee Delete 65535 0xffff +XF86AudioLowerVolume 269025041 0x1008FF11 +XF86AudioMute 269025042 0x1008FF12 +XF86AudioRaiseVolume 269025043 0x1008FF13 +XF86AudioPlay 269025044 0x1008FF14 +XF86AudioStop 269025045 0x1008FF15 +XF86AudioPrev 269025046 0x1008FF16 +XF86AudioNext 269025047 0x1008FF17 .CE .SH "SEE ALSO" bind(n), event(n) -- cgit v0.12 From 046813684f5fcdd4764db7fc53922266d6eb1586 Mon Sep 17 00:00:00 2001 From: avl Date: Tue, 14 Mar 2017 01:13:36 +0000 Subject: added a remark about some keysyms being valid across platforms... --- doc/keysyms.n | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/keysyms.n b/doc/keysyms.n index 84214ff..512c1a6 100644 --- a/doc/keysyms.n +++ b/doc/keysyms.n @@ -15,7 +15,9 @@ Tk recognizes many keysyms when specifying key bindings (e.g., .QW "\fBbind\fR \fB. \fR" ). The following list enumerates the keysyms that will be recognized by Tk. Note that not all keysyms will -be valid on all platforms. For example, on Unix systems, the presence +be valid on all platforms, and some keysyms are also available on +platforms that have a different native name for that key. +For example, on Unix systems, the presence of a particular keysym is dependant on the configuration of the keyboard modifier map. This list shows keysyms along with their decimal and hexadecimal values. -- cgit v0.12 From c0799b5e037e8c09e614bd614c0970464fd272f3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 26 Mar 2017 08:59:56 +0000 Subject: Fix [28a3c366e6]: memory leak in the text widget. Patch contributed anonymously --- generic/tkTextBTree.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c index 0fdc280..db0d71a 100644 --- a/generic/tkTextBTree.c +++ b/generic/tkTextBTree.c @@ -1439,6 +1439,7 @@ TkBTreeDeleteIndexRange( prevNodePtr->nextPtr = curNodePtr->nextPtr; } parentPtr->numChildren--; + ckfree(curNodePtr->numPixels); ckfree(curNodePtr); curNodePtr = parentPtr; } @@ -4185,6 +4186,7 @@ Rebalance( treePtr->rootPtr = nodePtr->children.nodePtr; treePtr->rootPtr->parentPtr = NULL; DeleteSummaries(nodePtr->summaryPtr); + ckfree(nodePtr->numPixels); ckfree(nodePtr); } return; @@ -4274,6 +4276,7 @@ Rebalance( nodePtr->nextPtr = otherPtr->nextPtr; nodePtr->parentPtr->numChildren--; DeleteSummaries(otherPtr->summaryPtr); + ckfree(otherPtr->numPixels); ckfree(otherPtr); continue; } -- cgit v0.12 From c5dc7621226a3234be4280cdc5c6c259e847fa50 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 31 Mar 2017 21:27:49 +0000 Subject: Fix [3089640fff], [6020ee2d03], [e016579efb] and [6bf197edbf]: ttk::notebook tabs can disappear (tab width incorrectly calculated). Patch from Koen Danckaert. --- generic/ttk/ttkNotebook.c | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 81a8b64..ac13d5f 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -437,16 +437,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) /* SqueezeTabs -- * Squeeze or stretch tabs to fit within the tab area parcel. * - * All tabs are adjusted by an equal amount, but will not be made - * smaller than the minimum width. (If all the tabs still do - * not fit in the available space, the rightmost ones will - * be further squozen by PlaceTabs()). - * - * The algorithm does not always yield an optimal layout, but does - * have the important property that decreasing the available width - * by one pixel will cause at most one tab to shrink by one pixel; - * this means that tabs resize "smoothly" when the window shrinks - * and grows. + * All tabs are adjusted by an equal amount. * * @@@ <> bug: only works for horizontal orientations * @@@ <> does not account for hidden tabs. @@ -458,25 +449,17 @@ static void SqueezeTabs( int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); if (nTabs > 0) { - int difference = available - needed, - delta = difference / nTabs, - remainder = difference % nTabs, - slack = 0; + int difference = available - needed; + double delta = (double)difference / needed; + double slack = 0; int i; - if (remainder < 0) { remainder += nTabs; --delta; } - + /* Ignore minTabWidth; it's ignored in TabRowSize() too. */ for (i = 0; i < nTabs; ++i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); - int adj = delta + (i < remainder) + slack; - - if (tab->width + adj >= minTabWidth) { - tab->width += adj; - slack = 0; - } else { - slack = adj - (minTabWidth - tab->width); - tab->width = minTabWidth; - } + double ad = slack + tab->width * delta; + tab->width += (int)ad; + slack = ad - (int)ad; } } } -- cgit v0.12 From f4c9b668c5a0329779df76cc8a18d4fc2fc6a6e8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 2 Apr 2017 21:01:42 +0000 Subject: The -mintabwidth style option is honored whenever possible. If there is not enough space available, then priority is given to displaying all tabs (previous behaviour was they disappeared) over mandatorily honoring -mintabwidth. --- generic/ttk/ttkNotebook.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index ac13d5f..389d520 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -325,6 +325,8 @@ static Ttk_State TabState(Notebook *nb, int index) /* TabrowSize -- * Compute max height and total width of all tabs (horizontal layouts) * or total height and max width (vertical layouts). + * The -mintabwidth style option is taken into account (for the width + * only). * * Side effects: * Sets width and height fields for all tabs. @@ -334,7 +336,7 @@ static Ttk_State TabState(Notebook *nb, int index) * (max height/width) but not parallel (total width/height). */ static void TabrowSize( - Notebook *nb, Ttk_Orient orient, int *widthPtr, int *heightPtr) + Notebook *nb, Ttk_Orient orient, int minTabWidth, int *widthPtr, int *heightPtr) { Ttk_Layout tabLayout = nb->notebook.tabLayout; int tabrowWidth = 0, tabrowHeight = 0; @@ -346,6 +348,7 @@ static void TabrowSize( Ttk_RebindSublayout(tabLayout, tab); Ttk_LayoutSize(tabLayout,tabState,&tab->width,&tab->height); + tab->width = MAX(tab->width, minTabWidth); if (orient == TTK_ORIENT_HORIZONTAL) { tabrowHeight = MAX(tabrowHeight, tab->height); @@ -406,7 +409,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) /* Tab row: */ - TabrowSize(nb, nbstyle.tabOrient, &tabrowWidth, &tabrowHeight); + TabrowSize(nb, nbstyle.tabOrient, nbstyle.minTabWidth, &tabrowWidth, &tabrowHeight); tabrowHeight += Ttk_PaddingHeight(nbstyle.tabMargins); tabrowWidth += Ttk_PaddingWidth(nbstyle.tabMargins); @@ -436,6 +439,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) /* SqueezeTabs -- * Squeeze or stretch tabs to fit within the tab area parcel. + * This happens independently of the -mintabwidth style option. * * All tabs are adjusted by an equal amount. * @@ -444,7 +448,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr) */ static void SqueezeTabs( - Notebook *nb, int needed, int available, int minTabWidth) + Notebook *nb, int needed, int available) { int nTabs = Ttk_NumberSlaves(nb->notebook.mgr); @@ -454,7 +458,6 @@ static void SqueezeTabs( double slack = 0; int i; - /* Ignore minTabWidth; it's ignored in TabRowSize() too. */ for (i = 0; i < nTabs; ++i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); double ad = slack + tab->width * delta; @@ -522,8 +525,13 @@ static void NotebookDoLayout(void *recordPtr) Ttk_PlaceLayout(nb->core.layout, nb->core.state, Ttk_WinBox(nbwin)); /* Place tabs: + * Note: TabrowSize() takes into account -mintabwidth, but the tabs will + * actually have this minimum size when displayed only if there is enough + * space to draw the tabs with this width. Otherwise some of the tabs can + * be squeezed to a size smaller than -mintabwidth because we prefer + * displaying all tabs than than honoring -mintabwidth for all of them. */ - TabrowSize(nb, nbstyle.tabOrient, &tabrowWidth, &tabrowHeight); + TabrowSize(nb, nbstyle.tabOrient, nbstyle.minTabWidth, &tabrowWidth, &tabrowHeight); tabrowBox = Ttk_PadBox( Ttk_PositionBox(&cavity, tabrowWidth + Ttk_PaddingWidth(nbstyle.tabMargins), @@ -531,7 +539,7 @@ static void NotebookDoLayout(void *recordPtr) nbstyle.tabPosition), nbstyle.tabMargins); - SqueezeTabs(nb, tabrowWidth, tabrowBox.width, nbstyle.minTabWidth); + SqueezeTabs(nb, tabrowWidth, tabrowBox.width); PlaceTabs(nb, tabrowBox, nbstyle.tabPlacement); /* Layout for client area frame: -- cgit v0.12 From d74ea96f8de64d42ea66d687e6ce4df95c2a1849 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 3 Apr 2017 06:29:04 +0000 Subject: Fix [2912962fff]: Notebook does not set TTK_STATE_USER1. Patch from Jos Decoster. --- generic/ttk/ttkNotebook.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 81a8b64..726257d 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -295,6 +295,7 @@ static Ttk_State TabState(Notebook *nb, int index) { Ttk_State state = nb->core.state; Tab *tab = Ttk_SlaveData(nb->notebook.mgr, index); + int i = 0; if (index == nb->notebook.currentIndex) { state |= TTK_STATE_SELECTED; @@ -305,8 +306,15 @@ static Ttk_State TabState(Notebook *nb, int index) if (index == nb->notebook.activeIndex) { state |= TTK_STATE_ACTIVE; } - if (index == 0) { - state |= TTK_STATE_USER1; + for (i = 0; i < Ttk_NumberSlaves(nb->notebook.mgr); ++i) { + Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); + if (tab->state == TAB_STATE_HIDDEN) { + continue; + } + if (index == i) { + state |= TTK_STATE_USER1; + } + break; } if (index == Ttk_NumberSlaves(nb->notebook.mgr) - 1) { state |= TTK_STATE_USER2; -- cgit v0.12 From 0b70616ba05255d0d81b5e4aac59becde0787af7 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 3 Apr 2017 14:44:48 +0000 Subject: Fixed TTK_STATE_USER2 similarly as TTK_STATE_USER1. These bits are set for the leftmost and rightmost *visible* (i.e. non hidden) tabs --- generic/ttk/ttkNotebook.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 726257d..2bb9f82 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -288,8 +288,8 @@ static void ActivateTab(Notebook *nb, int index) * TabState -- * Return the state of the specified tab, based on * notebook state, currentIndex, activeIndex, and user-specified tab state. - * The USER1 bit is set for the leftmost tab, and USER2 - * is set for the rightmost tab. + * 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) { @@ -316,8 +316,15 @@ static Ttk_State TabState(Notebook *nb, int index) } break; } - if (index == Ttk_NumberSlaves(nb->notebook.mgr) - 1) { - state |= TTK_STATE_USER2; + for (i = Ttk_NumberSlaves(nb->notebook.mgr) - 1; i >= 0; --i) { + Tab *tab = Ttk_SlaveData(nb->notebook.mgr, i); + if (tab->state == TAB_STATE_HIDDEN) { + continue; + } + if (index == i) { + state |= TTK_STATE_USER2; + } + break; } if (tab->state == TAB_STATE_DISABLED) { state |= TTK_STATE_DISABLED; -- cgit v0.12 From df1022df3551f9d35619f0ef10258fbcc7ac0f6f Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 3 Apr 2017 21:27:57 +0000 Subject: Fix [d6fd19e4e5]: Documentation of ttk::notebook 'tabs' widget command clarification --- doc/ttk_notebook.n | 3 ++- doc/ttk_panedwindow.n | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/ttk_notebook.n b/doc/ttk_notebook.n index 4d1b789..290a0c7 100644 --- a/doc/ttk_notebook.n +++ b/doc/ttk_notebook.n @@ -171,7 +171,8 @@ Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs. See \fBTAB OPTIONS\fR for the available options. .TP \fIpathname \fBtabs\fR -Returns the list of windows managed by the notebook. +Returns the list of windows managed by the notebook, in the index order of +their associated tabs. .SH "KEYBOARD TRAVERSAL" To enable keyboard traversal for a toplevel window containing a notebook widget \fI$nb\fR, call: diff --git a/doc/ttk_panedwindow.n b/doc/ttk_panedwindow.n index 29fca1d..4ba42bc 100644 --- a/doc/ttk_panedwindow.n +++ b/doc/ttk_panedwindow.n @@ -91,7 +91,8 @@ If one \fI\-option\fR is specified, returns the value of that \fIoption\fR. Otherwise, sets the \fI\-option\fRs to the corresponding \fIvalue\fRs. .TP \fIpathname \fBpanes\fR -Returns the list of all windows managed by the widget. +Returns the list of all windows managed by the widget, in the index order of +their associated panes. .TP \fIpathname \fBsashpos \fIindex\fR ?\fInewpos\fR? If \fInewpos\fR is specified, sets the position -- cgit v0.12 From 022b25baf0934b5ec3218354645491aea7674b5b Mon Sep 17 00:00:00 2001 From: dgp Date: Thu, 6 Apr 2017 16:08:17 +0000 Subject: [db8c541b6b] Prevent access of freed memory in warp pointer callbacks. --- generic/tkBind.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 567c51f..61b44df 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3466,12 +3466,28 @@ HandleEventGenerate( if ((warp != 0) && Tk_IsMapped(tkwin)) { TkDisplay *dispPtr = TkGetDisplay(event.general.xmotion.display); + /* + * TODO: No protection is in place to handle dispPtr destruction + * before DoWarp is called back. + */ + + Tk_Window warpWindow = Tk_IdToWindow(dispPtr->display, + event.general.xmotion.window); + if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) { Tcl_DoWhenIdle(DoWarp, dispPtr); dispPtr->flags |= TK_DISPLAY_IN_WARP; } - dispPtr->warpWindow = Tk_IdToWindow(dispPtr->display, - event.general.xmotion.window); + + if (warpWindow != dispPtr->warpWindow) { + if (warpWindow) { + Tcl_Preserve(warpWindow); + } + if (dispPtr->warpWindow) { + Tcl_Release(dispPtr->warpWindow); + } + dispPtr->warpWindow = warpWindow; + } dispPtr->warpMainwin = mainWin; dispPtr->warpX = event.general.xmotion.x; dispPtr->warpY = event.general.xmotion.y; @@ -3559,6 +3575,11 @@ DoWarp( TkpWarpPointer(dispPtr); XForceScreenSaver(dispPtr->display, ScreenSaverReset); } + + if (dispPtr->warpWindow) { + Tcl_Release(dispPtr->warpWindow); + dispPtr->warpWindow = None; + } dispPtr->flags &= ~TK_DISPLAY_IN_WARP; } -- cgit v0.12 From 00b1b03df4ce671eea9cc375ea1d6d7d892d73ea Mon Sep 17 00:00:00 2001 From: fvogel Date: Thu, 6 Apr 2017 20:01:59 +0000 Subject: Slightly better fix anonymously proposed in [6020ee2d03]. Use floor() instead of casting to an int. --- generic/ttk/ttkNotebook.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index 389d520..b649e4b 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -454,15 +455,17 @@ static void SqueezeTabs( if (nTabs > 0) { int difference = available - needed; - double delta = (double)difference / needed; + double fraction = (double)difference / needed; double slack = 0; + double ad; int i; for (i = 0; i < nTabs; ++i) { Tab *tab = Ttk_SlaveData(nb->notebook.mgr,i); - double ad = slack + tab->width * delta; + + ad = slack + tab->width * fraction; tab->width += (int)ad; - slack = ad - (int)ad; + slack = ad - floor(ad); } } } -- cgit v0.12 From 735fd7e290750c83ddd6d0e1db7e1511c306936b Mon Sep 17 00:00:00 2001 From: simonbachmann Date: Sat, 8 Apr 2017 07:17:12 +0000 Subject: Fixed bug [f0188aca9e] (color names parsing on Windows) --- tests/color.test | 22 ++++++++++++++++++++++ xlib/xcolors.c | 10 ++++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/color.test b/tests/color.test index 0b328cf..4e7adfc 100644 --- a/tests/color.test +++ b/tests/color.test @@ -90,6 +90,16 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { && ([lindex $vals 2]/256 == $blue) } +# -- WARNING (SB, 6.4.2017) -- +# +# The if block below looks _very_ outdated. It didn't get any +# substatial changes as far back as the fossil history goes. It might +# be from a time, when 256 color was the best you could get! :-o. +# +# The problem is, on machines with a fancy 24 truecolor display, the +# 'colorsFree' constraint doesn't get set, turning off pretty much every test +# in this file. + if {[testConstraint psuedocolor8]} { toplevel .t -visual {pseudocolor 8} -colormap new wm geom .t +0+0 @@ -185,6 +195,18 @@ test color-2.6 {Tk_GetColor procedure} {colorsFree nonPortable} { test color-2.7 {Tk_GetColor procedure} colorsFree { winfo rgb .t #ff0000 } {65535 0 0} +test color-2.8 {Tk_GetColor, invalid char after 3 valid hex digits} -body { + winfo rgb . #abcg +} -returnCodes error -result {invalid color name "#abcg"} +test color-2.9 {Tk_GetColor, invalid char after 6 vaild hex digits} -body { + winfo rgb . #aabbccz +} -returnCodes error -result {invalid color name "#aabbccz"} +test color-2.10 {Tk_GetColor, 3 hex digits, last one invalid} -body { + winfo rgb . #abz +} -returnCodes error -result {invalid color name "#abz"} +test color-2.11 {Tk_GetColor, 6 hex digits, last one invalid} -body { + winfo rgb . #12345g +} -returnCodes error -result {invalid color name "#12345g"} test color-3.1 {Tk_FreeColor procedure, reference counting} colorsFree { eval destroy [winfo child .t] diff --git a/xlib/xcolors.c b/xlib/xcolors.c index b5e45c9..36dc67c 100644 --- a/xlib/xcolors.c +++ b/xlib/xcolors.c @@ -345,6 +345,16 @@ XParseColor( char *p; Tcl_WideInt value = parseHex64bit(++spec, &p); + /* + * If *p does not point to the end of the string, there were invalid + * digits in the spec. Ergo, it is not a vailid color string. + * (Bug f0188aca9e) + */ + + if (*p != '\0') { + return 0; + } + switch ((int)(p-spec)) { case 3: colorPtr->red = US(((value >> 8) & 0xf) * 0x1111); -- cgit v0.12