From 31bf9a3245670aecdfc3dae4b73dff104eca0f93 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 18 Nov 2018 19:36:30 +0000 Subject: Fix [b2dd3b4fe8]: text-11a.41 sometimes hangs --- tests/text.test | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/text.test b/tests/text.test index 95e666a..ee46f02 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3088,14 +3088,19 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { append content [string repeat "$i " 50] \n } bind .top.yt <> {lappend res Sync:%d} + # make initial sync state known + .top.yt sync + update + # the next line triggers <> with %d==0 i.e. we're out of sync .top.yt insert 1.0 $content - vwait res ; # event dealt with by the event loop, with %d==0 i.e. we're out of sync - # ensure the test is relevant + vwait res + # ensure the test is relevant: the line metrics are not up-to-date (pendingsync is 1) lappend res "Pending:[.top.yt pendingsync]" - # - <> fires when sync returns if there was pending syncs - # - there is no more any pending sync after running 'sync' + # wait for the end of line metrics update by calling the sync command + # <> fires when sync returns with %d==1 i.e. we're in sync again + # at this time line metrics are up-to-date (pendingsync is 0) .top.yt sync - vwait res ; # event dealt with by the event loop, with %d==1 i.e. we're in sync again + vwait res lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { -- cgit v0.12 From 3392d3aacf40787f102904663aeb9ce163cfc10f Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 19 Nov 2018 21:11:42 +0000 Subject: Repair text-11a.41 logic --- tests/text.test | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/text.test b/tests/text.test index 203effd..2b54cc1 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3079,18 +3079,17 @@ test text-11a.31 {"<>" event} -setup { test text-11a.41 {"sync" "pendingsync" and <>} -setup { destroy .top.yt .top } -body { - set res {} toplevel .top pack [text .top.yt] + # make initial sync state known update + .top.yt sync set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } bind .top.yt <> {lappend res Sync:%d} - # make initial sync state known - .top.yt sync - update + set res {} # the next line triggers <> with %d==0 i.e. we're out of sync .top.yt insert 1.0 $content vwait res -- cgit v0.12 From ee8d969f18b463c672814118ae9b9fd20d6ad05d Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 19 Nov 2018 21:54:40 +0000 Subject: Make text-11a.41 pass this time (hopefully...) --- tests/text.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/text.test b/tests/text.test index 2b54cc1..ae45e5e 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3089,6 +3089,7 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { append content [string repeat "$i " 50] \n } bind .top.yt <> {lappend res Sync:%d} + update set res {} # the next line triggers <> with %d==0 i.e. we're out of sync .top.yt insert 1.0 $content -- cgit v0.12 From 19552978033a0979e5a96b551e65383ba7de2c03 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 19 Nov 2018 22:01:49 +0000 Subject: In TkTextUpdateLineMetrics, line numbers start at zero, not 1 --- generic/tkText.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkText.c b/generic/tkText.c index 4c536a2..e6a42bb 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -1559,7 +1559,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, + TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; } -- cgit v0.12 From dc9b1333fe05b998695e94b905c53c6521498f47 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Nov 2018 21:26:19 +0000 Subject: Fix [509cafafae]: ttk::treeview tag options ignored in 8.6.9 --- generic/ttk/ttkTreeview.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index bef84f3..a1ee325 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1709,8 +1709,17 @@ static void PrepareItem( Ttk_Style style = Ttk_LayoutStyle(tv->core.layout); Ttk_State state = ItemState(tv, item); - Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); - Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); + /* + * Tag options have precedence over the style, unless in selected state. + */ + + if (state & TTK_STATE_SELECTED) { + Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); + Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); + } else { + Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); + Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); + } } /* + DrawCells -- -- cgit v0.12 From 23de751222730f4e3b2e403c433e7c94f400ee8e Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 25 Nov 2018 21:38:18 +0000 Subject: Document precedence between tags and style, and priority order of tags. --- doc/ttk_treeview.n | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index b81bc62..6cb801e 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -432,8 +432,12 @@ Specifies the font to use when drawing text. .\" ??? Maybe: .IP \-text .IP \fB\-image\fR Specifies the item image, in case the item's \fB\-image\fR option is empty. -.\" .PP -.\" \fI(@@@ TODO: sort out order of precedence for options)\fR +.PP +Tag options \fB\-foreground\fR and \fB\-background\fR take precedence over +the style, except in the \fBselected\fR state. +.PP +Tag priority is decided by the creation order: tags created first receive +higher priority. .SH "COLUMN IDENTIFIERS" .PP Column identifiers take any of the following forms: -- cgit v0.12 From 28c44419e30f749753e31993963d0b5eb202c181 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 11 Dec 2018 19:55:11 +0000 Subject: fix bug [18a4ba19bd]: winfo containing gives wrong answer on linux. --- unix/tkUnixWm.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 19ac86c..399916f 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5855,16 +5855,15 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { - if (wmPtr->reparent == child) { - goto gotToplevel; - } - if (wmPtr->wrapperPtr != NULL) { - if (child == wmPtr->wrapperPtr->window) { - goto gotToplevel; - } - } else if (child == wmPtr->winPtr->window) { - goto gotToplevel; - } + winPtr = wmPtr->winPtr; + if (wmPtr->winPtr == NULL) { + continue; + } + if (x >= winPtr->changes.x && + x < winPtr->changes.x + winPtr->changes.width && + y < winPtr->changes.y + winPtr->changes.height) { + goto gotToplevel; + } } x = childX; y = childY; @@ -5882,7 +5881,6 @@ Tk_CoordsToWindow( Tk_DeleteErrorHandler(handler); handler = NULL; } - winPtr = wmPtr->winPtr; if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { return NULL; } @@ -5897,10 +5895,6 @@ Tk_CoordsToWindow( x = childX - winPtr->changes.x; y = childY - winPtr->changes.y; - if ((x < 0) || (x >= winPtr->changes.width) - || (y >= winPtr->changes.height)) { - return NULL; - } if (y < 0) { winPtr = (TkWindow *) wmPtr->menubar; if (winPtr == NULL) { -- cgit v0.12 From 76d4fe8f69c4551713f36190c1ae1d785b0b1e38 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 11 Dec 2018 20:20:49 +0000 Subject: Fix aqua FrontWindowAtPoint which was saying that every point was in the top window. --- macosx/tkMacOSXWm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 5cf0820..6a860e4 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -615,11 +615,16 @@ FrontWindowAtPoint( for (NSWindow *w in windows) { winPtr = TkMacOSXGetTkWindow(w); - if (winPtr && NSMouseInRect(p, [w frame], NO)) { - break; + if (winPtr) { + WmInfo *wmPtr = winPtr->wmInfoPtr; + if (NSMouseInRect(p, [w frame], NO) && + (wmPtr->hints.initial_state == NormalState || + wmPtr->hints.initial_state == ZoomState)) { + return winPtr; + } } } - return winPtr; + return NULL; } /* -- cgit v0.12 From 49d7bce77f6087d0abe19715ce2c5d39359e2313 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 12 Dec 2018 04:18:26 +0000 Subject: Correct some of the logic in Tk_CoordsToWindow. --- unix/tkUnixWm.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 399916f..e8d420a 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5856,14 +5856,27 @@ Tk_CoordsToWindow( for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { winPtr = wmPtr->winPtr; - if (wmPtr->winPtr == NULL) { + if (winPtr == NULL) { + + /* + * This happens, for example, if the wmPtr points to a Gnome3 + * "invisible border". Ignore this window and keep searching. + */ + continue; } - if (x >= winPtr->changes.x && - x < winPtr->changes.x + winPtr->changes.width && - y < winPtr->changes.y + winPtr->changes.height) { - goto gotToplevel; + if (x < winPtr->changes.x || + x > winPtr->changes.x + winPtr->changes.width || + y < winPtr->changes.y || + y > winPtr->changes.y + winPtr->changes.height) { + + /* + * The point is completely outside the window; keep searching. + */ + + continue; } + goto gotToplevel; } x = childX; y = childY; @@ -5871,7 +5884,7 @@ Tk_CoordsToWindow( window = child; } - gotToplevel: + gotToplevel: if (handler) { /* * Check value of handler, because we can reach this label from above @@ -5895,6 +5908,7 @@ Tk_CoordsToWindow( x = childX - winPtr->changes.x; y = childY - winPtr->changes.y; + if (y < 0) { winPtr = (TkWindow *) wmPtr->menubar; if (winPtr == NULL) { -- cgit v0.12 From d096455a67f38de40df05686c2a7a6611f255730 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 12 Dec 2018 15:50:35 +0000 Subject: Fix the containment test, check for iconified windows, adjust some tests. --- tests/unixWm.test | 65 ++++++++++++++++++++++++++++--------------------------- unix/tkUnixWm.c | 13 +++++++++-- 2 files changed, 44 insertions(+), 34 deletions(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index a0224a1..1025eed 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1779,46 +1779,47 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { deleteWindows wm iconify . test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { - deleteWindows + update toplevel .t -width 300 -height 400 -bg green - wm geom .t +40+0 + wm geom .t +100+100 tkwait visibility .t - toplevel .t2 -width 100 -height 80 -bg red - wm geom .t2 +140+200 + toplevel .t2 -width 100 -height 200 -bg red + wm geom .t2 +200+200 tkwait visibility .t2 raise .t2 + update set x [winfo rootx .t] set y [winfo rooty .t] - list [winfo containing [expr $x - 30] [expr $y + 250]] \ - [winfo containing [expr $x - 1] [expr $y + 250]] \ - [winfo containing $x [expr $y + 250]] \ - [winfo containing [expr $x + 99] [expr $y + 250]] \ - [winfo containing [expr $x + 100] [expr $y + 250]] \ - [winfo containing [expr $x + 199] [expr $y + 250]] \ - [winfo containing [expr $x + 200] [expr $y + 250]] \ - [winfo containing [expr $x + 220] [expr $y + 250]] -} {{} {} .t {} .t2 .t2 {} .t} + list [winfo containing [expr $x - 30] [expr $y + 250]] \ + [winfo containing [expr $x - 1] [expr $y + 250]] \ + [winfo containing $x [expr $y + 250]] \ + [winfo containing [expr $x + 99] [expr $y + 250]] \ + [winfo containing [expr $x + 100] [expr $y + 250]] \ + [winfo containing [expr $x + 199] [expr $y + 250]] \ + [winfo containing [expr $x + 200] [expr $y + 250]] \ + [winfo containing [expr $x + 220] [expr $y + 250]] +} {{} {} .t .t .t2 .t2 .t .t} test unixWm-50.2 {Tk_CoordsToWindow procedure, finding a toplevel, y-coords and overrideredirect} unix { deleteWindows - toplevel .t -width 300 -height 400 -bg yellow - wm geom .t +0+50 + toplevel .t -width 400 -height 300 -bg yellow + wm geom .t +100+100 tkwait visibility .t - toplevel .t2 -width 100 -height 80 -bg blue + toplevel .t2 -width 200 -height 100 -bg blue wm overrideredirect .t2 1 - wm geom .t2 +100+200 + wm geom .t2 +200+200 tkwait visibility .t2 raise .t2 set x [winfo rootx .t] set y [winfo rooty .t] set y2 [winfo rooty .t2] - list [winfo containing [expr $x +150] 10] \ - [winfo containing [expr $x +150] [expr $y - 1]] \ - [winfo containing [expr $x +150] $y] \ - [winfo containing [expr $x +150] [expr $y2 - 1]] \ - [winfo containing [expr $x +150] $y2] \ - [winfo containing [expr $x +150] [expr $y2 + 79]] \ - [winfo containing [expr $x +150] [expr $y2 + 80]] \ - [winfo containing [expr $x +150] [expr $y + 450]] + list [winfo containing [expr $x +200] [expr $y - 30]] \ + [winfo containing [expr $x +200] [expr $y - 1]] \ + [winfo containing [expr $x +200] $y] \ + [winfo containing [expr $x +200] [expr $y2 - 1]] \ + [winfo containing [expr $x +200] $y2] \ + [winfo containing [expr $x +200] [expr $y2 + 99]] \ + [winfo containing [expr $x +200] [expr $y2 + 100]] \ + [winfo containing [expr $x +200] [expr $y + 450]] } {{} {} .t .t .t2 .t2 .t {}} test unixWm-50.3 { Tk_CoordsToWindow procedure, finding a toplevel with embedding @@ -1876,13 +1877,13 @@ test unixWm-50.5 {Tk_CoordsToWindow procedure, handling menubars} {unix testmenu update set x [winfo rootx .t] set y [winfo rooty .t] - list [winfo containing $x [expr $y - 31]] \ - [winfo containing $x [expr $y - 30]] \ - [winfo containing [expr $x + 50] [expr $y - 19]] \ - [winfo containing [expr $x + 50] [expr $y - 18]] \ - [winfo containing [expr $x + 50] $y] \ - [winfo containing [expr $x + 11] [expr $y + 152]] \ - [winfo containing [expr $x + 12] [expr $y + 152]] + list [winfo containing $x [expr $y - 31]] \ + [winfo containing $x [expr $y - 30]] \ + [winfo containing [expr $x + 50] [expr $y - 19]] \ + [winfo containing [expr $x + 50] [expr $y - 18]] \ + [winfo containing [expr $x + 50] $y] \ + [winfo containing [expr $x + 11] [expr $y + 152]] \ + [winfo containing [expr $x + 12] [expr $y + 152]] } {{} .t.menu .t.menu .t.menu.f .t .t .t.f} test unixWm-50.6 {Tk_CoordsToWindow procedure, embedding within one app.} unix { deleteWindows diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index e8d420a..4ba3124 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5866,9 +5866,9 @@ Tk_CoordsToWindow( continue; } if (x < winPtr->changes.x || - x > winPtr->changes.x + winPtr->changes.width || + x >= winPtr->changes.x + winPtr->changes.width || y < winPtr->changes.y || - y > winPtr->changes.y + winPtr->changes.height) { + y >= winPtr->changes.y + winPtr->changes.height) { /* * The point is completely outside the window; keep searching. @@ -5876,6 +5876,15 @@ Tk_CoordsToWindow( continue; } + if (wmPtr->hints.initial_state != NormalState) { + + /* + * Ignore iconified windows. + */ + + continue; + } + goto gotToplevel; } x = childX; -- cgit v0.12 From 7ad31167c641a886e18a53e4e1505049657f7b63 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 13 Dec 2018 03:26:06 +0000 Subject: Fix the containment test for menubars. Ensure that the command returns an empty string if the point is in the title bar or covered by another application. --- unix/tkUnixWm.c | 50 +++++++++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 29 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 4ba3124..17f8d65 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5856,35 +5856,30 @@ Tk_CoordsToWindow( for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { winPtr = wmPtr->winPtr; - if (winPtr == NULL) { - - /* - * This happens, for example, if the wmPtr points to a Gnome3 - * "invisible border". Ignore this window and keep searching. - */ - + if (wmPtr->hints.initial_state != NormalState) { continue; } if (x < winPtr->changes.x || x >= winPtr->changes.x + winPtr->changes.width || - y < winPtr->changes.y || + y < winPtr->changes.y - wmPtr->menuHeight || y >= winPtr->changes.y + winPtr->changes.height) { - - /* - * The point is completely outside the window; keep searching. - */ - continue; } - if (wmPtr->hints.initial_state != NormalState) { - - /* - * Ignore iconified windows. - */ - continue; + /* + * This complicated conjunction is responsible for causing + * the command to return NULL when the point is covered by + * a higher window belonging to a different process. Surely + * there is a better way ... + */ + + if (wmPtr == (WmInfo *) dispPtr->firstWmPtr && + wmPtr->wrapperPtr != NULL && + child != wmPtr->wrapperPtr->window && + child != wmPtr->reparent && + child != wmPtr->winPtr->window) { + return NULL; } - goto gotToplevel; } x = childX; @@ -5918,15 +5913,12 @@ Tk_CoordsToWindow( x = childX - winPtr->changes.x; y = childY - winPtr->changes.y; - if (y < 0) { - winPtr = (TkWindow *) wmPtr->menubar; - if (winPtr == NULL) { - return NULL; - } - y += wmPtr->menuHeight; - if (y < 0) { - return NULL; - } + if (y < 0 && y >= -wmPtr->menuHeight ) { + winPtr = (TkWindow *) wmPtr->menubar; + y += wmPtr->menuHeight; + if (winPtr == NULL) { + return NULL; + } } /* -- cgit v0.12 From c506faa54e44b717a08939ddb801fa695db52e07 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 13 Dec 2018 16:40:05 +0000 Subject: Revert tkUnixWm.c to the core-8-6-branch version. --- unix/tkUnixWm.c | 59 ++++++++++++++++++++++++--------------------------------- 1 file changed, 25 insertions(+), 34 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 17f8d65..19ac86c 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5855,32 +5855,16 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { - winPtr = wmPtr->winPtr; - if (wmPtr->hints.initial_state != NormalState) { - continue; - } - if (x < winPtr->changes.x || - x >= winPtr->changes.x + winPtr->changes.width || - y < winPtr->changes.y - wmPtr->menuHeight || - y >= winPtr->changes.y + winPtr->changes.height) { - continue; - } - - /* - * This complicated conjunction is responsible for causing - * the command to return NULL when the point is covered by - * a higher window belonging to a different process. Surely - * there is a better way ... - */ - - if (wmPtr == (WmInfo *) dispPtr->firstWmPtr && - wmPtr->wrapperPtr != NULL && - child != wmPtr->wrapperPtr->window && - child != wmPtr->reparent && - child != wmPtr->winPtr->window) { - return NULL; - } - goto gotToplevel; + if (wmPtr->reparent == child) { + goto gotToplevel; + } + if (wmPtr->wrapperPtr != NULL) { + if (child == wmPtr->wrapperPtr->window) { + goto gotToplevel; + } + } else if (child == wmPtr->winPtr->window) { + goto gotToplevel; + } } x = childX; y = childY; @@ -5888,7 +5872,7 @@ Tk_CoordsToWindow( window = child; } - gotToplevel: + gotToplevel: if (handler) { /* * Check value of handler, because we can reach this label from above @@ -5898,6 +5882,7 @@ Tk_CoordsToWindow( Tk_DeleteErrorHandler(handler); handler = NULL; } + winPtr = wmPtr->winPtr; if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { return NULL; } @@ -5912,13 +5897,19 @@ Tk_CoordsToWindow( x = childX - winPtr->changes.x; y = childY - winPtr->changes.y; - - if (y < 0 && y >= -wmPtr->menuHeight ) { - winPtr = (TkWindow *) wmPtr->menubar; - y += wmPtr->menuHeight; - if (winPtr == NULL) { - return NULL; - } + if ((x < 0) || (x >= winPtr->changes.width) + || (y >= winPtr->changes.height)) { + return NULL; + } + if (y < 0) { + winPtr = (TkWindow *) wmPtr->menubar; + if (winPtr == NULL) { + return NULL; + } + y += wmPtr->menuHeight; + if (y < 0) { + return NULL; + } } /* -- cgit v0.12 From 7a5f3dba4c643c1bc760f4f9d7dda5cc34cb717d Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 13 Dec 2018 16:47:28 +0000 Subject: Make the minimal change needed to fix the issue with Gnome 3 invisible borders, without changing any other behavior. --- unix/tkUnixWm.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 19ac86c..2537ed9 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5855,8 +5855,34 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { - if (wmPtr->reparent == child) { - goto gotToplevel; + if (child == wmPtr->reparent) { + XWindowChanges changes = wmPtr->winPtr->changes; + + /* Gnome3-based window managers place an invisible border + * around a window to help grab the edge for resizing. + * XTranslateCoordinates returns a reparent of the window as + * the child whenever the point is inside the invisible + * border. But we only want to use the window as our toplevel + * when the point is actually inside the window. If the point + * is outside, we replace the window by the next window in the + * stack, provided it is a Tk window. (Gnome3 adds its own + * private window below when no lower Tk window contains the + * point. We can detect this by checking whether the winPtr + * is NULL.) + */ + + if (x >= changes.x && + x < changes.x + changes.width && + y >= changes.y - wmPtr->menuHeight && + y < changes.y + changes.height) { + goto gotToplevel; + } else if (wmPtr->nextPtr != NULL) { + wmPtr = wmPtr->nextPtr; + if (wmPtr->winPtr == NULL) { + return NULL; + } + goto gotToplevel; + } } if (wmPtr->wrapperPtr != NULL) { if (child == wmPtr->wrapperPtr->window) { -- cgit v0.12 From 06b907dffae1e534e41e72b16bcb68c8aa30e594 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 13 Dec 2018 23:09:41 +0000 Subject: Gnome3 behaves differently when the root window is involved. More intricate logic is needed to handle that case. --- tests/unixWm.test | 4 +++- unix/tkUnixWm.c | 27 +++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index 1025eed..224016b 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1777,7 +1777,9 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { } {52 7 12 62} deleteWindows -wm iconify . +# added temporarily because the root was not being iconified on Ubuntu. +wm geometry . +1000+1000 +#wm iconify . test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { update toplevel .t -width 300 -height 400 -bg green diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 2537ed9..1037c00 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5800,7 +5800,8 @@ Tk_CoordsToWindow( TkWindow *winPtr, *childPtr, *nextPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; Tk_ErrorHandler handler = NULL; - + int gnome3flag = 0; + /* * Step 1: scan the list of toplevel windows to see if there is a virtual * root for the screen we're interested in. If so, we have to translate @@ -5855,6 +5856,12 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { + if (wmPtr->winPtr->mainPtr == NULL) { + continue; + } + if (gnome3flag) { + goto gotToplevel; + } if (child == wmPtr->reparent) { XWindowChanges changes = wmPtr->winPtr->changes; @@ -5864,11 +5871,11 @@ Tk_CoordsToWindow( * the child whenever the point is inside the invisible * border. But we only want to use the window as our toplevel * when the point is actually inside the window. If the point - * is outside, we replace the window by the next window in the - * stack, provided it is a Tk window. (Gnome3 adds its own - * private window below when no lower Tk window contains the - * point. We can detect this by checking whether the winPtr - * is NULL.) + * is outside, we set the gnome3flag, which means to use the + * next genuine Tk window on the stack. (Gnome3 may add its + * own private window below the window with the invisible + * border. We can detect this by checking whether + * winPtr->mainPtr is NULL.) */ if (x >= changes.x && @@ -5876,12 +5883,8 @@ Tk_CoordsToWindow( y >= changes.y - wmPtr->menuHeight && y < changes.y + changes.height) { goto gotToplevel; - } else if (wmPtr->nextPtr != NULL) { - wmPtr = wmPtr->nextPtr; - if (wmPtr->winPtr == NULL) { - return NULL; - } - goto gotToplevel; + } else { + gnome3flag = 1; } } if (wmPtr->wrapperPtr != NULL) { -- cgit v0.12 From d2de96927a9b757b9e861e2468d0a90cfa325061 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 14 Dec 2018 03:52:36 +0000 Subject: Add a comment in unixWm.test about iconifying the root window. --- tests/unixWm.test | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index 224016b..4e82a67 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1777,7 +1777,11 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { } {52 7 12 62} deleteWindows -# added temporarily because the root was not being iconified on Ubuntu. +# The root window must not overlap the test windows during these +# tests. Previously this was arranged by iconifying the root. But +# this does not work on Ubuntu Unity, possibly because of +# https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1502370 +# A workaround is to just move it far away. wm geometry . +1000+1000 #wm iconify . test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { -- cgit v0.12 From 62e5b81ffd0255b22a55bb976983fc7377263ea5 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 14 Dec 2018 17:09:29 +0000 Subject: Another rework to *correctly* search for the highest toplevel containing a point when it is in an invisible border. --- unix/tkUnixWm.c | 73 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 24 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 1037c00..96a10c4 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5785,6 +5785,18 @@ Tk_GetRootCoords( *---------------------------------------------------------------------- */ +static int PointInWindow( + int x, + int y, + WmInfo *wmPtr) +{ + XWindowChanges changes = wmPtr->winPtr->changes; + return (x >= changes.x && + x < changes.x + changes.width && + y >= changes.y - wmPtr->menuHeight && + y < changes.y + changes.height); +} + Tk_Window Tk_CoordsToWindow( int rootX, int rootY, /* Coordinates of point in root window. If a @@ -5800,7 +5812,6 @@ Tk_CoordsToWindow( TkWindow *winPtr, *childPtr, *nextPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; Tk_ErrorHandler handler = NULL; - int gnome3flag = 0; /* * Step 1: scan the list of toplevel windows to see if there is a virtual @@ -5859,32 +5870,46 @@ Tk_CoordsToWindow( if (wmPtr->winPtr->mainPtr == NULL) { continue; } - if (gnome3flag) { - goto gotToplevel; - } if (child == wmPtr->reparent) { - XWindowChanges changes = wmPtr->winPtr->changes; - - /* Gnome3-based window managers place an invisible border - * around a window to help grab the edge for resizing. - * XTranslateCoordinates returns a reparent of the window as - * the child whenever the point is inside the invisible - * border. But we only want to use the window as our toplevel - * when the point is actually inside the window. If the point - * is outside, we set the gnome3flag, which means to use the - * next genuine Tk window on the stack. (Gnome3 may add its - * own private window below the window with the invisible - * border. We can detect this by checking whether - * winPtr->mainPtr is NULL.) - */ - - if (x >= changes.x && - x < changes.x + changes.width && - y >= changes.y - wmPtr->menuHeight && - y < changes.y + changes.height) { + if (PointInWindow(x, y, wmPtr)) { goto gotToplevel; } else { - gnome3flag = 1; + + /* Ouch! The point is not in the reparented window! + * + * This can happen with Gnome3-based window managers. + * They provide an invisible border around a window to + * help grab the edge for resizing. When the point is + * inside the invisible border of some window, + * XTranslateCoordinates will set the child to be a + * reparent of that window. But we don't want that + * window. What we have to do in this case is to search + * through all of the toplevels below this one and find + * the highest one which actually contains the point. + */ + + TkWindow **windows, **window_ptr; + windows = TkWmStackorderToplevel( + ((TkWindow *) tkwin)->mainPtr->winPtr); + if (windows == NULL) { + return NULL; + } + winPtr = NULL; + for (window_ptr = windows; *window_ptr ; window_ptr++) { + wmPtr = (*window_ptr)->wmInfoPtr; + if (wmPtr == NULL) { + continue; + } + if (PointInWindow(x, y, wmPtr)) { + winPtr = *window_ptr; + break; + } + } + ckfree(windows); + if (winPtr == NULL) { + return NULL; + } + goto gotToplevel; } } if (wmPtr->wrapperPtr != NULL) { -- cgit v0.12 From 815caa4c8cf60b0922c45dbc1d37f2a28e61680b Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 14 Dec 2018 18:14:48 +0000 Subject: For consistency, make "winfo containing" ignore the title bar on macOS. --- macosx/tkMacOSXWm.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 6a860e4..4d9002e 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -617,7 +617,16 @@ FrontWindowAtPoint( winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; - if (NSMouseInRect(p, [w frame], NO) && + NSRect frame = [w frame]; + + /* + * For consistency with other platforms, points in the + * title bar are not considered to be contained in the + * window. + */ + + frame.size.height = [[w contentView] frame].size.height; + if (NSMouseInRect(p, frame, NO) && (wmPtr->hints.initial_state == NormalState || wmPtr->hints.initial_state == ZoomState)) { return winPtr; -- cgit v0.12 From 7a359d16f322e88b8af5b7208eb63e53a5f3ec91 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 14 Dec 2018 19:15:03 +0000 Subject: On aqua, make FrontWindowAtPoint pay attention to which interpreter is calling it. --- macosx/tkMacOSXWm.c | 14 +++++++++----- tests/unixWm.test | 11 ++++++++++- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 4d9002e..0b39f1a 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -594,7 +594,8 @@ SetWindowSizeLimits( * * FrontWindowAtPoint -- * - * Find frontmost toplevel window at a given screen location. + * Find frontmost toplevel window at a given screen location + * which has the specified mainPtr. * * Results: * TkWindow*. @@ -607,7 +608,9 @@ SetWindowSizeLimits( static TkWindow* FrontWindowAtPoint( - int x, int y) + int x, + int y, + TkMainInfo *mainPtr) { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSArray *windows = [NSApp orderedWindows]; @@ -615,7 +618,7 @@ FrontWindowAtPoint( for (NSWindow *w in windows) { winPtr = TkMacOSXGetTkWindow(w); - if (winPtr) { + if (winPtr && winPtr->mainPtr == mainPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect frame = [w frame]; @@ -4398,14 +4401,15 @@ Tk_CoordsToWindow( TkWindow *winPtr, *childPtr; TkWindow *nextPtr; /* Coordinates of highest child found so far * that contains point. */ + TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr; int x, y; /* Coordinates in winPtr. */ int tmpx, tmpy, bd; - + /* * Step 1: find the top-level window that contains the desired point. */ - winPtr = FrontWindowAtPoint(rootX, rootY); + winPtr = FrontWindowAtPoint(rootX, rootY, mainPtr); if (!winPtr) { return NULL; } diff --git a/tests/unixWm.test b/tests/unixWm.test index 4e82a67..d77fcd5 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1855,8 +1855,17 @@ test unixWm-50.3 { } -cleanup { cleanupbg } -result {{} .x .t .t.f} +# On X11 winfo containing returns an empty string if the top window +# containing the point belongs to a different interpreter. Not so +# on aqua. +if {[tk windowingsystem] == "aqua"} { + set result_50_4 [list ".t" "."] + } else { + set result_50_4 [list "" "."] +} test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix { destroy .t + catch {interp delete slave} toplevel .t -width 200 -height 200 -bg green wm geometry .t +0+0 @@ -1868,7 +1877,7 @@ test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix [slave eval {winfo containing 100 100}]] interp delete slave set result -} {{} .} +} $result_50_4 test unixWm-50.5 {Tk_CoordsToWindow procedure, handling menubars} {unix testmenubar} { deleteWindows toplevel .t -width 300 -height 400 -bd 2 -relief raised -- cgit v0.12 From 55943785efe5639b3ada935ce718ad6fd0bed6b2 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 14 Dec 2018 19:44:43 +0000 Subject: On second thought, it is better to follow X11 and return an empty string when the top window containing the point has a different interpreter. --- macosx/tkMacOSXWm.c | 10 ++++------ tests/unixWm.test | 10 +--------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0b39f1a..2091de0 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -609,8 +609,7 @@ SetWindowSizeLimits( static TkWindow* FrontWindowAtPoint( int x, - int y, - TkMainInfo *mainPtr) + int y) { NSPoint p = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); NSArray *windows = [NSApp orderedWindows]; @@ -618,7 +617,7 @@ FrontWindowAtPoint( for (NSWindow *w in windows) { winPtr = TkMacOSXGetTkWindow(w); - if (winPtr && winPtr->mainPtr == mainPtr) { + if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect frame = [w frame]; @@ -4401,7 +4400,6 @@ Tk_CoordsToWindow( TkWindow *winPtr, *childPtr; TkWindow *nextPtr; /* Coordinates of highest child found so far * that contains point. */ - TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr; int x, y; /* Coordinates in winPtr. */ int tmpx, tmpy, bd; @@ -4409,8 +4407,8 @@ Tk_CoordsToWindow( * Step 1: find the top-level window that contains the desired point. */ - winPtr = FrontWindowAtPoint(rootX, rootY, mainPtr); - if (!winPtr) { + winPtr = FrontWindowAtPoint(rootX, rootY); + if (!winPtr || winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { return NULL; } diff --git a/tests/unixWm.test b/tests/unixWm.test index d77fcd5..443254c 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1855,14 +1855,6 @@ test unixWm-50.3 { } -cleanup { cleanupbg } -result {{} .x .t .t.f} -# On X11 winfo containing returns an empty string if the top window -# containing the point belongs to a different interpreter. Not so -# on aqua. -if {[tk windowingsystem] == "aqua"} { - set result_50_4 [list ".t" "."] - } else { - set result_50_4 [list "" "."] -} test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix { destroy .t @@ -1877,7 +1869,7 @@ test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix [slave eval {winfo containing 100 100}]] interp delete slave set result -} $result_50_4 +} {{} .} test unixWm-50.5 {Tk_CoordsToWindow procedure, handling menubars} {unix testmenubar} { deleteWindows toplevel .t -width 300 -height 400 -bd 2 -relief raised -- cgit v0.12 From b587cc3fcafb8c360bd85b80d638a0d1f7a6ebde Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 16 Dec 2018 21:54:22 +0000 Subject: Make unixWm-50.3 use a slave rather than dobg and fix the bug it revealed. --- tests/unixWm.test | 38 ++++++++++++++++++++------------------ unix/tkUnixWm.c | 35 +++++++++++++++++++++-------------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index 443254c..03a3e52 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1829,32 +1829,34 @@ test unixWm-50.2 {Tk_CoordsToWindow procedure, finding a toplevel, y-coords and } {{} {} .t .t .t2 .t2 .t {}} test unixWm-50.3 { Tk_CoordsToWindow procedure, finding a toplevel with embedding -} -constraints tempNotWin -setup { +} tempNotWin { deleteWindows toplevel .t -width 300 -height 400 -bg blue - wm geom .t +0+50 - frame .t.f -container 1 + wm geom .t +100+100 + frame .t.f -container 1 -bg red place .t.f -x 150 -y 50 tkwait visibility .t.f - setupbg -} -body { - dobg " + update + interp create slave + load {} Tk slave + slave alias frameid winfo id .t.f + slave eval { wm withdraw . - toplevel .x -width 100 -height 80 -use [winfo id .t.f] -bg yellow - tkwait visibility .x" - set result [dobg { - set x [winfo rootx .x] - set y [winfo rooty .x] - list [winfo containing [expr $x - 1] [expr $y + 50]] \ - [winfo containing $x [expr $y +50]] - }] + toplevel .x -width 100 -height 80 -use [frameid] -bg yellow + tkwait visibility .x + update + set x [winfo rootx .x] + set y [winfo rooty .x] + } + set result [list [slave eval {winfo containing [expr $x - 1] [expr $y + 50]}] \ + [slave eval {winfo containing $x [expr $y + 50]}]] + interp delete slave set x [winfo rootx .t] set y [winfo rooty .t] lappend result [winfo containing [expr $x + 200] [expr $y + 49]] \ - [winfo containing [expr $x + 200] [expr $y +50]] -} -cleanup { - cleanupbg -} -result {{} .x .t .t.f} + [winfo containing [expr $x + 200] [expr $y +50]] + set result +} {{} .x .t .t.f} test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix { destroy .t diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 96a10c4..5bee6ba 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5812,7 +5812,7 @@ Tk_CoordsToWindow( TkWindow *winPtr, *childPtr, *nextPtr; TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr; Tk_ErrorHandler handler = NULL; - + /* * Step 1: scan the list of toplevel windows to see if there is a virtual * root for the screen we're interested in. If so, we have to translate @@ -5915,7 +5915,14 @@ Tk_CoordsToWindow( if (wmPtr->wrapperPtr != NULL) { if (child == wmPtr->wrapperPtr->window) { goto gotToplevel; - } + } else if (wmPtr->winPtr->flags & TK_EMBEDDED && + TkpGetOtherWindow(wmPtr->winPtr) == NULL) { + int rx, ry; + Tk_GetRootCoords((Tk_Window) wmPtr->winPtr, &rx, &ry); + childX -= rx; + childY -= ry; + goto gotToplevel; + } } else if (child == wmPtr->winPtr->window) { goto gotToplevel; } @@ -5937,9 +5944,6 @@ Tk_CoordsToWindow( handler = NULL; } winPtr = wmPtr->winPtr; - if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { - return NULL; - } /* * Step 3: at this point winPtr and wmPtr refer to the toplevel that @@ -5996,27 +6000,30 @@ Tk_CoordsToWindow( if (nextPtr == NULL) { break; } - winPtr = nextPtr; - x -= winPtr->changes.x; - y -= winPtr->changes.y; - if ((winPtr->flags & TK_CONTAINER) - && (winPtr->flags & TK_BOTH_HALVES)) { + x -= nextPtr->changes.x; + y -= nextPtr->changes.y; + if ((nextPtr->flags & TK_CONTAINER) + && (nextPtr->flags & TK_BOTH_HALVES)) { /* * The window containing the point is a container, and the * embedded application is in this same process. Switch over to * the toplevel for the embedded application and start processing * that toplevel from scratch. */ - - winPtr = TkpGetOtherWindow(winPtr); + winPtr = TkpGetOtherWindow(nextPtr); if (winPtr == NULL) { - return NULL; + return (Tk_Window) nextPtr; } wmPtr = winPtr->wmInfoPtr; childX = x; childY = y; goto gotToplevel; - } + } else { + winPtr = nextPtr; + } + } + if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + return NULL; } return (Tk_Window) winPtr; } -- cgit v0.12 From e280e3fadd21cde4636ae3f691defde0f9537929 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 16 Dec 2018 22:20:26 +0000 Subject: Fix a small error in the aqua Tk_CoordsToWindow related to embedded toplevels. --- macosx/tkMacOSXWm.c | 5 ++++- tests/unixWm.test | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 2091de0..2764fee 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -4408,7 +4408,7 @@ Tk_CoordsToWindow( */ winPtr = FrontWindowAtPoint(rootX, rootY); - if (!winPtr || winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + if (!winPtr) { return NULL; } @@ -4472,6 +4472,9 @@ Tk_CoordsToWindow( } winPtr = nextPtr; } + if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + return NULL; + } return (Tk_Window) winPtr; } diff --git a/tests/unixWm.test b/tests/unixWm.test index 03a3e52..9764e60 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1831,6 +1831,8 @@ test unixWm-50.3 { Tk_CoordsToWindow procedure, finding a toplevel with embedding } tempNotWin { deleteWindows + catch {interp delete slave} + toplevel .t -width 300 -height 400 -bg blue wm geom .t +100+100 frame .t.f -container 1 -bg red @@ -1862,13 +1864,14 @@ test unixWm-50.4 {Tk_CoordsToWindow procedure, window in other application} unix catch {interp delete slave} toplevel .t -width 200 -height 200 -bg green - wm geometry .t +0+0 + wm geometry .t +100+100 tkwait visibility .t + update interp create slave load {} Tk slave - slave eval {wm geometry . 200x200+0+0; tkwait visibility .} - set result [list [winfo containing 100 100] \ - [slave eval {winfo containing 100 100}]] + slave eval {wm geometry . 200x200+100+100; tkwait visibility . ; update} + set result [list [winfo containing 200 200] \ + [slave eval {winfo containing 200 200}]] interp delete slave set result } {{} .} -- cgit v0.12 From 3a8a72f3acdebde1221166853af70577e5adbc11 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 16 Dec 2018 22:56:32 +0000 Subject: Fix typos in unixWm.test. --- tests/unixWm.test | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/unixWm.test b/tests/unixWm.test index 9764e60..9029fc9 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -808,14 +808,15 @@ test unixWm-22.2 {Tk_WmCmd procedure, "iconbitmap" option} {unix testwrapper} { WM_HINTS] 0]]] lappend result [wm iconbitmap .t] $bit } {{} questhead 0x4 {} 0x0} -test unixWm-22.3.1 {Tk_WmCmd procedure, "iconbitmap" option for unix only} \ -{unix notAqua} { - list [catch {wm iconbitmap .t bad-bitmap} msg] $msg -} {1 {bitmap "bad-bitmap" not defined}} -test unixWm-22.3.2 {Tk_WmCmd procedure, "iconbitmap" option for Aqua only} \ -Aqua { +if {[tk windowingsystem] == "aqua"} { + set result_22_3 {0 {}} +} else { + set result_22_3 {1 {bitmap "bad-bitmap" not defined}} +} +test unixWm-22.3 {Tk_WmCmd procedure, "iconbitmap" option for unix only} \ +unix { list [catch {wm iconbitmap .t bad-bitmap} msg] $msg -} {1 {}} +} $result_22_3 test unixWm-23.1 {Tk_WmCmd procedure, "iconify" option} unix { list [catch {wm iconify .t 12} msg] $msg @@ -1218,13 +1219,14 @@ test unixWm-34.2 {Tk_WmCmd procedure, "sizefrom" option} {unix testwrapper} { test unixWm-34.3 {Tk_WmCmd procedure, "sizefrom" option} unix { list [catch {wm sizefrom .t none} msg] $msg } {1 {bad argument "none": must be program or user}} - -test unixWm-35.1.1 {Tk_WmCmd procedure, "state" option} {unix notAqua} { - list [catch {wm state .t 1} msg] $msg -} {1 {bad argument "1": must be normal, iconic, or withdrawn}} -test unixWm-35.1.2 {Tk_WmCmd procedure, "state" option} Aqua { +if {[tk windowingsystem] == "aqua"} { + set result_35_1 {1 {bad argument "1": must be normal, iconic, withdrawn, or zoomed}} +} else { + set result_35_1 {1 {bad argument "1": must be normal, iconic, or withdrawn}} +} +test unixWm-35.1 {Tk_WmCmd procedure, "state" option} {unix notAqua} { list [catch {wm state .t 1} msg] $msg -} {1 {bad argument "1": must be normal, iconic, withdrawn, or zoomed}} +} $result_35_1 test unixWm-35.2 {Tk_WmCmd procedure, "state" option} unix { list [catch {wm state .t iconic 1} msg] $msg } {1 {wrong # args: should be "wm state window ?state?"}} -- cgit v0.12 From 8ba154154bdb9c4923685db7baff72c1c7a085c5 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 14:11:38 +0000 Subject: Restore the old behavior with unix title bars and borders, but document and test it. --- doc/winfo.n | 3 +++ tests/unixWm.test | 23 +++++++++++++---------- unix/tkUnixWm.c | 36 +++--------------------------------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/doc/winfo.n b/doc/winfo.n index 5008448..a833e31 100644 --- a/doc/winfo.n +++ b/doc/winfo.n @@ -73,6 +73,9 @@ to the screen containing \fIwindow\fR; otherwise they refer to the screen of the application's main window. If no window in this application contains the point then an empty string is returned. +An empty string is also returned if the point lies in the title bar +or border of its highest containing toplevel in this application. +(Note that with some window managers the borders may be invisible.) In selecting the containing window, children are given higher priority than parents and among siblings the highest one in the stacking order is chosen. diff --git a/tests/unixWm.test b/tests/unixWm.test index 9029fc9..6759f38 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1779,14 +1779,15 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { } {52 7 12 62} deleteWindows -# The root window must not overlap the test windows during these -# tests. Previously this was arranged by iconifying the root. But -# this does not work on Ubuntu Unity, possibly because of -# https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1502370 -# A workaround is to just move it far away. -wm geometry . +1000+1000 -#wm iconify . -test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { +wm withdraw . +if {[tk windowingsystem] == "aqua"} { + # Modern mac windows have no border. + set result_50_1 {{} {} .t .t .t2 {} .t2 .t .t} +} else { + # Windows are assumed to have a border (invisible in Gnome 3). + set result_50_1 {{} {} .t {} .t2 {} .t2 {} .t} +} +test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords, title bar} unix { update toplevel .t -width 300 -height 400 -bg green wm geom .t +100+100 @@ -1803,10 +1804,11 @@ test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} uni [winfo containing $x [expr $y + 250]] \ [winfo containing [expr $x + 99] [expr $y + 250]] \ [winfo containing [expr $x + 100] [expr $y + 250]] \ + [winfo containing [expr $x + 150] [expr $y + 90]] \ [winfo containing [expr $x + 199] [expr $y + 250]] \ [winfo containing [expr $x + 200] [expr $y + 250]] \ - [winfo containing [expr $x + 220] [expr $y + 250]] -} {{} {} .t .t .t2 .t2 .t .t} + [winfo containing [expr $x + 220] [expr $y + 250]] \ +} $result_50_1 test unixWm-50.2 {Tk_CoordsToWindow procedure, finding a toplevel, y-coords and overrideredirect} unix { deleteWindows toplevel .t -width 400 -height 300 -bg yellow @@ -1962,6 +1964,7 @@ test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix { tkwait visibility .t2 set result [list [winfo containing 100 100]] wm iconify .t2 + animationDelay lappend result [winfo containing 100 100] } {.t2 .t} test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix { diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 5bee6ba..fa54f56 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5875,41 +5875,11 @@ Tk_CoordsToWindow( goto gotToplevel; } else { - /* Ouch! The point is not in the reparented window! - * - * This can happen with Gnome3-based window managers. - * They provide an invisible border around a window to - * help grab the edge for resizing. When the point is - * inside the invisible border of some window, - * XTranslateCoordinates will set the child to be a - * reparent of that window. But we don't want that - * window. What we have to do in this case is to search - * through all of the toplevels below this one and find - * the highest one which actually contains the point. + /* + * Return NULL if the point is in the title bar or border. */ - TkWindow **windows, **window_ptr; - windows = TkWmStackorderToplevel( - ((TkWindow *) tkwin)->mainPtr->winPtr); - if (windows == NULL) { - return NULL; - } - winPtr = NULL; - for (window_ptr = windows; *window_ptr ; window_ptr++) { - wmPtr = (*window_ptr)->wmInfoPtr; - if (wmPtr == NULL) { - continue; - } - if (PointInWindow(x, y, wmPtr)) { - winPtr = *window_ptr; - break; - } - } - ckfree(windows); - if (winPtr == NULL) { - return NULL; - } - goto gotToplevel; + return NULL; } } if (wmPtr->wrapperPtr != NULL) { -- cgit v0.12 From 394280cc3f6bb4b807560ad4bd02688dc2c43d48 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 14:38:39 +0000 Subject: Make the Mac also return NULL for points in the title bar. --- macosx/tkMacOSXWm.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 2764fee..0eafbda 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -594,8 +594,8 @@ SetWindowSizeLimits( * * FrontWindowAtPoint -- * - * Find frontmost toplevel window at a given screen location - * which has the specified mainPtr. + * Find frontmost toplevel window at a given screen location which has the + * specified mainPtr. If the location is in the title bar, return NULL. * * Results: * TkWindow*. @@ -619,19 +619,22 @@ FrontWindowAtPoint( winPtr = TkMacOSXGetTkWindow(w); if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; - NSRect frame = [w frame]; - + NSRect windowFrame = [w frame]; + NSRect contentFrame = [w frame]; + contentFrame.size.height = [[w contentView] frame].size.height; /* * For consistency with other platforms, points in the * title bar are not considered to be contained in the * window. */ - frame.size.height = [[w contentView] frame].size.height; - if (NSMouseInRect(p, frame, NO) && - (wmPtr->hints.initial_state == NormalState || + if ((wmPtr->hints.initial_state == NormalState || wmPtr->hints.initial_state == ZoomState)) { - return winPtr; + if (NSMouseInRect(p, contentFrame, NO)) { + return winPtr; + } else if (NSMouseInRect(p, windowFrame, NO)) { + return NULL; + } } } } -- cgit v0.12 From e23f0234acc76259cea840a7b8c23b2a58bacd97 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 16:44:02 +0000 Subject: Fix a bug with window ordering in Aqua. Deal with remaining unixWm tests. --- macosx/tkMacOSXSubwindows.c | 6 +++++- macosx/tkMacOSXWm.c | 4 ---- tests/unixWm.test | 29 +++++++++++++++++++++++------ 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 0f9214f..7bc807a 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -157,11 +157,15 @@ XMapWindow( * the app to activate too early can make the menu bar * unresponsive. */ + TkMacOSXApplyWindowAttributes(macWin->winPtr, win); + [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:NO]; + [[win contentView] setNeedsDisplay:YES]; if ( [win canBecomeKeyWindow] ) { [win makeKeyAndOrderFront:NSApp]; + } else { + [win orderFrontRegardless]; } - TkMacOSXApplyWindowAttributes(macWin->winPtr, win); } else { /* * Rebuild the container's clipping region and display diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0eafbda..d49c7ee 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -833,10 +833,6 @@ TkWmMapWindow( */ XMapWindow(winPtr->display, winPtr->window); - - /*Add window to Window menu.*/ - NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - [win setExcludedFromWindowsMenu:NO]; } /* diff --git a/tests/unixWm.test b/tests/unixWm.test index 6759f38..59e0fa7 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -2050,6 +2050,7 @@ test unixWm-51.6 {TkWmRestackToplevel procedure, window to be stacked isn't mapp test unixWm-51.7 {TkWmRestackToplevel procedure, other window isn't mapped} unix { foreach w {.t .t2 .t3} { destroy $w + update toplevel $w -width 200 -height 200 -bg green wm geometry $w +0+0 } @@ -2086,13 +2087,19 @@ test unixWm-51.8 {TkWmRestackToplevel procedure, overrideredirect windows} unix raise .t2 lappend result [winfo containing $x $y] } {.t2 .t .t2} +# The mac won't put an overrideredirect window above the root, +if {[tk windowingsystem] == "aqua"} { + wm withdraw . +} test unixWm-51.9 {TkWmRestackToplevel procedure, other window overrideredirect} unix { foreach w {.t .t2 .t3} { destroy $w + update toplevel $w -width 200 -height 200 -bg green wm overrideredirect $w 1 wm geometry $w +0+0 tkwait visibility $w + update } lower .t3 .t2 update @@ -2108,6 +2115,9 @@ test unixWm-51.9 {TkWmRestackToplevel procedure, other window overrideredirect} lower .t2 lappend result [winfo containing $x $y] } {.t2 .t3} +if {[tk windowingsystem] == "aqua"} { + wm deiconify . +} test unixWm-51.10 {TkWmRestackToplevel procedure, don't move window that's already in the right place} unix { makeToplevels raise .raise1 @@ -2483,11 +2493,17 @@ test unixWm-59.3 {exit processing} unix { # NOTE: since [wm attributes] is not guaranteed to have any effect, # the only thing we can really test here is the syntax. # +if {[tk windowingsystem] == "aqua"} { + set result_60_1 {-alpha 1.0 -fullscreen 0 -modified 0 -notify 0\ + -titlepath {} -topmost 0 -transparent 0} +} else { + set result_60_1 {-alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}} +} test unixWm-60.1 {wm attributes - test} -constraints unix -body { destroy .t toplevel .t wm attributes .t -} -result [list -alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}] +} -result $result_60_1 test unixWm-60.2 {wm attributes - test} -constraints unix -body { destroy .t @@ -2527,7 +2543,8 @@ test unixWm-61.2 {Tk_WmCmd procedure, "iconphoto" option} unix { image delete blank16 blank32 } {} -test unixWm-62.0 {wm attributes -type void} -constraints unix -setup { +# Aqua does not support wm attributes -type +test unixWm-62.0 {wm attributes -type void} -constraints {unix notAqua} -setup { destroy .t toplevel .t } -body { @@ -2536,7 +2553,7 @@ test unixWm-62.0 {wm attributes -type void} -constraints unix -setup { destroy .t } -result {} -test unixWm-62.1 {wm attributes -type name} -constraints unix -setup { +test unixWm-62.1 {wm attributes -type name} -constraints {unix notAqua} -setup { destroy .t toplevel .t } -body { @@ -2545,7 +2562,7 @@ test unixWm-62.1 {wm attributes -type name} -constraints unix -setup { destroy .t } -result {} -test unixWm-62.2 {wm attributes -type name} -constraints unix -setup { +test unixWm-62.2 {wm attributes -type name} -constraints {unix notAqua} -setup { destroy .t toplevel .t } -body { @@ -2555,7 +2572,7 @@ test unixWm-62.2 {wm attributes -type name} -constraints unix -setup { destroy .t } -result {} -test unixWm-62.3 {wm attributes -type list} -constraints unix -setup { +test unixWm-62.3 {wm attributes -type list} -constraints {unix notAqua} -setup { destroy .t toplevel .t } -body { @@ -2564,7 +2581,7 @@ test unixWm-62.3 {wm attributes -type list} -constraints unix -setup { destroy .t } -result {} -test unixWm-62.4 {wm attributes -type list} -constraints unix -setup { +test unixWm-62.4 {wm attributes -type list} -constraints {unix notAqua} -setup { destroy .t toplevel .t } -body { -- cgit v0.12 From ffbffcbec913bd431f27b7097320dcf22dee7a55 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 20:01:21 +0000 Subject: Add a dummy implementation of "wm attribute pathname -type" for Aqua, to obviate platform dependent code. --- macosx/tkMacOSXWm.c | 9 ++++++--- tests/unixWm.test | 11 +++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index d49c7ee..3887001 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -152,13 +152,13 @@ static const struct { typedef enum { WMATT_ALPHA, WMATT_FULLSCREEN, WMATT_MODIFIED, WMATT_NOTIFY, WMATT_TITLEPATH, WMATT_TOPMOST, WMATT_TRANSPARENT, - _WMATT_LAST_ATTRIBUTE + WMATT_TYPE, _WMATT_LAST_ATTRIBUTE } WmAttribute; static const char *const WmAttributeNames[] = { "-alpha", "-fullscreen", "-modified", "-notify", "-titlepath", "-topmost", "-transparent", - NULL + "-type", NULL }; /* @@ -1316,7 +1316,7 @@ WmSetAttribute( #if !(MAC_OS_X_VERSION_MAX_ALLOWED < 1070) [macWindow toggleFullScreen:macWindow]; #else - TKLog(@"The fullscreen attribute is ignored on this system.."); + TKLog(@"The fullscreen attribute is ignored on this system."); #endif } break; @@ -1394,6 +1394,9 @@ WmSetAttribute( TK_PARENT_WINDOW); } break; + case WMATT_TYPE: + TKLog(@"The type attribute is ignored on macOX."); + break; case _WMATT_LAST_ATTRIBUTE: default: return TCL_ERROR; diff --git a/tests/unixWm.test b/tests/unixWm.test index 59e0fa7..d3edab2 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -2543,8 +2543,7 @@ test unixWm-61.2 {Tk_WmCmd procedure, "iconphoto" option} unix { image delete blank16 blank32 } {} -# Aqua does not support wm attributes -type -test unixWm-62.0 {wm attributes -type void} -constraints {unix notAqua} -setup { +test unixWm-62.0 {wm attributes -type void} -constraints unix -setup { destroy .t toplevel .t } -body { @@ -2553,7 +2552,7 @@ test unixWm-62.0 {wm attributes -type void} -constraints {unix notAqua} -setup { destroy .t } -result {} -test unixWm-62.1 {wm attributes -type name} -constraints {unix notAqua} -setup { +test unixWm-62.1 {wm attributes -type name} -constraints unix -setup { destroy .t toplevel .t } -body { @@ -2562,7 +2561,7 @@ test unixWm-62.1 {wm attributes -type name} -constraints {unix notAqua} -setup { destroy .t } -result {} -test unixWm-62.2 {wm attributes -type name} -constraints {unix notAqua} -setup { +test unixWm-62.2 {wm attributes -type name} -constraints unix -setup { destroy .t toplevel .t } -body { @@ -2572,7 +2571,7 @@ test unixWm-62.2 {wm attributes -type name} -constraints {unix notAqua} -setup { destroy .t } -result {} -test unixWm-62.3 {wm attributes -type list} -constraints {unix notAqua} -setup { +test unixWm-62.3 {wm attributes -type list} -constraints unix -setup { destroy .t toplevel .t } -body { @@ -2581,7 +2580,7 @@ test unixWm-62.3 {wm attributes -type list} -constraints {unix notAqua} -setup { destroy .t } -result {} -test unixWm-62.4 {wm attributes -type list} -constraints {unix notAqua} -setup { +test unixWm-62.4 {wm attributes -type list} -constraints unix -setup { destroy .t toplevel .t } -body { -- cgit v0.12 From be0681043b753334bead0bdbb13c3a2fefc01e45 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 20:28:36 +0000 Subject: On Aqua make "wm attribute pathname -type" return "unsupported" instead of crashing. --- macosx/tkMacOSXWm.c | 3 +++ tests/unixWm.test | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 3887001..b7357b9 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1447,6 +1447,9 @@ WmGetAttribute( case WMATT_TRANSPARENT: result = Tcl_NewBooleanObj(wmPtr->flags & WM_TRANSPARENT); break; + case WMATT_TYPE: + result = Tcl_NewStringObj("unsupported", -1); + break; case _WMATT_LAST_ATTRIBUTE: default: break; diff --git a/tests/unixWm.test b/tests/unixWm.test index d3edab2..12a2142 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -2495,7 +2495,8 @@ test unixWm-59.3 {exit processing} unix { # if {[tk windowingsystem] == "aqua"} { set result_60_1 {-alpha 1.0 -fullscreen 0 -modified 0 -notify 0\ - -titlepath {} -topmost 0 -transparent 0} + -titlepath {} -topmost 0 -transparent 0\ + -type unsupported} } else { set result_60_1 {-alpha 1.0 -topmost 0 -zoomed 0 -fullscreen 0 -type {}} } -- cgit v0.12 From 1ff30f9247f746a8f8e2508efc89e665270c50d6 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 20:46:39 +0000 Subject: Adjust wm.test to expect -type as a possible attribute on Aqua. --- tests/wm.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/wm.test b/tests/wm.test index f56eaa7..7b81985 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -140,7 +140,7 @@ test wm-attributes-1.2.4 {usage} -constraints {unix notAqua} -returnCodes error } -result {bad attribute "_": must be -alpha, -topmost, -zoomed, -fullscreen, or -type} test wm-attributes-1.2.5 {usage} -constraints aqua -returnCodes error -body { wm attributes . _ -} -result {bad attribute "_": must be -alpha, -fullscreen, -modified, -notify, -titlepath, -topmost, or -transparent} +} -result {bad attribute "_": must be -alpha, -fullscreen, -modified, -notify, -titlepath, -topmost, -transparent, or -type} ### wm client ### -- cgit v0.12 From 5c361e090b529c91eac0fb21d24adccc75fcd852 Mon Sep 17 00:00:00 2001 From: fvogel Date: Mon, 17 Dec 2018 20:50:02 +0000 Subject: Fix typo --- macosx/tkMacOSXWm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index b7357b9..eb826a6 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -1395,7 +1395,7 @@ WmSetAttribute( } break; case WMATT_TYPE: - TKLog(@"The type attribute is ignored on macOX."); + TKLog(@"The type attribute is ignored on macOS."); break; case _WMATT_LAST_ATTRIBUTE: default: -- cgit v0.12 From f0ba2d7b3ec3c978c9433acfb4766978cbef6175 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 19 Dec 2018 23:19:55 +0000 Subject: Add a comment. --- unix/tkUnixWm.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index fa54f56..8944ecc 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5787,7 +5787,7 @@ Tk_GetRootCoords( static int PointInWindow( int x, - int y, + int y, WmInfo *wmPtr) { XWindowChanges changes = wmPtr->winPtr->changes; @@ -5887,6 +5887,12 @@ Tk_CoordsToWindow( goto gotToplevel; } else if (wmPtr->winPtr->flags & TK_EMBEDDED && TkpGetOtherWindow(wmPtr->winPtr) == NULL) { + + /* + * This toplevel is embedded in a window belonging to + * a different application. + */ + int rx, ry; Tk_GetRootCoords((Tk_Window) wmPtr->winPtr, &rx, &ry); childX -= rx; -- cgit v0.12 From 81b0bd7641a9d2f63154c97d41c27bbb696ef674 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 20 Dec 2018 08:02:30 +0000 Subject: Fix [9e31fd944934e269121fa78ff56b7b86f33e6db6|9e31fd9449]: X11/X.h and Windows.h have conflicting symbols. Also fix a few newer (harmless) gcc warnings. --- generic/tk3d.c | 30 ++++++------ generic/tkBind.c | 4 +- generic/tkBitmap.c | 8 ++-- generic/tkButton.c | 70 ++++++++++++++-------------- generic/tkCanvArc.c | 118 ++++++++++++++++++++++++------------------------ generic/tkCanvBmap.c | 82 ++++++++++++++++----------------- generic/tkCanvImg.c | 8 ++-- generic/tkCanvLine.c | 58 ++++++++++++------------ generic/tkCanvPoly.c | 100 ++++++++++++++++++++-------------------- generic/tkCanvText.c | 84 +++++++++++++++++----------------- generic/tkCanvUtil.c | 82 ++++++++++++++++----------------- generic/tkCanvWind.c | 2 +- generic/tkCanvas.c | 16 +++---- generic/tkClipboard.c | 2 +- generic/tkColor.c | 10 ++-- generic/tkConfig.c | 22 ++++----- generic/tkCursor.c | 9 ++-- generic/tkEntry.c | 36 +++++++-------- generic/tkEntry.h | 2 +- generic/tkEvent.c | 18 ++++---- generic/tkFrame.c | 24 +++++----- generic/tkGC.c | 14 +++--- generic/tkGrab.c | 18 ++++---- generic/tkImage.c | 4 +- generic/tkImgBmap.c | 52 ++++++++++----------- generic/tkImgPhoto.c | 22 ++++----- generic/tkListbox.c | 26 +++++------ generic/tkMenu.c | 2 +- generic/tkMenuDraw.c | 74 +++++++++++++++--------------- generic/tkMenubutton.c | 42 ++++++++--------- generic/tkMessage.c | 18 ++++---- generic/tkOldConfig.c | 40 ++++++++-------- generic/tkPanedWindow.c | 16 +++---- generic/tkPlace.c | 2 +- generic/tkPointer.c | 11 ++--- generic/tkRectOval.c | 100 ++++++++++++++++++++-------------------- generic/tkScale.c | 20 ++++---- generic/tkScale.h | 2 +- generic/tkScrollbar.c | 2 +- generic/tkSelect.c | 10 ++-- generic/tkSquare.c | 10 ++-- generic/tkTest.c | 4 +- generic/tkText.c | 38 ++++++++-------- generic/tkTextDisp.c | 60 ++++++++++++------------ generic/tkTextTag.c | 42 ++++++++--------- generic/tkVisual.c | 8 ++-- generic/tkWindow.c | 62 ++++++++++++------------- generic/ttk/ttkEntry.c | 10 ++-- generic/ttk/ttkLabel.c | 8 ++-- unix/tkUnixMenubu.c | 12 ++--- win/stubs.c | 2 +- win/tkWin3d.c | 12 ++--- win/tkWinButton.c | 6 +-- win/tkWinDefault.h | 2 +- win/tkWinDraw.c | 14 +++--- win/tkWinEmbed.c | 4 +- win/tkWinFont.c | 12 ++--- win/tkWinInt.h | 5 ++ win/tkWinMenu.c | 4 +- win/tkWinPixmap.c | 2 +- win/tkWinPointer.c | 6 +-- win/tkWinPort.h | 4 +- win/tkWinScrlbr.c | 2 +- win/tkWinWindow.c | 6 +-- win/tkWinWm.c | 42 ++++++++--------- win/tkWinX.c | 18 ++++---- win/ttkWinXPTheme.c | 2 +- xlib/X11/X.h | 10 ++-- xlib/xgc.c | 22 ++++----- xlib/ximage.c | 2 +- 70 files changed, 847 insertions(+), 844 deletions(-) diff --git a/generic/tk3d.c b/generic/tk3d.c index caa40dd..a97bed3 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -236,10 +236,10 @@ Tk_Get3DBorder( borderPtr->bgColorPtr = bgColorPtr; borderPtr->darkColorPtr = NULL; borderPtr->lightColorPtr = NULL; - borderPtr->shadow = None; - borderPtr->bgGC = None; - borderPtr->darkGC = None; - borderPtr->lightGC = None; + borderPtr->shadow = 0; + borderPtr->bgGC = 0; + borderPtr->darkGC = 0; + borderPtr->lightGC = 0; borderPtr->hashPtr = hashPtr; borderPtr->nextPtr = existingBorderPtr; Tcl_SetHashValue(hashPtr, borderPtr); @@ -375,7 +375,7 @@ Tk_3DBorderGC( { TkBorder * borderPtr = (TkBorder *) border; - if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) { + if (!borderPtr->lightGC && (which != TK_3D_FLAT_GC)) { TkpGetShadows(borderPtr, tkwin); } if (which == TK_3D_FLAT_GC) { @@ -392,7 +392,7 @@ Tk_3DBorderGC( * compilers happy. */ - return (GC) None; + return 0; } /* @@ -428,29 +428,29 @@ Tk_Free3DBorder( prevPtr = (TkBorder *) Tcl_GetHashValue(borderPtr->hashPtr); TkpFreeBorder(borderPtr); - if (borderPtr->bgColorPtr != NULL) { + if (borderPtr->bgColorPtr) { Tk_FreeColor(borderPtr->bgColorPtr); } - if (borderPtr->darkColorPtr != NULL) { + if (borderPtr->darkColorPtr) { Tk_FreeColor(borderPtr->darkColorPtr); } - if (borderPtr->lightColorPtr != NULL) { + if (borderPtr->lightColorPtr) { Tk_FreeColor(borderPtr->lightColorPtr); } - if (borderPtr->shadow != None) { + if (borderPtr->shadow) { Tk_FreeBitmap(display, borderPtr->shadow); } - if (borderPtr->bgGC != None) { + if (borderPtr->bgGC) { Tk_FreeGC(display, borderPtr->bgGC); } - if (borderPtr->darkGC != None) { + if (borderPtr->darkGC) { Tk_FreeGC(display, borderPtr->darkGC); } - if (borderPtr->lightGC != None) { + if (borderPtr->lightGC) { Tk_FreeGC(display, borderPtr->lightGC); } if (prevPtr == borderPtr) { - if (borderPtr->nextPtr == NULL) { + if (!borderPtr->nextPtr) { Tcl_DeleteHashEntry(borderPtr->hashPtr); } else { Tcl_SetHashValue(borderPtr->hashPtr, borderPtr->nextPtr); @@ -759,7 +759,7 @@ Tk_Draw3DPolygon( int i, lightOnLeft, dx, dy, parallel, pointsSeen; Display *display = Tk_Display(tkwin); - if (borderPtr->lightGC == None) { + if (!borderPtr->lightGC) { TkpGetShadows(borderPtr, tkwin); } diff --git a/generic/tkBind.c b/generic/tkBind.c index c4f8226..476aed0 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -631,7 +631,7 @@ static const TkStateMap visNotify[] = { }; static const TkStateMap configureRequestDetail[] = { - {None, "None"}, + {0, "None"}, {Above, "Above"}, {Below, "Below"}, {BottomIf, "BottomIf"}, @@ -3870,7 +3870,7 @@ DoWarp( { TkDisplay *dispPtr = (TkDisplay *) clientData; - XWarpPointer(dispPtr->display, (Window) None, (Window) dispPtr->warpWindow, + XWarpPointer(dispPtr->display, 0, (Window) dispPtr->warpWindow, 0, 0, 0, 0, (int) dispPtr->warpX, (int) dispPtr->warpY); XForceScreenSaver(dispPtr->display, ScreenSaverReset); dispPtr->flags &= ~TK_DISPLAY_IN_WARP; diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index f7df546..73ab9fd 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -218,7 +218,7 @@ Tk_AllocBitmapFromObj( bitmapPtr = GetBitmap(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = (void *) bitmapPtr; if (bitmapPtr == NULL) { - return None; + return 0; } bitmapPtr->objRefCount++; return bitmapPtr->bitmap; @@ -260,7 +260,7 @@ Tk_GetBitmap( TkBitmap *bitmapPtr = GetBitmap(interp, tkwin, string); if (bitmapPtr == NULL) { - return None; + return 0; } return bitmapPtr->bitmap; } @@ -381,7 +381,7 @@ GetBitmap( bitmap = TkpGetNativeAppBitmap(Tk_Display(tkwin), string, &width, &height); - if (bitmap == None) { + if (!bitmap) { if (interp != NULL) { Tcl_AppendResult(interp, "bitmap \"", string, "\" not defined", NULL); @@ -395,7 +395,7 @@ GetBitmap( if (predefPtr->native) { bitmap = TkpCreateNativeBitmap(Tk_Display(tkwin), predefPtr->source); - if (bitmap == None) { + if (!bitmap) { Tcl_Panic("native bitmap creation failed"); } } else { diff --git a/generic/tkButton.c b/generic/tkButton.c index 70bba83..1967ab2 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -688,7 +688,7 @@ ButtonCreate( butPtr->textPtr = NULL; butPtr->underline = -1; butPtr->textVarNamePtr = NULL; - butPtr->bitmap = None; + butPtr->bitmap = 0; butPtr->imagePtr = NULL; butPtr->image = NULL; butPtr->selectImagePtr = NULL; @@ -710,12 +710,12 @@ ButtonCreate( butPtr->normalFg = NULL; butPtr->activeFg = NULL; butPtr->disabledFg = NULL; - butPtr->normalTextGC = None; - butPtr->activeTextGC = None; - butPtr->disabledGC = None; - butPtr->stippleGC = None; - butPtr->gray = None; - butPtr->copyGC = None; + butPtr->normalTextGC = 0; + butPtr->activeTextGC = 0; + butPtr->disabledGC = 0; + butPtr->stippleGC = 0; + butPtr->gray = 0; + butPtr->copyGC = 0; butPtr->widthPtr = NULL; butPtr->width = 0; butPtr->heightPtr = NULL; @@ -740,7 +740,7 @@ ButtonCreate( butPtr->onValuePtr = NULL; butPtr->offValuePtr = NULL; butPtr->tristateValuePtr = NULL; - butPtr->cursor = None; + butPtr->cursor = 0; butPtr->takeFocusPtr = NULL; butPtr->commandPtr = NULL; butPtr->flags = 0; @@ -969,37 +969,37 @@ DestroyButton( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonTextVarProc, (ClientData) butPtr); } - if (butPtr->image != NULL) { + if (butPtr->image) { Tk_FreeImage(butPtr->image); } - if (butPtr->selectImage != NULL) { + if (butPtr->selectImage) { Tk_FreeImage(butPtr->selectImage); } - if (butPtr->tristateImage != NULL) { + if (butPtr->tristateImage) { Tk_FreeImage(butPtr->tristateImage); } - if (butPtr->normalTextGC != None) { + if (butPtr->normalTextGC) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } - if (butPtr->activeTextGC != None) { + if (butPtr->activeTextGC) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } - if (butPtr->disabledGC != None) { + if (butPtr->disabledGC) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } - if (butPtr->stippleGC != None) { + if (butPtr->stippleGC) { Tk_FreeGC(butPtr->display, butPtr->stippleGC); } - if (butPtr->gray != None) { + if (butPtr->gray) { Tk_FreeBitmap(butPtr->display, butPtr->gray); } - if (butPtr->copyGC != None) { + if (butPtr->copyGC) { Tk_FreeGC(butPtr->display, butPtr->copyGC); } - if (butPtr->textLayout != NULL) { + if (butPtr->textLayout) { Tk_FreeTextLayout(butPtr->textLayout); } - if (butPtr->selVarNamePtr != NULL) { + if (butPtr->selVarNamePtr) { Tcl_UntraceVar(butPtr->interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonVarProc, (ClientData) butPtr); @@ -1184,7 +1184,7 @@ ConfigureButton( * don't go to zero and cause image data to be discarded. */ - if (butPtr->imagePtr != NULL) { + if (butPtr->imagePtr) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->imagePtr), ButtonImageProc, (ClientData) butPtr); @@ -1198,7 +1198,7 @@ ConfigureButton( Tk_FreeImage(butPtr->image); } butPtr->image = image; - if (butPtr->selectImagePtr != NULL) { + if (butPtr->selectImagePtr) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->selectImagePtr), ButtonSelectImageProc, (ClientData) butPtr); @@ -1208,7 +1208,7 @@ ConfigureButton( } else { image = NULL; } - if (butPtr->selectImage != NULL) { + if (butPtr->selectImage) { Tk_FreeImage(butPtr->selectImage); } butPtr->selectImage = image; @@ -1228,7 +1228,7 @@ ConfigureButton( butPtr->tristateImage = image; haveImage = 0; - if (butPtr->imagePtr != NULL || butPtr->bitmap != None) { + if (butPtr->imagePtr || butPtr->bitmap) { haveImage = 1; } if ((!haveImage || butPtr->compound != COMPOUND_NONE) @@ -1243,14 +1243,14 @@ ConfigureButton( namePtr = butPtr->textVarNamePtr; valuePtr = Tcl_ObjGetVar2(interp, namePtr, NULL, TCL_GLOBAL_ONLY); - if (valuePtr == NULL) { + if (!valuePtr) { if (Tcl_ObjSetVar2(interp, namePtr, NULL, butPtr->textPtr, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { continue; } } else { - if (butPtr->textPtr != NULL) { + if (butPtr->textPtr) { Tcl_DecrRefCount(butPtr->textPtr); } butPtr->textPtr = valuePtr; @@ -1258,7 +1258,7 @@ ConfigureButton( } } - if ((butPtr->bitmap != None) || (butPtr->imagePtr != NULL)) { + if (butPtr->bitmap || butPtr->imagePtr) { /* * The button must display the contents of an image or bitmap. */ @@ -1366,17 +1366,17 @@ TkButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->normalTextGC != None) { + if (butPtr->normalTextGC) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } butPtr->normalTextGC = newGC; - if (butPtr->activeFg != NULL) { + if (butPtr->activeFg) { gcValues.foreground = butPtr->activeFg->pixel; gcValues.background = Tk_3DBorderColor(butPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->activeTextGC != None) { + if (butPtr->activeTextGC) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } butPtr->activeTextGC = newGC; @@ -1388,13 +1388,13 @@ TkButtonWorldChanged( * Create the GC that can be used for stippling */ - if (butPtr->stippleGC == None) { + if (!butPtr->stippleGC) { gcValues.foreground = gcValues.background; mask = GCForeground; - if (butPtr->gray == None) { + if (!butPtr->gray) { butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin, "gray50"); } - if (butPtr->gray != None) { + if (butPtr->gray) { gcValues.fill_style = FillStippled; gcValues.stipple = butPtr->gray; mask |= GCFillStyle | GCStipple; @@ -1408,18 +1408,18 @@ TkButtonWorldChanged( */ mask = GCForeground | GCBackground | GCFont; - if (butPtr->disabledFg != NULL) { + if (butPtr->disabledFg) { gcValues.foreground = butPtr->disabledFg->pixel; } else { gcValues.foreground = gcValues.background; } newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->disabledGC != None) { + if (butPtr->disabledGC) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } butPtr->disabledGC = newGC; - if (butPtr->copyGC == None) { + if (!butPtr->copyGC) { butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues); } diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index ecd57b8..101f7aa 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -296,11 +296,11 @@ CreateArc( arcPtr->fillColor = NULL; arcPtr->activeFillColor = NULL; arcPtr->disabledFillColor = NULL; - arcPtr->fillStipple = None; - arcPtr->activeFillStipple = None; - arcPtr->disabledFillStipple = None; + arcPtr->fillStipple = 0; + arcPtr->activeFillStipple = 0; + arcPtr->disabledFillStipple = 0; arcPtr->style = PIESLICE_STYLE; - arcPtr->fillGC = None; + arcPtr->fillGC = 0; /* * Process the arguments to fill in the item record. @@ -452,11 +452,11 @@ ConfigureArc( */ if (arcPtr->outline.activeWidth > arcPtr->outline.width || - arcPtr->outline.activeDash.number != 0 || - arcPtr->outline.activeColor != NULL || - arcPtr->outline.activeStipple != None || - arcPtr->activeFillColor != NULL || - arcPtr->activeFillStipple != None) { + arcPtr->outline.activeDash.number || + arcPtr->outline.activeColor || + arcPtr->outline.activeStipple || + arcPtr->activeFillColor || + arcPtr->activeFillStipple) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -493,9 +493,9 @@ ConfigureArc( mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = 0; } - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->outline.gc); } arcPtr->outline.gc = newGC; @@ -511,25 +511,23 @@ ConfigureArc( color = arcPtr->fillColor; stipple = arcPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (arcPtr->activeFillColor!=NULL) { + if (arcPtr->activeFillColor) { color = arcPtr->activeFillColor; } - if (arcPtr->activeFillStipple!=None) { + if (arcPtr->activeFillStipple) { stipple = arcPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { - if (arcPtr->disabledFillColor!=NULL) { + if (arcPtr->disabledFillColor) { color = arcPtr->disabledFillColor; } - if (arcPtr->disabledFillStipple!=None) { + if (arcPtr->disabledFillStipple) { stipple = arcPtr->disabledFillStipple; } } - if (arcPtr->style == ARC_STYLE) { - newGC = None; - } else if (color == NULL) { - newGC = None; + if ((arcPtr->style == ARC_STYLE) || !color) { + newGC = 0; } else { gcValues.foreground = color->pixel; if (arcPtr->style == CHORD_STYLE) { @@ -538,14 +536,14 @@ ConfigureArc( gcValues.arc_mode = ArcPieSlice; } mask = GCForeground|GCArcMode; - if (stipple != None) { + if (stipple) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->fillGC); } arcPtr->fillGC = newGC; @@ -600,25 +598,25 @@ DeleteArc( if (arcPtr->numOutlinePoints != 0) { ckfree((char *) arcPtr->outlinePtr); } - if (arcPtr->fillColor != NULL) { + if (arcPtr->fillColor) { Tk_FreeColor(arcPtr->fillColor); } - if (arcPtr->activeFillColor != NULL) { + if (arcPtr->activeFillColor) { Tk_FreeColor(arcPtr->activeFillColor); } - if (arcPtr->disabledFillColor != NULL) { + if (arcPtr->disabledFillColor) { Tk_FreeColor(arcPtr->disabledFillColor); } - if (arcPtr->fillStipple != None) { + if (arcPtr->fillStipple) { Tk_FreeBitmap(display, arcPtr->fillStipple); } - if (arcPtr->activeFillStipple != None) { + if (arcPtr->activeFillStipple) { Tk_FreeBitmap(display, arcPtr->activeFillStipple); } - if (arcPtr->disabledFillStipple != None) { + if (arcPtr->disabledFillStipple) { Tk_FreeBitmap(display, arcPtr->disabledFillStipple); } - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC) { Tk_FreeGC(display, arcPtr->fillGC); } } @@ -749,7 +747,7 @@ ComputeArcBbox( * drawn) and add one extra pixel just for safety. */ - if (arcPtr->outline.gc == None) { + if (!arcPtr->outline.gc) { tmp = 1; } else { tmp = (int) ((width + 1.0)/2.0 + 1); @@ -806,20 +804,20 @@ DisplayArc( if (arcPtr->outline.activeWidth>lineWidth) { lineWidth = arcPtr->outline.activeWidth; } - if (arcPtr->outline.activeDash.number != 0) { + if (arcPtr->outline.activeDash.number) { dashnumber = arcPtr->outline.activeDash.number; } - if (arcPtr->activeFillStipple != None) { + if (arcPtr->activeFillStipple) { stipple = arcPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { if (arcPtr->outline.disabledWidth > 0) { lineWidth = arcPtr->outline.disabledWidth; } - if (arcPtr->outline.disabledDash.number != 0) { + if (arcPtr->outline.disabledDash.number) { dashnumber = arcPtr->outline.disabledDash.number; } - if (arcPtr->disabledFillStipple != None) { + if (arcPtr->disabledFillStipple) { stipple = arcPtr->disabledFillStipple; } } @@ -848,8 +846,8 @@ DisplayArc( * window servers to crash and should be a no-op anyway. */ - if ((arcPtr->fillGC != None) && (extent != 0)) { - if (stipple != None) { + if ((arcPtr->fillGC) && (extent != 0)) { + if (stipple) { int w = 0; int h = 0; Tk_TSOffset *tsoffset = &arcPtr->tsoffset; @@ -878,14 +876,14 @@ DisplayArc( } XFillArc(display, drawable, arcPtr->fillGC, x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), start, extent); - if (stipple != None) { + if (stipple) { XSetTSOrigin(display, arcPtr->fillGC, 0, 0); } } - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc) { Tk_ChangeOutlineGC(canvas, itemPtr, &(arcPtr->outline)); - if (extent != 0) { + if (extent) { XDrawArc(display, drawable, arcPtr->outline.gc, x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), start, extent); } @@ -897,7 +895,7 @@ DisplayArc( * outline is dashed, because then polygons don't work. */ - if (lineWidth < 1.5 || dashnumber != 0) { + if (lineWidth < 1.5 || dashnumber) { Tk_CanvasDrawableCoords(canvas, arcPtr->center1[0], arcPtr->center1[1], &x1, &y1); Tk_CanvasDrawableCoords(canvas, arcPtr->center2[0], @@ -920,13 +918,13 @@ DisplayArc( } else { if (arcPtr->style == CHORD_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS, - display, drawable, arcPtr->outline.gc, None); + display, drawable, arcPtr->outline.gc, 0); } else if (arcPtr->style == PIESLICE_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS, - display, drawable, arcPtr->outline.gc, None); + display, drawable, arcPtr->outline.gc, 0); TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS, PIE_OUTLINE2_PTS, display, drawable, - arcPtr->outline.gc, None); + arcPtr->outline.gc, 0); } } @@ -1032,12 +1030,12 @@ ArcToPoint( return dist; } - if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { + if (arcPtr->fillGC || !arcPtr->outline.gc) { filled = 1; } else { filled = 0; } - if (arcPtr->outline.gc == None) { + if (!arcPtr->outline.gc) { width = 0.0; } @@ -1159,12 +1157,12 @@ ArcToArea( } } - if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { + if ((arcPtr->fillGC) || !arcPtr->outline.gc) { filled = 1; } else { filled = 0; } - if (arcPtr->outline.gc == None) { + if (!arcPtr->outline.gc) { width = 0.0; } @@ -1859,29 +1857,29 @@ ArcToPostscript( fillColor = arcPtr->fillColor; fillStipple = arcPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (arcPtr->outline.activeColor!=NULL) { + if (arcPtr->outline.activeColor) { color = arcPtr->outline.activeColor; } - if (arcPtr->outline.activeStipple!=None) { + if (arcPtr->outline.activeStipple) { stipple = arcPtr->outline.activeStipple; } - if (arcPtr->activeFillColor!=NULL) { + if (arcPtr->activeFillColor) { fillColor = arcPtr->activeFillColor; } - if (arcPtr->activeFillStipple!=None) { + if (arcPtr->activeFillStipple) { fillStipple = arcPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (arcPtr->outline.disabledColor!=NULL) { + if (arcPtr->outline.disabledColor) { color = arcPtr->outline.disabledColor; } - if (arcPtr->outline.disabledStipple!=None) { + if (arcPtr->outline.disabledStipple) { stipple = arcPtr->outline.disabledStipple; } - if (arcPtr->disabledFillColor!=NULL) { + if (arcPtr->disabledFillColor) { fillColor = arcPtr->disabledFillColor; } - if (arcPtr->disabledFillStipple!=None) { + if (arcPtr->disabledFillStipple) { fillStipple = arcPtr->disabledFillStipple; } } @@ -1891,7 +1889,7 @@ ArcToPostscript( * arc. */ - if (arcPtr->fillGC != None) { + if (arcPtr->fillGC) { sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); @@ -1908,12 +1906,12 @@ ArcToPostscript( if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple != None) { + if (fillStipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; } - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } } else { @@ -1925,7 +1923,7 @@ ArcToPostscript( * If there's an outline for the arc, draw it. */ - if (arcPtr->outline.gc != None) { + if (arcPtr->outline.gc) { sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); @@ -1948,7 +1946,7 @@ ArcToPostscript( != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK){ return TCL_ERROR; @@ -1965,7 +1963,7 @@ ArcToPostscript( != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 30aa429..6f38293 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -182,16 +182,16 @@ TkcCreateBitmap( */ bmapPtr->anchor = TK_ANCHOR_CENTER; - bmapPtr->bitmap = None; - bmapPtr->activeBitmap = None; - bmapPtr->disabledBitmap = None; + bmapPtr->bitmap = 0; + bmapPtr->activeBitmap = 0; + bmapPtr->disabledBitmap = 0; bmapPtr->fgColor = NULL; bmapPtr->activeFgColor = NULL; bmapPtr->disabledFgColor = NULL; bmapPtr->bgColor = NULL; bmapPtr->activeBgColor = NULL; bmapPtr->disabledBgColor = NULL; - bmapPtr->gc = None; + bmapPtr->gc = 0; /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x @@ -336,9 +336,9 @@ ConfigureBitmap( state = itemPtr->state; - if (bmapPtr->activeFgColor!=NULL || - bmapPtr->activeBgColor!=NULL || - bmapPtr->activeBitmap!=None) { + if (bmapPtr->activeFgColor || + bmapPtr->activeBgColor || + bmapPtr->activeBitmap) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -355,33 +355,33 @@ ConfigureBitmap( bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeFgColor!=NULL) { + if (bmapPtr->activeFgColor) { fgColor = bmapPtr->activeFgColor; } - if (bmapPtr->activeBgColor!=NULL) { + if (bmapPtr->activeBgColor) { bgColor = bmapPtr->activeBgColor; } - if (bmapPtr->activeBitmap!=None) { + if (bmapPtr->activeBitmap) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledFgColor!=NULL) { + if (bmapPtr->disabledFgColor) { fgColor = bmapPtr->disabledFgColor; } - if (bmapPtr->disabledBgColor!=NULL) { + if (bmapPtr->disabledBgColor) { bgColor = bmapPtr->disabledBgColor; } - if (bmapPtr->disabledBitmap!=None) { + if (bmapPtr->disabledBitmap) { bitmap = bmapPtr->disabledBitmap; } } - if (bitmap == None) { - newGC = None; + if (!bitmap) { + newGC = 0; } else { gcValues.foreground = fgColor->pixel; mask = GCForeground; - if (bgColor != NULL) { + if (bgColor) { gcValues.background = bgColor->pixel; mask |= GCBackground; } else { @@ -390,7 +390,7 @@ ConfigureBitmap( } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (bmapPtr->gc != None) { + if (bmapPtr->gc) { Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc); } bmapPtr->gc = newGC; @@ -424,34 +424,34 @@ DeleteBitmap( { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; - if (bmapPtr->bitmap != None) { + if (bmapPtr->bitmap) { Tk_FreeBitmap(display, bmapPtr->bitmap); } - if (bmapPtr->activeBitmap != None) { + if (bmapPtr->activeBitmap) { Tk_FreeBitmap(display, bmapPtr->activeBitmap); } - if (bmapPtr->disabledBitmap != None) { + if (bmapPtr->disabledBitmap) { Tk_FreeBitmap(display, bmapPtr->disabledBitmap); } - if (bmapPtr->fgColor != NULL) { + if (bmapPtr->fgColor) { Tk_FreeColor(bmapPtr->fgColor); } - if (bmapPtr->activeFgColor != NULL) { + if (bmapPtr->activeFgColor) { Tk_FreeColor(bmapPtr->activeFgColor); } - if (bmapPtr->disabledFgColor != NULL) { + if (bmapPtr->disabledFgColor) { Tk_FreeColor(bmapPtr->disabledFgColor); } - if (bmapPtr->bgColor != NULL) { + if (bmapPtr->bgColor) { Tk_FreeColor(bmapPtr->bgColor); } - if (bmapPtr->activeBgColor != NULL) { + if (bmapPtr->activeBgColor) { Tk_FreeColor(bmapPtr->activeBgColor); } - if (bmapPtr->disabledBgColor != NULL) { + if (bmapPtr->disabledBgColor) { Tk_FreeColor(bmapPtr->disabledBgColor); } - if (bmapPtr->gc != NULL) { + if (bmapPtr->gc) { Tk_FreeGC(display, bmapPtr->gc); } } @@ -490,11 +490,11 @@ ComputeBitmapBbox( } bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)bmapPtr) { - if (bmapPtr->activeBitmap!=None) { + if (bmapPtr->activeBitmap) { bitmap = bmapPtr->activeBitmap; } - } else if (state==TK_STATE_DISABLED) { - if (bmapPtr->disabledBitmap!=None) { + } else if (state == TK_STATE_DISABLED) { + if (bmapPtr->disabledBitmap) { bitmap = bmapPtr->disabledBitmap; } } @@ -502,7 +502,7 @@ ComputeBitmapBbox( x = (int) (bmapPtr->x + ((bmapPtr->x >= 0) ? 0.5 : - 0.5)); y = (int) (bmapPtr->y + ((bmapPtr->y >= 0) ? 0.5 : - 0.5)); - if (state==TK_STATE_HIDDEN || bitmap == None) { + if ((state == TK_STATE_HIDDEN) || !bitmap) { bmapPtr->header.x1 = bmapPtr->header.x2 = x; bmapPtr->header.y1 = bmapPtr->header.y2 = y; return; @@ -600,16 +600,16 @@ DisplayBitmap( } bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeBitmap!=None) { + if (bmapPtr->activeBitmap) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledBitmap!=None) { + if (bmapPtr->disabledBitmap) { bitmap = bmapPtr->disabledBitmap; } } - if (bitmap != None) { + if (bitmap) { if (x > bmapPtr->header.x1) { bmapX = x - bmapPtr->header.x1; bmapWidth = bmapPtr->header.x2 - x; @@ -868,28 +868,28 @@ BitmapToPostscript( bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeFgColor!=NULL) { + if (bmapPtr->activeFgColor) { fgColor = bmapPtr->activeFgColor; } - if (bmapPtr->activeBgColor!=NULL) { + if (bmapPtr->activeBgColor) { bgColor = bmapPtr->activeBgColor; } - if (bmapPtr->activeBitmap!=None) { + if (bmapPtr->activeBitmap) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledFgColor!=NULL) { + if (bmapPtr->disabledFgColor) { fgColor = bmapPtr->disabledFgColor; } - if (bmapPtr->disabledBgColor!=NULL) { + if (bmapPtr->disabledBgColor) { bgColor = bmapPtr->disabledBgColor; } - if (bmapPtr->disabledBitmap!=None) { + if (bmapPtr->disabledBitmap) { bitmap = bmapPtr->disabledBitmap; } } - if (bitmap == None) { + if (!bitmap) { return TCL_OK; } diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c index 9e928c7..134cc23 100644 --- a/generic/tkCanvImg.c +++ b/generic/tkCanvImg.c @@ -436,16 +436,16 @@ ComputeImageBbox( Tk_Image image; Tk_State state = imgPtr->header.state; - if(state == TK_STATE_NULL) { + if (state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } image = imgPtr->image; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)imgPtr) { - if (imgPtr->activeImage != NULL) { + if (imgPtr->activeImage) { image = imgPtr->activeImage; } } else if (state == TK_STATE_DISABLED) { - if (imgPtr->disabledImage != NULL) { + if (imgPtr->disabledImage) { image = imgPtr->disabledImage; } } @@ -453,7 +453,7 @@ ComputeImageBbox( x = (int) (imgPtr->x + ((imgPtr->x >= 0) ? 0.5 : - 0.5)); y = (int) (imgPtr->y + ((imgPtr->y >= 0) ? 0.5 : - 0.5)); - if ((state == TK_STATE_HIDDEN) || (image == None)) { + if ((state == TK_STATE_HIDDEN) || !image) { imgPtr->header.x1 = imgPtr->header.x2 = x; imgPtr->header.y1 = imgPtr->header.y2 = y; return; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index cce3460..78cf74c 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -303,7 +303,7 @@ CreateLine( linePtr->coordPtr = NULL; linePtr->capStyle = CapButt; linePtr->joinStyle = JoinRound; - linePtr->arrowGC = None; + linePtr->arrowGC = 0; linePtr->arrow = ARROWS_NONE; linePtr->arrowShapeA = (float)8.0; linePtr->arrowShapeB = (float)10.0; @@ -503,9 +503,9 @@ ConfigureLine( } if (linePtr->outline.activeWidth > linePtr->outline.width || - linePtr->outline.activeDash.number != 0 || - linePtr->outline.activeColor != NULL || - linePtr->outline.activeStipple != None) { + linePtr->outline.activeDash.number || + linePtr->outline.activeColor || + linePtr->outline.activeStipple) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -531,12 +531,12 @@ ConfigureLine( #endif arrowGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = arrowGC = None; + newGC = arrowGC = 0; } - if (linePtr->outline.gc != None) { + if (linePtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc); } - if (linePtr->arrowGC != None) { + if (linePtr->arrowGC) { Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC); } linePtr->outline.gc = newGC; @@ -552,7 +552,7 @@ ConfigureLine( linePtr->splineSteps = 100; } - if ((!linePtr->numPoints) || (state==TK_STATE_HIDDEN)) { + if (!linePtr->numPoints || (state==TK_STATE_HIDDEN)) { ComputeLineBbox(canvas, linePtr); return TCL_OK; } @@ -562,7 +562,7 @@ ConfigureLine( * line's endpoints (they were shortened when the arrowheads were added). */ - if ((linePtr->firstArrowPtr != NULL) && (linePtr->arrow != ARROWS_FIRST) + if (linePtr->firstArrowPtr && (linePtr->arrow != ARROWS_FIRST) && (linePtr->arrow != ARROWS_BOTH)) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; @@ -618,16 +618,16 @@ DeleteLine( LineItem *linePtr = (LineItem *) itemPtr; Tk_DeleteOutline(display, &(linePtr->outline)); - if (linePtr->coordPtr != NULL) { + if (linePtr->coordPtr) { ckfree((char *) linePtr->coordPtr); } - if (linePtr->arrowGC != None) { + if (linePtr->arrowGC) { Tk_FreeGC(display, linePtr->arrowGC); } - if (linePtr->firstArrowPtr != NULL) { + if (linePtr->firstArrowPtr) { ckfree((char *) linePtr->firstArrowPtr); } - if (linePtr->lastArrowPtr != NULL) { + if (linePtr->lastArrowPtr) { ckfree((char *) linePtr->lastArrowPtr); } } @@ -664,7 +664,7 @@ ComputeLineBbox( state = ((TkCanvas *)canvas)->canvas_state; } - if (!(linePtr->numPoints) || (state==TK_STATE_HIDDEN)) { + if (!(linePtr->numPoints) || (state == TK_STATE_HIDDEN)) { linePtr->header.x1 = -1; linePtr->header.x2 = -1; linePtr->header.y1 = -1; @@ -677,7 +677,7 @@ ComputeLineBbox( if (linePtr->outline.activeWidth>width) { width = linePtr->outline.activeWidth; } - } else if (state==TK_STATE_DISABLED) { + } else if (state == TK_STATE_DISABLED) { if (linePtr->outline.disabledWidth>0) { width = linePtr->outline.disabledWidth; } @@ -846,7 +846,7 @@ DisplayLine( int numPoints; Tk_State state = itemPtr->state; - if ((!linePtr->numPoints)||(linePtr->outline.gc==None)) { + if (!linePtr->numPoints || !linePtr->outline.gc) { return; } @@ -2251,7 +2251,7 @@ LineToPostscript( * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; - char buffer[64 + TCL_INTEGER_SPACE]; + char buffer[64 + 4*TCL_INTEGER_SPACE]; char *style; double width; @@ -2270,20 +2270,20 @@ LineToPostscript( if (linePtr->outline.activeWidth>width) { width = linePtr->outline.activeWidth; } - if (linePtr->outline.activeColor!=NULL) { + if (linePtr->outline.activeColor) { color = linePtr->outline.activeColor; } - if (linePtr->outline.activeStipple!=None) { + if (linePtr->outline.activeStipple) { stipple = linePtr->outline.activeStipple; } } else if (state==TK_STATE_DISABLED) { if (linePtr->outline.disabledWidth>0) { width = linePtr->outline.disabledWidth; } - if (linePtr->outline.disabledColor!=NULL) { + if (linePtr->outline.disabledColor) { color = linePtr->outline.disabledColor; } - if (linePtr->outline.disabledStipple!=None) { + if (linePtr->outline.disabledStipple) { stipple = linePtr->outline.disabledStipple; } } @@ -2301,7 +2301,7 @@ LineToPostscript( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; @@ -2319,7 +2319,7 @@ LineToPostscript( if ((!linePtr->smooth) || (linePtr->numPoints < 3)) { Tk_CanvasPsPath(interp, canvas, linePtr->coordPtr, linePtr->numPoints); } else { - if ((stipple == None) && linePtr->smooth->postscriptProc) { + if (!stipple && linePtr->smooth->postscriptProc) { linePtr->smooth->postscriptProc(interp, canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps); } else { @@ -2379,8 +2379,8 @@ LineToPostscript( * Output polygons for the arrowheads, if there are any. */ - if (linePtr->firstArrowPtr != NULL) { - if (stipple != None) { + if (linePtr->firstArrowPtr) { + if (stipple) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } if (ArrowheadPostscript(interp, canvas, linePtr, @@ -2389,7 +2389,7 @@ LineToPostscript( } } if (linePtr->lastArrowPtr != NULL) { - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } if (ArrowheadPostscript(interp, canvas, linePtr, @@ -2438,17 +2438,17 @@ ArrowheadPostscript( stipple = linePtr->outline.stipple; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)linePtr) { - if (linePtr->outline.activeStipple!=None) { + if (linePtr->outline.activeStipple) { stipple = linePtr->outline.activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (linePtr->outline.activeStipple!=None) { + if (linePtr->outline.activeStipple) { stipple = linePtr->outline.disabledStipple; } } Tk_CanvasPsPath(interp, canvas, arrowPtr, PTS_IN_ARROW); - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index b86bc63..9b210fa 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -276,10 +276,10 @@ CreatePolygon( polyPtr->fillColor = NULL; polyPtr->activeFillColor = NULL; polyPtr->disabledFillColor = NULL; - polyPtr->fillStipple = None; - polyPtr->activeFillStipple = None; - polyPtr->disabledFillStipple = None; - polyPtr->fillGC = None; + polyPtr->fillStipple = 0; + polyPtr->activeFillStipple = 0; + polyPtr->disabledFillStipple = 0; + polyPtr->fillGC = 0; polyPtr->smooth = NULL; polyPtr->splineSteps = 12; polyPtr->autoClosed = 0; @@ -459,11 +459,11 @@ ConfigurePolygon( state = itemPtr->state; if (polyPtr->outline.activeWidth > polyPtr->outline.width || - polyPtr->outline.activeDash.number != 0 || - polyPtr->outline.activeColor != NULL || - polyPtr->outline.activeStipple != None || - polyPtr->activeFillColor != NULL || - polyPtr->activeFillStipple != None) { + polyPtr->outline.activeDash.number || + polyPtr->outline.activeColor || + polyPtr->outline.activeStipple || + polyPtr->activeFillColor || + polyPtr->activeFillStipple) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -484,9 +484,9 @@ ConfigurePolygon( mask |= GCCapStyle|GCJoinStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = 0; } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc); } polyPtr->outline.gc = newGC; @@ -494,27 +494,27 @@ ConfigurePolygon( color = polyPtr->fillColor; stipple = polyPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (polyPtr->activeFillColor!=NULL) { + if (polyPtr->activeFillColor) { color = polyPtr->activeFillColor; } - if (polyPtr->activeFillStipple!=None) { + if (polyPtr->activeFillStipple) { stipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->disabledFillColor!=NULL) { color = polyPtr->disabledFillColor; } - if (polyPtr->disabledFillStipple!=None) { + if (polyPtr->disabledFillStipple) { stipple = polyPtr->disabledFillStipple; } } if (color == NULL) { - newGC = None; + newGC = 0; } else { gcValues.foreground = color->pixel; mask = GCForeground; - if (stipple != None) { + if (stipple) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -530,7 +530,7 @@ ConfigurePolygon( #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->fillGC); } polyPtr->fillGC = newGC; @@ -575,28 +575,28 @@ DeletePolygon( PolygonItem *polyPtr = (PolygonItem *) itemPtr; Tk_DeleteOutline(display,&(polyPtr->outline)); - if (polyPtr->coordPtr != NULL) { + if (polyPtr->coordPtr) { ckfree((char *) polyPtr->coordPtr); } - if (polyPtr->fillColor != NULL) { + if (polyPtr->fillColor) { Tk_FreeColor(polyPtr->fillColor); } - if (polyPtr->activeFillColor != NULL) { + if (polyPtr->activeFillColor) { Tk_FreeColor(polyPtr->activeFillColor); } - if (polyPtr->disabledFillColor != NULL) { + if (polyPtr->disabledFillColor) { Tk_FreeColor(polyPtr->disabledFillColor); } - if (polyPtr->fillStipple != None) { + if (polyPtr->fillStipple) { Tk_FreeBitmap(display, polyPtr->fillStipple); } - if (polyPtr->activeFillStipple != None) { + if (polyPtr->activeFillStipple) { Tk_FreeBitmap(display, polyPtr->activeFillStipple); } - if (polyPtr->disabledFillStipple != None) { + if (polyPtr->disabledFillStipple) { Tk_FreeBitmap(display, polyPtr->disabledFillStipple); } - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC) { Tk_FreeGC(display, polyPtr->fillGC); } } @@ -698,7 +698,7 @@ ComputePolygonBbox( } } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc) { tsoffset = &polyPtr->outline.tsoffset; if (tsoffset) { if (tsoffset->flags & TK_OFFSET_INDEX) { @@ -840,11 +840,11 @@ TkFillPolygon( * allocated. */ - if (gc != None && numPoints>3) { + if (gc && (numPoints > 3)) { XFillPolygon(display, drawable, gc, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (outlineGC != None) { + if (outlineGC) { XDrawLines(display, drawable, outlineGC, pointPtr, numPoints, CoordModeOrigin); } @@ -885,9 +885,9 @@ DisplayPolygon( Pixmap stipple = polyPtr->fillStipple; double linewidth = polyPtr->outline.width; - if (((polyPtr->fillGC == None) && (polyPtr->outline.gc == None)) || + if ((!polyPtr->fillGC && !polyPtr->outline.gc) || (polyPtr->numPoints < 1) || - (polyPtr->numPoints < 3 && polyPtr->outline.gc == None)) { + (polyPtr->numPoints < 3 && !polyPtr->outline.gc)) { return; } @@ -898,14 +898,14 @@ DisplayPolygon( if (polyPtr->outline.activeWidth>linewidth) { linewidth = polyPtr->outline.activeWidth; } - if (polyPtr->activeFillStipple != None) { + if (polyPtr->activeFillStipple) { stipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->outline.disabledWidth>0.0) { linewidth = polyPtr->outline.disabledWidth; } - if (polyPtr->disabledFillStipple != None) { + if (polyPtr->disabledFillStipple) { stipple = polyPtr->disabledFillStipple; } } @@ -915,7 +915,7 @@ DisplayPolygon( * reset the offset when done, since the GC is supposed to be read-only. */ - if ((stipple != None) && (polyPtr->fillGC != None)) { + if (stipple && polyPtr->fillGC) { Tk_TSOffset *tsoffset = &polyPtr->tsoffset; int w=0; int h=0; int flags = tsoffset->flags; @@ -977,11 +977,11 @@ DisplayPolygon( } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL); - if (polyPtr->fillGC != None) { + if (polyPtr->fillGC) { XFillPolygon(display, drawable, polyPtr->fillGC, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (polyPtr->outline.gc != None) { + if (polyPtr->outline.gc) { XDrawLines(display, drawable, polyPtr->outline.gc, pointPtr, numPoints, CoordModeOrigin); } @@ -990,7 +990,7 @@ DisplayPolygon( } } Tk_ResetOutlineGC(canvas, itemPtr, &(polyPtr->outline)); - if ((stipple != None) && (polyPtr->fillGC != None)) { + if (stipple && polyPtr->fillGC) { XSetTSOrigin(display, polyPtr->fillGC, 0, 0); } } @@ -1303,7 +1303,7 @@ PolygonToPoint( if (bestDist<=0.0) { goto donepoint; } - if ((polyPtr->outline.gc != None) && (polyPtr->joinStyle == JoinRound)) { + if (polyPtr->outline.gc && (polyPtr->joinStyle == JoinRound)) { dist = bestDist - radius; if (dist <= 0.0) { bestDist = 0.0; @@ -1313,7 +1313,7 @@ PolygonToPoint( } } - if ((polyPtr->outline.gc == None) || (width <= 1)) { + if (!polyPtr->outline.gc || (width <= 1)) { goto donepoint; } @@ -1520,7 +1520,7 @@ PolygonToArea( goto donearea; } - if (polyPtr->outline.gc == None) { + if (!polyPtr->outline.gc) { goto donearea; } @@ -1830,32 +1830,32 @@ PolygonToPostscript( if (polyPtr->outline.activeWidth>width) { width = polyPtr->outline.activeWidth; } - if (polyPtr->outline.activeColor!=NULL) { + if (polyPtr->outline.activeColor) { color = polyPtr->outline.activeColor; } - if (polyPtr->outline.activeStipple!=None) { + if (polyPtr->outline.activeStipple) { stipple = polyPtr->outline.activeStipple; } - if (polyPtr->activeFillColor!=NULL) { + if (polyPtr->activeFillColor) { fillColor = polyPtr->activeFillColor; } - if (polyPtr->activeFillStipple!=None) { + if (polyPtr->activeFillStipple) { fillStipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->outline.disabledWidth>0.0) { width = polyPtr->outline.disabledWidth; } - if (polyPtr->outline.disabledColor!=NULL) { + if (polyPtr->outline.disabledColor) { color = polyPtr->outline.disabledColor; } - if (polyPtr->outline.disabledStipple!=None) { + if (polyPtr->outline.disabledStipple) { stipple = polyPtr->outline.disabledStipple; } - if (polyPtr->disabledFillColor!=NULL) { + if (polyPtr->disabledFillColor) { fillColor = polyPtr->disabledFillColor; } - if (polyPtr->disabledFillStipple!=None) { + if (polyPtr->disabledFillStipple) { fillStipple = polyPtr->disabledFillStipple; } } @@ -1873,7 +1873,7 @@ PolygonToPostscript( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; @@ -1899,7 +1899,7 @@ PolygonToPostscript( if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple != None) { + if (fillStipple) { Tcl_AppendResult(interp, "eoclip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; @@ -1916,7 +1916,7 @@ PolygonToPostscript( * Now draw the outline, if there is one. */ - if (color != NULL) { + if (color) { if (!polyPtr->smooth || !polyPtr->smooth->postscriptProc) { Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints); diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 24c3c7f..e187871 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -253,9 +253,9 @@ CreateText( textPtr->disabledColor = NULL; textPtr->tkfont = NULL; textPtr->justify = TK_JUSTIFY_LEFT; - textPtr->stipple = None; - textPtr->activeStipple = None; - textPtr->disabledStipple = None; + textPtr->stipple = 0; + textPtr->activeStipple = 0; + textPtr->disabledStipple = 0; textPtr->text = NULL; textPtr->width = 0; textPtr->underline = -1; @@ -265,9 +265,9 @@ CreateText( textPtr->textLayout = NULL; textPtr->leftEdge = 0; textPtr->rightEdge = 0; - textPtr->gc = None; - textPtr->selTextGC = None; - textPtr->cursorOffGC = None; + textPtr->gc = 0; + textPtr->selTextGC = 0; + textPtr->cursorOffGC = 0; /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x @@ -414,7 +414,7 @@ ConfigureText( state = itemPtr->state; - if (textPtr->activeColor != NULL || textPtr->activeStipple != None) { + if (textPtr->activeColor || textPtr->activeStipple) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -427,29 +427,29 @@ ConfigureText( color = textPtr->color; stipple = textPtr->stipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (textPtr->activeColor!=NULL) { + if (textPtr->activeColor) { color = textPtr->activeColor; } - if (textPtr->activeStipple!=None) { + if (textPtr->activeStipple) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledColor!=NULL) { + if (textPtr->disabledColor) { color = textPtr->disabledColor; } - if (textPtr->disabledStipple!=None) { + if (textPtr->disabledStipple) { stipple = textPtr->disabledStipple; } } - newGC = newSelGC = None; - if (textPtr->tkfont != NULL) { + newGC = newSelGC = 0; + if (textPtr->tkfont) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; - if (color != NULL) { + if (color) { gcValues.foreground = color->pixel; mask |= GCForeground; - if (stipple != None) { + if (stipple) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -457,7 +457,7 @@ ConfigureText( newGC = Tk_GetGC(tkwin, mask, &gcValues); } mask &= ~(GCTile|GCFillStyle|GCStipple); - if (stipple != None) { + if (stipple) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -467,11 +467,11 @@ ConfigureText( } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } - if (textPtr->gc != None) { + if (textPtr->gc) { Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; - if (textPtr->selTextGC != None) { + if (textPtr->selTextGC) { Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC); } textPtr->selTextGC = newSelGC; @@ -486,9 +486,9 @@ ConfigureText( } newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); } else { - newGC = None; + newGC = 0; } - if (textPtr->cursorOffGC != None) { + if (textPtr->cursorOffGC) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); } textPtr->cursorOffGC = newGC; @@ -548,37 +548,37 @@ DeleteText( { TextItem *textPtr = (TextItem *) itemPtr; - if (textPtr->color != NULL) { + if (textPtr->color) { Tk_FreeColor(textPtr->color); } - if (textPtr->activeColor != NULL) { + if (textPtr->activeColor) { Tk_FreeColor(textPtr->activeColor); } - if (textPtr->disabledColor != NULL) { + if (textPtr->disabledColor) { Tk_FreeColor(textPtr->disabledColor); } Tk_FreeFont(textPtr->tkfont); - if (textPtr->stipple != None) { + if (textPtr->stipple) { Tk_FreeBitmap(display, textPtr->stipple); } - if (textPtr->activeStipple != None) { + if (textPtr->activeStipple) { Tk_FreeBitmap(display, textPtr->activeStipple); } - if (textPtr->disabledStipple != None) { + if (textPtr->disabledStipple) { Tk_FreeBitmap(display, textPtr->disabledStipple); } - if (textPtr->text != NULL) { + if (textPtr->text) { ckfree(textPtr->text); } Tk_FreeTextLayout(textPtr->textLayout); - if (textPtr->gc != None) { + if (textPtr->gc) { Tk_FreeGC(display, textPtr->gc); } - if (textPtr->selTextGC != None) { + if (textPtr->selTextGC) { Tk_FreeGC(display, textPtr->selTextGC); } - if (textPtr->cursorOffGC != None) { + if (textPtr->cursorOffGC) { Tk_FreeGC(display, textPtr->cursorOffGC); } } @@ -731,16 +731,16 @@ DisplayCanvText( } stipple = textPtr->stipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (textPtr->activeStipple!=None) { + if (textPtr->activeStipple) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledStipple!=None) { + if (textPtr->disabledStipple) { stipple = textPtr->disabledStipple; } } - if (textPtr->gc == None) { + if (!textPtr->gc) { return; } @@ -750,7 +750,7 @@ DisplayCanvText( * read-only. */ - if (stipple != None) { + if (stipple) { Tk_CanvasSetOffset(canvas, textPtr->gc, &textPtr->tsoffset); } @@ -830,7 +830,7 @@ DisplayCanvText( drawableX, drawableY, textInfoPtr->insertWidth, height, textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED); - } else if (textPtr->cursorOffGC != None) { + } else if (textPtr->cursorOffGC) { /* * Redraw the background over the area of the cursor, even * though the cursor is turned off. This guarantees that the @@ -874,7 +874,7 @@ DisplayCanvText( Tk_UnderlineTextLayout(display, drawable, textPtr->gc, textPtr->textLayout, drawableX, drawableY, textPtr->underline); - if (stipple != None) { + if (stipple) { XSetTSOrigin(display, textPtr->gc, 0, 0); } } @@ -1447,14 +1447,14 @@ TextToPostscript( if (textPtr->activeColor!=NULL) { color = textPtr->activeColor; } - if (textPtr->activeStipple!=None) { + if (textPtr->activeStipple) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledColor!=NULL) { + if (textPtr->disabledColor) { color = textPtr->disabledColor; } - if (textPtr->disabledStipple!=None) { + if (textPtr->disabledStipple) { stipple = textPtr->disabledStipple; } } @@ -1462,13 +1462,13 @@ TextToPostscript( if (Tk_CanvasPsFont(interp, canvas, textPtr->tkfont) != TCL_OK) { return TCL_ERROR; } - if (prepass != 0) { + if (prepass) { return TCL_OK; } if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "/StippleText {\n ", NULL); Tk_CanvasPsStipple(interp, canvas, stipple); Tcl_AppendResult(interp, "} bind def\n", NULL); @@ -1506,7 +1506,7 @@ TextToPostscript( Tcl_PrintDouble(NULL, y / 2.0, buffer); Tcl_AppendResult(interp, " ", buffer, NULL); sprintf(buffer, " %s %s DrawText\n", - justify, ((stipple == None) ? "false" : "true")); + justify, (stipple ? "true" : "false")); Tcl_AppendResult(interp, buffer, NULL); return TCL_OK; diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index 08aeab7..cacceda 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -959,7 +959,7 @@ void Tk_CreateOutline( Tk_Outline *outline) /* Outline structure to be filled in. */ { - outline->gc = None; + outline->gc = 0; outline->width = 1.0; outline->activeWidth = 0.0; outline->disabledWidth = 0.0; @@ -973,9 +973,9 @@ Tk_CreateOutline( outline->color = NULL; outline->activeColor = NULL; outline->disabledColor = NULL; - outline->stipple = None; - outline->activeStipple = None; - outline->disabledStipple = None; + outline->stipple = 0; + outline->activeStipple = 0; + outline->disabledStipple = 0; } /* @@ -1000,7 +1000,7 @@ Tk_DeleteOutline( Display *display, /* Display containing window. */ Tk_Outline *outline) { - if (outline->gc != None) { + if (outline->gc) { Tk_FreeGC(display, outline->gc); } if ((unsigned int)ABS(outline->dash.number) > sizeof(char *)) { @@ -1012,22 +1012,22 @@ Tk_DeleteOutline( if ((unsigned int)ABS(outline->disabledDash.number) > sizeof(char *)) { ckfree((char *) outline->disabledDash.pattern.pt); } - if (outline->color != NULL) { + if (outline->color) { Tk_FreeColor(outline->color); } - if (outline->activeColor != NULL) { + if (outline->activeColor) { Tk_FreeColor(outline->activeColor); } - if (outline->disabledColor != NULL) { + if (outline->disabledColor) { Tk_FreeColor(outline->disabledColor); } - if (outline->stipple != None) { + if (outline->stipple) { Tk_FreeBitmap(display, outline->stipple); } - if (outline->activeStipple != None) { + if (outline->activeStipple) { Tk_FreeBitmap(display, outline->activeStipple); } - if (outline->disabledStipple != None) { + if (outline->disabledStipple) { Tk_FreeBitmap(display, outline->disabledStipple); } } @@ -1093,26 +1093,26 @@ Tk_ConfigOutlineGC( if (outline->activeWidth>width) { width = outline->activeWidth; } - if (outline->activeDash.number != 0) { + if (outline->activeDash.number) { dash = &(outline->activeDash); } - if (outline->activeColor!=NULL) { + if (outline->activeColor) { color = outline->activeColor; } - if (outline->activeStipple!=None) { + if (outline->activeStipple) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth>0) { width = outline->disabledWidth; } - if (outline->disabledDash.number != 0) { + if (outline->disabledDash.number) { dash = &(outline->disabledDash); } - if (outline->disabledColor!=NULL) { + if (outline->disabledColor) { color = outline->disabledColor; } - if (outline->disabledStipple!=None) { + if (outline->disabledStipple) { stipple = outline->disabledStipple; } } @@ -1125,18 +1125,18 @@ Tk_ConfigOutlineGC( if (color != NULL) { gcValues->foreground = color->pixel; mask = GCForeground|GCLineWidth; - if (stipple != None) { + if (stipple) { gcValues->stipple = stipple; gcValues->fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } } - if (mask && (dash->number != 0)) { + if (mask && dash->number) { gcValues->line_style = LineOnOffDash; gcValues->dash_offset = outline->offset; if ((unsigned int)ABS(dash->number) > sizeof(char *)) { gcValues->dashes = dash->pattern.pt[0]; - } else if (dash->number != 0) { + } else if (dash->number) { gcValues->dashes = dash->pattern.array[0]; } else { gcValues->dashes = (char) (4 * width + 0.5); @@ -1191,30 +1191,30 @@ Tk_ChangeOutlineGC( if (outline->activeWidth > width) { width = outline->activeWidth; } - if (outline->activeDash.number != 0) { + if (outline->activeDash.number) { dash = &(outline->activeDash); } - if (outline->activeColor != NULL) { + if (outline->activeColor) { color = outline->activeColor; } - if (outline->activeStipple != None) { + if (outline->activeStipple) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth > width) { width = outline->disabledWidth; } - if (outline->disabledDash.number != 0) { + if (outline->disabledDash.number) { dash = &(outline->disabledDash); } - if (outline->disabledColor != NULL) { + if (outline->disabledColor) { color = outline->disabledColor; } - if (outline->disabledStipple != None) { + if (outline->disabledStipple) { stipple = outline->disabledStipple; } } - if (color==NULL) { + if (!color) { return 0; } @@ -1236,7 +1236,7 @@ Tk_ChangeOutlineGC( XSetDashes(((TkCanvas *)canvas)->display, outline->gc, outline->offset, p, dash->number); } - if (stipple!=None) { + if (stipple) { int w=0; int h=0; Tk_TSOffset *tsoffset = &outline->tsoffset; int flags = tsoffset->flags; @@ -1310,26 +1310,26 @@ Tk_ResetOutlineGC( if (outline->activeWidth>width) { width = outline->activeWidth; } - if (outline->activeDash.number != 0) { + if (outline->activeDash.number) { dash = &(outline->activeDash); } - if (outline->activeColor!=NULL) { + if (outline->activeColor) { color = outline->activeColor; } - if (outline->activeStipple!=None) { + if (outline->activeStipple) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth>width) { width = outline->disabledWidth; } - if (outline->disabledDash.number != 0) { + if (outline->disabledDash.number) { dash = &(outline->disabledDash); } - if (outline->disabledColor!=NULL) { + if (outline->disabledColor) { color = outline->disabledColor; } - if (outline->disabledStipple!=None) { + if (outline->disabledStipple) { stipple = outline->disabledStipple; } } @@ -1342,7 +1342,7 @@ Tk_ResetOutlineGC( ((dash->number == -1) && (dash->pattern.array[0] != ','))) { if ((unsigned int)ABS(dash->number) > sizeof(char *)) { dashList = dash->pattern.pt[0]; - } else if (dash->number != 0) { + } else if (dash->number) { dashList = dash->pattern.array[0]; } else { dashList = (char) (4 * width + 0.5); @@ -1350,7 +1350,7 @@ Tk_ResetOutlineGC( XSetDashes(((TkCanvas *)canvas)->display, outline->gc, outline->offset, &dashList , 1); } - if (stipple != None) { + if (stipple) { XSetTSOrigin(((TkCanvas *)canvas)->display, outline->gc, 0, 0); return 1; } @@ -1409,10 +1409,10 @@ Tk_CanvasPsOutline( if (outline->activeDash.number > 0) { dash = &(outline->activeDash); } - if (outline->activeColor != NULL) { + if (outline->activeColor) { color = outline->activeColor; } - if (outline->activeStipple != None) { + if (outline->activeStipple) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { @@ -1422,10 +1422,10 @@ Tk_CanvasPsOutline( if (outline->disabledDash.number > 0) { dash = &(outline->disabledDash); } - if (outline->disabledColor != NULL) { + if (outline->disabledColor) { color = outline->disabledColor; } - if (outline->disabledStipple != None) { + if (outline->disabledStipple) { stipple = outline->disabledStipple; } } @@ -1482,7 +1482,7 @@ Tk_CanvasPsOutline( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple != None) { + if (stipple) { Tcl_AppendResult(interp, "StrokeClip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c index b62859c..c5ecf1a 100644 --- a/generic/tkCanvWind.c +++ b/generic/tkCanvWind.c @@ -583,7 +583,7 @@ DisplayWinItem( * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ - if (state == TK_STATE_HIDDEN || drawable == None) { + if (state == TK_STATE_HIDDEN || !drawable) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 8ebe9ba..27a3a32 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -417,9 +417,9 @@ Tk_CanvasObjCmd( canvasPtr->highlightBgColorPtr = NULL; canvasPtr->highlightColorPtr = NULL; canvasPtr->inset = 0; - canvasPtr->pixmapGC = None; - canvasPtr->width = None; - canvasPtr->height = None; + canvasPtr->pixmapGC = 0; + canvasPtr->width = 0; + canvasPtr->height = 0; canvasPtr->confine = 0; canvasPtr->textInfo.selBorder = NULL; canvasPtr->textInfo.selBorderWidth = 0; @@ -463,7 +463,7 @@ Tk_CanvasObjCmd( canvasPtr->scanYOrigin = 0; canvasPtr->hotPtr = NULL; canvasPtr->hotPrevPtr = NULL; - canvasPtr->cursor = None; + canvasPtr->cursor = 0; canvasPtr->takeFocus = NULL; canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(newWin)); canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(newWin)); @@ -1834,7 +1834,7 @@ DestroyCanvas( */ Tcl_DeleteHashTable(&canvasPtr->idTable); - if (canvasPtr->pixmapGC != None) { + if (canvasPtr->pixmapGC) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } #ifndef USE_OLD_TAG_SEARCH @@ -1910,7 +1910,7 @@ ConfigureCanvas( gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel; newGC = Tk_GetGC(canvasPtr->tkwin, GCFunction|GCGraphicsExposures|GCForeground, &gcValues); - if (canvasPtr->pixmapGC != None) { + if (canvasPtr->pixmapGC) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } canvasPtr->pixmapGC = newGC; @@ -2405,7 +2405,7 @@ CanvasEventProc( itemPtr = itemPtr->nextPtr) { if (itemPtr->typePtr->alwaysRedraw & 1) { (*itemPtr->typePtr->displayProc)((Tk_Canvas) canvasPtr, - itemPtr, canvasPtr->display, None, 0, 0, 0, 0); + itemPtr, canvasPtr->display, 0, 0, 0, 0, 0); } } } @@ -4545,7 +4545,7 @@ PickCurrentItem( canvasPtr->pickEvent.xcrossing.display = eventPtr->xmotion.display; canvasPtr->pickEvent.xcrossing.window = eventPtr->xmotion.window; canvasPtr->pickEvent.xcrossing.root = eventPtr->xmotion.root; - canvasPtr->pickEvent.xcrossing.subwindow = None; + canvasPtr->pickEvent.xcrossing.subwindow = 0; canvasPtr->pickEvent.xcrossing.time = eventPtr->xmotion.time; canvasPtr->pickEvent.xcrossing.x = eventPtr->xmotion.x; canvasPtr->pickEvent.xcrossing.y = eventPtr->xmotion.y; diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index c6748a1..4c564e7 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -654,7 +654,7 @@ TkClipInit( Tk_ChangeWindowAttributes(dispPtr->clipWindow, CWOverrideRedirect, &atts); Tk_MakeWindowExist(dispPtr->clipWindow); - if (dispPtr->multipleAtom == None) { + if (!dispPtr->multipleAtom) { /* * Need to invoke selection initialization to make sure that atoms we * depend on below are defined. diff --git a/generic/tkColor.c b/generic/tkColor.c index 76d0baa..1ec4ab1 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -242,7 +242,7 @@ Tk_GetColor( */ tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = None; + tkColPtr->gc = 0; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = Tk_Colormap(tkwin); tkColPtr->visual = Tk_Visual(tkwin); @@ -323,7 +323,7 @@ Tk_GetColorByValue( tkColPtr = TkpGetColorByValue(tkwin, colorPtr); tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = None; + tkColPtr->gc = 0; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = valueKey.colormap; tkColPtr->visual = Tk_Visual(tkwin); @@ -414,7 +414,7 @@ Tk_GCForColor( Tcl_Panic("Tk_GCForColor called with bogus color"); } - if (tkColPtr->gc == None) { + if (!tkColPtr->gc) { gcValues.foreground = tkColPtr->color.pixel; tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable, GCForeground, &gcValues); @@ -469,9 +469,9 @@ Tk_FreeColor( * longer any objects referencing it. */ - if (tkColPtr->gc != None) { + if (tkColPtr->gc) { XFreeGC(DisplayOfScreen(screen), tkColPtr->gc); - tkColPtr->gc = None; + tkColPtr->gc = 0; } TkpFreeColor(tkColPtr); diff --git a/generic/tkConfig.c b/generic/tkConfig.c index f2eaa33..5fcbab8 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -802,10 +802,10 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newBitmap = None; + newBitmap = 0; } else { newBitmap = Tk_AllocBitmapFromObj(interp, tkwin, valuePtr); - if (newBitmap == None) { + if (!newBitmap) { return TCL_ERROR; } } @@ -854,11 +854,11 @@ DoObjConfig( Tk_Cursor newCursor; if (nullOK && ObjectIsEmpty(valuePtr)) { - newCursor = None; + newCursor = 0; valuePtr = NULL; } else { newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr); - if (newCursor == None) { + if (!newCursor) { return TCL_ERROR; } } @@ -916,7 +916,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newWin = None; + newWin = 0; } else { if (TkGetWindowFromObj(interp, tkwin, valuePtr, &newWin) != TCL_OK) { @@ -1680,9 +1680,9 @@ FreeResources( break; case TK_OPTION_BITMAP: if (internalFormExists) { - if (*((Pixmap *) internalPtr) != None) { + if (*((Pixmap *) internalPtr)) { Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *) internalPtr)); - *((Pixmap *) internalPtr) = None; + *((Pixmap *) internalPtr) = 0; } } else if (objPtr != NULL) { Tk_FreeBitmapFromObj(tkwin, objPtr); @@ -1700,9 +1700,9 @@ FreeResources( break; case TK_OPTION_CURSOR: if (internalFormExists) { - if (*((Tk_Cursor *) internalPtr) != None) { + if (*((Tk_Cursor *) internalPtr)) { Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr)); - *((Tk_Cursor *) internalPtr) = None; + *((Tk_Cursor *) internalPtr) = 0; } } else if (objPtr != NULL) { Tk_FreeCursorFromObj(tkwin, objPtr); @@ -1954,7 +1954,7 @@ GetObjectForOption( case TK_OPTION_BITMAP: { Pixmap pixmap = *((Pixmap *) internalPtr); - if (pixmap != None) { + if (pixmap) { objPtr = Tcl_NewStringObj( Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), -1); } @@ -1974,7 +1974,7 @@ GetObjectForOption( case TK_OPTION_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) internalPtr); - if (cursor != None) { + if (cursor) { objPtr = Tcl_NewStringObj( Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1); } diff --git a/generic/tkCursor.c b/generic/tkCursor.c index 410aea9..ced2534 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -149,7 +149,7 @@ Tk_AllocCursorFromObj( cursorPtr = TkcGetCursor(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = (void *) cursorPtr; if (cursorPtr == NULL) { - return None; + return 0; } cursorPtr->objRefCount++; return cursorPtr->cursor; @@ -187,10 +187,7 @@ Tk_GetCursor( * details on legal syntax. */ { TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); - if (cursorPtr == NULL) { - return None; - } - return cursorPtr->cursor; + return cursorPtr ? cursorPtr->cursor : 0; } /* @@ -382,7 +379,7 @@ Tk_GetCursorFromData( error: Tcl_DeleteHashEntry(dataHashPtr); - return None; + return 0; } /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 9f43f90..5eaca77 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -523,16 +523,16 @@ Tk_EntryObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = None; + entryPtr->cursor = 0; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = None; - entryPtr->selTextGC = None; - entryPtr->highlightGC = None; + entryPtr->textGC = 0; + entryPtr->selTextGC = 0; + entryPtr->highlightGC = 0; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; @@ -1030,10 +1030,10 @@ DestroyEntry( EntryTextVarProc, (ClientData) entryPtr); entryPtr->flags &= ~ENTRY_VAR_TRACED; } - if (entryPtr->textGC != None) { + if (entryPtr->textGC) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } - if (entryPtr->selTextGC != None) { + if (entryPtr->selTextGC) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler); @@ -1043,7 +1043,7 @@ DestroyEntry( if (entryPtr->type == TK_SPINBOX) { Spinbox *sbPtr = (Spinbox *) entryPtr; - if (sbPtr->listObj != NULL) { + if (sbPtr->listObj) { Tcl_DecrRefCount(sbPtr->listObj); sbPtr->listObj = NULL; } @@ -1423,7 +1423,7 @@ EntryWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = None; + GC gc = 0; unsigned long mask; Tk_3DBorder border; XColor *colorPtr; @@ -1475,18 +1475,18 @@ EntryWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->textGC != None) { + if (entryPtr->textGC) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } entryPtr->textGC = gc; - if (entryPtr->selFgColorPtr != NULL) { + if (entryPtr->selFgColorPtr) { gcValues.foreground = entryPtr->selFgColorPtr->pixel; } gcValues.font = Tk_FontId(entryPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->selTextGC != None) { + if (entryPtr->selTextGC) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } entryPtr->selTextGC = gc; @@ -2451,9 +2451,9 @@ EntryEventProc( } else if ((elem == SEL_BUTTONDOWN) || (elem == SEL_BUTTONUP)) { cursor = sbPtr->bCursor; } else { - cursor = None; + cursor = 0; } - if (cursor != None) { + if (cursor) { Tk_DefineCursor(entryPtr->tkwin, cursor); } else { Tk_UndefineCursor(entryPtr->tkwin); @@ -3591,22 +3591,22 @@ Tk_SpinboxObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = None; + entryPtr->cursor = 0; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = None; - entryPtr->selTextGC = None; - entryPtr->highlightGC = None; + entryPtr->textGC = 0; + entryPtr->selTextGC = 0; + entryPtr->highlightGC = 0; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; sbPtr->selElement = SEL_NONE; sbPtr->curElement = SEL_NONE; - sbPtr->bCursor = None; + sbPtr->bCursor = 0; sbPtr->repeatDelay = 400; sbPtr->repeatInterval = 100; sbPtr->fromValue = 0.0; diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 7f8aa1f..2ea7936 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 747555e..ac5b68c 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -421,11 +421,11 @@ GetTkWindowFromXEvent( } TkSelPropProc(eventPtr); parentXId = ParentXId(eventPtr->xany.display, handlerWindow); - if (parentXId == None) { + if (!parentXId) { return NULL; } winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, parentXId); - if (winPtr == NULL) { + if (!winPtr) { return NULL; } if (!(winPtr->flags & TK_PROP_PROPCHANGE)) { @@ -601,7 +601,7 @@ UpdateButtonEventState( case ButtonRelease: dispPtr = TkGetDisplay(eventPtr->xbutton.display); - dispPtr->mouseButtonWindow = None; + dispPtr->mouseButtonWindow = 0; dispPtr->mouseButtonState &= ~GetButtonMask(eventPtr->xbutton.button); eventPtr->xbutton.state |= dispPtr->mouseButtonState; break; @@ -617,7 +617,7 @@ UpdateButtonEventState( */ dispPtr->mouseButtonState &= ~allButtonsMask; - dispPtr->mouseButtonWindow = None; + dispPtr->mouseButtonWindow = 0; } else { eventPtr->xmotion.state |= dispPtr->mouseButtonState; } @@ -1192,7 +1192,7 @@ ParentXId( XFree(childList); } if (status == 0) { - parent = None; + parent = 0; } return parent; @@ -1365,7 +1365,7 @@ Tk_HandleEvent( * handle CreateNotify events, so we gotta pass 'em through. */ - if ((ip.winPtr != None) + if ((ip.winPtr) && ((mask != SubstructureNotifyMask) || (eventPtr->type == CreateNotify))) { TkBindEventProc(winPtr, eventPtr); @@ -1379,7 +1379,7 @@ Tk_HandleEvent( */ releaseInterpreter: - if (interp != NULL) { + if (interp) { Tcl_Release((ClientData) interp); } @@ -1427,7 +1427,7 @@ TkEventDeadWindow( * to quit (all of the handlers are being deleted). */ - while (winPtr->handlerList != NULL) { + while (winPtr->handlerList) { handlerPtr = winPtr->handlerList; winPtr->handlerList = handlerPtr->nextPtr; for (ipPtr = tsdPtr->pendingPtr; ipPtr != NULL; @@ -1436,7 +1436,7 @@ TkEventDeadWindow( ipPtr->nextHandler = NULL; } if (ipPtr->winPtr == winPtr) { - ipPtr->winPtr = None; + ipPtr->winPtr = 0; } } ckfree((char *) handlerPtr); diff --git a/generic/tkFrame.c b/generic/tkFrame.c index 0c3c016..ef1338e 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -487,7 +487,7 @@ CreateFrame( */ className = colormapName = screenName = visualName = useOption = NULL; - colormap = None; + colormap = 0; for (i = 2; i < objc; i += 2) { arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { @@ -591,14 +591,14 @@ CreateFrame( if (visualName != NULL) { visual = Tk_GetVisual(interp, newWin, visualName, &depth, (colormapName == NULL) ? &colormap : NULL); - if (visual == NULL) { + if (!visual) { goto error; } Tk_SetWindowVisual(newWin, visual, depth, colormap); } - if (colormapName != NULL) { + if (colormapName) { colormap = Tk_GetColormap(interp, newWin, colormapName); - if (colormap == None) { + if (!colormap) { goto error; } Tk_SetWindowColormap(newWin, colormap); @@ -637,12 +637,12 @@ CreateFrame( framePtr->type = type; framePtr->colormap = colormap; framePtr->relief = TK_RELIEF_FLAT; - framePtr->cursor = None; + framePtr->cursor = 0; if (framePtr->type == TYPE_LABELFRAME) { Labelframe *labelframePtr = (Labelframe *) framePtr; labelframePtr->labelAnchor = LABELANCHOR_NW; - labelframePtr->textGC = None; + labelframePtr->textGC = 0; } /* @@ -840,11 +840,11 @@ DestroyFrame( if (framePtr->type == TYPE_LABELFRAME) { Tk_FreeTextLayout(labelframePtr->textLayout); - if (labelframePtr->textGC != None) { + if (labelframePtr->textGC) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } } - if (framePtr->colormap != None) { + if (framePtr->colormap) { Tk_FreeColormap(framePtr->display, framePtr->colormap); } ckfree((char *) framePtr); @@ -967,7 +967,7 @@ ConfigureFrame( if (framePtr->border != NULL) { Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border); } else { - Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); + Tk_SetWindowBackgroundPixmap(framePtr->tkwin, 0); } if (framePtr->highlightWidth < 0) { @@ -1096,7 +1096,7 @@ FrameWorldChanged( gcValues.graphics_exposures = False; gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures, &gcValues); - if (labelframePtr->textGC != None) { + if (labelframePtr->textGC) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } labelframePtr->textGC = gc; @@ -1528,8 +1528,8 @@ DisplayFrame( labelframePtr->labelTextX + LABELSPACING, labelframePtr->labelTextY + LABELSPACING, 0, -1); - if (clipRegion != NULL) { - XSetClipMask(framePtr->display, labelframePtr->textGC, None); + if (clipRegion) { + XSetClipMask(framePtr->display, labelframePtr->textGC, 0); TkDestroyRegion(clipRegion); } } else { diff --git a/generic/tkGC.c b/generic/tkGC.c index 800e4d3..c0864d0 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -155,12 +155,12 @@ Tk_GetGC( if (valueMask & GCTile) { valueKey.values.tile = valuePtr->tile; } else { - valueKey.values.tile = None; + valueKey.values.tile = 0; } if (valueMask & GCStipple) { valueKey.values.stipple = valuePtr->stipple; } else { - valueKey.values.stipple = None; + valueKey.values.stipple = 0; } if (valueMask & GCTileStipXOrigin) { valueKey.values.ts_x_origin = valuePtr->ts_x_origin; @@ -175,7 +175,7 @@ Tk_GetGC( if (valueMask & GCFont) { valueKey.values.font = valuePtr->font; } else { - valueKey.values.font = None; + valueKey.values.font = 0; } if (valueMask & GCSubwindowMode) { valueKey.values.subwindow_mode = valuePtr->subwindow_mode; @@ -200,7 +200,7 @@ Tk_GetGC( if (valueMask & GCClipMask) { valueKey.values.clip_mask = valuePtr->clip_mask; } else { - valueKey.values.clip_mask = None; + valueKey.values.clip_mask = 0; } if (valueMask & GCDashOffset) { valueKey.values.dash_offset = valuePtr->dash_offset; @@ -236,8 +236,8 @@ Tk_GetGC( * Tk_MakeWindowExist on the window. */ - freeDrawable = None; - if (Tk_WindowId(tkwin) != None) { + freeDrawable = 0; + if (Tk_WindowId(tkwin)) { d = Tk_WindowId(tkwin); } else if (valueKey.depth == DefaultDepth(valueKey.display, valueKey.screenNum)) { @@ -260,7 +260,7 @@ Tk_GetGC( } Tcl_SetHashValue(valueHashPtr, gcPtr); Tcl_SetHashValue(idHashPtr, gcPtr); - if (freeDrawable != None) { + if (freeDrawable) { Tk_FreePixmap(valueKey.display, freeDrawable); } diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 44a4f8c..3039ea0 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -468,8 +468,8 @@ Tk_Grab( for (numTries = 0; numTries < 10; numTries++) { grabResult = XGrabPointer(dispPtr->display, winPtr->window, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask - |PointerMotionMask, GrabModeAsync, GrabModeAsync, None, - None, CurrentTime); + |PointerMotionMask, GrabModeAsync, GrabModeAsync, 0, + 0, CurrentTime); if (grabResult != AlreadyGrabbed) { break; } @@ -854,7 +854,7 @@ TkPointerEvent( if (XGrabPointer(dispPtr->display, dispPtr->grabWinPtr->window, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, - GrabModeAsync, GrabModeAsync, None, None, + GrabModeAsync, GrabModeAsync, 0, 0, CurrentTime) == 0) { EatGrabEvents(dispPtr, serial); if (XGrabKeyboard(dispPtr->display, winPtr->window, @@ -921,7 +921,7 @@ TkChangeEventWindow( Tk_GetRootCoords((Tk_Window) winPtr, &x, &y); eventPtr->xmotion.x = eventPtr->xmotion.x_root - x; eventPtr->xmotion.y = eventPtr->xmotion.y_root - y; - eventPtr->xmotion.subwindow = None; + eventPtr->xmotion.subwindow = 0; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { if (childPtr->flags & TK_TOP_HIERARCHY) { @@ -940,7 +940,7 @@ TkChangeEventWindow( } else { eventPtr->xmotion.x = 0; eventPtr->xmotion.y = 0; - eventPtr->xmotion.subwindow = None; + eventPtr->xmotion.subwindow = 0; sameScreen = 0; } if (eventPtr->type == MotionNotify) { @@ -1029,7 +1029,7 @@ TkInOutEvents( */ #define QUEUE(w, t, d) \ - if (w->window != None) { \ + if (w->window) { \ eventPtr->type = t; \ if (focus) { \ eventPtr->xfocus.window = w->window; \ @@ -1145,9 +1145,9 @@ MovePointer2( TkWindow *winPtr; winPtr = sourcePtr; - if ((winPtr == NULL) || (winPtr->window == None)) { + if (!winPtr || !winPtr->window) { winPtr = destPtr; - if ((winPtr == NULL) || (winPtr->window == None)) { + if (!winPtr || !winPtr->window) { return; } } @@ -1338,7 +1338,7 @@ QueueGrabWindowChange( grabEvPtr->header.proc = GrabWinEventProc; grabEvPtr->dispPtr = dispPtr; if (grabWinPtr == NULL) { - grabEvPtr->grabWindow = None; + grabEvPtr->grabWindow = 0; } else { grabEvPtr->grabWindow = grabWinPtr->window; } diff --git a/generic/tkImage.c b/generic/tkImage.c index 6c7c9cd..99a1726 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -759,7 +759,7 @@ Tk_PostscriptImage( gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin)); newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); - if (newGC != None) { + if (newGC) { XFillRectangle(Tk_Display(tkwin), pmap, newGC, 0, 0, (unsigned int)width, (unsigned int)height); Tk_FreeGC(Tk_Display(tkwin), newGC); @@ -772,7 +772,7 @@ Tk_PostscriptImage( Tk_FreePixmap(Tk_Display(tkwin), pmap); - if (ximage == NULL) { + if (!ximage) { /* * The XGetImage() function is apparently not implemented on this * system. Just ignore it. diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 4f5c6ac..4e0082a 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -381,9 +381,9 @@ ImgBmapConfigureInstance( */ oldBitmap = instancePtr->bitmap; - instancePtr->bitmap = None; + instancePtr->bitmap = 0; oldMask = instancePtr->mask; - instancePtr->mask = None; + instancePtr->mask = 0; if (masterPtr->data != NULL) { instancePtr->bitmap = XCreateBitmapFromData( @@ -400,21 +400,21 @@ ImgBmapConfigureInstance( (unsigned) masterPtr->height); } - if (oldMask != None) { + if (oldMask) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } - if (oldBitmap != None) { + if (oldBitmap) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap); } - if (masterPtr->data != NULL) { + if (masterPtr->data) { gcValues.foreground = instancePtr->fg->pixel; gcValues.graphics_exposures = False; mask = GCForeground|GCGraphicsExposures; - if (instancePtr->bg != NULL) { + if (instancePtr->bg) { gcValues.background = instancePtr->bg->pixel; mask |= GCBackground; - if (instancePtr->mask != None) { + if (instancePtr->mask) { gcValues.clip_mask = instancePtr->mask; mask |= GCClipMask; } @@ -424,9 +424,9 @@ ImgBmapConfigureInstance( } gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues); } else { - gc = None; + gc = 0; } - if (instancePtr->gc != None) { + if (instancePtr->gc) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = gc; @@ -438,10 +438,10 @@ ImgBmapConfigureInstance( * it clear that this instance cannot be displayed. Then report the error. */ - if (instancePtr->gc != None) { + if (instancePtr->gc) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } - instancePtr->gc = None; + instancePtr->gc = 0; Tcl_AddErrorInfo(masterPtr->interp, "\n (while configuring image \""); Tcl_AddErrorInfo(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); Tcl_AddErrorInfo(masterPtr->interp, "\")"); @@ -834,9 +834,9 @@ ImgBmapGet( instancePtr->tkwin = tkwin; instancePtr->fg = NULL; instancePtr->bg = NULL; - instancePtr->bitmap = None; - instancePtr->mask = None; - instancePtr->gc = None; + instancePtr->bitmap = 0; + instancePtr->mask = 0; + instancePtr->gc = 0; instancePtr->nextPtr = masterPtr->instancePtr; masterPtr->instancePtr = instancePtr; ImgBmapConfigureInstance(instancePtr); @@ -890,7 +890,7 @@ ImgBmapDisplay( * creating the image instance so it can't be displayed. */ - if (instancePtr->gc == None) { + if (!instancePtr->gc) { return; } @@ -900,7 +900,7 @@ ImgBmapDisplay( * image and reset the clip origin, if there's a mask. */ - masking = (instancePtr->mask != None) || (instancePtr->bg == NULL); + masking = instancePtr->mask || !instancePtr->bg; if (masking) { XSetClipOrigin(display, instancePtr->gc, drawableX - imageX, drawableY - imageY); @@ -949,19 +949,19 @@ ImgBmapFree( * instance structure. */ - if (instancePtr->fg != NULL) { + if (instancePtr->fg) { Tk_FreeColor(instancePtr->fg); } - if (instancePtr->bg != NULL) { + if (instancePtr->bg) { Tk_FreeColor(instancePtr->bg); } - if (instancePtr->bitmap != None) { + if (instancePtr->bitmap) { Tk_FreePixmap(display, instancePtr->bitmap); } - if (instancePtr->mask != None) { + if (instancePtr->mask) { Tk_FreePixmap(display, instancePtr->mask); } - if (instancePtr->gc != None) { + if (instancePtr->gc) { Tk_FreeGC(display, instancePtr->gc); } if (instancePtr->masterPtr->instancePtr == instancePtr) { @@ -1000,17 +1000,17 @@ ImgBmapDelete( { BitmapMaster *masterPtr = (BitmapMaster *) masterData; - if (masterPtr->instancePtr != NULL) { + if (masterPtr->instancePtr) { Tcl_Panic("tried to delete bitmap image when instances still exist"); } masterPtr->tkMaster = NULL; - if (masterPtr->imageCmd != NULL) { + if (masterPtr->imageCmd) { Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd); } - if (masterPtr->data != NULL) { + if (masterPtr->data) { ckfree(masterPtr->data); } - if (masterPtr->maskData != NULL) { + if (masterPtr->maskData) { ckfree(masterPtr->maskData); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); @@ -1042,7 +1042,7 @@ ImgBmapCmdDeletedProc( BitmapMaster *masterPtr = (BitmapMaster *) clientData; masterPtr->imageCmd = NULL; - if (masterPtr->tkMaster != NULL) { + if (masterPtr->tkMaster) { Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); } } diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index 4e1aa01..d1503f6 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -2285,7 +2285,7 @@ ImgPhotoConfigureInstance( * has the side effect of allocating a pixmap for us. */ - if ((instancePtr->pixels == None) || (instancePtr->error == NULL) + if (!instancePtr->pixels || !instancePtr->error || (instancePtr->width != masterPtr->width) || (instancePtr->height != masterPtr->height)) { ImgPhotoInstanceSetSize(instancePtr); @@ -2403,7 +2403,7 @@ ImgPhotoGet( Tk_PreserveColormap(instancePtr->display, instancePtr->colormap); instancePtr->refCount = 1; instancePtr->colorTablePtr = NULL; - instancePtr->pixels = None; + instancePtr->pixels = 0; instancePtr->error = NULL; instancePtr->width = 0; instancePtr->height = 0; @@ -2776,7 +2776,7 @@ ImgPhotoDisplay( * the image instance so it can't be displayed. */ - if (instancePtr->pixels == None) { + if (!instancePtr->pixels) { return; } @@ -2834,7 +2834,7 @@ ImgPhotoDisplay( XCopyArea(display, instancePtr->pixels, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY); - XSetClipMask(display, instancePtr->gc, None); + XSetClipMask(display, instancePtr->gc, 0); XSetClipOrigin(display, instancePtr->gc, 0, 0); } XFlush(display); @@ -3196,7 +3196,7 @@ ImgPhotoInstanceSetSize( if ((instancePtr->width != masterPtr->width) || (instancePtr->height != masterPtr->height) - || (instancePtr->pixels == None)) { + || !instancePtr->pixels) { newPixmap = Tk_GetPixmap(instancePtr->display, RootWindow(instancePtr->display, instancePtr->visualInfo.screen), @@ -3218,7 +3218,7 @@ ImgPhotoInstanceSetSize( TkSetPixmapColormap(newPixmap, instancePtr->colormap); - if (instancePtr->pixels != None) { + if (instancePtr->pixels) { /* * Copy any common pixels from the old pixmap and free it. */ @@ -3995,19 +3995,19 @@ DisposeInstance( PhotoInstance *instancePtr = (PhotoInstance *) clientData; PhotoInstance *prevPtr; - if (instancePtr->pixels != None) { + if (instancePtr->pixels) { Tk_FreePixmap(instancePtr->display, instancePtr->pixels); } - if (instancePtr->gc != None) { + if (instancePtr->gc) { Tk_FreeGC(instancePtr->display, instancePtr->gc); } - if (instancePtr->imagePtr != NULL) { + if (instancePtr->imagePtr) { XDestroyImage(instancePtr->imagePtr); } - if (instancePtr->error != NULL) { + if (instancePtr->error) { ckfree((char *) instancePtr->error); } - if (instancePtr->colorTablePtr != NULL) { + if (instancePtr->colorTablePtr) { FreeColorTable(instancePtr->colorTablePtr, 1); } diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 86fb671..70e4e3c 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -534,15 +534,15 @@ Tk_ListboxObjCmd( ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS); listPtr->relief = TK_RELIEF_RAISED; - listPtr->textGC = None; - listPtr->selFgColorPtr = None; - listPtr->selTextGC = None; + listPtr->textGC = 0; + listPtr->selFgColorPtr = 0; + listPtr->selTextGC = 0; listPtr->fullLines = 1; listPtr->xScrollUnit = 1; listPtr->exportSelection = 1; - listPtr->cursor = None; + listPtr->cursor = 0; listPtr->state = STATE_NORMAL; - listPtr->gray = None; + listPtr->gray = 0; /* * Keep a hold of the associated tkwin until we destroy the listbox, @@ -1474,13 +1474,13 @@ DestroyListbox( * Tk_FreeOptions handle all the standard option-related stuff. */ - if (listPtr->textGC != None) { + if (listPtr->textGC) { Tk_FreeGC(listPtr->display, listPtr->textGC); } - if (listPtr->selTextGC != None) { + if (listPtr->selTextGC) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } - if (listPtr->gray != None) { + if (listPtr->gray) { Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray); } @@ -1765,10 +1765,10 @@ ListboxWorldChanged( } else { gcValues.foreground = listPtr->fgColorPtr->pixel; mask = GCForeground | GCFont; - if (listPtr->gray == None) { + if (!listPtr->gray) { listPtr->gray = Tk_GetBitmap(NULL, listPtr->tkwin, "gray50"); } - if (listPtr->gray != None) { + if (listPtr->gray) { gcValues.fill_style = FillStippled; gcValues.stipple = listPtr->gray; mask |= GCFillStyle | GCStipple; @@ -1777,18 +1777,18 @@ ListboxWorldChanged( gcValues.font = Tk_FontId(listPtr->tkfont); gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->textGC != None) { + if (listPtr->textGC) { Tk_FreeGC(listPtr->display, listPtr->textGC); } listPtr->textGC = gc; - if (listPtr->selFgColorPtr != NULL) { + if (listPtr->selFgColorPtr) { gcValues.foreground = listPtr->selFgColorPtr->pixel; } gcValues.font = Tk_FontId(listPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->selTextGC != None) { + if (listPtr->selTextGC) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } listPtr->selTextGC = gc; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index b35be24..fa14b7e 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -506,7 +506,7 @@ MenuCmd( Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, (ClientData) menuPtr, MenuCmdDeletedProc); menuPtr->active = -1; - menuPtr->cursorPtr = None; + menuPtr->cursorPtr = 0; menuPtr->masterMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; menuPtr->optionTablesPtr = optionTablesPtr; diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index c49f513..d26f83b 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -43,12 +43,12 @@ void TkMenuInitializeDrawingFields( TkMenu *menuPtr) /* The menu we are initializing. */ { - menuPtr->textGC = None; - menuPtr->gray = None; - menuPtr->disabledGC = None; - menuPtr->activeGC = None; - menuPtr->indicatorGC = None; - menuPtr->disabledImageGC = None; + menuPtr->textGC = 0; + menuPtr->gray = 0; + menuPtr->disabledGC = 0; + menuPtr->activeGC = 0; + menuPtr->indicatorGC = 0; + menuPtr->disabledImageGC = 0; menuPtr->totalWidth = menuPtr->totalHeight = 0; } @@ -79,10 +79,10 @@ TkMenuInitializeEntryDrawingFields( mePtr->y = 0; mePtr->indicatorSpace = 0; mePtr->labelWidth = 0; - mePtr->textGC = None; - mePtr->activeGC = None; - mePtr->disabledGC = None; - mePtr->indicatorGC = None; + mePtr->textGC = 0; + mePtr->activeGC = 0; + mePtr->disabledGC = 0; + mePtr->indicatorGC = 0; } /* @@ -106,22 +106,22 @@ void TkMenuFreeDrawOptions( TkMenu *menuPtr) { - if (menuPtr->textGC != None) { + if (menuPtr->textGC) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } - if (menuPtr->disabledImageGC != None) { + if (menuPtr->disabledImageGC) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } - if (menuPtr->gray != None) { + if (menuPtr->gray) { Tk_FreeBitmap(menuPtr->display, menuPtr->gray); } - if (menuPtr->disabledGC != None) { + if (menuPtr->disabledGC) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } - if (menuPtr->activeGC != None) { + if (menuPtr->activeGC) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } - if (menuPtr->indicatorGC != None) { + if (menuPtr->indicatorGC) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } } @@ -147,16 +147,16 @@ void TkMenuEntryFreeDrawOptions( TkMenuEntry *mePtr) { - if (mePtr->textGC != None) { + if (mePtr->textGC) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->textGC); } - if (mePtr->disabledGC != None) { + if (mePtr->disabledGC) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->disabledGC); } - if (mePtr->activeGC != None) { + if (mePtr->activeGC) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->activeGC); } - if (mePtr->indicatorGC != None) { + if (mePtr->indicatorGC) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->indicatorGC); } } @@ -205,7 +205,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->textGC != None) { + if (menuPtr->textGC) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } menuPtr->textGC = newGC; @@ -222,34 +222,34 @@ TkMenuConfigureDrawOptions( } else { gcValues.foreground = gcValues.background; mask = GCForeground; - if (menuPtr->gray == None) { + if (!menuPtr->gray) { menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin, "gray50"); } - if (menuPtr->gray != None) { + if (menuPtr->gray) { gcValues.fill_style = FillStippled; gcValues.stipple = menuPtr->gray; mask = GCForeground|GCFillStyle|GCStipple; } } newGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues); - if (menuPtr->disabledGC != None) { + if (menuPtr->disabledGC) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } menuPtr->disabledGC = newGC; gcValues.foreground = Tk_3DBorderColor(border)->pixel; - if (menuPtr->gray == None) { + if (!menuPtr->gray) { menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin, "gray50"); } - if (menuPtr->gray != None) { + if (menuPtr->gray) { gcValues.fill_style = FillStippled; gcValues.stipple = menuPtr->gray; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCFillStyle|GCStipple, &gcValues); } - if (menuPtr->disabledImageGC != None) { + if (menuPtr->disabledImageGC) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } menuPtr->disabledImageGC = newGC; @@ -262,7 +262,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(activeBorder)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->activeGC != None) { + if (menuPtr->activeGC) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } menuPtr->activeGC = newGC; @@ -273,7 +273,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->indicatorGC != None) { + if (menuPtr->indicatorGC) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } menuPtr->indicatorGC = newGC; @@ -385,24 +385,24 @@ TkMenuConfigureEntryDrawOptions( GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); } else { - newGC = None; - newActiveGC = None; - newDisabledGC = None; - newIndicatorGC = None; + newGC = 0; + newActiveGC = 0; + newDisabledGC = 0; + newIndicatorGC = 0; } - if (mePtr->textGC != None) { + if (mePtr->textGC) { Tk_FreeGC(menuPtr->display, mePtr->textGC); } mePtr->textGC = newGC; - if (mePtr->activeGC != None) { + if (mePtr->activeGC) { Tk_FreeGC(menuPtr->display, mePtr->activeGC); } mePtr->activeGC = newActiveGC; - if (mePtr->disabledGC != None) { + if (mePtr->disabledGC) { Tk_FreeGC(menuPtr->display, mePtr->disabledGC); } mePtr->disabledGC = newDisabledGC; - if (mePtr->indicatorGC != None) { + if (mePtr->indicatorGC) { Tk_FreeGC(menuPtr->display, mePtr->indicatorGC); } mePtr->indicatorGC = newIndicatorGC; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index 94ac8b2..a24ab98 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -251,7 +251,7 @@ Tk_MenubuttonObjCmd( mbPtr->text = NULL; mbPtr->underline = -1; mbPtr->textVarName = NULL; - mbPtr->bitmap = None; + mbPtr->bitmap = 0; mbPtr->imageString = NULL; mbPtr->image = NULL; mbPtr->state = STATE_NORMAL; @@ -267,11 +267,11 @@ Tk_MenubuttonObjCmd( mbPtr->normalFg = NULL; mbPtr->activeFg = NULL; mbPtr->disabledFg = NULL; - mbPtr->normalTextGC = None; - mbPtr->activeTextGC = None; - mbPtr->gray = None; - mbPtr->disabledGC = None; - mbPtr->stippleGC = None; + mbPtr->normalTextGC = 0; + mbPtr->activeTextGC = 0; + mbPtr->gray = 0; + mbPtr->disabledGC = 0; + mbPtr->stippleGC = 0; mbPtr->leftBearing = 0; mbPtr->rightBearing = 0; mbPtr->widthString = NULL; @@ -288,7 +288,7 @@ Tk_MenubuttonObjCmd( mbPtr->indicatorWidth = 0; mbPtr->indicatorHeight = 0; mbPtr->direction = DIRECTION_FLUSH; - mbPtr->cursor = None; + mbPtr->cursor = 0; mbPtr->takeFocus = NULL; mbPtr->flags = 0; @@ -433,22 +433,22 @@ DestroyMenuButton( if (mbPtr->image != NULL) { Tk_FreeImage(mbPtr->image); } - if (mbPtr->normalTextGC != None) { + if (mbPtr->normalTextGC) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } - if (mbPtr->activeTextGC != None) { + if (mbPtr->activeTextGC) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } - if (mbPtr->disabledGC != None) { + if (mbPtr->disabledGC) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } - if (mbPtr->stippleGC != None) { + if (mbPtr->stippleGC) { Tk_FreeGC(mbPtr->display, mbPtr->stippleGC); } - if (mbPtr->gray != None) { + if (mbPtr->gray) { Tk_FreeBitmap(mbPtr->display, mbPtr->gray); } - if (mbPtr->textLayout != NULL) { + if (mbPtr->textLayout) { Tk_FreeTextLayout(mbPtr->textLayout); } Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable, mbPtr->tkwin); @@ -578,7 +578,7 @@ ConfigureMenuButton( * Recompute the geometry for the button. */ - if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { + if (mbPtr->bitmap || mbPtr->image) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, &mbPtr->width) != TCL_OK) { widthError: @@ -683,7 +683,7 @@ TkMenuButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->normalTextGC != None) { + if (mbPtr->normalTextGC) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } mbPtr->normalTextGC = gc; @@ -692,7 +692,7 @@ TkMenuButtonWorldChanged( gcValues.background = Tk_3DBorderColor(mbPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->activeTextGC != None) { + if (mbPtr->activeTextGC) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } mbPtr->activeTextGC = gc; @@ -703,13 +703,13 @@ TkMenuButtonWorldChanged( * Create the GC that can be used for stippling */ - if (mbPtr->stippleGC == None) { + if (!mbPtr->stippleGC) { gcValues.foreground = gcValues.background; mask = GCForeground; - if (mbPtr->gray == None) { + if (!mbPtr->gray) { mbPtr->gray = Tk_GetBitmap(NULL, mbPtr->tkwin, "gray50"); } - if (mbPtr->gray != None) { + if (mbPtr->gray) { gcValues.fill_style = FillStippled; gcValues.stipple = mbPtr->gray; mask |= GCFillStyle | GCStipple; @@ -723,13 +723,13 @@ TkMenuButtonWorldChanged( */ mask = GCForeground | GCBackground | GCFont; - if (mbPtr->disabledFg != NULL) { + if (mbPtr->disabledFg) { gcValues.foreground = mbPtr->disabledFg->pixel; } else { gcValues.foreground = gcValues.background; } gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->disabledGC != None) { + if (mbPtr->disabledGC) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } mbPtr->disabledGC = gc; diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 0fd57a9..9cfa593 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -254,11 +254,11 @@ Tk_MessageObjCmd( (ClientData) msgPtr, MessageCmdDeletedProc); msgPtr->optionTable = optionTable; msgPtr->relief = TK_RELIEF_FLAT; - msgPtr->textGC = None; + msgPtr->textGC = 0; msgPtr->anchor = TK_ANCHOR_CENTER; msgPtr->aspect = 150; msgPtr->justify = TK_JUSTIFY_LEFT; - msgPtr->cursor = None; + msgPtr->cursor = 0; Tk_SetClass(msgPtr->tkwin, "Message"); Tk_SetClassProcs(msgPtr->tkwin, &messageClass, (ClientData) msgPtr); @@ -396,13 +396,13 @@ DestroyMessage( * Tk_FreeConfigOptions handle all the standard option-related stuff. */ - if (msgPtr->textGC != None) { + if (msgPtr->textGC) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } - if (msgPtr->textLayout != NULL) { + if (msgPtr->textLayout) { Tk_FreeTextLayout(msgPtr->textLayout); } - if (msgPtr->textVarName != NULL) { + if (msgPtr->textVarName) { Tcl_UntraceVar(msgPtr->interp, msgPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, (ClientData) msgPtr); @@ -469,7 +469,7 @@ ConfigureMessage( CONST char *value; value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY); - if (value == NULL) { + if (!value) { Tcl_SetVar(interp, msgPtr->textVarName, msgPtr->string, TCL_GLOBAL_ONLY); } else { @@ -523,20 +523,20 @@ MessageWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = None; + GC gc = 0; Tk_FontMetrics fm; Message *msgPtr; msgPtr = (Message *) instanceData; - if (msgPtr->border != NULL) { + if (msgPtr->border) { Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border); } gcValues.font = Tk_FontId(msgPtr->tkfont); gcValues.foreground = msgPtr->fgColorPtr->pixel; gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues); - if (msgPtr->textGC != None) { + if (msgPtr->textGC) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } msgPtr->textGC = gc; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index d7a33f7..955b3e0 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -431,16 +431,16 @@ DoConfig( Pixmap newBmp, oldBmp; if (nullValue) { - newBmp = None; + newBmp = 0; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBmp = Tk_GetBitmap(interp, tkwin, uid); - if (newBmp == None) { + if (!newBmp) { return TCL_ERROR; } } oldBmp = *((Pixmap *) ptr); - if (oldBmp != None) { + if (oldBmp) { Tk_FreeBitmap(Tk_Display(tkwin), oldBmp); } *((Pixmap *) ptr) = newBmp; @@ -454,12 +454,12 @@ DoConfig( } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBorder = Tk_Get3DBorder(interp, tkwin, uid); - if (newBorder == NULL) { + if (!newBorder) { return TCL_ERROR; } } oldBorder = *((Tk_3DBorder *) ptr); - if (oldBorder != NULL) { + if (oldBorder) { Tk_Free3DBorder(oldBorder); } *((Tk_3DBorder *) ptr) = newBorder; @@ -476,16 +476,16 @@ DoConfig( Tk_Cursor newCursor, oldCursor; if (nullValue) { - newCursor = None; + newCursor = 0; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); - if (newCursor == None) { + if (!newCursor) { return TCL_ERROR; } } oldCursor = *((Tk_Cursor *) ptr); - if (oldCursor != None) { + if (oldCursor) { Tk_FreeCursor(Tk_Display(tkwin), oldCursor); } *((Tk_Cursor *) ptr) = newCursor; @@ -794,7 +794,7 @@ FormatConfigValue( case TK_CONFIG_UID: { Tk_Uid uid = *((Tk_Uid *) ptr); - if (uid != NULL) { + if (uid) { result = uid; } break; @@ -802,7 +802,7 @@ FormatConfigValue( case TK_CONFIG_COLOR: { XColor *colorPtr = *((XColor **) ptr); - if (colorPtr != NULL) { + if (colorPtr) { result = Tk_NameOfColor(colorPtr); } break; @@ -810,7 +810,7 @@ FormatConfigValue( case TK_CONFIG_FONT: { Tk_Font tkfont = *((Tk_Font *) ptr); - if (tkfont != NULL) { + if (tkfont) { result = Tk_NameOfFont(tkfont); } break; @@ -818,7 +818,7 @@ FormatConfigValue( case TK_CONFIG_BITMAP: { Pixmap pixmap = *((Pixmap *) ptr); - if (pixmap != None) { + if (pixmap) { result = Tk_NameOfBitmap(Tk_Display(tkwin), pixmap); } break; @@ -826,7 +826,7 @@ FormatConfigValue( case TK_CONFIG_BORDER: { Tk_3DBorder border = *((Tk_3DBorder *) ptr); - if (border != NULL) { + if (border) { result = Tk_NameOf3DBorder(border); } break; @@ -838,7 +838,7 @@ FormatConfigValue( case TK_CONFIG_ACTIVE_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) ptr); - if (cursor != None) { + if (cursor) { result = Tk_NameOfCursor(Tk_Display(tkwin), cursor); } break; @@ -995,7 +995,7 @@ Tk_FreeOptions( ptr = widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_STRING: - if (*((char **) ptr) != NULL) { + if (*((char **) ptr)) { ckfree(*((char **) ptr)); *((char **) ptr) = NULL; } @@ -1011,22 +1011,22 @@ Tk_FreeOptions( *((Tk_Font *) ptr) = NULL; break; case TK_CONFIG_BITMAP: - if (*((Pixmap *) ptr) != None) { + if (*((Pixmap *) ptr)) { Tk_FreeBitmap(display, *((Pixmap *) ptr)); - *((Pixmap *) ptr) = None; + *((Pixmap *) ptr) = 0; } break; case TK_CONFIG_BORDER: - if (*((Tk_3DBorder *) ptr) != NULL) { + if (*((Tk_3DBorder *) ptr)) { Tk_Free3DBorder(*((Tk_3DBorder *) ptr)); *((Tk_3DBorder *) ptr) = NULL; } break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: - if (*((Tk_Cursor *) ptr) != None) { + if (*((Tk_Cursor *) ptr)) { Tk_FreeCursor(display, *((Tk_Cursor *) ptr)); - *((Tk_Cursor *) ptr) = None; + *((Tk_Cursor *) ptr) = 0; } } } diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index 99ed179..f37892c 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -448,9 +448,9 @@ Tk_PanedWindowObjCmd( pwPtr->optionTable = pwOpts->pwOptions; pwPtr->slaveOpts = pwOpts->slaveOpts; pwPtr->relief = TK_RELIEF_RAISED; - pwPtr->gc = None; - pwPtr->cursor = None; - pwPtr->sashCursor = None; + pwPtr->gc = 0; + pwPtr->cursor = 0; + pwPtr->sashCursor = 0; /* * Keep a hold of the associated tkwin until we destroy the widget, @@ -859,7 +859,7 @@ ConfigureSlaves( index = -1; haveLoc = 0; - if (options.after != None) { + if (options.after) { tkwin = options.after; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -868,7 +868,7 @@ ConfigureSlaves( break; } } - } else if (options.before != None) { + } else if (options.before) { tkwin = options.before; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -1299,7 +1299,7 @@ PanedWindowWorldChanged( gcValues.background = Tk_3DBorderColor(pwPtr->background)->pixel; newGC = Tk_GetGC(pwPtr->tkwin, GCBackground, &gcValues); - if (pwPtr->gc != None) { + if (pwPtr->gc) { Tk_FreeGC(pwPtr->display, pwPtr->gc); } pwPtr->gc = newGC; @@ -2018,10 +2018,10 @@ Unlink( for (i = 0; i < masterPtr->numSlaves; i++) { if (masterPtr->slaves[i]->before == slavePtr->tkwin) { - masterPtr->slaves[i]->before = None; + masterPtr->slaves[i]->before = 0; } if (masterPtr->slaves[i]->after == slavePtr->tkwin) { - masterPtr->slaves[i]->after = None; + masterPtr->slaves[i]->after = 0; } } diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 2f527ba..c435b12 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -397,7 +397,7 @@ CreateSlave( slavePtr = (Slave *) ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); slavePtr->tkwin = tkwin; - slavePtr->inTkwin = None; + slavePtr->inTkwin = 0; slavePtr->anchor = TK_ANCHOR_NW; slavePtr->borderMode = BM_INSIDE; slavePtr->optionTable = table; diff --git a/generic/tkPointer.c b/generic/tkPointer.c index dd4f7e6..00e1328 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -179,14 +179,13 @@ GenerateEnterLeave( } else { TkWindow *targetPtr; - if ((lastWinPtr == NULL) - || (lastWinPtr->window == None)) { + if (!lastWinPtr || !lastWinPtr->window) { targetPtr = winPtr; } else { targetPtr = lastWinPtr; } - if (targetPtr && (targetPtr->window != None)) { + if (targetPtr && targetPtr->window) { XEvent event; /* @@ -540,7 +539,7 @@ static void UpdateCursor( TkWindow *winPtr) { - Cursor cursor = None; + Cursor cursor = 0; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -550,8 +549,8 @@ UpdateCursor( */ tsdPtr->cursorWinPtr = winPtr; - while (winPtr != NULL) { - if (winPtr->atts.cursor != None) { + while (winPtr) { + if (winPtr->atts.cursor) { cursor = winPtr->atts.cursor; break; } else if (winPtr->flags & TK_TOP_HIERARCHY) { diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index c9cd7cb..6ed4488 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -259,10 +259,10 @@ CreateRectOval( rectOvalPtr->fillColor = NULL; rectOvalPtr->activeFillColor = NULL; rectOvalPtr->disabledFillColor = NULL; - rectOvalPtr->fillStipple = None; - rectOvalPtr->activeFillStipple = None; - rectOvalPtr->disabledFillStipple = None; - rectOvalPtr->fillGC = None; + rectOvalPtr->fillStipple = 0; + rectOvalPtr->activeFillStipple = 0; + rectOvalPtr->disabledFillStipple = 0; + rectOvalPtr->fillGC = 0; /* * Process the arguments to fill in the item record. @@ -429,11 +429,11 @@ ConfigureRectOval( */ if (rectOvalPtr->outline.activeWidth > rectOvalPtr->outline.width || - rectOvalPtr->outline.activeDash.number != 0 || - rectOvalPtr->outline.activeColor != NULL || - rectOvalPtr->outline.activeStipple != None || - rectOvalPtr->activeFillColor != NULL || - rectOvalPtr->activeFillStipple != None) { + rectOvalPtr->outline.activeDash.number || + rectOvalPtr->outline.activeColor || + rectOvalPtr->outline.activeStipple || + rectOvalPtr->activeFillColor || + rectOvalPtr->activeFillStipple) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -467,15 +467,15 @@ ConfigureRectOval( mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(rectOvalPtr->outline)); if (mask && \ - rectOvalPtr->outline.width != 0 && \ - rectOvalPtr->outline.color != NULL) { + rectOvalPtr->outline.width && \ + rectOvalPtr->outline.color) { gcValues.cap_style = CapProjecting; mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = None; + newGC = 0; } - if (rectOvalPtr->outline.gc != None) { + if (rectOvalPtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); } rectOvalPtr->outline.gc = newGC; @@ -494,23 +494,23 @@ ConfigureRectOval( if (rectOvalPtr->activeFillColor!=NULL) { color = rectOvalPtr->activeFillColor; } - if (rectOvalPtr->activeFillStipple!=None) { + if (rectOvalPtr->activeFillStipple) { stipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (rectOvalPtr->disabledFillColor!=NULL) { + if (rectOvalPtr->disabledFillColor) { color = rectOvalPtr->disabledFillColor; } - if (rectOvalPtr->disabledFillStipple!=None) { + if (rectOvalPtr->disabledFillStipple) { stipple = rectOvalPtr->disabledFillStipple; } } - if (color == NULL) { - newGC = None; + if (!color) { + newGC = 0; } else { gcValues.foreground = color->pixel; - if (stipple != None) { + if (stipple) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask = GCForeground|GCStipple|GCFillStyle; @@ -528,7 +528,7 @@ ConfigureRectOval( #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (rectOvalPtr->fillGC != None) { + if (rectOvalPtr->fillGC) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC); } rectOvalPtr->fillGC = newGC; @@ -583,25 +583,25 @@ DeleteRectOval( RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; Tk_DeleteOutline(display, &(rectOvalPtr->outline)); - if (rectOvalPtr->fillColor != NULL) { + if (rectOvalPtr->fillColor) { Tk_FreeColor(rectOvalPtr->fillColor); } - if (rectOvalPtr->activeFillColor != NULL) { + if (rectOvalPtr->activeFillColor) { Tk_FreeColor(rectOvalPtr->activeFillColor); } - if (rectOvalPtr->disabledFillColor != NULL) { + if (rectOvalPtr->disabledFillColor) { Tk_FreeColor(rectOvalPtr->disabledFillColor); } - if (rectOvalPtr->fillStipple != None) { + if (rectOvalPtr->fillStipple) { Tk_FreeBitmap(display, rectOvalPtr->fillStipple); } - if (rectOvalPtr->activeFillStipple != None) { + if (rectOvalPtr->activeFillStipple) { Tk_FreeBitmap(display, rectOvalPtr->activeFillStipple); } - if (rectOvalPtr->disabledFillStipple != None) { + if (rectOvalPtr->disabledFillStipple) { Tk_FreeBitmap(display, rectOvalPtr->disabledFillStipple); } - if (rectOvalPtr->fillGC != None) { + if (rectOvalPtr->fillGC) { Tk_FreeGC(display, rectOvalPtr->fillGC); } } @@ -670,7 +670,7 @@ ComputeRectOvalBbox( rectOvalPtr->bbox[0] = tmpX; } - if (rectOvalPtr->outline.gc == None) { + if (!rectOvalPtr->outline.gc) { /* * The Win32 switch was added for 8.3 to solve a problem with ovals * leaving traces on bottom and right of 1 pixel. This may not be the @@ -783,17 +783,17 @@ DisplayRectOval( } fillStipple = rectOvalPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)rectOvalPtr) { - if (rectOvalPtr->activeFillStipple != None) { + if (rectOvalPtr->activeFillStipple) { fillStipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (rectOvalPtr->disabledFillStipple != None) { + if (rectOvalPtr->disabledFillStipple) { fillStipple = rectOvalPtr->disabledFillStipple; } } - if (rectOvalPtr->fillGC != None) { - if (fillStipple != None) { + if (rectOvalPtr->fillGC) { + if (fillStipple) { Tk_TSOffset *tsoffset; int w = 0, h = 0; @@ -831,12 +831,12 @@ DisplayRectOval( x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), 0, 360*64); } - if (fillStipple != None) { + if (fillStipple) { XSetTSOrigin(display, rectOvalPtr->fillGC, 0, 0); } } - if (rectOvalPtr->outline.gc != None) { + if (rectOvalPtr->outline.gc) { Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline)); if (rectOvalPtr->header.typePtr == &tkRectangleType) { XDrawRectangle(display, drawable, rectOvalPtr->outline.gc, @@ -907,7 +907,7 @@ RectToPoint( y1 = rectPtr->bbox[1]; x2 = rectPtr->bbox[2]; y2 = rectPtr->bbox[3]; - if (rectPtr->outline.gc != None) { + if (rectPtr->outline.gc) { inc = width/2.0; x1 -= inc; y1 -= inc; @@ -923,7 +923,7 @@ RectToPoint( if ((pointPtr[0] >= x1) && (pointPtr[0] < x2) && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) { - if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) { + if (rectPtr->fillGC || !rectPtr->outline.gc) { return 0.0; } xDiff = pointPtr[0] - x1; @@ -1019,8 +1019,8 @@ OvalToPoint( } - filled = ovalPtr->fillGC != None; - if (ovalPtr->outline.gc == None) { + filled = ovalPtr->fillGC != 0; + if (!ovalPtr->outline.gc) { width = 0.0; filled = 1; } @@ -1075,7 +1075,7 @@ RectToArea( } halfWidth = width/2.0; - if (rectPtr->outline.gc == None) { + if (!rectPtr->outline.gc) { halfWidth = 0.0; } @@ -1085,7 +1085,7 @@ RectToArea( || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) { return -1; } - if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None) + if (!rectPtr->fillGC && rectPtr->outline.gc && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth)) && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth)) && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth)) @@ -1154,7 +1154,7 @@ OvalToArea( */ halfWidth = width/2.0; - if (ovalPtr->outline.gc == None) { + if (!ovalPtr->outline.gc) { halfWidth = 0.0; } oval[0] = ovalPtr->bbox[0] - halfWidth; @@ -1171,8 +1171,8 @@ OvalToArea( * return "outside". */ - if ((result == 0) && (ovalPtr->outline.gc != None) - && (ovalPtr->fillGC == None)) { + if ((result == 0) && ovalPtr->outline.gc + && !ovalPtr->fillGC) { double centerX, centerY, height; double xDelta1, yDelta1, xDelta2, yDelta2; @@ -1335,20 +1335,20 @@ RectOvalToPostscript( if (rectOvalPtr->outline.activeColor!=NULL) { color = rectOvalPtr->outline.activeColor; } - if (rectOvalPtr->activeFillColor!=NULL) { + if (rectOvalPtr->activeFillColor) { fillColor = rectOvalPtr->activeFillColor; } - if (rectOvalPtr->activeFillStipple!=None) { + if (rectOvalPtr->activeFillStipple) { fillStipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->outline.disabledColor!=NULL) { color = rectOvalPtr->outline.disabledColor; } - if (rectOvalPtr->disabledFillColor!=NULL) { + if (rectOvalPtr->disabledFillColor) { fillColor = rectOvalPtr->disabledFillColor; } - if (rectOvalPtr->disabledFillStipple!=None) { + if (rectOvalPtr->disabledFillStipple) { fillStipple = rectOvalPtr->disabledFillStipple; } } @@ -1357,12 +1357,12 @@ RectOvalToPostscript( * First draw the filled area of the rectangle. */ - if (fillColor != NULL) { + if (fillColor) { Tcl_AppendResult(interp, pathCmd, NULL); if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple != None) { + if (fillStipple) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; @@ -1379,7 +1379,7 @@ RectOvalToPostscript( * Now draw the outline, if there is one. */ - if (color != NULL) { + if (color) { Tcl_AppendResult(interp, pathCmd, "0 setlinejoin 2 setlinecap\n", NULL); if (Tk_CanvasPsOutline(canvas, itemPtr, diff --git a/generic/tkScale.c b/generic/tkScale.c index 69a7d91..32cb1b2 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -264,11 +264,11 @@ Tk_ScaleObjCmd( scalePtr->activeBorder = NULL; scalePtr->sliderRelief = TK_RELIEF_RAISED; scalePtr->troughColorPtr = NULL; - scalePtr->troughGC = None; - scalePtr->copyGC = None; + scalePtr->troughGC = 0; + scalePtr->copyGC = 0; scalePtr->tkfont = NULL; scalePtr->textColorPtr = NULL; - scalePtr->textGC = None; + scalePtr->textGC = 0; scalePtr->relief = TK_RELIEF_FLAT; scalePtr->highlightWidth = 0; scalePtr->highlightBorder = NULL; @@ -285,7 +285,7 @@ Tk_ScaleObjCmd( scalePtr->vertTroughX = 0; scalePtr->vertLabelX = 0; scalePtr->fontHeight = 0; - scalePtr->cursor = None; + scalePtr->cursor = 0; scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; @@ -514,13 +514,13 @@ DestroyScale( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ScaleVarProc, (ClientData) scalePtr); } - if (scalePtr->troughGC != None) { + if (scalePtr->troughGC) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } - if (scalePtr->copyGC != None) { + if (scalePtr->copyGC) { Tk_FreeGC(scalePtr->display, scalePtr->copyGC); } - if (scalePtr->textGC != None) { + if (scalePtr->textGC) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } Tk_FreeConfigOptions((char *) scalePtr, scalePtr->optionTable, @@ -727,7 +727,7 @@ ScaleWorldChanged( gcValues.foreground = scalePtr->troughColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues); - if (scalePtr->troughGC != None) { + if (scalePtr->troughGC) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } scalePtr->troughGC = gc; @@ -735,12 +735,12 @@ ScaleWorldChanged( gcValues.font = Tk_FontId(scalePtr->tkfont); gcValues.foreground = scalePtr->textColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground | GCFont, &gcValues); - if (scalePtr->textGC != None) { + if (scalePtr->textGC) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } scalePtr->textGC = gc; - if (scalePtr->copyGC == None) { + if (!scalePtr->copyGC) { gcValues.graphics_exposures = False; scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures, &gcValues); diff --git a/generic/tkScale.h b/generic/tkScale.h index a2c5f2b..a19695f 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[16]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index ba42c20..67fdd2b 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -188,7 +188,7 @@ Tk_ScrollbarCmd( scrollPtr->lastUnit = 0; scrollPtr->firstFraction = 0.0; scrollPtr->lastFraction = 0.0; - scrollPtr->cursor = None; + scrollPtr->cursor = 0; scrollPtr->takeFocus = NULL; scrollPtr->flags = 0; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 7c96b94..2f74172 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -130,7 +130,7 @@ Tk_CreateSelHandler( register TkSelHandler *selPtr; TkWindow *winPtr = (TkWindow *) tkwin; - if (winPtr->dispPtr->multipleAtom == None) { + if (!winPtr->dispPtr->multipleAtom) { TkSelInit(tkwin); } @@ -362,7 +362,7 @@ Tk_OwnSelection( ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ - if (dispPtr->multipleAtom == None) { + if (!dispPtr->multipleAtom) { TkSelInit(tkwin); } Tk_MakeWindowExist(tkwin); @@ -471,7 +471,7 @@ Tk_ClearSelection( ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ - if (dispPtr->multipleAtom == None) { + if (!dispPtr->multipleAtom) { TkSelInit(tkwin); } @@ -494,7 +494,7 @@ Tk_ClearSelection( clearData = infoPtr->clearData; ckfree((char *) infoPtr); } - XSetSelectionOwner(winPtr->display, selection, None, CurrentTime); + XSetSelectionOwner(winPtr->display, selection, 0, CurrentTime); if (clearProc != NULL) { (*clearProc)(clearData); @@ -561,7 +561,7 @@ Tk_GetSelection( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (dispPtr->multipleAtom == None) { + if (!dispPtr->multipleAtom) { TkSelInit(tkwin); } diff --git a/generic/tkSquare.c b/generic/tkSquare.c index a35832a..305d756 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -166,7 +166,7 @@ SquareObjCmd( squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, (ClientData) squarePtr, SquareDeletedProc); - squarePtr->gc = None; + squarePtr->gc = 0; squarePtr->optionTable = optionTable; if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) @@ -332,7 +332,7 @@ SquareConfigure( Tk_SetWindowBackground(squarePtr->tkwin, Tk_3DBorderColor(bgBorder)->pixel); Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); - if ((squarePtr->gc == None) && (doubleBuffer)) { + if (!squarePtr->gc && doubleBuffer) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -394,10 +394,10 @@ SquareObjEventProc( squarePtr->updatePending = 1; } } else if (eventPtr->type == DestroyNotify) { - if (squarePtr->tkwin != NULL) { + if (squarePtr->tkwin) { Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, squarePtr->tkwin); - if (squarePtr->gc != None) { + if (squarePtr->gc) { Tk_FreeGC(squarePtr->display, squarePtr->gc); } squarePtr->tkwin = NULL; @@ -472,7 +472,7 @@ SquareDisplay( { Square *squarePtr = (Square *) clientData; Tk_Window tkwin = squarePtr->tkwin; - Pixmap pm = None; + Pixmap pm = 0; Drawable d; int borderWidth, size, relief; Tk_3DBorder bgBorder, fgBorder; diff --git a/generic/tkTest.c b/generic/tkTest.c index d06769d..8f54781 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -1047,7 +1047,7 @@ TestobjconfigObjCmd( recordPtr->index = 0; recordPtr->colorPtr = NULL; recordPtr->tkfont = NULL; - recordPtr->bitmap = None; + recordPtr->bitmap = 0; recordPtr->border = NULL; recordPtr->relief = TK_RELIEF_FLAT; recordPtr->cursor = NULL; @@ -1985,7 +1985,7 @@ TestpropCmd( w, propName, 0, 100000, False, AnyPropertyType, &actualType, &actualFormat, &length, &bytesAfter, &property); - if ((result == Success) && (actualType != None)) { + if ((result == Success) && actualType) { if ((actualFormat == 8) && (actualType == XA_STRING)) { for (p = property; ((unsigned long)(p-property)) < length; p++) { if (*p == 0) { diff --git a/generic/tkText.c b/generic/tkText.c index 8edf82d..425687f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -568,7 +568,7 @@ CreateWidget( textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; - textPtr->cursor = None; + textPtr->cursor = 0; textPtr->charWidth = 1; textPtr->charHeight = 10; textPtr->wrapMode = TEXT_WRAPMODE_CHAR; @@ -2186,28 +2186,28 @@ ConfigureText( textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; - if ((textPtr->selTagPtr->elideString != NULL) - || (textPtr->selTagPtr->tkfont != None) - || (textPtr->selTagPtr->justifyString != NULL) - || (textPtr->selTagPtr->lMargin1String != NULL) - || (textPtr->selTagPtr->lMargin2String != NULL) - || (textPtr->selTagPtr->offsetString != NULL) - || (textPtr->selTagPtr->rMarginString != NULL) - || (textPtr->selTagPtr->spacing1String != NULL) - || (textPtr->selTagPtr->spacing2String != NULL) - || (textPtr->selTagPtr->spacing3String != NULL) - || (textPtr->selTagPtr->tabStringPtr != NULL) + if (textPtr->selTagPtr->elideString + || textPtr->selTagPtr->tkfont + || textPtr->selTagPtr->justifyString + || textPtr->selTagPtr->lMargin1String + || textPtr->selTagPtr->lMargin2String + || textPtr->selTagPtr->offsetString + || textPtr->selTagPtr->rMarginString + || textPtr->selTagPtr->spacing1String + || textPtr->selTagPtr->spacing2String + || textPtr->selTagPtr->spacing3String + || textPtr->selTagPtr->tabStringPtr || (textPtr->selTagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { textPtr->selTagPtr->affectsDisplay = 1; textPtr->selTagPtr->affectsDisplayGeometry = 1; } - if ((textPtr->selTagPtr->border != NULL) - || (textPtr->selTagPtr->reliefString != NULL) - || (textPtr->selTagPtr->bgStipple != None) - || (textPtr->selTagPtr->fgColor != NULL) - || (textPtr->selTagPtr->fgStipple != None) - || (textPtr->selTagPtr->overstrikeString != NULL) - || (textPtr->selTagPtr->underlineString != NULL)) { + if (textPtr->selTagPtr->border + || textPtr->selTagPtr->reliefString + || textPtr->selTagPtr->bgStipple + || textPtr->selTagPtr->fgColor + || textPtr->selTagPtr->fgStipple + || textPtr->selTagPtr->overstrikeString + || textPtr->selTagPtr->underlineString) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 1f39112..cc304de 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -632,7 +632,7 @@ TkTextCreateDInfo( dInfoPtr = (TextDInfo *) ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; - dInfoPtr->copyGC = None; + dInfoPtr->copyGC = 0; gcValues.graphics_exposures = True; dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); @@ -696,19 +696,19 @@ TkTextFreeDInfo( FreeDLines(textPtr, dInfoPtr->dLinePtr, NULL, DLINE_UNLINK); Tcl_DeleteHashTable(&dInfoPtr->styleTable); - if (dInfoPtr->copyGC != None) { + if (dInfoPtr->copyGC) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } Tk_FreeGC(textPtr->display, dInfoPtr->scrollGC); if (dInfoPtr->flags & REDRAW_PENDING) { Tcl_CancelIdleCall(DisplayText, (ClientData) textPtr); } - if (dInfoPtr->lineUpdateTimer != NULL) { + if (dInfoPtr->lineUpdateTimer) { Tcl_DeleteTimerHandler(dInfoPtr->lineUpdateTimer); textPtr->refCount--; dInfoPtr->lineUpdateTimer = NULL; } - if (dInfoPtr->scrollbarTimer != NULL) { + if (dInfoPtr->scrollbarTimer) { Tcl_DeleteTimerHandler(dInfoPtr->scrollbarTimer); textPtr->refCount--; dInfoPtr->scrollbarTimer = NULL; @@ -827,70 +827,70 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((tagPtr->bgStipple != None) + if ((tagPtr->bgStipple) && (tagPtr->priority > bgStipplePrio)) { styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } - if ((tagPtr->fgColor != None) && (tagPtr->priority > fgPrio)) { + if ((tagPtr->fgColor) && (tagPtr->priority > fgPrio)) { styleValues.fgColor = tagPtr->fgColor; fgPrio = tagPtr->priority; } - if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) { + if ((tagPtr->tkfont) && (tagPtr->priority > fontPrio)) { styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((tagPtr->fgStipple != None) + if ((tagPtr->fgStipple) && (tagPtr->priority > fgStipplePrio)) { styleValues.fgStipple = tagPtr->fgStipple; fgStipplePrio = tagPtr->priority; } - if ((tagPtr->justifyString != NULL) + if ((tagPtr->justifyString) && (tagPtr->priority > justifyPrio)) { styleValues.justify = tagPtr->justify; justifyPrio = tagPtr->priority; } - if ((tagPtr->lMargin1String != NULL) + if ((tagPtr->lMargin1String) && (tagPtr->priority > lMargin1Prio)) { styleValues.lMargin1 = tagPtr->lMargin1; lMargin1Prio = tagPtr->priority; } - if ((tagPtr->lMargin2String != NULL) + if ((tagPtr->lMargin2String) && (tagPtr->priority > lMargin2Prio)) { styleValues.lMargin2 = tagPtr->lMargin2; lMargin2Prio = tagPtr->priority; } - if ((tagPtr->offsetString != NULL) + if ((tagPtr->offsetString) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; offsetPrio = tagPtr->priority; } - if ((tagPtr->overstrikeString != NULL) + if ((tagPtr->overstrikeString) && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike; overstrikePrio = tagPtr->priority; } - if ((tagPtr->rMarginString != NULL) + if ((tagPtr->rMarginString) && (tagPtr->priority > rMarginPrio)) { styleValues.rMargin = tagPtr->rMargin; rMarginPrio = tagPtr->priority; } - if ((tagPtr->spacing1String != NULL) + if ((tagPtr->spacing1String) && (tagPtr->priority > spacing1Prio)) { styleValues.spacing1 = tagPtr->spacing1; spacing1Prio = tagPtr->priority; } - if ((tagPtr->spacing2String != NULL) + if ((tagPtr->spacing2String) && (tagPtr->priority > spacing2Prio)) { styleValues.spacing2 = tagPtr->spacing2; spacing2Prio = tagPtr->priority; } - if ((tagPtr->spacing3String != NULL) + if ((tagPtr->spacing3String) && (tagPtr->priority > spacing3Prio)) { styleValues.spacing3 = tagPtr->spacing3; spacing3Prio = tagPtr->priority; } - if ((tagPtr->tabStringPtr != NULL) + if ((tagPtr->tabStringPtr) && (tagPtr->priority > tabPrio)) { styleValues.tabArrayPtr = tagPtr->tabArrayPtr; tabPrio = tagPtr->priority; @@ -900,12 +900,12 @@ GetStyle( styleValues.tabStyle = tagPtr->tabStyle; tabStylePrio = tagPtr->priority; } - if ((tagPtr->underlineString != NULL) + if ((tagPtr->underlineString) && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline; underlinePrio = tagPtr->priority; } - if ((tagPtr->elideString != NULL) + if ((tagPtr->elideString) && (tagPtr->priority > elidePrio)) { styleValues.elide = tagPtr->elide; elidePrio = tagPtr->priority; @@ -916,7 +916,7 @@ GetStyle( wrapPrio = tagPtr->priority; } } - if (tagPtrs != NULL) { + if (tagPtrs) { ckfree((char *) tagPtrs); } @@ -941,20 +941,20 @@ GetStyle( if (styleValues.border != NULL) { gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel; mask = GCForeground; - if (styleValues.bgStipple != None) { + if (styleValues.bgStipple) { gcValues.stipple = styleValues.bgStipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } stylePtr->bgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); } else { - stylePtr->bgGC = None; + stylePtr->bgGC = 0; } mask = GCFont; gcValues.font = Tk_FontId(styleValues.tkfont); mask |= GCForeground; gcValues.foreground = styleValues.fgColor->pixel; - if (styleValues.fgStipple != None) { + if (styleValues.fgStipple) { gcValues.stipple = styleValues.fgStipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -994,10 +994,10 @@ FreeStyle( { stylePtr->refCount--; if (stylePtr->refCount == 0) { - if (stylePtr->bgGC != None) { + if (stylePtr->bgGC) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } - if (stylePtr->fgGC != None) { + if (stylePtr->fgGC) { Tk_FreeGC(textPtr->display, stylePtr->fgGC); } Tcl_DeleteHashEntry(stylePtr->hPtr); @@ -2578,7 +2578,7 @@ DisplayLineBackground( if ((chunkPtr->nextPtr == NULL) && (rightX < maxX)) { rightX = maxX; } - if (chunkPtr->stylePtr->bgGC != None) { + if (chunkPtr->stylePtr->bgGC) { /* * Not visible - bail out now. */ @@ -4335,7 +4335,7 @@ DisplayText( dlPtr->spaceAbove, dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, NULL, - (Drawable) None, dlPtr->y + dlPtr->spaceAbove); + 0, dlPtr->y + dlPtr->spaceAbove); } } @@ -4970,7 +4970,7 @@ TkTextRelayoutWindow( gcValues.graphics_exposures = False; newGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); - if (dInfoPtr->copyGC != None) { + if (dInfoPtr->copyGC) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } dInfoPtr->copyGC = newGC; @@ -7708,7 +7708,7 @@ CharDisplayProc( */ if (!sValuePtr->elide && (numBytes > offsetBytes) - && (stylePtr->fgGC != None)) { + && stylePtr->fgGC) { #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index a310dd7..5bf1899 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -489,29 +489,29 @@ TkTextTagCmd( tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; - if ((tagPtr->elideString != NULL) - || (tagPtr->tkfont != None) - || (tagPtr->justifyString != NULL) - || (tagPtr->lMargin1String != NULL) - || (tagPtr->lMargin2String != NULL) - || (tagPtr->offsetString != NULL) - || (tagPtr->rMarginString != NULL) - || (tagPtr->spacing1String != NULL) - || (tagPtr->spacing2String != NULL) - || (tagPtr->spacing3String != NULL) - || (tagPtr->tabStringPtr != NULL) + if (tagPtr->elideString + || tagPtr->tkfont + || tagPtr->justifyString + || tagPtr->lMargin1String + || tagPtr->lMargin2String + || tagPtr->offsetString + || tagPtr->rMarginString + || tagPtr->spacing1String + || tagPtr->spacing2String + || tagPtr->spacing3String + || tagPtr->tabStringPtr || (tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE) || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { tagPtr->affectsDisplay = 1; tagPtr->affectsDisplayGeometry = 1; } - if ((tagPtr->border != NULL) - || (tagPtr->reliefString != NULL) - || (tagPtr->bgStipple != None) - || (tagPtr->fgColor != NULL) - || (tagPtr->fgStipple != None) - || (tagPtr->overstrikeString != NULL) - || (tagPtr->underlineString != NULL)) { + if (tagPtr->border + || tagPtr->reliefString + || tagPtr->bgStipple + || tagPtr->fgColor + || tagPtr->fgStipple + || tagPtr->overstrikeString + || tagPtr->underlineString) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -987,10 +987,10 @@ TkTextCreateTag( tagPtr->borderWidthPtr = NULL; tagPtr->reliefString = NULL; tagPtr->relief = TK_RELIEF_FLAT; - tagPtr->bgStipple = None; + tagPtr->bgStipple = 0; tagPtr->fgColor = NULL; tagPtr->tkfont = NULL; - tagPtr->fgStipple = None; + tagPtr->fgStipple = 0; tagPtr->justifyString = NULL; tagPtr->justify = TK_JUSTIFY_LEFT; tagPtr->lMargin1String = NULL; @@ -1556,7 +1556,7 @@ TkTextPickCurrent( textPtr->pickEvent.xcrossing.display = eventPtr->xmotion.display; textPtr->pickEvent.xcrossing.window = eventPtr->xmotion.window; textPtr->pickEvent.xcrossing.root = eventPtr->xmotion.root; - textPtr->pickEvent.xcrossing.subwindow = None; + textPtr->pickEvent.xcrossing.subwindow = 0; textPtr->pickEvent.xcrossing.time = eventPtr->xmotion.time; textPtr->pickEvent.xcrossing.x = eventPtr->xmotion.x; textPtr->pickEvent.xcrossing.y = eventPtr->xmotion.y; diff --git a/generic/tkVisual.c b/generic/tkVisual.c index ec8be11..fe3e447 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -398,18 +398,18 @@ Tk_GetColormap( */ other = Tk_NameToWindow(interp, string, tkwin); - if (other == NULL) { - return None; + if (!other) { + return 0; } if (Tk_Screen(other) != Tk_Screen(tkwin)) { Tcl_AppendResult(interp, "can't use colormap for ", string, ": not on same screen", NULL); - return None; + return 0; } if (Tk_Visual(other) != Tk_Visual(tkwin)) { Tcl_AppendResult(interp, "can't use colormap for ", string, ": incompatible visuals", NULL); - return None; + return 0; } colormap = Tk_Colormap(other); diff --git a/generic/tkWindow.c b/generic/tkWindow.c index 4ac2849..c122128 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -73,7 +73,7 @@ static const XWindowChanges defChanges = { EnterWindowMask|LeaveWindowMask|PointerMotionMask|ExposureMask| \ VisibilityChangeMask|PropertyChangeMask|ColormapChangeMask static const XSetWindowAttributes defAtts= { - None, /* background_pixmap */ + 0, /* background_pixmap */ 0, /* background_pixel */ CopyFromParent, /* border_pixmap */ 0, /* border_pixel */ @@ -87,7 +87,7 @@ static const XSetWindowAttributes defAtts= { 0, /* do_not_propagate_mask */ False, /* override_redirect */ CopyFromParent, /* colormap */ - None /* cursor */ + 0 /* cursor */ }; /* @@ -504,9 +504,9 @@ GetScreen( dispPtr->lastEventTime = CurrentTime; dispPtr->bindInfoStale = 1; - dispPtr->cursorFont = None; - dispPtr->warpWindow = None; - dispPtr->multipleAtom = None; + dispPtr->cursorFont = 0; + dispPtr->warpWindow = 0; + dispPtr->multipleAtom = 0; /* * By default we do want to collapse motion events in @@ -667,7 +667,7 @@ TkAllocWindow( winPtr->visual = DefaultVisual(dispPtr->display, screenNum); winPtr->depth = DefaultDepth(dispPtr->display, screenNum); } - winPtr->window = None; + winPtr->window = 0; winPtr->childList = NULL; winPtr->lastChildPtr = NULL; winPtr->parentPtr = NULL; @@ -1403,7 +1403,7 @@ Tk_DestroyWindow( winPtr->pathName != NULL && !(winPtr->flags & TK_ANONYMOUS_WINDOW)) { halfdeadPtr->flags |= HD_DESTROY_EVENT; - if (winPtr->window == None) { + if (!winPtr->window) { Tk_MakeWindowExist(tkwin); } event.type = DestroyNotify; @@ -1449,7 +1449,7 @@ Tk_DestroyWindow( } else if (winPtr->flags & TK_WM_COLORMAP_WINDOW) { TkWmRemoveFromColormapWindows(winPtr); } - if (winPtr->window != None) { + if (winPtr->window) { #if defined(MAC_OSX_TK) || defined(__WIN32__) XDestroyWindow(winPtr->display, winPtr->window); #else @@ -1469,7 +1469,7 @@ Tk_DestroyWindow( TkFreeWindowId(dispPtr, winPtr->window); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->winTable, (char *) winPtr->window)); - winPtr->window = None; + winPtr->window = 0; } dispPtr->destroyCount--; UnlinkWindow(winPtr); @@ -1642,7 +1642,7 @@ Tk_MapWindow( if (winPtr->flags & TK_MAPPED) { return; } - if (winPtr->window == None) { + if (!winPtr->window) { Tk_MakeWindowExist(tkwin); } /* @@ -1704,21 +1704,21 @@ Tk_MakeWindowExist( Tk_ClassCreateProc *createProc; int isNew; - if (winPtr->window != None) { + if (winPtr->window) { return; } if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_HIERARCHY)) { parent = XRootWindow(winPtr->display, winPtr->screenNum); } else { - if (winPtr->parentPtr->window == None) { + if (!winPtr->parentPtr->window) { Tk_MakeWindowExist((Tk_Window) winPtr->parentPtr); } parent = winPtr->parentPtr->window; } createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); - if (createProc != NULL && parent != None) { + if (createProc != NULL && parent) { winPtr->window = (*createProc)(tkwin, parent, winPtr->instanceData); } else { winPtr->window = TkpMakeWindow(winPtr, parent); @@ -1744,7 +1744,7 @@ Tk_MakeWindowExist( for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { - if ((winPtr2->window != None) + if (winPtr2->window && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; @@ -1863,7 +1863,7 @@ Tk_ConfigureWindow( Tcl_Panic("Can't set sibling or stack mode from Tk_ConfigureWindow."); } - if (winPtr->window != None) { + if (winPtr->window) { XConfigureWindow(winPtr->display, winPtr->window, valueMask, valuePtr); TkDoConfigureNotify(winPtr); @@ -1882,7 +1882,7 @@ Tk_MoveWindow( winPtr->changes.x = x; winPtr->changes.y = y; - if (winPtr->window != None) { + if (winPtr->window) { XMoveWindow(winPtr->display, winPtr->window, x, y); TkDoConfigureNotify(winPtr); } else { @@ -1900,7 +1900,7 @@ Tk_ResizeWindow( winPtr->changes.width = (unsigned) width; winPtr->changes.height = (unsigned) height; - if (winPtr->window != None) { + if (winPtr->window) { XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, (unsigned) height); TkDoConfigureNotify(winPtr); @@ -1922,7 +1922,7 @@ Tk_MoveResizeWindow( winPtr->changes.y = y; winPtr->changes.width = (unsigned) width; winPtr->changes.height = (unsigned) height; - if (winPtr->window != None) { + if (winPtr->window) { XMoveResizeWindow(winPtr->display, winPtr->window, x, y, (unsigned) width, (unsigned) height); TkDoConfigureNotify(winPtr); @@ -1940,7 +1940,7 @@ Tk_SetWindowBorderWidth( register TkWindow *winPtr = (TkWindow *) tkwin; winPtr->changes.border_width = width; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowBorderWidth(winPtr->display, winPtr->window, (unsigned) width); TkDoConfigureNotify(winPtr); @@ -2007,7 +2007,7 @@ Tk_ChangeWindowAttributes( winPtr->atts.cursor = attsPtr->cursor; } - if (winPtr->window != None) { + if (winPtr->window) { XChangeWindowAttributes(winPtr->display, winPtr->window, valueMask, attsPtr); } else { @@ -2025,7 +2025,7 @@ Tk_SetWindowBackground( winPtr->atts.background_pixel = pixel; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowBackground(winPtr->display, winPtr->window, pixel); } else { winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBackPixmap) @@ -2042,7 +2042,7 @@ Tk_SetWindowBackgroundPixmap( winPtr->atts.background_pixmap = pixmap; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowBackgroundPixmap(winPtr->display, winPtr->window, pixmap); } else { @@ -2060,7 +2060,7 @@ Tk_SetWindowBorder( winPtr->atts.border_pixel = pixel; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowBorder(winPtr->display, winPtr->window, pixel); } else { winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBorderPixmap) @@ -2077,7 +2077,7 @@ Tk_SetWindowBorderPixmap( winPtr->atts.border_pixmap = pixmap; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowBorderPixmap(winPtr->display, winPtr->window, pixmap); } else { @@ -2099,7 +2099,7 @@ Tk_DefineCursor( winPtr->atts.cursor = (Cursor) cursor; #endif - if (winPtr->window != None) { + if (winPtr->window) { XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor); } else { winPtr->dirtyAtts = winPtr->dirtyAtts | CWCursor; @@ -2110,7 +2110,7 @@ void Tk_UndefineCursor( Tk_Window tkwin) /* Window to manipulate. */ { - Tk_DefineCursor(tkwin, None); + Tk_DefineCursor(tkwin, 0); } void @@ -2122,7 +2122,7 @@ Tk_SetWindowColormap( winPtr->atts.colormap = colormap; - if (winPtr->window != None) { + if (winPtr->window) { XSetWindowColormap(winPtr->display, winPtr->window, colormap); if (!(winPtr->flags & TK_WIN_MANAGED)) { TkWmAddToColormapWindows(winPtr); @@ -2162,7 +2162,7 @@ Tk_SetWindowVisual( { register TkWindow *winPtr = (TkWindow *) tkwin; - if (winPtr->window != None) { + if (winPtr->window) { /* Too late! */ return 0; } @@ -2222,7 +2222,7 @@ TkDoConfigureNotify( if (winPtr->changes.stack_mode == Above) { event.xconfigure.above = winPtr->changes.sibling; } else { - event.xconfigure.above = None; + event.xconfigure.above = 0; } event.xconfigure.override_redirect = winPtr->atts.override_redirect; Tk_HandleEvent(&event); @@ -2585,7 +2585,7 @@ Tk_RestackWindow( * will be handled properly when the window is finally created. */ - if (winPtr->window != None) { + if (winPtr->window) { XWindowChanges changes; unsigned int mask; @@ -2593,7 +2593,7 @@ Tk_RestackWindow( changes.stack_mode = Above; for (otherPtr = winPtr->nextPtr; otherPtr != NULL; otherPtr = otherPtr->nextPtr) { - if ((otherPtr->window != None) + if (otherPtr->window && !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ changes.sibling = otherPtr->window; changes.stack_mode = Below; diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index ae43ae6..48aeb5c 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1151,7 +1151,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip) mask |= GCForeground; } gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues); - if (clip != None) { + if (clip) { TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip); } return gc; @@ -1256,7 +1256,7 @@ static void EntryDisplay(void *clientData, Drawable d) gc = EntryGetGC(entryPtr, es.insertColorObj, clipRegion); XFillRectangle(Tk_Display(tkwin), d, gc, cursorX-cursorWidth/2, cursorY, cursorWidth, cursorHeight); - XSetClipMask(Tk_Display(tkwin), gc, None); + XSetClipMask(Tk_Display(tkwin), gc, 0); Tk_FreeGC(Tk_Display(tkwin), gc); } @@ -1267,7 +1267,7 @@ static void EntryDisplay(void *clientData, Drawable d) Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, entryPtr->entry.layoutX, entryPtr->entry.layoutY, leftIndex, rightIndex); - XSetClipMask(Tk_Display(tkwin), gc, None); + XSetClipMask(Tk_Display(tkwin), gc, 0); Tk_FreeGC(Tk_Display(tkwin), gc); /* Overwrite the selected portion (if any) in the -selectforeground color: @@ -1278,7 +1278,7 @@ static void EntryDisplay(void *clientData, Drawable d) Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, entryPtr->entry.layoutX, entryPtr->entry.layoutY, selFirst, selLast); - XSetClipMask(Tk_Display(tkwin), gc, None); + XSetClipMask(Tk_Display(tkwin), gc, 0); Tk_FreeGC(Tk_Display(tkwin), gc); } @@ -1286,7 +1286,7 @@ static void EntryDisplay(void *clientData, Drawable d) * it from the Xft guts (if they're being used). */ #ifdef HAVE_XFT - TkUnixSetXftClipRegion(None); + TkUnixSetXftClipRegion(0); #endif TkDestroyRegion(clipRegion); } diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 1037840..9b80c59 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -183,10 +183,10 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) if (clipRegion != NULL) { #ifdef HAVE_XFT - TkUnixSetXftClipRegion(None); + TkUnixSetXftClipRegion(0); #endif - XSetClipMask(Tk_Display(tkwin), gc1, None); - XSetClipMask(Tk_Display(tkwin), gc2, None); + XSetClipMask(Tk_Display(tkwin), gc1, 0); + XSetClipMask(Tk_Display(tkwin), gc2, 0); TkDestroyRegion(clipRegion); } Tk_FreeGC(Tk_Display(tkwin), gc1); @@ -305,7 +305,7 @@ static void StippleOver( Pixmap stipple = Tk_AllocBitmapFromObj(NULL, tkwin, image->stippleObj); XColor *color = Tk_GetColorFromObj(tkwin, image->backgroundObj); - if (stipple != None) { + if (stipple) { unsigned long mask = GCFillStyle | GCStipple | GCForeground; XGCValues gcvalues; GC gc; diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index 48d3fb9..95bee0a 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -103,10 +103,10 @@ TkpDisplayMenuButton( border = mbPtr->normalBorder; } - if (mbPtr->image != None) { + if (mbPtr->image) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap != None) { + } else if (mbPtr->bitmap) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } @@ -194,7 +194,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap != None) { + } else if (mbPtr->bitmap) { XSetClipOrigin(mbPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -214,7 +214,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap != None) { + } else if (mbPtr->bitmap) { XSetClipOrigin(mbPtr->display, gc, x, y); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -369,10 +369,10 @@ TkpComputeMenuButtonGeometry( txtHeight = 0; avgWidth = 0; - if (mbPtr->image != None) { + if (mbPtr->image) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap != None) { + } else if (mbPtr->bitmap) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } diff --git a/win/stubs.c b/win/stubs.c index 4564639..7e791b5 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -397,7 +397,7 @@ XGetWindowProperty( unsigned long *bytes_after_return, unsigned char **prop_return) { - *actual_type_return = None; + *actual_type_return = 0; *actual_format_return = 0; *nitems_return = 0; *bytes_after_return = 0; diff --git a/win/tkWin3d.c b/win/tkWin3d.c index df6aa95..aa026e8 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -127,7 +127,7 @@ Tk_3DVerticalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int half; - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { + if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -222,7 +222,7 @@ Tk_3DHorizontalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int topColor, bottomColor; - if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { + if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -339,7 +339,7 @@ TkpGetShadows( int r, g, b; XGCValues gcValues; - if (borderPtr->lightGC != None) { + if (borderPtr->lightGC) { return; } @@ -465,10 +465,10 @@ TkpGetShadows( return; } - if (borderPtr->shadow == None) { + if (!borderPtr->shadow) { borderPtr->shadow = Tk_GetBitmap((Tcl_Interp *) NULL, tkwin, Tk_GetUid("gray50")); - if (borderPtr->shadow == None) { + if (!borderPtr->shadow) { Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border"); } } @@ -540,7 +540,7 @@ TkWinGetBorderPixels( { WinBorder *borderPtr = (WinBorder *) border; - if (borderPtr->info.lightGC == None) { + if (!borderPtr->info.lightGC) { TkpGetShadows(&borderPtr->info, tkwin); } switch (which) { diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 9e1960d..0a11a20 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -433,10 +433,10 @@ TkpDisplayButton( * Display image or bitmap or text for button. */ - if (butPtr->image != None) { + if (butPtr->image) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; - } else if (butPtr->bitmap != None) { + } else if (butPtr->bitmap) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } @@ -839,7 +839,7 @@ TkpComputeButtonGeometry( if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &imgWidth, &imgHeight); haveImage = 1; - } else if (butPtr->bitmap != None) { + } else if (butPtr->bitmap) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &imgWidth, &imgHeight); haveImage = 1; diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index d0bae8f..7f48703 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -246,7 +246,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG (char *) NULL #define DEF_MENU_ENTRY_ACCELERATOR (char *) NULL #define DEF_MENU_ENTRY_BG (char *) NULL -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP 0 #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND (char *) NULL #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 1897bc8..e94c893 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -631,7 +631,7 @@ XFillRectangles( TkWinDCState state; HBRUSH brush, oldBrush; - if (d == None) { + if (!d) { return BadDrawable; } @@ -641,7 +641,7 @@ XFillRectangles( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple != None) { + && gc->stipple) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH stipple; HBITMAP oldBitmap, bitmap; @@ -756,7 +756,7 @@ RenderObject( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple != None) { + && gc->stipple) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HDC dcMem; @@ -882,7 +882,7 @@ XDrawLines( TkWinDCState state; HDC dc; - if (d == None) { + if (!d) { return BadDrawable; } @@ -927,7 +927,7 @@ XFillPolygon( TkWinDCState state; HDC dc; - if (d == None) { + if (!d) { return BadDrawable; } @@ -969,7 +969,7 @@ XDrawRectangle( HBRUSH oldBrush; HDC dc; - if (d == None) { + if (!d) { return BadDrawable; } @@ -1085,7 +1085,7 @@ DrawOrFillArc( int xstart, ystart, xend, yend; double radian_start, radian_end, xr, yr; - if (d == None) { + if (!d) { return BadDrawable; } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index a0670cc..539349f 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -242,7 +242,7 @@ TkpUseWindow( */ /* - if (winPtr->window != None) { + if (winPtr->window) { Tcl_AppendResult(interp, "can't modify container after widget is created", NULL); return TCL_ERROR; @@ -298,7 +298,7 @@ TkpUseWindow( * order to avoid bug 1096074 in future. */ - char msg[256]; + char msg[260]; sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", diff --git a/win/tkWinFont.c b/win/tkWinFont.c index 1292772..b60a918 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -519,7 +519,7 @@ TkpGetFontFromAttributes( tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hwnd = window ? TkWinGetHWND(window) : NULL; hdc = GetDC(hwnd); /* @@ -631,7 +631,7 @@ TkpGetFontFamilies( Window window; window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hwnd = window ? TkWinGetHWND(window) : NULL; hdc = GetDC(hwnd); /* @@ -1095,7 +1095,7 @@ Tk_DrawChars( fontPtr = (WinFont *) gc->font; display->request++; - if (drawable == None) { + if (!drawable) { return; } @@ -1103,14 +1103,14 @@ Tk_DrawChars( SetROP2(dc, tkpWinRopModes[gc->function]); - if ((gc->clip_mask != None) && + if (gc->clip_mask && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { SelectClipRgn(dc, (HRGN)((TkpClipMask*)gc->clip_mask)->value.region); } if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple != None) { + && gc->stipple) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; @@ -1395,7 +1395,7 @@ InitFont( char buf[LF_FACESIZE * sizeof(WCHAR)]; window = Tk_WindowId(tkwin); - hwnd = (window == None) ? NULL : TkWinGetHWND(window); + hwnd = window ? TkWinGetHWND(window) : NULL; hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); diff --git a/win/tkWinInt.h b/win/tkWinInt.h index abac7b0..b6f7a98 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -41,6 +41,11 @@ #define SPI_SETKEYBOARDCUES 0x100B #endif +#if defined(_WIN32) && !defined(ControlMask) /* prevent conflicting define against windows.h, bug [9e31fd9449] */ +# define ControlMask (1<<2) +#endif + + /* * The TkWinDCState is used to save the state of a device context so that it * can be restored later. diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 9a35266..6240ceb 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2345,7 +2345,7 @@ DrawMenuEntryLabel( XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y, (unsigned) width, (unsigned) height); } else if ((mePtr->image != NULL) - && (menuPtr->disabledImageGC != None)) { + && menuPtr->disabledImageGC) { XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC, leftEdge + imageXOffset, (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset), @@ -2990,7 +2990,7 @@ MenuSelectEvent( Tk_MakeWindowExist(menuPtr->tkwin); event.event = Tk_WindowId(menuPtr->tkwin); event.root = XRootWindow(menuPtr->display, 0); - event.subwindow = None; + event.subwindow = 0; event.time = TkpGetMS(); root.msgpos = GetMessagePos(); diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index 51f0f59..60e218d 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -115,7 +115,7 @@ Tk_GetPixmap( if (newTwdPtr->bitmap.handle == NULL) { ckfree((char *) newTwdPtr); - return None; + return 0; } return (Pixmap) newTwdPtr; diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index dcddb8f..d5706ac 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -387,7 +387,7 @@ XGetInputFocus( { Tk_Window tkwin = Tk_HWNDToWindow(GetFocus()); - *focus_return = tkwin ? Tk_WindowId(tkwin) : None; + *focus_return = tkwin ? Tk_WindowId(tkwin) : 0; *revert_to_return = RevertToParent; display->request++; return Success; @@ -418,7 +418,7 @@ XSetInputFocus( Time time) { display->request++; - if (focus != None) { + if (focus) { SetFocus(Tk_GetHWND(focus)); } return Success; @@ -465,7 +465,7 @@ TkpChangeFocus( } } - if (winPtr->window == None) { + if (!winPtr->window) { Tcl_Panic("ChangeXFocus got null X window"); } diff --git a/win/tkWinPort.h b/win/tkWinPort.h index b94628e..aec5a66 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -118,7 +118,7 @@ */ #define TkpDefineNativeBitmaps() -#define TkpCreateNativeBitmap(display, source) None -#define TkpGetNativeAppBitmap(display, name, w, h) None +#define TkpCreateNativeBitmap(display, source) 0 +#define TkpGetNativeAppBitmap(display, name, w, h) 0 #endif /* _WINPORT */ diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index fc9685d..f30a957 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -238,7 +238,7 @@ CreateProc( for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL; winPtr = winPtr->nextPtr) { - if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) { + if ((winPtr->window) && !(winPtr->flags & TK_TOP_HIERARCHY)) { TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window), Below); break; diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 3dfc078..0675bc6 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -228,7 +228,7 @@ TkpScanWindowId( if (tkwin) { *idPtr = Tk_WindowId(tkwin); } else { - *idPtr = None; + *idPtr = 0; } return TCL_OK; } @@ -259,7 +259,7 @@ TkpMakeWindow( int style; HWND hwnd; - if (parent != None) { + if (parent) { parentWin = Tk_GetHWND(parent); style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; } else { @@ -657,7 +657,7 @@ XConfigureWindow( if (valueMask & CWStackMode) { HWND sibling; - if ((valueMask & CWSibling) && (values->sibling != None)) { + if ((valueMask & CWSibling) && values->sibling) { sibling = Tk_GetHWND(values->sibling); } else { sibling = NULL; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 2c3b0e4..8e6683f 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -1035,7 +1035,7 @@ WinSetIcon( "\" isn't a top-level window", NULL); return TCL_ERROR; } - if (Tk_WindowId(tkw) == None) { + if (!Tk_WindowId(tkw)) { Tk_MakeWindowExist(tkw); } @@ -1198,7 +1198,7 @@ TkWinGetIcon( } } - if (Tk_WindowId(tkwin) == None) { + if (!Tk_WindowId(tkwin)) { Tk_MakeWindowExist(tkwin); } @@ -1977,11 +1977,11 @@ TkWmNewWindow( wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; - wmPtr->hints.icon_pixmap = None; - wmPtr->hints.icon_window = None; + wmPtr->hints.icon_pixmap = 0; + wmPtr->hints.icon_window = 0; wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; - wmPtr->hints.icon_mask = None; - wmPtr->hints.window_group = None; + wmPtr->hints.icon_mask = 0; + wmPtr->hints.window_group = 0; /* * Default the maximum dimensions to the size of the display. @@ -2062,7 +2062,7 @@ UpdateWrapper( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (winPtr->window == None) { + if (!winPtr->window) { /* * Ensure existence of the window to update the wrapper for. */ @@ -2683,7 +2683,7 @@ TkWmDeadWindow( VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, (ClientData) wmPtr2->winPtr); wmPtr2->masterPtr = NULL; - if ((wmPtr2->wrapper != None) + if (wmPtr2->wrapper && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { UpdateWrapper(wmPtr2->winPtr); } @@ -3474,7 +3474,7 @@ WmColormapwindowsCmd( if (winPtr2 == winPtr) { gotToplevel = 1; } - if (winPtr2->window == None) { + if (!winPtr2->window) { Tk_MakeWindowExist((Tk_Window) winPtr2); } cmapList[i] = winPtr2; @@ -3750,7 +3750,7 @@ WmFrameCmd( Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (Tk_WindowId((Tk_Window) winPtr) == None) { + if (!Tk_WindowId((Tk_Window) winPtr)) { Tk_MakeWindowExist((Tk_Window) winPtr); } hwnd = wmPtr->wrapper; @@ -4044,9 +4044,9 @@ WmIconbitmapCmd( string = Tcl_GetString(objv[objc-1]); if (*string == '\0') { - if (wmPtr->hints.icon_pixmap != None) { + if (wmPtr->hints.icon_pixmap) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); - wmPtr->hints.icon_pixmap = None; + wmPtr->hints.icon_pixmap = 0; } wmPtr->hints.flags &= ~IconPixmapHint; if (WinSetIcon(interp, NULL, (Tk_Window) useWinPtr) != TCL_OK) { @@ -4098,7 +4098,7 @@ WmIconbitmapCmd( Pixmap pixmap; Tcl_ResetResult(interp); pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string); - if (pixmap == None) { + if (!pixmap) { return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; @@ -4217,13 +4217,13 @@ WmIconmaskCmd( } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { - if (wmPtr->hints.icon_mask != None) { + if (wmPtr->hints.icon_mask) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } wmPtr->hints.flags &= ~IconMaskHint; } else { pixmap = Tk_GetBitmap(interp, tkwin, argv3); - if (pixmap == None) { + if (!pixmap) { return TCL_ERROR; } wmPtr->hints.icon_mask = pixmap; @@ -6388,7 +6388,7 @@ Tk_GetRootCoords( * If the window is mapped, let Windows figure out the translation. */ - if (winPtr->window != None) { + if (winPtr->window) { HWND hwnd = Tk_GetHWND(winPtr->window); POINT point; @@ -6816,7 +6816,7 @@ TkWmRestackToplevel( * (mapping it may give it a reparent window). */ - if (winPtr->window == None) { + if (!winPtr->window) { Tk_MakeWindowExist((Tk_Window) winPtr); } if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6826,7 +6826,7 @@ TkWmRestackToplevel( ? winPtr->wmInfoPtr->wrapper : Tk_GetHWND(winPtr->window); if (otherPtr != NULL) { - if (otherPtr->window == None) { + if (!otherPtr->window) { Tk_MakeWindowExist((Tk_Window) otherPtr); } if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6877,7 +6877,7 @@ TkWmAddToColormapWindows( TkWindow **oldPtr, **newPtr; int count, i; - if (winPtr->window == None) { + if (!winPtr->window) { return; } @@ -7312,7 +7312,7 @@ GenerateConfigureNotify( event.xconfigure.y = winPtr->changes.y; event.xconfigure.width = winPtr->changes.width; event.xconfigure.height = winPtr->changes.height; - event.xconfigure.above = None; + event.xconfigure.above = 0; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } @@ -8586,7 +8586,7 @@ TkpWinToplevelDetachWindow( SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); winPtr->flags &= ~TK_EMBEDDED; winPtr->privatePtr = NULL; - wmPtr->wrapper = None; + wmPtr->wrapper = 0; if (state >= 0 && state <= 3) { wmPtr->hints.initial_state = state; } diff --git a/win/tkWinX.c b/win/tkWinX.c index af28e41..ce639a0 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -573,10 +573,10 @@ TkWinDisplayChanged( screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); - if (screen->cmap != None) { + if (screen->cmap) { XFreeColormap(display, screen->cmap); } - screen->cmap = XCreateColormap(display, None, screen->root_visual, + screen->cmap = XCreateColormap(display, 0, screen->root_visual, AllocNone); } @@ -636,7 +636,7 @@ TkpOpenDisplay( twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable)); if (twdPtr == NULL) { - return None; + return 0; } twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = NULL; @@ -649,7 +649,7 @@ TkpOpenDisplay( screen->white_pixel = RGB(255, 255, 255); screen->black_pixel = RGB(0, 0, 0); - screen->cmap = None; + screen->cmap = 0; display->screens = screen; display->nscreens = 1; @@ -704,10 +704,10 @@ TkpCloseDisplay( if (display->screens->root_visual != NULL) { ckfree((char *) display->screens->root_visual); } - if (display->screens->root != None) { + if (display->screens->root) { ckfree((char *) display->screens->root); } - if (display->screens->cmap != None) { + if (display->screens->cmap) { XFreeColormap(display, display->screens->cmap); } ckfree((char *) display->screens); @@ -1018,7 +1018,7 @@ GenerateXEvent( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd); - if (!winPtr || winPtr->window == None) { + if (!winPtr || !winPtr->window) { return; } @@ -1146,7 +1146,7 @@ GenerateXEvent( */ event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xbutton.subwindow = None; + event.xbutton.subwindow = 0; event.xbutton.x = clientPoint.x; event.xbutton.y = clientPoint.y; event.xbutton.x_root = root.point.x; @@ -1654,7 +1654,7 @@ HandleIMEComposition( event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xkey.subwindow = None; + event.xkey.subwindow = 0; event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 6359891..65b7240 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -453,7 +453,7 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) { Window win = Tk_WindowId(tkwin); - if (win != None) { + if (win) { elementData->hwnd = Tk_GetHWND(win); } else { elementData->hwnd = elementData->procs->stubWindow; diff --git a/xlib/X11/X.h b/xlib/X11/X.h index daf2283..ad8f630 100644 --- a/xlib/X11/X.h +++ b/xlib/X11/X.h @@ -73,7 +73,9 @@ typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ -#define None 0L /* universal null resource or null atom */ +#ifndef _WIN32 /* prevent conflicting define against windows.h, bug [9e31fd9449] */ +# define None 0L /* universal null resource or null atom */ +#endif #define ParentRelative 1L /* background pixmap in CreateWindow and ChangeWindowAttributes */ @@ -179,7 +181,9 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -#define ControlMask (1<<2) +#ifndef _WIN32 /* prevent conflicting define against windows.h, bug [9e31fd9449] */ +# define ControlMask (1<<2) +#endif #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) @@ -294,7 +298,7 @@ are reserved in the protocol for errors and replies. */ /* Used in SetInputFocus, GetInputFocus */ -#define RevertToNone (int)None +#define RevertToNone 0 #define RevertToPointerRoot (int)PointerRoot #define RevertToParent 2 diff --git a/xlib/xgc.c b/xlib/xgc.c index b18cb9e..e62f0de 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -50,7 +50,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; - if (clip_mask == None) { + if (!clip_mask) { clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK @@ -78,14 +78,14 @@ static TkpClipMask *AllocClipMask(GC gc) { */ static void FreeClipMask(GC gc) { - if (gc->clip_mask != None) { + if (gc->clip_mask) { #ifdef MAC_OSX_TK if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif ckfree((char*) gc->clip_mask); - gc->clip_mask = None; + gc->clip_mask = 0; } } @@ -126,7 +126,7 @@ XCreateGC( gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { - return None; + return 0; } #define InitField(name,maskbit,default) \ @@ -145,11 +145,11 @@ XCreateGC( InitField(fill_style, GCFillStyle, FillSolid); InitField(fill_rule, GCFillRule, WindingRule); InitField(arc_mode, GCArcMode, ArcPieSlice); - InitField(tile, GCTile, None); - InitField(stipple, GCStipple, None); + InitField(tile, GCTile, 0); + InitField(stipple, GCStipple, 0); InitField(ts_x_origin, GCTileStipXOrigin, 0); InitField(ts_y_origin, GCTileStipYOrigin, 0); - InitField(font, GCFont, None); + InitField(font, GCFont, 0); InitField(subwindow_mode, GCSubwindowMode, ClipByChildren); InitField(graphics_exposures, GCGraphicsExposures, True); InitField(clip_x_origin, GCClipXOrigin, 0); @@ -158,7 +158,7 @@ XCreateGC( InitField(dashes, GCDashList, 4); (&(gp->dashes))[1] = 0; - gp->clip_mask = None; + gp->clip_mask = 0; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); @@ -269,7 +269,7 @@ int XFreeGC( Display *d, GC gc) { - if (gc != None) { + if (gc) { FreeClipMask(gc); TkpFreeGCCache(gc); ckfree((char *) gc); @@ -465,7 +465,7 @@ TkSetRegion( GC gc, TkRegion r) { - if (r == None) { + if (!r) { Tcl_Panic("must not pass None to TkSetRegion for compatibility with X11; use XSetClipMask instead"); } else { TkpClipMask *clip_mask = AllocClipMask(gc); @@ -484,7 +484,7 @@ XSetClipMask( GC gc, Pixmap pixmap) { - if (pixmap == None) { + if (!pixmap) { FreeClipMask(gc); } else { TkpClipMask *clip_mask = AllocClipMask(gc); diff --git a/xlib/ximage.c b/xlib/ximage.c index aaab946..f7bf1cc 100644 --- a/xlib/ximage.c +++ b/xlib/ximage.c @@ -47,7 +47,7 @@ XCreateBitmapFromData( pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1); gc = XCreateGC(display, pix, 0, NULL); if (gc == NULL) { - return None; + return 0; } ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width, height, 8, (width + 7) / 8); -- cgit v0.12 From 36b48da5ca6c18d23f774188450f6f2bedbf1034 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 20 Dec 2018 20:00:37 +0000 Subject: Let's see if we can build something with Travis-CI --- .travis.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2095d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +sudo: required +language: c +addons: + apt: + packages: + - tcl-dev + - libx11-dev +matrix: + include: + - os: linux + dist: trusty + compiler: clang + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: clang + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-4.9 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-5 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-7 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - BUILD_DIR=unix +before_install: + - export ERROR_ON_FAILURES=1 + - cd ${BUILD_DIR} +install: + - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT} +script: + - make + # The styles=develop avoids some weird problems on OSX + #- test -n "$NO_DIRECT_TEST" || make test styles=develop -- cgit v0.12 From b68e469c6fcec04a86935ae2e8853197213f40db Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Wed, 26 Dec 2018 14:55:18 +0000 Subject: Change None/ControlMask on win32 (and MacOSX - which is harmless) to being an enum. This fixes (hopefully) the ***POTENTIAL INCOMPATABILITY*** in previous commit --- generic/tkBind.c | 2 +- generic/tkRectOval.c | 2 +- win/tkWinInt.h | 5 ----- xlib/X11/X.h | 11 +++++------ 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 476aed0..df82323 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -631,7 +631,7 @@ static const TkStateMap visNotify[] = { }; static const TkStateMap configureRequestDetail[] = { - {0, "None"}, + {0, "None"}, {Above, "Above"}, {Below, "Below"}, {BottomIf, "BottomIf"}, diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index 6ed4488..af94c6f 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -522,7 +522,7 @@ ConfigureRectOval( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = rectOvalPtr->outline.gc != None ? + gcValues.line_width = rectOvalPtr->outline.gc ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif diff --git a/win/tkWinInt.h b/win/tkWinInt.h index b6f7a98..abac7b0 100644 --- a/win/tkWinInt.h +++ b/win/tkWinInt.h @@ -41,11 +41,6 @@ #define SPI_SETKEYBOARDCUES 0x100B #endif -#if defined(_WIN32) && !defined(ControlMask) /* prevent conflicting define against windows.h, bug [9e31fd9449] */ -# define ControlMask (1<<2) -#endif - - /* * The TkWinDCState is used to save the state of a device context so that it * can be restored later. diff --git a/xlib/X11/X.h b/xlib/X11/X.h index ad8f630..316683b 100644 --- a/xlib/X11/X.h +++ b/xlib/X11/X.h @@ -73,9 +73,7 @@ typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ -#ifndef _WIN32 /* prevent conflicting define against windows.h, bug [9e31fd9449] */ -# define None 0L /* universal null resource or null atom */ -#endif +/* define None 0L See bug [9e31fd9449] and below */ #define ParentRelative 1L /* background pixmap in CreateWindow and ChangeWindowAttributes */ @@ -181,15 +179,16 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -#ifndef _WIN32 /* prevent conflicting define against windows.h, bug [9e31fd9449] */ -# define ControlMask (1<<2) -#endif +/* define ControlMask (1<<2) See bug [9e31fd9449] and below */ #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) #define Mod4Mask (1<<6) #define Mod5Mask (1<<7) +/* See bug [9e31fd9449], this way prevents conflicts with Win32 headers */ +enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; + /* modifier names. Used to build a SetModifierMapping request or to read a GetModifierMapping request. These correspond to the masks defined above. */ -- cgit v0.12 From 4e81da6984774cee4b599265f08e08c1698e8887 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 29 Dec 2018 21:42:12 +0000 Subject: Fix [21525158b0]: On MS Windows XImage data and Tk_Visual() return wrong information. Bug report, analysis and patch provided by Scott Pitcher (many thanks!) --- generic/tkCanvas.c | 2 +- win/tkWinDraw.c | 18 ++++++++++++++++++ win/tkWinX.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 2f45399..53bfe00 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -2777,7 +2777,7 @@ DrawCanvas( * swap anything here. */ -#ifdef _WIN32 +#if defined(NO_WINRGBFIX) && defined(_WIN32) #define R_OFFSET 2 #define B_OFFSET 0 #else diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 2c35d3b..0ec63dc 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -519,6 +519,9 @@ TkPutImage( BITMAPINFO *infoPtr; HBITMAP bitmap; char *data; +#ifndef NO_WINRGBFIX + Visual *visual; +#endif display->request++; @@ -564,13 +567,18 @@ TkPutImage( infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */ infoPtr->bmiHeader.biPlanes = 1; infoPtr->bmiHeader.biBitCount = image->bits_per_pixel; +#ifdef NO_WINRGBFIX infoPtr->bmiHeader.biCompression = BI_RGB; +#endif infoPtr->bmiHeader.biSizeImage = 0; infoPtr->bmiHeader.biXPelsPerMeter = 0; infoPtr->bmiHeader.biYPelsPerMeter = 0; infoPtr->bmiHeader.biClrImportant = 0; if (usePalette) { +#ifndef NO_WINRGBFIX + infoPtr->bmiHeader.biCompression = BI_RGB; +#endif infoPtr->bmiHeader.biClrUsed = ncolors; for (i = 0; i < ncolors; i++) { infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]); @@ -579,7 +587,17 @@ TkPutImage( infoPtr->bmiColors[i].rgbReserved = 0; } } else { +#ifdef NO_WINRGBFIX infoPtr->bmiHeader.biClrUsed = 0; +#else + infoPtr->bmiHeader.biCompression = BI_BITFIELDS; + /* Modelled on XGetVisualInfo() in xutil.c. + * We want to get the rgb masks for the default visual for the given display. */ + visual = DefaultVisual(display,0); + *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))) = visual->blue_mask; + *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+1) = visual->green_mask; + *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+2) = visual->red_mask; +#endif } bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT, image->data, infoPtr, DIB_RGB_COLORS); diff --git a/win/tkWinX.c b/win/tkWinX.c index 761d9ca..d010be2 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -457,21 +457,39 @@ TkWinDisplayChanged( } else if (screen->root_depth == 12) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 32; +#ifdef NO_WINRGBFIX screen->root_visual->red_mask = 0xf0; screen->root_visual->green_mask = 0xf000; screen->root_visual->blue_mask = 0xf00000; +#else + screen->root_visual->red_mask = 0xf00000; + screen->root_visual->green_mask = 0xf000; + screen->root_visual->blue_mask = 0xf0; +#endif } else if (screen->root_depth == 16) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 64; +#ifdef NO_WINRGBFIX screen->root_visual->red_mask = 0xf8; screen->root_visual->green_mask = 0xfc00; screen->root_visual->blue_mask = 0xf80000; +#else + screen->root_visual->red_mask = 0xf80000; + screen->root_visual->green_mask = 0xfc00; + screen->root_visual->blue_mask = 0xf8; +#endif } else if (screen->root_depth >= 24) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 256; +#ifdef NO_WINRGBFIX screen->root_visual->red_mask = 0xff; screen->root_visual->green_mask = 0xff00; screen->root_visual->blue_mask = 0xff0000; +#else + screen->root_visual->red_mask = 0xff0000; + screen->root_visual->green_mask = 0xff00; + screen->root_visual->blue_mask = 0xff; +#endif } screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); -- cgit v0.12 From bb7a96e1cb79f95854115959f5209ef6c02b8797 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 30 Dec 2018 13:22:12 +0000 Subject: Fix crash in canvPs-5.1 test (thanks to Christian Werner), and remove unnecessary #ifdef and an obsolete comment --- generic/tkCanvas.c | 11 ----------- win/tkWinDraw.c | 11 +---------- win/tkWinX.c | 18 ------------------ 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 53bfe00..14e9f20 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -2769,21 +2769,10 @@ DrawCanvas( * colours and place them in the photo block. Perhaps we could * just not bother with the alpha byte because we are using * TK_PHOTO_COMPOSITE_SET later? - * ***Windows: We have to swap the red and blue values. The - * XImage storage is B - G - R - A which becomes a 32bit ARGB - * quad. However the visual mask is a 32bit ABGR quad. And - * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. - * If the visual mask was correct there would be no need to - * swap anything here. */ -#if defined(NO_WINRGBFIX) && defined(_WIN32) -#define R_OFFSET 2 -#define B_OFFSET 0 -#else #define R_OFFSET 0 #define B_OFFSET 2 -#endif blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] = (unsigned char)((pixel & visualPtr->red_mask) >> rshift); blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] = diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index 0ec63dc..a396937 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -559,7 +559,7 @@ TkPutImage( infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*ncolors); } else { - infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)); + infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(DWORD)*4); } infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -567,18 +567,13 @@ TkPutImage( infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */ infoPtr->bmiHeader.biPlanes = 1; infoPtr->bmiHeader.biBitCount = image->bits_per_pixel; -#ifdef NO_WINRGBFIX - infoPtr->bmiHeader.biCompression = BI_RGB; -#endif infoPtr->bmiHeader.biSizeImage = 0; infoPtr->bmiHeader.biXPelsPerMeter = 0; infoPtr->bmiHeader.biYPelsPerMeter = 0; infoPtr->bmiHeader.biClrImportant = 0; if (usePalette) { -#ifndef NO_WINRGBFIX infoPtr->bmiHeader.biCompression = BI_RGB; -#endif infoPtr->bmiHeader.biClrUsed = ncolors; for (i = 0; i < ncolors; i++) { infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]); @@ -587,9 +582,6 @@ TkPutImage( infoPtr->bmiColors[i].rgbReserved = 0; } } else { -#ifdef NO_WINRGBFIX - infoPtr->bmiHeader.biClrUsed = 0; -#else infoPtr->bmiHeader.biCompression = BI_BITFIELDS; /* Modelled on XGetVisualInfo() in xutil.c. * We want to get the rgb masks for the default visual for the given display. */ @@ -597,7 +589,6 @@ TkPutImage( *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))) = visual->blue_mask; *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+1) = visual->green_mask; *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+2) = visual->red_mask; -#endif } bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT, image->data, infoPtr, DIB_RGB_COLORS); diff --git a/win/tkWinX.c b/win/tkWinX.c index d010be2..3ac9a32 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -457,39 +457,21 @@ TkWinDisplayChanged( } else if (screen->root_depth == 12) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 32; -#ifdef NO_WINRGBFIX - screen->root_visual->red_mask = 0xf0; - screen->root_visual->green_mask = 0xf000; - screen->root_visual->blue_mask = 0xf00000; -#else screen->root_visual->red_mask = 0xf00000; screen->root_visual->green_mask = 0xf000; screen->root_visual->blue_mask = 0xf0; -#endif } else if (screen->root_depth == 16) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 64; -#ifdef NO_WINRGBFIX - screen->root_visual->red_mask = 0xf8; - screen->root_visual->green_mask = 0xfc00; - screen->root_visual->blue_mask = 0xf80000; -#else screen->root_visual->red_mask = 0xf80000; screen->root_visual->green_mask = 0xfc00; screen->root_visual->blue_mask = 0xf8; -#endif } else if (screen->root_depth >= 24) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 256; -#ifdef NO_WINRGBFIX - screen->root_visual->red_mask = 0xff; - screen->root_visual->green_mask = 0xff00; - screen->root_visual->blue_mask = 0xff0000; -#else screen->root_visual->red_mask = 0xff0000; screen->root_visual->green_mask = 0xff00; screen->root_visual->blue_mask = 0xff; -#endif } screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); -- cgit v0.12 From 1b3c5a847413a1fc2d6c0334091a2c499e08c13c Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 30 Dec 2018 22:41:47 +0000 Subject: TextInvalidateLineMetrics should always send a <> event, whether an asynchronous update is scheduled at that moment or not. --- generic/tkTextDisp.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index a6ee33e..6d24d22 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3526,8 +3526,14 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); } + + /* + * The widget is now out of sync: send a <> event. + */ + + GenerateWidgetViewSyncEvent(textPtr, 0); + } /* -- cgit v0.12 From f2b5a87d6dc6d3468828d48929583d950690a40b Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Mon, 31 Dec 2018 15:36:56 +0000 Subject: =?UTF-8?q?As=20requested=20by=20Christian=20Werner/Fran=C3=A7ois?= =?UTF-8?q?=20Vogel=20and=20others:=20Undo=20many=20None=20->=200=20change?= =?UTF-8?q?s,=20in=20order=20to=20reduce=20the=20probability=20of=20merge?= =?UTF-8?q?=20conflicts=20with=20other=20branches.=20Remark:=20Many=20usag?= =?UTF-8?q?es=20of=20"None"=20in=20Tk=20are=20wrong,=20"NULL"=20should=20b?= =?UTF-8?q?e=20used=20in=20many=20places=20where=20pointers=20are=20refere?= =?UTF-8?q?nced=20in=20stead=20of=20XID's.=20Those=20places=20are=20correc?= =?UTF-8?q?ted.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generic/tk3d.c | 24 +++++----- generic/tkBind.c | 4 +- generic/tkBitmap.c | 8 ++-- generic/tkButton.c | 70 ++++++++++++++-------------- generic/tkCanvArc.c | 116 +++++++++++++++++++++++------------------------ generic/tkCanvBmap.c | 80 ++++++++++++++++---------------- generic/tkCanvImg.c | 8 ++-- generic/tkCanvLine.c | 54 +++++++++++----------- generic/tkCanvPoly.c | 98 +++++++++++++++++++-------------------- generic/tkCanvText.c | 76 +++++++++++++++---------------- generic/tkCanvUtil.c | 82 ++++++++++++++++----------------- generic/tkCanvWind.c | 2 +- generic/tkCanvas.c | 16 +++---- generic/tkClipboard.c | 2 +- generic/tkColor.c | 4 +- generic/tkConfig.c | 16 +++---- generic/tkCursor.c | 5 +- generic/tkEntry.c | 34 +++++++------- generic/tkEntry.h | 2 +- generic/tkEvent.c | 16 +++---- generic/tkFrame.c | 24 +++++----- generic/tkGC.c | 14 +++--- generic/tkGrab.c | 18 ++++---- generic/tkImage.c | 4 +- generic/tkImgBmap.c | 40 ++++++++-------- generic/tkImgPhoto.c | 22 ++++----- generic/tkListbox.c | 26 +++++------ generic/tkMenu.c | 2 +- generic/tkMenuDraw.c | 74 +++++++++++++++--------------- generic/tkMenubutton.c | 42 ++++++++--------- generic/tkMessage.c | 18 ++++---- generic/tkOldConfig.c | 38 ++++++++-------- generic/tkPanedWindow.c | 16 +++---- generic/tkPointer.c | 11 +++-- generic/tkRectOval.c | 94 +++++++++++++++++++------------------- generic/tkScale.c | 20 ++++---- generic/tkScale.h | 2 +- generic/tkScrollbar.c | 2 +- generic/tkSelect.c | 10 ++-- generic/tkSquare.c | 10 ++-- generic/tkTest.c | 4 +- generic/tkText.c | 38 ++++++++-------- generic/tkTextDisp.c | 60 ++++++++++++------------ generic/tkTextTag.c | 42 ++++++++--------- generic/tkVisual.c | 8 ++-- generic/tkWindow.c | 62 ++++++++++++------------- generic/ttk/ttkEntry.c | 10 ++-- generic/ttk/ttkLabel.c | 8 ++-- macosx/tkMacOSXDefault.h | 4 +- macosx/tkMacOSXEmbed.c | 6 +-- macosx/tkMacOSXMenu.c | 4 +- macosx/tkMacOSXScrlbr.c | 4 +- macosx/tkMacOSXXStubs.c | 2 +- unix/tkUnix3d.c | 4 +- unix/tkUnixDefault.h | 2 +- win/tkWinDefault.h | 2 +- 56 files changed, 734 insertions(+), 730 deletions(-) diff --git a/generic/tk3d.c b/generic/tk3d.c index a97bed3..eebe122 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -236,7 +236,7 @@ Tk_Get3DBorder( borderPtr->bgColorPtr = bgColorPtr; borderPtr->darkColorPtr = NULL; borderPtr->lightColorPtr = NULL; - borderPtr->shadow = 0; + borderPtr->shadow = None; borderPtr->bgGC = 0; borderPtr->darkGC = 0; borderPtr->lightGC = 0; @@ -375,7 +375,7 @@ Tk_3DBorderGC( { TkBorder * borderPtr = (TkBorder *) border; - if (!borderPtr->lightGC && (which != TK_3D_FLAT_GC)) { + if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) { TkpGetShadows(borderPtr, tkwin); } if (which == TK_3D_FLAT_GC) { @@ -392,7 +392,7 @@ Tk_3DBorderGC( * compilers happy. */ - return 0; + return (GC) None; } /* @@ -428,29 +428,29 @@ Tk_Free3DBorder( prevPtr = (TkBorder *) Tcl_GetHashValue(borderPtr->hashPtr); TkpFreeBorder(borderPtr); - if (borderPtr->bgColorPtr) { + if (borderPtr->bgColorPtr != NULL) { Tk_FreeColor(borderPtr->bgColorPtr); } - if (borderPtr->darkColorPtr) { + if (borderPtr->darkColorPtr != NULL) { Tk_FreeColor(borderPtr->darkColorPtr); } - if (borderPtr->lightColorPtr) { + if (borderPtr->lightColorPtr != NULL) { Tk_FreeColor(borderPtr->lightColorPtr); } - if (borderPtr->shadow) { + if (borderPtr->shadow != None) { Tk_FreeBitmap(display, borderPtr->shadow); } - if (borderPtr->bgGC) { + if (borderPtr->bgGC != None) { Tk_FreeGC(display, borderPtr->bgGC); } - if (borderPtr->darkGC) { + if (borderPtr->darkGC != None) { Tk_FreeGC(display, borderPtr->darkGC); } - if (borderPtr->lightGC) { + if (borderPtr->lightGC != None) { Tk_FreeGC(display, borderPtr->lightGC); } if (prevPtr == borderPtr) { - if (!borderPtr->nextPtr) { + if (borderPtr->nextPtr == NULL) { Tcl_DeleteHashEntry(borderPtr->hashPtr); } else { Tcl_SetHashValue(borderPtr->hashPtr, borderPtr->nextPtr); @@ -759,7 +759,7 @@ Tk_Draw3DPolygon( int i, lightOnLeft, dx, dy, parallel, pointsSeen; Display *display = Tk_Display(tkwin); - if (!borderPtr->lightGC) { + if (borderPtr->lightGC == None) { TkpGetShadows(borderPtr, tkwin); } diff --git a/generic/tkBind.c b/generic/tkBind.c index df82323..c4f8226 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -631,7 +631,7 @@ static const TkStateMap visNotify[] = { }; static const TkStateMap configureRequestDetail[] = { - {0, "None"}, + {None, "None"}, {Above, "Above"}, {Below, "Below"}, {BottomIf, "BottomIf"}, @@ -3870,7 +3870,7 @@ DoWarp( { TkDisplay *dispPtr = (TkDisplay *) clientData; - XWarpPointer(dispPtr->display, 0, (Window) dispPtr->warpWindow, + XWarpPointer(dispPtr->display, (Window) None, (Window) dispPtr->warpWindow, 0, 0, 0, 0, (int) dispPtr->warpX, (int) dispPtr->warpY); XForceScreenSaver(dispPtr->display, ScreenSaverReset); dispPtr->flags &= ~TK_DISPLAY_IN_WARP; diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c index 73ab9fd..f7df546 100644 --- a/generic/tkBitmap.c +++ b/generic/tkBitmap.c @@ -218,7 +218,7 @@ Tk_AllocBitmapFromObj( bitmapPtr = GetBitmap(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = (void *) bitmapPtr; if (bitmapPtr == NULL) { - return 0; + return None; } bitmapPtr->objRefCount++; return bitmapPtr->bitmap; @@ -260,7 +260,7 @@ Tk_GetBitmap( TkBitmap *bitmapPtr = GetBitmap(interp, tkwin, string); if (bitmapPtr == NULL) { - return 0; + return None; } return bitmapPtr->bitmap; } @@ -381,7 +381,7 @@ GetBitmap( bitmap = TkpGetNativeAppBitmap(Tk_Display(tkwin), string, &width, &height); - if (!bitmap) { + if (bitmap == None) { if (interp != NULL) { Tcl_AppendResult(interp, "bitmap \"", string, "\" not defined", NULL); @@ -395,7 +395,7 @@ GetBitmap( if (predefPtr->native) { bitmap = TkpCreateNativeBitmap(Tk_Display(tkwin), predefPtr->source); - if (!bitmap) { + if (bitmap == None) { Tcl_Panic("native bitmap creation failed"); } } else { diff --git a/generic/tkButton.c b/generic/tkButton.c index 1967ab2..0d8b9a4 100644 --- a/generic/tkButton.c +++ b/generic/tkButton.c @@ -688,7 +688,7 @@ ButtonCreate( butPtr->textPtr = NULL; butPtr->underline = -1; butPtr->textVarNamePtr = NULL; - butPtr->bitmap = 0; + butPtr->bitmap = None; butPtr->imagePtr = NULL; butPtr->image = NULL; butPtr->selectImagePtr = NULL; @@ -710,12 +710,12 @@ ButtonCreate( butPtr->normalFg = NULL; butPtr->activeFg = NULL; butPtr->disabledFg = NULL; - butPtr->normalTextGC = 0; - butPtr->activeTextGC = 0; - butPtr->disabledGC = 0; - butPtr->stippleGC = 0; - butPtr->gray = 0; - butPtr->copyGC = 0; + butPtr->normalTextGC = NULL; + butPtr->activeTextGC = NULL; + butPtr->disabledGC = NULL; + butPtr->stippleGC = NULL; + butPtr->gray = None; + butPtr->copyGC = NULL; butPtr->widthPtr = NULL; butPtr->width = 0; butPtr->heightPtr = NULL; @@ -740,7 +740,7 @@ ButtonCreate( butPtr->onValuePtr = NULL; butPtr->offValuePtr = NULL; butPtr->tristateValuePtr = NULL; - butPtr->cursor = 0; + butPtr->cursor = NULL; butPtr->takeFocusPtr = NULL; butPtr->commandPtr = NULL; butPtr->flags = 0; @@ -969,37 +969,37 @@ DestroyButton( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonTextVarProc, (ClientData) butPtr); } - if (butPtr->image) { + if (butPtr->image != NULL) { Tk_FreeImage(butPtr->image); } - if (butPtr->selectImage) { + if (butPtr->selectImage != NULL) { Tk_FreeImage(butPtr->selectImage); } - if (butPtr->tristateImage) { + if (butPtr->tristateImage != NULL) { Tk_FreeImage(butPtr->tristateImage); } - if (butPtr->normalTextGC) { + if (butPtr->normalTextGC != None) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } - if (butPtr->activeTextGC) { + if (butPtr->activeTextGC != None) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } - if (butPtr->disabledGC) { + if (butPtr->disabledGC != None) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } - if (butPtr->stippleGC) { + if (butPtr->stippleGC != None) { Tk_FreeGC(butPtr->display, butPtr->stippleGC); } - if (butPtr->gray) { + if (butPtr->gray != None) { Tk_FreeBitmap(butPtr->display, butPtr->gray); } - if (butPtr->copyGC) { + if (butPtr->copyGC != None) { Tk_FreeGC(butPtr->display, butPtr->copyGC); } - if (butPtr->textLayout) { + if (butPtr->textLayout != NULL) { Tk_FreeTextLayout(butPtr->textLayout); } - if (butPtr->selVarNamePtr) { + if (butPtr->selVarNamePtr != NULL) { Tcl_UntraceVar(butPtr->interp, Tcl_GetString(butPtr->selVarNamePtr), TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ButtonVarProc, (ClientData) butPtr); @@ -1184,7 +1184,7 @@ ConfigureButton( * don't go to zero and cause image data to be discarded. */ - if (butPtr->imagePtr) { + if (butPtr->imagePtr != NULL) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->imagePtr), ButtonImageProc, (ClientData) butPtr); @@ -1198,7 +1198,7 @@ ConfigureButton( Tk_FreeImage(butPtr->image); } butPtr->image = image; - if (butPtr->selectImagePtr) { + if (butPtr->selectImagePtr != NULL) { image = Tk_GetImage(butPtr->interp, butPtr->tkwin, Tcl_GetString(butPtr->selectImagePtr), ButtonSelectImageProc, (ClientData) butPtr); @@ -1208,7 +1208,7 @@ ConfigureButton( } else { image = NULL; } - if (butPtr->selectImage) { + if (butPtr->selectImage != NULL) { Tk_FreeImage(butPtr->selectImage); } butPtr->selectImage = image; @@ -1228,7 +1228,7 @@ ConfigureButton( butPtr->tristateImage = image; haveImage = 0; - if (butPtr->imagePtr || butPtr->bitmap) { + if (butPtr->imagePtr != NULL || butPtr->bitmap != None) { haveImage = 1; } if ((!haveImage || butPtr->compound != COMPOUND_NONE) @@ -1243,14 +1243,14 @@ ConfigureButton( namePtr = butPtr->textVarNamePtr; valuePtr = Tcl_ObjGetVar2(interp, namePtr, NULL, TCL_GLOBAL_ONLY); - if (!valuePtr) { + if (valuePtr == NULL) { if (Tcl_ObjSetVar2(interp, namePtr, NULL, butPtr->textPtr, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) { continue; } } else { - if (butPtr->textPtr) { + if (butPtr->textPtr != NULL) { Tcl_DecrRefCount(butPtr->textPtr); } butPtr->textPtr = valuePtr; @@ -1258,7 +1258,7 @@ ConfigureButton( } } - if (butPtr->bitmap || butPtr->imagePtr) { + if ((butPtr->bitmap != None) || (butPtr->imagePtr != NULL)) { /* * The button must display the contents of an image or bitmap. */ @@ -1366,17 +1366,17 @@ TkButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->normalTextGC) { + if (butPtr->normalTextGC != None) { Tk_FreeGC(butPtr->display, butPtr->normalTextGC); } butPtr->normalTextGC = newGC; - if (butPtr->activeFg) { + if (butPtr->activeFg != NULL) { gcValues.foreground = butPtr->activeFg->pixel; gcValues.background = Tk_3DBorderColor(butPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->activeTextGC) { + if (butPtr->activeTextGC != None) { Tk_FreeGC(butPtr->display, butPtr->activeTextGC); } butPtr->activeTextGC = newGC; @@ -1388,13 +1388,13 @@ TkButtonWorldChanged( * Create the GC that can be used for stippling */ - if (!butPtr->stippleGC) { + if (butPtr->stippleGC == None) { gcValues.foreground = gcValues.background; mask = GCForeground; - if (!butPtr->gray) { + if (butPtr->gray == None) { butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin, "gray50"); } - if (butPtr->gray) { + if (butPtr->gray != None) { gcValues.fill_style = FillStippled; gcValues.stipple = butPtr->gray; mask |= GCFillStyle | GCStipple; @@ -1408,18 +1408,18 @@ TkButtonWorldChanged( */ mask = GCForeground | GCBackground | GCFont; - if (butPtr->disabledFg) { + if (butPtr->disabledFg != NULL) { gcValues.foreground = butPtr->disabledFg->pixel; } else { gcValues.foreground = gcValues.background; } newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues); - if (butPtr->disabledGC) { + if (butPtr->disabledGC != None) { Tk_FreeGC(butPtr->display, butPtr->disabledGC); } butPtr->disabledGC = newGC; - if (!butPtr->copyGC) { + if (butPtr->copyGC == None) { butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues); } diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 101f7aa..33367de 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -296,11 +296,11 @@ CreateArc( arcPtr->fillColor = NULL; arcPtr->activeFillColor = NULL; arcPtr->disabledFillColor = NULL; - arcPtr->fillStipple = 0; - arcPtr->activeFillStipple = 0; - arcPtr->disabledFillStipple = 0; + arcPtr->fillStipple = None; + arcPtr->activeFillStipple = None; + arcPtr->disabledFillStipple = None; arcPtr->style = PIESLICE_STYLE; - arcPtr->fillGC = 0; + arcPtr->fillGC = NULL; /* * Process the arguments to fill in the item record. @@ -452,11 +452,11 @@ ConfigureArc( */ if (arcPtr->outline.activeWidth > arcPtr->outline.width || - arcPtr->outline.activeDash.number || - arcPtr->outline.activeColor || - arcPtr->outline.activeStipple || - arcPtr->activeFillColor || - arcPtr->activeFillStipple) { + arcPtr->outline.activeDash.number != 0 || + arcPtr->outline.activeColor != NULL || + arcPtr->outline.activeStipple != None || + arcPtr->activeFillColor != NULL || + arcPtr->activeFillStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -493,9 +493,9 @@ ConfigureArc( mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = 0; + newGC = NULL; } - if (arcPtr->outline.gc) { + if (arcPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->outline.gc); } arcPtr->outline.gc = newGC; @@ -511,23 +511,23 @@ ConfigureArc( color = arcPtr->fillColor; stipple = arcPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (arcPtr->activeFillColor) { + if (arcPtr->activeFillColor!=NULL) { color = arcPtr->activeFillColor; } - if (arcPtr->activeFillStipple) { + if (arcPtr->activeFillStipple!=None) { stipple = arcPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { - if (arcPtr->disabledFillColor) { + if (arcPtr->disabledFillColor!=NULL) { color = arcPtr->disabledFillColor; } - if (arcPtr->disabledFillStipple) { + if (arcPtr->disabledFillStipple!=None) { stipple = arcPtr->disabledFillStipple; } } - if ((arcPtr->style == ARC_STYLE) || !color) { - newGC = 0; + if ((arcPtr->style == ARC_STYLE) || (!color)) { + newGC = NULL; } else { gcValues.foreground = color->pixel; if (arcPtr->style == CHORD_STYLE) { @@ -536,14 +536,14 @@ ConfigureArc( gcValues.arc_mode = ArcPieSlice; } mask = GCForeground|GCArcMode; - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (arcPtr->fillGC) { + if (arcPtr->fillGC != None) { Tk_FreeGC(Tk_Display(tkwin), arcPtr->fillGC); } arcPtr->fillGC = newGC; @@ -598,25 +598,25 @@ DeleteArc( if (arcPtr->numOutlinePoints != 0) { ckfree((char *) arcPtr->outlinePtr); } - if (arcPtr->fillColor) { + if (arcPtr->fillColor != NULL) { Tk_FreeColor(arcPtr->fillColor); } - if (arcPtr->activeFillColor) { + if (arcPtr->activeFillColor != NULL) { Tk_FreeColor(arcPtr->activeFillColor); } - if (arcPtr->disabledFillColor) { + if (arcPtr->disabledFillColor != NULL) { Tk_FreeColor(arcPtr->disabledFillColor); } - if (arcPtr->fillStipple) { + if (arcPtr->fillStipple != None) { Tk_FreeBitmap(display, arcPtr->fillStipple); } - if (arcPtr->activeFillStipple) { + if (arcPtr->activeFillStipple != None) { Tk_FreeBitmap(display, arcPtr->activeFillStipple); } - if (arcPtr->disabledFillStipple) { + if (arcPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, arcPtr->disabledFillStipple); } - if (arcPtr->fillGC) { + if (arcPtr->fillGC != None) { Tk_FreeGC(display, arcPtr->fillGC); } } @@ -747,7 +747,7 @@ ComputeArcBbox( * drawn) and add one extra pixel just for safety. */ - if (!arcPtr->outline.gc) { + if (arcPtr->outline.gc == None) { tmp = 1; } else { tmp = (int) ((width + 1.0)/2.0 + 1); @@ -804,20 +804,20 @@ DisplayArc( if (arcPtr->outline.activeWidth>lineWidth) { lineWidth = arcPtr->outline.activeWidth; } - if (arcPtr->outline.activeDash.number) { + if (arcPtr->outline.activeDash.number != 0) { dashnumber = arcPtr->outline.activeDash.number; } - if (arcPtr->activeFillStipple) { + if (arcPtr->activeFillStipple != None) { stipple = arcPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { if (arcPtr->outline.disabledWidth > 0) { lineWidth = arcPtr->outline.disabledWidth; } - if (arcPtr->outline.disabledDash.number) { + if (arcPtr->outline.disabledDash.number != 0) { dashnumber = arcPtr->outline.disabledDash.number; } - if (arcPtr->disabledFillStipple) { + if (arcPtr->disabledFillStipple != None) { stipple = arcPtr->disabledFillStipple; } } @@ -846,8 +846,8 @@ DisplayArc( * window servers to crash and should be a no-op anyway. */ - if ((arcPtr->fillGC) && (extent != 0)) { - if (stipple) { + if ((arcPtr->fillGC != None) && (extent != 0)) { + if (stipple != None) { int w = 0; int h = 0; Tk_TSOffset *tsoffset = &arcPtr->tsoffset; @@ -876,14 +876,14 @@ DisplayArc( } XFillArc(display, drawable, arcPtr->fillGC, x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), start, extent); - if (stipple) { + if (stipple != None) { XSetTSOrigin(display, arcPtr->fillGC, 0, 0); } } - if (arcPtr->outline.gc) { + if (arcPtr->outline.gc != None) { Tk_ChangeOutlineGC(canvas, itemPtr, &(arcPtr->outline)); - if (extent) { + if (extent != 0) { XDrawArc(display, drawable, arcPtr->outline.gc, x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), start, extent); } @@ -895,7 +895,7 @@ DisplayArc( * outline is dashed, because then polygons don't work. */ - if (lineWidth < 1.5 || dashnumber) { + if (lineWidth < 1.5 || dashnumber != 0) { Tk_CanvasDrawableCoords(canvas, arcPtr->center1[0], arcPtr->center1[1], &x1, &y1); Tk_CanvasDrawableCoords(canvas, arcPtr->center2[0], @@ -918,13 +918,13 @@ DisplayArc( } else { if (arcPtr->style == CHORD_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS, - display, drawable, arcPtr->outline.gc, 0); + display, drawable, arcPtr->outline.gc, NULL); } else if (arcPtr->style == PIESLICE_STYLE) { TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS, - display, drawable, arcPtr->outline.gc, 0); + display, drawable, arcPtr->outline.gc, NULL); TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS, PIE_OUTLINE2_PTS, display, drawable, - arcPtr->outline.gc, 0); + arcPtr->outline.gc, NULL); } } @@ -1030,12 +1030,12 @@ ArcToPoint( return dist; } - if (arcPtr->fillGC || !arcPtr->outline.gc) { + if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { filled = 1; } else { filled = 0; } - if (!arcPtr->outline.gc) { + if (arcPtr->outline.gc == None) { width = 0.0; } @@ -1157,12 +1157,12 @@ ArcToArea( } } - if ((arcPtr->fillGC) || !arcPtr->outline.gc) { + if ((arcPtr->fillGC != None) || (arcPtr->outline.gc == None)) { filled = 1; } else { filled = 0; } - if (!arcPtr->outline.gc) { + if (arcPtr->outline.gc == None) { width = 0.0; } @@ -1857,29 +1857,29 @@ ArcToPostscript( fillColor = arcPtr->fillColor; fillStipple = arcPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (arcPtr->outline.activeColor) { + if (arcPtr->outline.activeColor!=NULL) { color = arcPtr->outline.activeColor; } - if (arcPtr->outline.activeStipple) { + if (arcPtr->outline.activeStipple!=None) { stipple = arcPtr->outline.activeStipple; } - if (arcPtr->activeFillColor) { + if (arcPtr->activeFillColor!=NULL) { fillColor = arcPtr->activeFillColor; } - if (arcPtr->activeFillStipple) { + if (arcPtr->activeFillStipple!=None) { fillStipple = arcPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (arcPtr->outline.disabledColor) { + if (arcPtr->outline.disabledColor!=NULL) { color = arcPtr->outline.disabledColor; } - if (arcPtr->outline.disabledStipple) { + if (arcPtr->outline.disabledStipple!=None) { stipple = arcPtr->outline.disabledStipple; } - if (arcPtr->disabledFillColor) { + if (arcPtr->disabledFillColor!=NULL) { fillColor = arcPtr->disabledFillColor; } - if (arcPtr->disabledFillStipple) { + if (arcPtr->disabledFillStipple!=None) { fillStipple = arcPtr->disabledFillStipple; } } @@ -1889,7 +1889,7 @@ ArcToPostscript( * arc. */ - if (arcPtr->fillGC) { + if (arcPtr->fillGC != None) { sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); @@ -1906,12 +1906,12 @@ ArcToPostscript( if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple) { + if (fillStipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; } - if (arcPtr->outline.gc) { + if (arcPtr->outline.gc != None) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } } else { @@ -1923,7 +1923,7 @@ ArcToPostscript( * If there's an outline for the arc, draw it. */ - if (arcPtr->outline.gc) { + if (arcPtr->outline.gc != None) { sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n", (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2, (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2); @@ -1946,7 +1946,7 @@ ArcToPostscript( != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK){ return TCL_ERROR; @@ -1963,7 +1963,7 @@ ArcToPostscript( != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 6f38293..5f97ef2 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -182,16 +182,16 @@ TkcCreateBitmap( */ bmapPtr->anchor = TK_ANCHOR_CENTER; - bmapPtr->bitmap = 0; - bmapPtr->activeBitmap = 0; - bmapPtr->disabledBitmap = 0; + bmapPtr->bitmap = None; + bmapPtr->activeBitmap = None; + bmapPtr->disabledBitmap = None; bmapPtr->fgColor = NULL; bmapPtr->activeFgColor = NULL; bmapPtr->disabledFgColor = NULL; bmapPtr->bgColor = NULL; bmapPtr->activeBgColor = NULL; bmapPtr->disabledBgColor = NULL; - bmapPtr->gc = 0; + bmapPtr->gc = NULL; /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x @@ -336,9 +336,9 @@ ConfigureBitmap( state = itemPtr->state; - if (bmapPtr->activeFgColor || - bmapPtr->activeBgColor || - bmapPtr->activeBitmap) { + if (bmapPtr->activeFgColor!=NULL || + bmapPtr->activeBgColor!=NULL || + bmapPtr->activeBitmap!=None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -355,33 +355,33 @@ ConfigureBitmap( bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeFgColor) { + if (bmapPtr->activeFgColor!=NULL) { fgColor = bmapPtr->activeFgColor; } - if (bmapPtr->activeBgColor) { + if (bmapPtr->activeBgColor!=NULL) { bgColor = bmapPtr->activeBgColor; } - if (bmapPtr->activeBitmap) { + if (bmapPtr->activeBitmap!=None) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledFgColor) { + if (bmapPtr->disabledFgColor!=NULL) { fgColor = bmapPtr->disabledFgColor; } - if (bmapPtr->disabledBgColor) { + if (bmapPtr->disabledBgColor!=NULL) { bgColor = bmapPtr->disabledBgColor; } - if (bmapPtr->disabledBitmap) { + if (bmapPtr->disabledBitmap!=None) { bitmap = bmapPtr->disabledBitmap; } } if (!bitmap) { - newGC = 0; + newGC = NULL; } else { gcValues.foreground = fgColor->pixel; mask = GCForeground; - if (bgColor) { + if (bgColor != NULL) { gcValues.background = bgColor->pixel; mask |= GCBackground; } else { @@ -390,7 +390,7 @@ ConfigureBitmap( } newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (bmapPtr->gc) { + if (bmapPtr->gc != None) { Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc); } bmapPtr->gc = newGC; @@ -424,34 +424,34 @@ DeleteBitmap( { BitmapItem *bmapPtr = (BitmapItem *) itemPtr; - if (bmapPtr->bitmap) { + if (bmapPtr->bitmap != None) { Tk_FreeBitmap(display, bmapPtr->bitmap); } - if (bmapPtr->activeBitmap) { + if (bmapPtr->activeBitmap != None) { Tk_FreeBitmap(display, bmapPtr->activeBitmap); } - if (bmapPtr->disabledBitmap) { + if (bmapPtr->disabledBitmap != None) { Tk_FreeBitmap(display, bmapPtr->disabledBitmap); } - if (bmapPtr->fgColor) { + if (bmapPtr->fgColor != NULL) { Tk_FreeColor(bmapPtr->fgColor); } - if (bmapPtr->activeFgColor) { + if (bmapPtr->activeFgColor != NULL) { Tk_FreeColor(bmapPtr->activeFgColor); } - if (bmapPtr->disabledFgColor) { + if (bmapPtr->disabledFgColor != NULL) { Tk_FreeColor(bmapPtr->disabledFgColor); } - if (bmapPtr->bgColor) { + if (bmapPtr->bgColor != NULL) { Tk_FreeColor(bmapPtr->bgColor); } - if (bmapPtr->activeBgColor) { + if (bmapPtr->activeBgColor != NULL) { Tk_FreeColor(bmapPtr->activeBgColor); } - if (bmapPtr->disabledBgColor) { + if (bmapPtr->disabledBgColor != NULL) { Tk_FreeColor(bmapPtr->disabledBgColor); } - if (bmapPtr->gc) { + if (bmapPtr->gc != NULL) { Tk_FreeGC(display, bmapPtr->gc); } } @@ -490,11 +490,11 @@ ComputeBitmapBbox( } bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)bmapPtr) { - if (bmapPtr->activeBitmap) { + if (bmapPtr->activeBitmap!=None) { bitmap = bmapPtr->activeBitmap; } - } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledBitmap) { + } else if (state==TK_STATE_DISABLED) { + if (bmapPtr->disabledBitmap!=None) { bitmap = bmapPtr->disabledBitmap; } } @@ -502,7 +502,7 @@ ComputeBitmapBbox( x = (int) (bmapPtr->x + ((bmapPtr->x >= 0) ? 0.5 : - 0.5)); y = (int) (bmapPtr->y + ((bmapPtr->y >= 0) ? 0.5 : - 0.5)); - if ((state == TK_STATE_HIDDEN) || !bitmap) { + if (state==TK_STATE_HIDDEN || bitmap == None) { bmapPtr->header.x1 = bmapPtr->header.x2 = x; bmapPtr->header.y1 = bmapPtr->header.y2 = y; return; @@ -600,16 +600,16 @@ DisplayBitmap( } bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeBitmap) { + if (bmapPtr->activeBitmap!=None) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledBitmap) { + if (bmapPtr->disabledBitmap!=None) { bitmap = bmapPtr->disabledBitmap; } } - if (bitmap) { + if (bitmap != None) { if (x > bmapPtr->header.x1) { bmapX = x - bmapPtr->header.x1; bmapWidth = bmapPtr->header.x2 - x; @@ -868,28 +868,28 @@ BitmapToPostscript( bgColor = bmapPtr->bgColor; bitmap = bmapPtr->bitmap; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (bmapPtr->activeFgColor) { + if (bmapPtr->activeFgColor!=NULL) { fgColor = bmapPtr->activeFgColor; } - if (bmapPtr->activeBgColor) { + if (bmapPtr->activeBgColor!=NULL) { bgColor = bmapPtr->activeBgColor; } - if (bmapPtr->activeBitmap) { + if (bmapPtr->activeBitmap!=None) { bitmap = bmapPtr->activeBitmap; } } else if (state == TK_STATE_DISABLED) { - if (bmapPtr->disabledFgColor) { + if (bmapPtr->disabledFgColor!=NULL) { fgColor = bmapPtr->disabledFgColor; } - if (bmapPtr->disabledBgColor) { + if (bmapPtr->disabledBgColor!=NULL) { bgColor = bmapPtr->disabledBgColor; } - if (bmapPtr->disabledBitmap) { + if (bmapPtr->disabledBitmap!=None) { bitmap = bmapPtr->disabledBitmap; } } - if (!bitmap) { + if (bitmap == None) { return TCL_OK; } diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c index 134cc23..9e928c7 100644 --- a/generic/tkCanvImg.c +++ b/generic/tkCanvImg.c @@ -436,16 +436,16 @@ ComputeImageBbox( Tk_Image image; Tk_State state = imgPtr->header.state; - if (state == TK_STATE_NULL) { + if(state == TK_STATE_NULL) { state = ((TkCanvas *)canvas)->canvas_state; } image = imgPtr->image; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)imgPtr) { - if (imgPtr->activeImage) { + if (imgPtr->activeImage != NULL) { image = imgPtr->activeImage; } } else if (state == TK_STATE_DISABLED) { - if (imgPtr->disabledImage) { + if (imgPtr->disabledImage != NULL) { image = imgPtr->disabledImage; } } @@ -453,7 +453,7 @@ ComputeImageBbox( x = (int) (imgPtr->x + ((imgPtr->x >= 0) ? 0.5 : - 0.5)); y = (int) (imgPtr->y + ((imgPtr->y >= 0) ? 0.5 : - 0.5)); - if ((state == TK_STATE_HIDDEN) || !image) { + if ((state == TK_STATE_HIDDEN) || (image == None)) { imgPtr->header.x1 = imgPtr->header.x2 = x; imgPtr->header.y1 = imgPtr->header.y2 = y; return; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 78cf74c..fea2103 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -303,7 +303,7 @@ CreateLine( linePtr->coordPtr = NULL; linePtr->capStyle = CapButt; linePtr->joinStyle = JoinRound; - linePtr->arrowGC = 0; + linePtr->arrowGC = NULL; linePtr->arrow = ARROWS_NONE; linePtr->arrowShapeA = (float)8.0; linePtr->arrowShapeB = (float)10.0; @@ -503,9 +503,9 @@ ConfigureLine( } if (linePtr->outline.activeWidth > linePtr->outline.width || - linePtr->outline.activeDash.number || - linePtr->outline.activeColor || - linePtr->outline.activeStipple) { + linePtr->outline.activeDash.number != 0 || + linePtr->outline.activeColor != NULL || + linePtr->outline.activeStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -531,7 +531,7 @@ ConfigureLine( #endif arrowGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = arrowGC = 0; + newGC = arrowGC = NULL; } if (linePtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc); @@ -552,7 +552,7 @@ ConfigureLine( linePtr->splineSteps = 100; } - if (!linePtr->numPoints || (state==TK_STATE_HIDDEN)) { + if ((!linePtr->numPoints) || (state==TK_STATE_HIDDEN)) { ComputeLineBbox(canvas, linePtr); return TCL_OK; } @@ -562,7 +562,7 @@ ConfigureLine( * line's endpoints (they were shortened when the arrowheads were added). */ - if (linePtr->firstArrowPtr && (linePtr->arrow != ARROWS_FIRST) + if ((linePtr->firstArrowPtr != NULL) && (linePtr->arrow != ARROWS_FIRST) && (linePtr->arrow != ARROWS_BOTH)) { linePtr->coordPtr[0] = linePtr->firstArrowPtr[0]; linePtr->coordPtr[1] = linePtr->firstArrowPtr[1]; @@ -618,16 +618,16 @@ DeleteLine( LineItem *linePtr = (LineItem *) itemPtr; Tk_DeleteOutline(display, &(linePtr->outline)); - if (linePtr->coordPtr) { + if (linePtr->coordPtr != NULL) { ckfree((char *) linePtr->coordPtr); } - if (linePtr->arrowGC) { + if (linePtr->arrowGC != None) { Tk_FreeGC(display, linePtr->arrowGC); } - if (linePtr->firstArrowPtr) { + if (linePtr->firstArrowPtr != NULL) { ckfree((char *) linePtr->firstArrowPtr); } - if (linePtr->lastArrowPtr) { + if (linePtr->lastArrowPtr != NULL) { ckfree((char *) linePtr->lastArrowPtr); } } @@ -664,7 +664,7 @@ ComputeLineBbox( state = ((TkCanvas *)canvas)->canvas_state; } - if (!(linePtr->numPoints) || (state == TK_STATE_HIDDEN)) { + if (!(linePtr->numPoints) || (state==TK_STATE_HIDDEN)) { linePtr->header.x1 = -1; linePtr->header.x2 = -1; linePtr->header.y1 = -1; @@ -677,7 +677,7 @@ ComputeLineBbox( if (linePtr->outline.activeWidth>width) { width = linePtr->outline.activeWidth; } - } else if (state == TK_STATE_DISABLED) { + } else if (state==TK_STATE_DISABLED) { if (linePtr->outline.disabledWidth>0) { width = linePtr->outline.disabledWidth; } @@ -846,7 +846,7 @@ DisplayLine( int numPoints; Tk_State state = itemPtr->state; - if (!linePtr->numPoints || !linePtr->outline.gc) { + if ((!linePtr->numPoints)||(linePtr->outline.gc==None)) { return; } @@ -2251,7 +2251,7 @@ LineToPostscript( * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; - char buffer[64 + 4*TCL_INTEGER_SPACE]; + char buffer[64 + TCL_INTEGER_SPACE]; char *style; double width; @@ -2270,20 +2270,20 @@ LineToPostscript( if (linePtr->outline.activeWidth>width) { width = linePtr->outline.activeWidth; } - if (linePtr->outline.activeColor) { + if (linePtr->outline.activeColor!=NULL) { color = linePtr->outline.activeColor; } - if (linePtr->outline.activeStipple) { + if (linePtr->outline.activeStipple!=None) { stipple = linePtr->outline.activeStipple; } } else if (state==TK_STATE_DISABLED) { if (linePtr->outline.disabledWidth>0) { width = linePtr->outline.disabledWidth; } - if (linePtr->outline.disabledColor) { + if (linePtr->outline.disabledColor!=NULL) { color = linePtr->outline.disabledColor; } - if (linePtr->outline.disabledStipple) { + if (linePtr->outline.disabledStipple!=None) { stipple = linePtr->outline.disabledStipple; } } @@ -2301,7 +2301,7 @@ LineToPostscript( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; @@ -2319,7 +2319,7 @@ LineToPostscript( if ((!linePtr->smooth) || (linePtr->numPoints < 3)) { Tk_CanvasPsPath(interp, canvas, linePtr->coordPtr, linePtr->numPoints); } else { - if (!stipple && linePtr->smooth->postscriptProc) { + if ((stipple == None) && linePtr->smooth->postscriptProc) { linePtr->smooth->postscriptProc(interp, canvas, linePtr->coordPtr, linePtr->numPoints, linePtr->splineSteps); } else { @@ -2379,8 +2379,8 @@ LineToPostscript( * Output polygons for the arrowheads, if there are any. */ - if (linePtr->firstArrowPtr) { - if (stipple) { + if (linePtr->firstArrowPtr != NULL) { + if (stipple != None) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } if (ArrowheadPostscript(interp, canvas, linePtr, @@ -2389,7 +2389,7 @@ LineToPostscript( } } if (linePtr->lastArrowPtr != NULL) { - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "grestore gsave\n", NULL); } if (ArrowheadPostscript(interp, canvas, linePtr, @@ -2438,17 +2438,17 @@ ArrowheadPostscript( stipple = linePtr->outline.stipple; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)linePtr) { - if (linePtr->outline.activeStipple) { + if (linePtr->outline.activeStipple!=None) { stipple = linePtr->outline.activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (linePtr->outline.activeStipple) { + if (linePtr->outline.activeStipple!=None) { stipple = linePtr->outline.disabledStipple; } } Tk_CanvasPsPath(interp, canvas, arrowPtr, PTS_IN_ARROW); - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 9b210fa..0810ab6 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -276,10 +276,10 @@ CreatePolygon( polyPtr->fillColor = NULL; polyPtr->activeFillColor = NULL; polyPtr->disabledFillColor = NULL; - polyPtr->fillStipple = 0; - polyPtr->activeFillStipple = 0; - polyPtr->disabledFillStipple = 0; - polyPtr->fillGC = 0; + polyPtr->fillStipple = None; + polyPtr->activeFillStipple = None; + polyPtr->disabledFillStipple = None; + polyPtr->fillGC = NULL; polyPtr->smooth = NULL; polyPtr->splineSteps = 12; polyPtr->autoClosed = 0; @@ -459,11 +459,11 @@ ConfigurePolygon( state = itemPtr->state; if (polyPtr->outline.activeWidth > polyPtr->outline.width || - polyPtr->outline.activeDash.number || - polyPtr->outline.activeColor || - polyPtr->outline.activeStipple || - polyPtr->activeFillColor || - polyPtr->activeFillStipple) { + polyPtr->outline.activeDash.number != 0 || + polyPtr->outline.activeColor != NULL || + polyPtr->outline.activeStipple != None || + polyPtr->activeFillColor != NULL || + polyPtr->activeFillStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -484,7 +484,7 @@ ConfigurePolygon( mask |= GCCapStyle|GCJoinStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = 0; + newGC = NULL; } if (polyPtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc); @@ -494,23 +494,23 @@ ConfigurePolygon( color = polyPtr->fillColor; stipple = polyPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (polyPtr->activeFillColor) { + if (polyPtr->activeFillColor!=NULL) { color = polyPtr->activeFillColor; } - if (polyPtr->activeFillStipple) { + if (polyPtr->activeFillStipple!=None) { stipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->disabledFillColor!=NULL) { color = polyPtr->disabledFillColor; } - if (polyPtr->disabledFillStipple) { + if (polyPtr->disabledFillStipple!=None) { stipple = polyPtr->disabledFillStipple; } } - if (color == NULL) { - newGC = 0; + if (!color) { + newGC = NULL; } else { gcValues.foreground = color->pixel; mask = GCForeground; @@ -530,7 +530,7 @@ ConfigurePolygon( #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (polyPtr->fillGC) { + if (polyPtr->fillGC != None) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->fillGC); } polyPtr->fillGC = newGC; @@ -575,28 +575,28 @@ DeletePolygon( PolygonItem *polyPtr = (PolygonItem *) itemPtr; Tk_DeleteOutline(display,&(polyPtr->outline)); - if (polyPtr->coordPtr) { + if (polyPtr->coordPtr != NULL) { ckfree((char *) polyPtr->coordPtr); } - if (polyPtr->fillColor) { + if (polyPtr->fillColor != NULL) { Tk_FreeColor(polyPtr->fillColor); } - if (polyPtr->activeFillColor) { + if (polyPtr->activeFillColor != NULL) { Tk_FreeColor(polyPtr->activeFillColor); } - if (polyPtr->disabledFillColor) { + if (polyPtr->disabledFillColor != NULL) { Tk_FreeColor(polyPtr->disabledFillColor); } - if (polyPtr->fillStipple) { + if (polyPtr->fillStipple != None) { Tk_FreeBitmap(display, polyPtr->fillStipple); } - if (polyPtr->activeFillStipple) { + if (polyPtr->activeFillStipple != None) { Tk_FreeBitmap(display, polyPtr->activeFillStipple); } - if (polyPtr->disabledFillStipple) { + if (polyPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, polyPtr->disabledFillStipple); } - if (polyPtr->fillGC) { + if (polyPtr->fillGC != None) { Tk_FreeGC(display, polyPtr->fillGC); } } @@ -698,7 +698,7 @@ ComputePolygonBbox( } } - if (polyPtr->outline.gc) { + if (polyPtr->outline.gc != None) { tsoffset = &polyPtr->outline.tsoffset; if (tsoffset) { if (tsoffset->flags & TK_OFFSET_INDEX) { @@ -840,11 +840,11 @@ TkFillPolygon( * allocated. */ - if (gc && (numPoints > 3)) { + if (gc != None && numPoints>3) { XFillPolygon(display, drawable, gc, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (outlineGC) { + if (outlineGC != None) { XDrawLines(display, drawable, outlineGC, pointPtr, numPoints, CoordModeOrigin); } @@ -885,9 +885,9 @@ DisplayPolygon( Pixmap stipple = polyPtr->fillStipple; double linewidth = polyPtr->outline.width; - if ((!polyPtr->fillGC && !polyPtr->outline.gc) || + if (((polyPtr->fillGC == None) && (polyPtr->outline.gc == None)) || (polyPtr->numPoints < 1) || - (polyPtr->numPoints < 3 && !polyPtr->outline.gc)) { + (polyPtr->numPoints < 3 && polyPtr->outline.gc == None)) { return; } @@ -898,14 +898,14 @@ DisplayPolygon( if (polyPtr->outline.activeWidth>linewidth) { linewidth = polyPtr->outline.activeWidth; } - if (polyPtr->activeFillStipple) { + if (polyPtr->activeFillStipple != None) { stipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->outline.disabledWidth>0.0) { linewidth = polyPtr->outline.disabledWidth; } - if (polyPtr->disabledFillStipple) { + if (polyPtr->disabledFillStipple != None) { stipple = polyPtr->disabledFillStipple; } } @@ -915,7 +915,7 @@ DisplayPolygon( * reset the offset when done, since the GC is supposed to be read-only. */ - if (stipple && polyPtr->fillGC) { + if ((stipple != None) && (polyPtr->fillGC != None)) { Tk_TSOffset *tsoffset = &polyPtr->tsoffset; int w=0; int h=0; int flags = tsoffset->flags; @@ -977,11 +977,11 @@ DisplayPolygon( } numPoints = polyPtr->smooth->coordProc(canvas, polyPtr->coordPtr, polyPtr->numPoints, polyPtr->splineSteps, pointPtr, NULL); - if (polyPtr->fillGC) { + if (polyPtr->fillGC != None) { XFillPolygon(display, drawable, polyPtr->fillGC, pointPtr, numPoints, Complex, CoordModeOrigin); } - if (polyPtr->outline.gc) { + if (polyPtr->outline.gc != None) { XDrawLines(display, drawable, polyPtr->outline.gc, pointPtr, numPoints, CoordModeOrigin); } @@ -990,7 +990,7 @@ DisplayPolygon( } } Tk_ResetOutlineGC(canvas, itemPtr, &(polyPtr->outline)); - if (stipple && polyPtr->fillGC) { + if ((stipple != None) && (polyPtr->fillGC != None)) { XSetTSOrigin(display, polyPtr->fillGC, 0, 0); } } @@ -1303,7 +1303,7 @@ PolygonToPoint( if (bestDist<=0.0) { goto donepoint; } - if (polyPtr->outline.gc && (polyPtr->joinStyle == JoinRound)) { + if ((polyPtr->outline.gc != None) && (polyPtr->joinStyle == JoinRound)) { dist = bestDist - radius; if (dist <= 0.0) { bestDist = 0.0; @@ -1313,7 +1313,7 @@ PolygonToPoint( } } - if (!polyPtr->outline.gc || (width <= 1)) { + if ((polyPtr->outline.gc == None) || (width <= 1)) { goto donepoint; } @@ -1520,7 +1520,7 @@ PolygonToArea( goto donearea; } - if (!polyPtr->outline.gc) { + if (polyPtr->outline.gc == None) { goto donearea; } @@ -1830,32 +1830,32 @@ PolygonToPostscript( if (polyPtr->outline.activeWidth>width) { width = polyPtr->outline.activeWidth; } - if (polyPtr->outline.activeColor) { + if (polyPtr->outline.activeColor!=NULL) { color = polyPtr->outline.activeColor; } - if (polyPtr->outline.activeStipple) { + if (polyPtr->outline.activeStipple!=None) { stipple = polyPtr->outline.activeStipple; } - if (polyPtr->activeFillColor) { + if (polyPtr->activeFillColor!=NULL) { fillColor = polyPtr->activeFillColor; } - if (polyPtr->activeFillStipple) { + if (polyPtr->activeFillStipple!=None) { fillStipple = polyPtr->activeFillStipple; } } else if (state==TK_STATE_DISABLED) { if (polyPtr->outline.disabledWidth>0.0) { width = polyPtr->outline.disabledWidth; } - if (polyPtr->outline.disabledColor) { + if (polyPtr->outline.disabledColor!=NULL) { color = polyPtr->outline.disabledColor; } - if (polyPtr->outline.disabledStipple) { + if (polyPtr->outline.disabledStipple!=None) { stipple = polyPtr->outline.disabledStipple; } - if (polyPtr->disabledFillColor) { + if (polyPtr->disabledFillColor!=NULL) { fillColor = polyPtr->disabledFillColor; } - if (polyPtr->disabledFillStipple) { + if (polyPtr->disabledFillStipple!=None) { fillStipple = polyPtr->disabledFillStipple; } } @@ -1873,7 +1873,7 @@ PolygonToPostscript( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; @@ -1899,7 +1899,7 @@ PolygonToPostscript( if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple) { + if (fillStipple != None) { Tcl_AppendResult(interp, "eoclip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; @@ -1916,7 +1916,7 @@ PolygonToPostscript( * Now draw the outline, if there is one. */ - if (color) { + if (color != NULL) { if (!polyPtr->smooth || !polyPtr->smooth->postscriptProc) { Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr, polyPtr->numPoints); diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index e187871..187ec40 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -253,9 +253,9 @@ CreateText( textPtr->disabledColor = NULL; textPtr->tkfont = NULL; textPtr->justify = TK_JUSTIFY_LEFT; - textPtr->stipple = 0; - textPtr->activeStipple = 0; - textPtr->disabledStipple = 0; + textPtr->stipple = None; + textPtr->activeStipple = None; + textPtr->disabledStipple = None; textPtr->text = NULL; textPtr->width = 0; textPtr->underline = -1; @@ -265,9 +265,9 @@ CreateText( textPtr->textLayout = NULL; textPtr->leftEdge = 0; textPtr->rightEdge = 0; - textPtr->gc = 0; - textPtr->selTextGC = 0; - textPtr->cursorOffGC = 0; + textPtr->gc = NULL; + textPtr->selTextGC = NULL; + textPtr->cursorOffGC = NULL; /* * Process the arguments to fill in the item record. Only 1 (list) or 2 (x @@ -414,7 +414,7 @@ ConfigureText( state = itemPtr->state; - if (textPtr->activeColor || textPtr->activeStipple) { + if (textPtr->activeColor != NULL || textPtr->activeStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -427,29 +427,29 @@ ConfigureText( color = textPtr->color; stipple = textPtr->stipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (textPtr->activeColor) { + if (textPtr->activeColor!=NULL) { color = textPtr->activeColor; } - if (textPtr->activeStipple) { + if (textPtr->activeStipple!=None) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledColor) { + if (textPtr->disabledColor!=NULL) { color = textPtr->disabledColor; } - if (textPtr->disabledStipple) { + if (textPtr->disabledStipple!=None) { stipple = textPtr->disabledStipple; } } - newGC = newSelGC = 0; - if (textPtr->tkfont) { + newGC = newSelGC = NULL; + if (textPtr->tkfont != NULL) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; if (color) { gcValues.foreground = color->pixel; mask |= GCForeground; - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -471,7 +471,7 @@ ConfigureText( Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; - if (textPtr->selTextGC) { + if (textPtr->selTextGC != None) { Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC); } textPtr->selTextGC = newSelGC; @@ -486,7 +486,7 @@ ConfigureText( } newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); } else { - newGC = 0; + newGC = NULL; } if (textPtr->cursorOffGC) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); @@ -548,37 +548,37 @@ DeleteText( { TextItem *textPtr = (TextItem *) itemPtr; - if (textPtr->color) { + if (textPtr->color != NULL) { Tk_FreeColor(textPtr->color); } - if (textPtr->activeColor) { + if (textPtr->activeColor != NULL) { Tk_FreeColor(textPtr->activeColor); } - if (textPtr->disabledColor) { + if (textPtr->disabledColor != NULL) { Tk_FreeColor(textPtr->disabledColor); } Tk_FreeFont(textPtr->tkfont); - if (textPtr->stipple) { + if (textPtr->stipple != None) { Tk_FreeBitmap(display, textPtr->stipple); } - if (textPtr->activeStipple) { + if (textPtr->activeStipple != None) { Tk_FreeBitmap(display, textPtr->activeStipple); } - if (textPtr->disabledStipple) { + if (textPtr->disabledStipple != None) { Tk_FreeBitmap(display, textPtr->disabledStipple); } - if (textPtr->text) { + if (textPtr->text != NULL) { ckfree(textPtr->text); } Tk_FreeTextLayout(textPtr->textLayout); - if (textPtr->gc) { + if (textPtr->gc != None) { Tk_FreeGC(display, textPtr->gc); } - if (textPtr->selTextGC) { + if (textPtr->selTextGC != None) { Tk_FreeGC(display, textPtr->selTextGC); } - if (textPtr->cursorOffGC) { + if (textPtr->cursorOffGC != None) { Tk_FreeGC(display, textPtr->cursorOffGC); } } @@ -731,16 +731,16 @@ DisplayCanvText( } stipple = textPtr->stipple; if (((TkCanvas *)canvas)->currentItemPtr == itemPtr) { - if (textPtr->activeStipple) { + if (textPtr->activeStipple!=None) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledStipple) { + if (textPtr->disabledStipple!=None) { stipple = textPtr->disabledStipple; } } - if (!textPtr->gc) { + if (textPtr->gc == None) { return; } @@ -750,7 +750,7 @@ DisplayCanvText( * read-only. */ - if (stipple) { + if (stipple != None) { Tk_CanvasSetOffset(canvas, textPtr->gc, &textPtr->tsoffset); } @@ -830,7 +830,7 @@ DisplayCanvText( drawableX, drawableY, textInfoPtr->insertWidth, height, textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED); - } else if (textPtr->cursorOffGC) { + } else if (textPtr->cursorOffGC != None) { /* * Redraw the background over the area of the cursor, even * though the cursor is turned off. This guarantees that the @@ -874,7 +874,7 @@ DisplayCanvText( Tk_UnderlineTextLayout(display, drawable, textPtr->gc, textPtr->textLayout, drawableX, drawableY, textPtr->underline); - if (stipple) { + if (stipple != None) { XSetTSOrigin(display, textPtr->gc, 0, 0); } } @@ -1447,14 +1447,14 @@ TextToPostscript( if (textPtr->activeColor!=NULL) { color = textPtr->activeColor; } - if (textPtr->activeStipple) { + if (textPtr->activeStipple!=None) { stipple = textPtr->activeStipple; } } else if (state==TK_STATE_DISABLED) { - if (textPtr->disabledColor) { + if (textPtr->disabledColor!=NULL) { color = textPtr->disabledColor; } - if (textPtr->disabledStipple) { + if (textPtr->disabledStipple!=None) { stipple = textPtr->disabledStipple; } } @@ -1462,13 +1462,13 @@ TextToPostscript( if (Tk_CanvasPsFont(interp, canvas, textPtr->tkfont) != TCL_OK) { return TCL_ERROR; } - if (prepass) { + if (prepass != 0) { return TCL_OK; } if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "/StippleText {\n ", NULL); Tk_CanvasPsStipple(interp, canvas, stipple); Tcl_AppendResult(interp, "} bind def\n", NULL); @@ -1506,7 +1506,7 @@ TextToPostscript( Tcl_PrintDouble(NULL, y / 2.0, buffer); Tcl_AppendResult(interp, " ", buffer, NULL); sprintf(buffer, " %s %s DrawText\n", - justify, (stipple ? "true" : "false")); + justify, ((stipple == None) ? "false" : "true")); Tcl_AppendResult(interp, buffer, NULL); return TCL_OK; diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c index cacceda..299f502 100644 --- a/generic/tkCanvUtil.c +++ b/generic/tkCanvUtil.c @@ -959,7 +959,7 @@ void Tk_CreateOutline( Tk_Outline *outline) /* Outline structure to be filled in. */ { - outline->gc = 0; + outline->gc = NULL; outline->width = 1.0; outline->activeWidth = 0.0; outline->disabledWidth = 0.0; @@ -973,9 +973,9 @@ Tk_CreateOutline( outline->color = NULL; outline->activeColor = NULL; outline->disabledColor = NULL; - outline->stipple = 0; - outline->activeStipple = 0; - outline->disabledStipple = 0; + outline->stipple = None; + outline->activeStipple = None; + outline->disabledStipple = None; } /* @@ -1000,7 +1000,7 @@ Tk_DeleteOutline( Display *display, /* Display containing window. */ Tk_Outline *outline) { - if (outline->gc) { + if (outline->gc != None) { Tk_FreeGC(display, outline->gc); } if ((unsigned int)ABS(outline->dash.number) > sizeof(char *)) { @@ -1012,22 +1012,22 @@ Tk_DeleteOutline( if ((unsigned int)ABS(outline->disabledDash.number) > sizeof(char *)) { ckfree((char *) outline->disabledDash.pattern.pt); } - if (outline->color) { + if (outline->color != NULL) { Tk_FreeColor(outline->color); } - if (outline->activeColor) { + if (outline->activeColor != NULL) { Tk_FreeColor(outline->activeColor); } - if (outline->disabledColor) { + if (outline->disabledColor != NULL) { Tk_FreeColor(outline->disabledColor); } - if (outline->stipple) { + if (outline->stipple != None) { Tk_FreeBitmap(display, outline->stipple); } - if (outline->activeStipple) { + if (outline->activeStipple != None) { Tk_FreeBitmap(display, outline->activeStipple); } - if (outline->disabledStipple) { + if (outline->disabledStipple != None) { Tk_FreeBitmap(display, outline->disabledStipple); } } @@ -1093,26 +1093,26 @@ Tk_ConfigOutlineGC( if (outline->activeWidth>width) { width = outline->activeWidth; } - if (outline->activeDash.number) { + if (outline->activeDash.number != 0) { dash = &(outline->activeDash); } - if (outline->activeColor) { + if (outline->activeColor!=NULL) { color = outline->activeColor; } - if (outline->activeStipple) { + if (outline->activeStipple!=None) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth>0) { width = outline->disabledWidth; } - if (outline->disabledDash.number) { + if (outline->disabledDash.number != 0) { dash = &(outline->disabledDash); } - if (outline->disabledColor) { + if (outline->disabledColor!=NULL) { color = outline->disabledColor; } - if (outline->disabledStipple) { + if (outline->disabledStipple!=None) { stipple = outline->disabledStipple; } } @@ -1125,18 +1125,18 @@ Tk_ConfigOutlineGC( if (color != NULL) { gcValues->foreground = color->pixel; mask = GCForeground|GCLineWidth; - if (stipple) { + if (stipple != None) { gcValues->stipple = stipple; gcValues->fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } } - if (mask && dash->number) { + if (mask && (dash->number != 0)) { gcValues->line_style = LineOnOffDash; gcValues->dash_offset = outline->offset; if ((unsigned int)ABS(dash->number) > sizeof(char *)) { gcValues->dashes = dash->pattern.pt[0]; - } else if (dash->number) { + } else if (dash->number != 0) { gcValues->dashes = dash->pattern.array[0]; } else { gcValues->dashes = (char) (4 * width + 0.5); @@ -1191,30 +1191,30 @@ Tk_ChangeOutlineGC( if (outline->activeWidth > width) { width = outline->activeWidth; } - if (outline->activeDash.number) { + if (outline->activeDash.number != 0) { dash = &(outline->activeDash); } - if (outline->activeColor) { + if (outline->activeColor != NULL) { color = outline->activeColor; } - if (outline->activeStipple) { + if (outline->activeStipple != None) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth > width) { width = outline->disabledWidth; } - if (outline->disabledDash.number) { + if (outline->disabledDash.number != 0) { dash = &(outline->disabledDash); } - if (outline->disabledColor) { + if (outline->disabledColor != NULL) { color = outline->disabledColor; } - if (outline->disabledStipple) { + if (outline->disabledStipple != None) { stipple = outline->disabledStipple; } } - if (!color) { + if (color==NULL) { return 0; } @@ -1236,7 +1236,7 @@ Tk_ChangeOutlineGC( XSetDashes(((TkCanvas *)canvas)->display, outline->gc, outline->offset, p, dash->number); } - if (stipple) { + if (stipple!=None) { int w=0; int h=0; Tk_TSOffset *tsoffset = &outline->tsoffset; int flags = tsoffset->flags; @@ -1310,26 +1310,26 @@ Tk_ResetOutlineGC( if (outline->activeWidth>width) { width = outline->activeWidth; } - if (outline->activeDash.number) { + if (outline->activeDash.number != 0) { dash = &(outline->activeDash); } - if (outline->activeColor) { + if (outline->activeColor!=NULL) { color = outline->activeColor; } - if (outline->activeStipple) { + if (outline->activeStipple!=None) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { if (outline->disabledWidth>width) { width = outline->disabledWidth; } - if (outline->disabledDash.number) { + if (outline->disabledDash.number != 0) { dash = &(outline->disabledDash); } - if (outline->disabledColor) { + if (outline->disabledColor!=NULL) { color = outline->disabledColor; } - if (outline->disabledStipple) { + if (outline->disabledStipple!=None) { stipple = outline->disabledStipple; } } @@ -1342,7 +1342,7 @@ Tk_ResetOutlineGC( ((dash->number == -1) && (dash->pattern.array[0] != ','))) { if ((unsigned int)ABS(dash->number) > sizeof(char *)) { dashList = dash->pattern.pt[0]; - } else if (dash->number) { + } else if (dash->number != 0) { dashList = dash->pattern.array[0]; } else { dashList = (char) (4 * width + 0.5); @@ -1350,7 +1350,7 @@ Tk_ResetOutlineGC( XSetDashes(((TkCanvas *)canvas)->display, outline->gc, outline->offset, &dashList , 1); } - if (stipple) { + if (stipple != None) { XSetTSOrigin(((TkCanvas *)canvas)->display, outline->gc, 0, 0); return 1; } @@ -1409,10 +1409,10 @@ Tk_CanvasPsOutline( if (outline->activeDash.number > 0) { dash = &(outline->activeDash); } - if (outline->activeColor) { + if (outline->activeColor != NULL) { color = outline->activeColor; } - if (outline->activeStipple) { + if (outline->activeStipple != None) { stipple = outline->activeStipple; } } else if (state == TK_STATE_DISABLED) { @@ -1422,10 +1422,10 @@ Tk_CanvasPsOutline( if (outline->disabledDash.number > 0) { dash = &(outline->disabledDash); } - if (outline->disabledColor) { + if (outline->disabledColor != NULL) { color = outline->disabledColor; } - if (outline->disabledStipple) { + if (outline->disabledStipple != None) { stipple = outline->disabledStipple; } } @@ -1482,7 +1482,7 @@ Tk_CanvasPsOutline( if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) { return TCL_ERROR; } - if (stipple) { + if (stipple != None) { Tcl_AppendResult(interp, "StrokeClip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) { return TCL_ERROR; diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c index c5ecf1a..b62859c 100644 --- a/generic/tkCanvWind.c +++ b/generic/tkCanvWind.c @@ -583,7 +583,7 @@ DisplayWinItem( * A drawable of None is used by the canvas UnmapNotify handler * to indicate that we should no longer display ourselves. */ - if (state == TK_STATE_HIDDEN || !drawable) { + if (state == TK_STATE_HIDDEN || drawable == None) { if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) { Tk_UnmapWindow(winItemPtr->tkwin); } else { diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 27a3a32..1024529 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -417,9 +417,9 @@ Tk_CanvasObjCmd( canvasPtr->highlightBgColorPtr = NULL; canvasPtr->highlightColorPtr = NULL; canvasPtr->inset = 0; - canvasPtr->pixmapGC = 0; - canvasPtr->width = 0; - canvasPtr->height = 0; + canvasPtr->pixmapGC = NULL; + canvasPtr->width = None; + canvasPtr->height = None; canvasPtr->confine = 0; canvasPtr->textInfo.selBorder = NULL; canvasPtr->textInfo.selBorderWidth = 0; @@ -463,7 +463,7 @@ Tk_CanvasObjCmd( canvasPtr->scanYOrigin = 0; canvasPtr->hotPtr = NULL; canvasPtr->hotPrevPtr = NULL; - canvasPtr->cursor = 0; + canvasPtr->cursor = NULL; canvasPtr->takeFocus = NULL; canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(newWin)); canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(newWin)); @@ -1834,7 +1834,7 @@ DestroyCanvas( */ Tcl_DeleteHashTable(&canvasPtr->idTable); - if (canvasPtr->pixmapGC) { + if (canvasPtr->pixmapGC != None) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } #ifndef USE_OLD_TAG_SEARCH @@ -1910,7 +1910,7 @@ ConfigureCanvas( gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel; newGC = Tk_GetGC(canvasPtr->tkwin, GCFunction|GCGraphicsExposures|GCForeground, &gcValues); - if (canvasPtr->pixmapGC) { + if (canvasPtr->pixmapGC != None) { Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC); } canvasPtr->pixmapGC = newGC; @@ -2405,7 +2405,7 @@ CanvasEventProc( itemPtr = itemPtr->nextPtr) { if (itemPtr->typePtr->alwaysRedraw & 1) { (*itemPtr->typePtr->displayProc)((Tk_Canvas) canvasPtr, - itemPtr, canvasPtr->display, 0, 0, 0, 0, 0); + itemPtr, canvasPtr->display, None, 0, 0, 0, 0); } } } @@ -4545,7 +4545,7 @@ PickCurrentItem( canvasPtr->pickEvent.xcrossing.display = eventPtr->xmotion.display; canvasPtr->pickEvent.xcrossing.window = eventPtr->xmotion.window; canvasPtr->pickEvent.xcrossing.root = eventPtr->xmotion.root; - canvasPtr->pickEvent.xcrossing.subwindow = 0; + canvasPtr->pickEvent.xcrossing.subwindow = None; canvasPtr->pickEvent.xcrossing.time = eventPtr->xmotion.time; canvasPtr->pickEvent.xcrossing.x = eventPtr->xmotion.x; canvasPtr->pickEvent.xcrossing.y = eventPtr->xmotion.y; diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c index 4c564e7..c6748a1 100644 --- a/generic/tkClipboard.c +++ b/generic/tkClipboard.c @@ -654,7 +654,7 @@ TkClipInit( Tk_ChangeWindowAttributes(dispPtr->clipWindow, CWOverrideRedirect, &atts); Tk_MakeWindowExist(dispPtr->clipWindow); - if (!dispPtr->multipleAtom) { + if (dispPtr->multipleAtom == None) { /* * Need to invoke selection initialization to make sure that atoms we * depend on below are defined. diff --git a/generic/tkColor.c b/generic/tkColor.c index 1ec4ab1..bde08cf 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -414,7 +414,7 @@ Tk_GCForColor( Tcl_Panic("Tk_GCForColor called with bogus color"); } - if (!tkColPtr->gc) { + if (tkColPtr->gc == None) { gcValues.foreground = tkColPtr->color.pixel; tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen), drawable, GCForeground, &gcValues); @@ -469,7 +469,7 @@ Tk_FreeColor( * longer any objects referencing it. */ - if (tkColPtr->gc) { + if (tkColPtr->gc != None) { XFreeGC(DisplayOfScreen(screen), tkColPtr->gc); tkColPtr->gc = 0; } diff --git a/generic/tkConfig.c b/generic/tkConfig.c index 5fcbab8..ace7135 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -802,10 +802,10 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newBitmap = 0; + newBitmap = None; } else { newBitmap = Tk_AllocBitmapFromObj(interp, tkwin, valuePtr); - if (!newBitmap) { + if (newBitmap == None) { return TCL_ERROR; } } @@ -858,7 +858,7 @@ DoObjConfig( valuePtr = NULL; } else { newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr); - if (!newCursor) { + if (newCursor == None) { return TCL_ERROR; } } @@ -1680,9 +1680,9 @@ FreeResources( break; case TK_OPTION_BITMAP: if (internalFormExists) { - if (*((Pixmap *) internalPtr)) { + if (*((Pixmap *) internalPtr) != None) { Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *) internalPtr)); - *((Pixmap *) internalPtr) = 0; + *((Pixmap *) internalPtr) = None; } } else if (objPtr != NULL) { Tk_FreeBitmapFromObj(tkwin, objPtr); @@ -1700,7 +1700,7 @@ FreeResources( break; case TK_OPTION_CURSOR: if (internalFormExists) { - if (*((Tk_Cursor *) internalPtr)) { + if (*((Tk_Cursor *) internalPtr) != None) { Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr)); *((Tk_Cursor *) internalPtr) = 0; } @@ -1954,7 +1954,7 @@ GetObjectForOption( case TK_OPTION_BITMAP: { Pixmap pixmap = *((Pixmap *) internalPtr); - if (pixmap) { + if (pixmap != None) { objPtr = Tcl_NewStringObj( Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), -1); } @@ -1974,7 +1974,7 @@ GetObjectForOption( case TK_OPTION_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) internalPtr); - if (cursor) { + if (cursor != None) { objPtr = Tcl_NewStringObj( Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1); } diff --git a/generic/tkCursor.c b/generic/tkCursor.c index ced2534..a1c2723 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -187,7 +187,10 @@ Tk_GetCursor( * details on legal syntax. */ { TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); - return cursorPtr ? cursorPtr->cursor : 0; + if (cursorPtr == NULL) { + return 0; + } + return cursorPtr->cursor; } /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 5eaca77..f5b4339 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -523,16 +523,16 @@ Tk_EntryObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = 0; + entryPtr->cursor = NULL; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = 0; - entryPtr->selTextGC = 0; - entryPtr->highlightGC = 0; + entryPtr->textGC = NULL; + entryPtr->selTextGC = NULL; + entryPtr->highlightGC = NULL; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; @@ -1030,10 +1030,10 @@ DestroyEntry( EntryTextVarProc, (ClientData) entryPtr); entryPtr->flags &= ~ENTRY_VAR_TRACED; } - if (entryPtr->textGC) { + if (entryPtr->textGC != None) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } - if (entryPtr->selTextGC) { + if (entryPtr->selTextGC != None) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler); @@ -1043,7 +1043,7 @@ DestroyEntry( if (entryPtr->type == TK_SPINBOX) { Spinbox *sbPtr = (Spinbox *) entryPtr; - if (sbPtr->listObj) { + if (sbPtr->listObj != NULL) { Tcl_DecrRefCount(sbPtr->listObj); sbPtr->listObj = NULL; } @@ -1423,7 +1423,7 @@ EntryWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = 0; + GC gc = NULL; unsigned long mask; Tk_3DBorder border; XColor *colorPtr; @@ -1475,18 +1475,18 @@ EntryWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->textGC) { + if (entryPtr->textGC != None) { Tk_FreeGC(entryPtr->display, entryPtr->textGC); } entryPtr->textGC = gc; - if (entryPtr->selFgColorPtr) { + if (entryPtr->selFgColorPtr != NULL) { gcValues.foreground = entryPtr->selFgColorPtr->pixel; } gcValues.font = Tk_FontId(entryPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues); - if (entryPtr->selTextGC) { + if (entryPtr->selTextGC != None) { Tk_FreeGC(entryPtr->display, entryPtr->selTextGC); } entryPtr->selTextGC = gc; @@ -2451,7 +2451,7 @@ EntryEventProc( } else if ((elem == SEL_BUTTONDOWN) || (elem == SEL_BUTTONUP)) { cursor = sbPtr->bCursor; } else { - cursor = 0; + cursor = NULL; } if (cursor) { Tk_DefineCursor(entryPtr->tkwin, cursor); @@ -3591,22 +3591,22 @@ Tk_SpinboxObjCmd( entryPtr->selectFirst = -1; entryPtr->selectLast = -1; - entryPtr->cursor = 0; + entryPtr->cursor = NULL; entryPtr->exportSelection = 1; entryPtr->justify = TK_JUSTIFY_LEFT; entryPtr->relief = TK_RELIEF_FLAT; entryPtr->state = STATE_NORMAL; entryPtr->displayString = entryPtr->string; entryPtr->inset = XPAD; - entryPtr->textGC = 0; - entryPtr->selTextGC = 0; - entryPtr->highlightGC = 0; + entryPtr->textGC = NULL; + entryPtr->selTextGC = NULL; + entryPtr->highlightGC = NULL; entryPtr->avgWidth = 1; entryPtr->validate = VALIDATE_NONE; sbPtr->selElement = SEL_NONE; sbPtr->curElement = SEL_NONE; - sbPtr->bCursor = 0; + sbPtr->bCursor = NULL; sbPtr->repeatDelay = 400; sbPtr->repeatInterval = 100; sbPtr->fromValue = 0.0; diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 2ea7936..7f8aa1f 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[16]; /* Sprintf conversion specifier computed from + char digitFormat[10]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index ac5b68c..9b001e1 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -421,11 +421,11 @@ GetTkWindowFromXEvent( } TkSelPropProc(eventPtr); parentXId = ParentXId(eventPtr->xany.display, handlerWindow); - if (!parentXId) { + if (parentXId == None) { return NULL; } winPtr = (TkWindow *) Tk_IdToWindow(eventPtr->xany.display, parentXId); - if (!winPtr) { + if (winPtr == NULL) { return NULL; } if (!(winPtr->flags & TK_PROP_PROPCHANGE)) { @@ -601,7 +601,7 @@ UpdateButtonEventState( case ButtonRelease: dispPtr = TkGetDisplay(eventPtr->xbutton.display); - dispPtr->mouseButtonWindow = 0; + dispPtr->mouseButtonWindow = None; dispPtr->mouseButtonState &= ~GetButtonMask(eventPtr->xbutton.button); eventPtr->xbutton.state |= dispPtr->mouseButtonState; break; @@ -617,7 +617,7 @@ UpdateButtonEventState( */ dispPtr->mouseButtonState &= ~allButtonsMask; - dispPtr->mouseButtonWindow = 0; + dispPtr->mouseButtonWindow = None; } else { eventPtr->xmotion.state |= dispPtr->mouseButtonState; } @@ -1192,7 +1192,7 @@ ParentXId( XFree(childList); } if (status == 0) { - parent = 0; + parent = None; } return parent; @@ -1365,7 +1365,7 @@ Tk_HandleEvent( * handle CreateNotify events, so we gotta pass 'em through. */ - if ((ip.winPtr) + if ((ip.winPtr != None) && ((mask != SubstructureNotifyMask) || (eventPtr->type == CreateNotify))) { TkBindEventProc(winPtr, eventPtr); @@ -1379,7 +1379,7 @@ Tk_HandleEvent( */ releaseInterpreter: - if (interp) { + if (interp != NULL) { Tcl_Release((ClientData) interp); } @@ -1427,7 +1427,7 @@ TkEventDeadWindow( * to quit (all of the handlers are being deleted). */ - while (winPtr->handlerList) { + while (winPtr->handlerList != NULL) { handlerPtr = winPtr->handlerList; winPtr->handlerList = handlerPtr->nextPtr; for (ipPtr = tsdPtr->pendingPtr; ipPtr != NULL; diff --git a/generic/tkFrame.c b/generic/tkFrame.c index ef1338e..3203cfa 100644 --- a/generic/tkFrame.c +++ b/generic/tkFrame.c @@ -487,7 +487,7 @@ CreateFrame( */ className = colormapName = screenName = visualName = useOption = NULL; - colormap = 0; + colormap = None; for (i = 2; i < objc; i += 2) { arg = Tcl_GetStringFromObj(objv[i], &length); if (length < 2) { @@ -591,14 +591,14 @@ CreateFrame( if (visualName != NULL) { visual = Tk_GetVisual(interp, newWin, visualName, &depth, (colormapName == NULL) ? &colormap : NULL); - if (!visual) { + if (visual == NULL) { goto error; } Tk_SetWindowVisual(newWin, visual, depth, colormap); } - if (colormapName) { + if (colormapName != NULL) { colormap = Tk_GetColormap(interp, newWin, colormapName); - if (!colormap) { + if (colormap == None) { goto error; } Tk_SetWindowColormap(newWin, colormap); @@ -637,12 +637,12 @@ CreateFrame( framePtr->type = type; framePtr->colormap = colormap; framePtr->relief = TK_RELIEF_FLAT; - framePtr->cursor = 0; + framePtr->cursor = NULL; if (framePtr->type == TYPE_LABELFRAME) { Labelframe *labelframePtr = (Labelframe *) framePtr; labelframePtr->labelAnchor = LABELANCHOR_NW; - labelframePtr->textGC = 0; + labelframePtr->textGC = NULL; } /* @@ -840,11 +840,11 @@ DestroyFrame( if (framePtr->type == TYPE_LABELFRAME) { Tk_FreeTextLayout(labelframePtr->textLayout); - if (labelframePtr->textGC) { + if (labelframePtr->textGC != None) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } } - if (framePtr->colormap) { + if (framePtr->colormap != None) { Tk_FreeColormap(framePtr->display, framePtr->colormap); } ckfree((char *) framePtr); @@ -967,7 +967,7 @@ ConfigureFrame( if (framePtr->border != NULL) { Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border); } else { - Tk_SetWindowBackgroundPixmap(framePtr->tkwin, 0); + Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None); } if (framePtr->highlightWidth < 0) { @@ -1096,7 +1096,7 @@ FrameWorldChanged( gcValues.graphics_exposures = False; gc = Tk_GetGC(tkwin, GCForeground | GCFont | GCGraphicsExposures, &gcValues); - if (labelframePtr->textGC) { + if (labelframePtr->textGC != None) { Tk_FreeGC(framePtr->display, labelframePtr->textGC); } labelframePtr->textGC = gc; @@ -1528,8 +1528,8 @@ DisplayFrame( labelframePtr->labelTextX + LABELSPACING, labelframePtr->labelTextY + LABELSPACING, 0, -1); - if (clipRegion) { - XSetClipMask(framePtr->display, labelframePtr->textGC, 0); + if (clipRegion != NULL) { + XSetClipMask(framePtr->display, labelframePtr->textGC, None); TkDestroyRegion(clipRegion); } } else { diff --git a/generic/tkGC.c b/generic/tkGC.c index c0864d0..800e4d3 100644 --- a/generic/tkGC.c +++ b/generic/tkGC.c @@ -155,12 +155,12 @@ Tk_GetGC( if (valueMask & GCTile) { valueKey.values.tile = valuePtr->tile; } else { - valueKey.values.tile = 0; + valueKey.values.tile = None; } if (valueMask & GCStipple) { valueKey.values.stipple = valuePtr->stipple; } else { - valueKey.values.stipple = 0; + valueKey.values.stipple = None; } if (valueMask & GCTileStipXOrigin) { valueKey.values.ts_x_origin = valuePtr->ts_x_origin; @@ -175,7 +175,7 @@ Tk_GetGC( if (valueMask & GCFont) { valueKey.values.font = valuePtr->font; } else { - valueKey.values.font = 0; + valueKey.values.font = None; } if (valueMask & GCSubwindowMode) { valueKey.values.subwindow_mode = valuePtr->subwindow_mode; @@ -200,7 +200,7 @@ Tk_GetGC( if (valueMask & GCClipMask) { valueKey.values.clip_mask = valuePtr->clip_mask; } else { - valueKey.values.clip_mask = 0; + valueKey.values.clip_mask = None; } if (valueMask & GCDashOffset) { valueKey.values.dash_offset = valuePtr->dash_offset; @@ -236,8 +236,8 @@ Tk_GetGC( * Tk_MakeWindowExist on the window. */ - freeDrawable = 0; - if (Tk_WindowId(tkwin)) { + freeDrawable = None; + if (Tk_WindowId(tkwin) != None) { d = Tk_WindowId(tkwin); } else if (valueKey.depth == DefaultDepth(valueKey.display, valueKey.screenNum)) { @@ -260,7 +260,7 @@ Tk_GetGC( } Tcl_SetHashValue(valueHashPtr, gcPtr); Tcl_SetHashValue(idHashPtr, gcPtr); - if (freeDrawable) { + if (freeDrawable != None) { Tk_FreePixmap(valueKey.display, freeDrawable); } diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 3039ea0..44a4f8c 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -468,8 +468,8 @@ Tk_Grab( for (numTries = 0; numTries < 10; numTries++) { grabResult = XGrabPointer(dispPtr->display, winPtr->window, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask - |PointerMotionMask, GrabModeAsync, GrabModeAsync, 0, - 0, CurrentTime); + |PointerMotionMask, GrabModeAsync, GrabModeAsync, None, + None, CurrentTime); if (grabResult != AlreadyGrabbed) { break; } @@ -854,7 +854,7 @@ TkPointerEvent( if (XGrabPointer(dispPtr->display, dispPtr->grabWinPtr->window, True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask, - GrabModeAsync, GrabModeAsync, 0, 0, + GrabModeAsync, GrabModeAsync, None, None, CurrentTime) == 0) { EatGrabEvents(dispPtr, serial); if (XGrabKeyboard(dispPtr->display, winPtr->window, @@ -921,7 +921,7 @@ TkChangeEventWindow( Tk_GetRootCoords((Tk_Window) winPtr, &x, &y); eventPtr->xmotion.x = eventPtr->xmotion.x_root - x; eventPtr->xmotion.y = eventPtr->xmotion.y_root - y; - eventPtr->xmotion.subwindow = 0; + eventPtr->xmotion.subwindow = None; for (childPtr = winPtr->childList; childPtr != NULL; childPtr = childPtr->nextPtr) { if (childPtr->flags & TK_TOP_HIERARCHY) { @@ -940,7 +940,7 @@ TkChangeEventWindow( } else { eventPtr->xmotion.x = 0; eventPtr->xmotion.y = 0; - eventPtr->xmotion.subwindow = 0; + eventPtr->xmotion.subwindow = None; sameScreen = 0; } if (eventPtr->type == MotionNotify) { @@ -1029,7 +1029,7 @@ TkInOutEvents( */ #define QUEUE(w, t, d) \ - if (w->window) { \ + if (w->window != None) { \ eventPtr->type = t; \ if (focus) { \ eventPtr->xfocus.window = w->window; \ @@ -1145,9 +1145,9 @@ MovePointer2( TkWindow *winPtr; winPtr = sourcePtr; - if (!winPtr || !winPtr->window) { + if ((winPtr == NULL) || (winPtr->window == None)) { winPtr = destPtr; - if (!winPtr || !winPtr->window) { + if ((winPtr == NULL) || (winPtr->window == None)) { return; } } @@ -1338,7 +1338,7 @@ QueueGrabWindowChange( grabEvPtr->header.proc = GrabWinEventProc; grabEvPtr->dispPtr = dispPtr; if (grabWinPtr == NULL) { - grabEvPtr->grabWindow = 0; + grabEvPtr->grabWindow = None; } else { grabEvPtr->grabWindow = grabWinPtr->window; } diff --git a/generic/tkImage.c b/generic/tkImage.c index 99a1726..6c7c9cd 100644 --- a/generic/tkImage.c +++ b/generic/tkImage.c @@ -759,7 +759,7 @@ Tk_PostscriptImage( gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin)); newGC = Tk_GetGC(tkwin, GCForeground, &gcValues); - if (newGC) { + if (newGC != None) { XFillRectangle(Tk_Display(tkwin), pmap, newGC, 0, 0, (unsigned int)width, (unsigned int)height); Tk_FreeGC(Tk_Display(tkwin), newGC); @@ -772,7 +772,7 @@ Tk_PostscriptImage( Tk_FreePixmap(Tk_Display(tkwin), pmap); - if (!ximage) { + if (ximage == NULL) { /* * The XGetImage() function is apparently not implemented on this * system. Just ignore it. diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index 4e0082a..fab6afb 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -381,9 +381,9 @@ ImgBmapConfigureInstance( */ oldBitmap = instancePtr->bitmap; - instancePtr->bitmap = 0; + instancePtr->bitmap = None; oldMask = instancePtr->mask; - instancePtr->mask = 0; + instancePtr->mask = None; if (masterPtr->data != NULL) { instancePtr->bitmap = XCreateBitmapFromData( @@ -414,7 +414,7 @@ ImgBmapConfigureInstance( if (instancePtr->bg) { gcValues.background = instancePtr->bg->pixel; mask |= GCBackground; - if (instancePtr->mask) { + if (instancePtr->mask != None) { gcValues.clip_mask = instancePtr->mask; mask |= GCClipMask; } @@ -424,7 +424,7 @@ ImgBmapConfigureInstance( } gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues); } else { - gc = 0; + gc = NULL; } if (instancePtr->gc) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); @@ -441,7 +441,7 @@ ImgBmapConfigureInstance( if (instancePtr->gc) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } - instancePtr->gc = 0; + instancePtr->gc = NULL; Tcl_AddErrorInfo(masterPtr->interp, "\n (while configuring image \""); Tcl_AddErrorInfo(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); Tcl_AddErrorInfo(masterPtr->interp, "\")"); @@ -834,9 +834,9 @@ ImgBmapGet( instancePtr->tkwin = tkwin; instancePtr->fg = NULL; instancePtr->bg = NULL; - instancePtr->bitmap = 0; - instancePtr->mask = 0; - instancePtr->gc = 0; + instancePtr->bitmap = None; + instancePtr->mask = None; + instancePtr->gc = NULL; instancePtr->nextPtr = masterPtr->instancePtr; masterPtr->instancePtr = instancePtr; ImgBmapConfigureInstance(instancePtr); @@ -890,7 +890,7 @@ ImgBmapDisplay( * creating the image instance so it can't be displayed. */ - if (!instancePtr->gc) { + if (instancePtr->gc == None) { return; } @@ -900,7 +900,7 @@ ImgBmapDisplay( * image and reset the clip origin, if there's a mask. */ - masking = instancePtr->mask || !instancePtr->bg; + masking = (instancePtr->mask != None) || (instancePtr->bg == NULL); if (masking) { XSetClipOrigin(display, instancePtr->gc, drawableX - imageX, drawableY - imageY); @@ -949,19 +949,19 @@ ImgBmapFree( * instance structure. */ - if (instancePtr->fg) { + if (instancePtr->fg != NULL) { Tk_FreeColor(instancePtr->fg); } - if (instancePtr->bg) { + if (instancePtr->bg != NULL) { Tk_FreeColor(instancePtr->bg); } - if (instancePtr->bitmap) { + if (instancePtr->bitmap != None) { Tk_FreePixmap(display, instancePtr->bitmap); } - if (instancePtr->mask) { + if (instancePtr->mask != None) { Tk_FreePixmap(display, instancePtr->mask); } - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(display, instancePtr->gc); } if (instancePtr->masterPtr->instancePtr == instancePtr) { @@ -1000,17 +1000,17 @@ ImgBmapDelete( { BitmapMaster *masterPtr = (BitmapMaster *) masterData; - if (masterPtr->instancePtr) { + if (masterPtr->instancePtr != NULL) { Tcl_Panic("tried to delete bitmap image when instances still exist"); } masterPtr->tkMaster = NULL; - if (masterPtr->imageCmd) { + if (masterPtr->imageCmd != NULL) { Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd); } - if (masterPtr->data) { + if (masterPtr->data != NULL) { ckfree(masterPtr->data); } - if (masterPtr->maskData) { + if (masterPtr->maskData != NULL) { ckfree(masterPtr->maskData); } Tk_FreeOptions(configSpecs, (char *) masterPtr, NULL, 0); @@ -1042,7 +1042,7 @@ ImgBmapCmdDeletedProc( BitmapMaster *masterPtr = (BitmapMaster *) clientData; masterPtr->imageCmd = NULL; - if (masterPtr->tkMaster) { + if (masterPtr->tkMaster != NULL) { Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster)); } } diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c index d1503f6..4e1aa01 100644 --- a/generic/tkImgPhoto.c +++ b/generic/tkImgPhoto.c @@ -2285,7 +2285,7 @@ ImgPhotoConfigureInstance( * has the side effect of allocating a pixmap for us. */ - if (!instancePtr->pixels || !instancePtr->error + if ((instancePtr->pixels == None) || (instancePtr->error == NULL) || (instancePtr->width != masterPtr->width) || (instancePtr->height != masterPtr->height)) { ImgPhotoInstanceSetSize(instancePtr); @@ -2403,7 +2403,7 @@ ImgPhotoGet( Tk_PreserveColormap(instancePtr->display, instancePtr->colormap); instancePtr->refCount = 1; instancePtr->colorTablePtr = NULL; - instancePtr->pixels = 0; + instancePtr->pixels = None; instancePtr->error = NULL; instancePtr->width = 0; instancePtr->height = 0; @@ -2776,7 +2776,7 @@ ImgPhotoDisplay( * the image instance so it can't be displayed. */ - if (!instancePtr->pixels) { + if (instancePtr->pixels == None) { return; } @@ -2834,7 +2834,7 @@ ImgPhotoDisplay( XCopyArea(display, instancePtr->pixels, drawable, instancePtr->gc, imageX, imageY, (unsigned) width, (unsigned) height, drawableX, drawableY); - XSetClipMask(display, instancePtr->gc, 0); + XSetClipMask(display, instancePtr->gc, None); XSetClipOrigin(display, instancePtr->gc, 0, 0); } XFlush(display); @@ -3196,7 +3196,7 @@ ImgPhotoInstanceSetSize( if ((instancePtr->width != masterPtr->width) || (instancePtr->height != masterPtr->height) - || !instancePtr->pixels) { + || (instancePtr->pixels == None)) { newPixmap = Tk_GetPixmap(instancePtr->display, RootWindow(instancePtr->display, instancePtr->visualInfo.screen), @@ -3218,7 +3218,7 @@ ImgPhotoInstanceSetSize( TkSetPixmapColormap(newPixmap, instancePtr->colormap); - if (instancePtr->pixels) { + if (instancePtr->pixels != None) { /* * Copy any common pixels from the old pixmap and free it. */ @@ -3995,19 +3995,19 @@ DisposeInstance( PhotoInstance *instancePtr = (PhotoInstance *) clientData; PhotoInstance *prevPtr; - if (instancePtr->pixels) { + if (instancePtr->pixels != None) { Tk_FreePixmap(instancePtr->display, instancePtr->pixels); } - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(instancePtr->display, instancePtr->gc); } - if (instancePtr->imagePtr) { + if (instancePtr->imagePtr != NULL) { XDestroyImage(instancePtr->imagePtr); } - if (instancePtr->error) { + if (instancePtr->error != NULL) { ckfree((char *) instancePtr->error); } - if (instancePtr->colorTablePtr) { + if (instancePtr->colorTablePtr != NULL) { FreeColorTable(instancePtr->colorTablePtr, 1); } diff --git a/generic/tkListbox.c b/generic/tkListbox.c index 70e4e3c..1c9a8ae 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -534,15 +534,15 @@ Tk_ListboxObjCmd( ckalloc(sizeof(Tcl_HashTable)); Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS); listPtr->relief = TK_RELIEF_RAISED; - listPtr->textGC = 0; - listPtr->selFgColorPtr = 0; - listPtr->selTextGC = 0; + listPtr->textGC = NULL; + listPtr->selFgColorPtr = NULL; + listPtr->selTextGC = NULL; listPtr->fullLines = 1; listPtr->xScrollUnit = 1; listPtr->exportSelection = 1; - listPtr->cursor = 0; + listPtr->cursor = NULL; listPtr->state = STATE_NORMAL; - listPtr->gray = 0; + listPtr->gray = None; /* * Keep a hold of the associated tkwin until we destroy the listbox, @@ -1474,13 +1474,13 @@ DestroyListbox( * Tk_FreeOptions handle all the standard option-related stuff. */ - if (listPtr->textGC) { + if (listPtr->textGC != None) { Tk_FreeGC(listPtr->display, listPtr->textGC); } - if (listPtr->selTextGC) { + if (listPtr->selTextGC != None) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } - if (listPtr->gray) { + if (listPtr->gray != None) { Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray); } @@ -1765,10 +1765,10 @@ ListboxWorldChanged( } else { gcValues.foreground = listPtr->fgColorPtr->pixel; mask = GCForeground | GCFont; - if (!listPtr->gray) { + if (listPtr->gray == None) { listPtr->gray = Tk_GetBitmap(NULL, listPtr->tkwin, "gray50"); } - if (listPtr->gray) { + if (listPtr->gray != None) { gcValues.fill_style = FillStippled; gcValues.stipple = listPtr->gray; mask |= GCFillStyle | GCStipple; @@ -1777,18 +1777,18 @@ ListboxWorldChanged( gcValues.font = Tk_FontId(listPtr->tkfont); gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->textGC) { + if (listPtr->textGC != None) { Tk_FreeGC(listPtr->display, listPtr->textGC); } listPtr->textGC = gc; - if (listPtr->selFgColorPtr) { + if (listPtr->selFgColorPtr != NULL) { gcValues.foreground = listPtr->selFgColorPtr->pixel; } gcValues.font = Tk_FontId(listPtr->tkfont); mask = GCForeground | GCFont; gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues); - if (listPtr->selTextGC) { + if (listPtr->selTextGC != None) { Tk_FreeGC(listPtr->display, listPtr->selTextGC); } listPtr->selTextGC = gc; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index fa14b7e..171087a 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -506,7 +506,7 @@ MenuCmd( Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, (ClientData) menuPtr, MenuCmdDeletedProc); menuPtr->active = -1; - menuPtr->cursorPtr = 0; + menuPtr->cursorPtr = NULL; menuPtr->masterMenuPtr = menuPtr; menuPtr->menuType = UNKNOWN_TYPE; menuPtr->optionTablesPtr = optionTablesPtr; diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index d26f83b..11faa0a 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -43,12 +43,12 @@ void TkMenuInitializeDrawingFields( TkMenu *menuPtr) /* The menu we are initializing. */ { - menuPtr->textGC = 0; - menuPtr->gray = 0; - menuPtr->disabledGC = 0; - menuPtr->activeGC = 0; - menuPtr->indicatorGC = 0; - menuPtr->disabledImageGC = 0; + menuPtr->textGC = NULL; + menuPtr->gray = None; + menuPtr->disabledGC = NULL; + menuPtr->activeGC = NULL; + menuPtr->indicatorGC = NULL; + menuPtr->disabledImageGC = NULL; menuPtr->totalWidth = menuPtr->totalHeight = 0; } @@ -79,10 +79,10 @@ TkMenuInitializeEntryDrawingFields( mePtr->y = 0; mePtr->indicatorSpace = 0; mePtr->labelWidth = 0; - mePtr->textGC = 0; - mePtr->activeGC = 0; - mePtr->disabledGC = 0; - mePtr->indicatorGC = 0; + mePtr->textGC = NULL; + mePtr->activeGC = NULL; + mePtr->disabledGC = NULL; + mePtr->indicatorGC = NULL; } /* @@ -106,22 +106,22 @@ void TkMenuFreeDrawOptions( TkMenu *menuPtr) { - if (menuPtr->textGC) { + if (menuPtr->textGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } - if (menuPtr->disabledImageGC) { + if (menuPtr->disabledImageGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } - if (menuPtr->gray) { + if (menuPtr->gray != None) { Tk_FreeBitmap(menuPtr->display, menuPtr->gray); } - if (menuPtr->disabledGC) { + if (menuPtr->disabledGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } - if (menuPtr->activeGC) { + if (menuPtr->activeGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } - if (menuPtr->indicatorGC) { + if (menuPtr->indicatorGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } } @@ -147,16 +147,16 @@ void TkMenuEntryFreeDrawOptions( TkMenuEntry *mePtr) { - if (mePtr->textGC) { + if (mePtr->textGC != None) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->textGC); } - if (mePtr->disabledGC) { + if (mePtr->disabledGC != None) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->disabledGC); } - if (mePtr->activeGC) { + if (mePtr->activeGC != None) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->activeGC); } - if (mePtr->indicatorGC) { + if (mePtr->indicatorGC != None) { Tk_FreeGC(mePtr->menuPtr->display, mePtr->indicatorGC); } } @@ -205,7 +205,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->textGC) { + if (menuPtr->textGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->textGC); } menuPtr->textGC = newGC; @@ -222,34 +222,34 @@ TkMenuConfigureDrawOptions( } else { gcValues.foreground = gcValues.background; mask = GCForeground; - if (!menuPtr->gray) { + if (menuPtr->gray == None) { menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin, "gray50"); } - if (menuPtr->gray) { + if (menuPtr->gray != None) { gcValues.fill_style = FillStippled; gcValues.stipple = menuPtr->gray; mask = GCForeground|GCFillStyle|GCStipple; } } newGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues); - if (menuPtr->disabledGC) { + if (menuPtr->disabledGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->disabledGC); } menuPtr->disabledGC = newGC; gcValues.foreground = Tk_3DBorderColor(border)->pixel; - if (!menuPtr->gray) { + if (menuPtr->gray == None) { menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin, "gray50"); } - if (menuPtr->gray) { + if (menuPtr->gray != None) { gcValues.fill_style = FillStippled; gcValues.stipple = menuPtr->gray; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCFillStyle|GCStipple, &gcValues); } - if (menuPtr->disabledImageGC) { + if (menuPtr->disabledImageGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC); } menuPtr->disabledImageGC = newGC; @@ -262,7 +262,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(activeBorder)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->activeGC) { + if (menuPtr->activeGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->activeGC); } menuPtr->activeGC = newGC; @@ -273,7 +273,7 @@ TkMenuConfigureDrawOptions( gcValues.background = Tk_3DBorderColor(border)->pixel; newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont, &gcValues); - if (menuPtr->indicatorGC) { + if (menuPtr->indicatorGC != None) { Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC); } menuPtr->indicatorGC = newGC; @@ -385,24 +385,24 @@ TkMenuConfigureEntryDrawOptions( GCForeground|GCBackground|GCFont|GCGraphicsExposures, &gcValues); } else { - newGC = 0; - newActiveGC = 0; - newDisabledGC = 0; - newIndicatorGC = 0; + newGC = NULL; + newActiveGC = NULL; + newDisabledGC = NULL; + newIndicatorGC = NULL; } - if (mePtr->textGC) { + if (mePtr->textGC != None) { Tk_FreeGC(menuPtr->display, mePtr->textGC); } mePtr->textGC = newGC; - if (mePtr->activeGC) { + if (mePtr->activeGC != None) { Tk_FreeGC(menuPtr->display, mePtr->activeGC); } mePtr->activeGC = newActiveGC; - if (mePtr->disabledGC) { + if (mePtr->disabledGC != None) { Tk_FreeGC(menuPtr->display, mePtr->disabledGC); } mePtr->disabledGC = newDisabledGC; - if (mePtr->indicatorGC) { + if (mePtr->indicatorGC != None) { Tk_FreeGC(menuPtr->display, mePtr->indicatorGC); } mePtr->indicatorGC = newIndicatorGC; diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c index a24ab98..95fb9a4 100644 --- a/generic/tkMenubutton.c +++ b/generic/tkMenubutton.c @@ -251,7 +251,7 @@ Tk_MenubuttonObjCmd( mbPtr->text = NULL; mbPtr->underline = -1; mbPtr->textVarName = NULL; - mbPtr->bitmap = 0; + mbPtr->bitmap = None; mbPtr->imageString = NULL; mbPtr->image = NULL; mbPtr->state = STATE_NORMAL; @@ -267,11 +267,11 @@ Tk_MenubuttonObjCmd( mbPtr->normalFg = NULL; mbPtr->activeFg = NULL; mbPtr->disabledFg = NULL; - mbPtr->normalTextGC = 0; - mbPtr->activeTextGC = 0; - mbPtr->gray = 0; - mbPtr->disabledGC = 0; - mbPtr->stippleGC = 0; + mbPtr->normalTextGC = NULL; + mbPtr->activeTextGC = NULL; + mbPtr->gray = None; + mbPtr->disabledGC = NULL; + mbPtr->stippleGC = NULL; mbPtr->leftBearing = 0; mbPtr->rightBearing = 0; mbPtr->widthString = NULL; @@ -288,7 +288,7 @@ Tk_MenubuttonObjCmd( mbPtr->indicatorWidth = 0; mbPtr->indicatorHeight = 0; mbPtr->direction = DIRECTION_FLUSH; - mbPtr->cursor = 0; + mbPtr->cursor = NULL; mbPtr->takeFocus = NULL; mbPtr->flags = 0; @@ -433,22 +433,22 @@ DestroyMenuButton( if (mbPtr->image != NULL) { Tk_FreeImage(mbPtr->image); } - if (mbPtr->normalTextGC) { + if (mbPtr->normalTextGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } - if (mbPtr->activeTextGC) { + if (mbPtr->activeTextGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } - if (mbPtr->disabledGC) { + if (mbPtr->disabledGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } - if (mbPtr->stippleGC) { + if (mbPtr->stippleGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->stippleGC); } - if (mbPtr->gray) { + if (mbPtr->gray != None) { Tk_FreeBitmap(mbPtr->display, mbPtr->gray); } - if (mbPtr->textLayout) { + if (mbPtr->textLayout != NULL) { Tk_FreeTextLayout(mbPtr->textLayout); } Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable, mbPtr->tkwin); @@ -578,7 +578,7 @@ ConfigureMenuButton( * Recompute the geometry for the button. */ - if (mbPtr->bitmap || mbPtr->image) { + if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) { if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString, &mbPtr->width) != TCL_OK) { widthError: @@ -683,7 +683,7 @@ TkMenuButtonWorldChanged( gcValues.graphics_exposures = False; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->normalTextGC) { + if (mbPtr->normalTextGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC); } mbPtr->normalTextGC = gc; @@ -692,7 +692,7 @@ TkMenuButtonWorldChanged( gcValues.background = Tk_3DBorderColor(mbPtr->activeBorder)->pixel; mask = GCForeground | GCBackground | GCFont; gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->activeTextGC) { + if (mbPtr->activeTextGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC); } mbPtr->activeTextGC = gc; @@ -703,13 +703,13 @@ TkMenuButtonWorldChanged( * Create the GC that can be used for stippling */ - if (!mbPtr->stippleGC) { + if (mbPtr->stippleGC == None) { gcValues.foreground = gcValues.background; mask = GCForeground; - if (!mbPtr->gray) { + if (mbPtr->gray == None) { mbPtr->gray = Tk_GetBitmap(NULL, mbPtr->tkwin, "gray50"); } - if (mbPtr->gray) { + if (mbPtr->gray != None) { gcValues.fill_style = FillStippled; gcValues.stipple = mbPtr->gray; mask |= GCFillStyle | GCStipple; @@ -723,13 +723,13 @@ TkMenuButtonWorldChanged( */ mask = GCForeground | GCBackground | GCFont; - if (mbPtr->disabledFg) { + if (mbPtr->disabledFg != NULL) { gcValues.foreground = mbPtr->disabledFg->pixel; } else { gcValues.foreground = gcValues.background; } gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues); - if (mbPtr->disabledGC) { + if (mbPtr->disabledGC != None) { Tk_FreeGC(mbPtr->display, mbPtr->disabledGC); } mbPtr->disabledGC = gc; diff --git a/generic/tkMessage.c b/generic/tkMessage.c index 9cfa593..40535b3 100644 --- a/generic/tkMessage.c +++ b/generic/tkMessage.c @@ -254,11 +254,11 @@ Tk_MessageObjCmd( (ClientData) msgPtr, MessageCmdDeletedProc); msgPtr->optionTable = optionTable; msgPtr->relief = TK_RELIEF_FLAT; - msgPtr->textGC = 0; + msgPtr->textGC = NULL; msgPtr->anchor = TK_ANCHOR_CENTER; msgPtr->aspect = 150; msgPtr->justify = TK_JUSTIFY_LEFT; - msgPtr->cursor = 0; + msgPtr->cursor = NULL; Tk_SetClass(msgPtr->tkwin, "Message"); Tk_SetClassProcs(msgPtr->tkwin, &messageClass, (ClientData) msgPtr); @@ -396,13 +396,13 @@ DestroyMessage( * Tk_FreeConfigOptions handle all the standard option-related stuff. */ - if (msgPtr->textGC) { + if (msgPtr->textGC != None) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } - if (msgPtr->textLayout) { + if (msgPtr->textLayout != NULL) { Tk_FreeTextLayout(msgPtr->textLayout); } - if (msgPtr->textVarName) { + if (msgPtr->textVarName != NULL) { Tcl_UntraceVar(msgPtr->interp, msgPtr->textVarName, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, MessageTextVarProc, (ClientData) msgPtr); @@ -469,7 +469,7 @@ ConfigureMessage( CONST char *value; value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY); - if (!value) { + if (value == NULL) { Tcl_SetVar(interp, msgPtr->textVarName, msgPtr->string, TCL_GLOBAL_ONLY); } else { @@ -523,20 +523,20 @@ MessageWorldChanged( ClientData instanceData) /* Information about widget. */ { XGCValues gcValues; - GC gc = 0; + GC gc = NULL; Tk_FontMetrics fm; Message *msgPtr; msgPtr = (Message *) instanceData; - if (msgPtr->border) { + if (msgPtr->border != NULL) { Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border); } gcValues.font = Tk_FontId(msgPtr->tkfont); gcValues.foreground = msgPtr->fgColorPtr->pixel; gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues); - if (msgPtr->textGC) { + if (msgPtr->textGC != None) { Tk_FreeGC(msgPtr->display, msgPtr->textGC); } msgPtr->textGC = gc; diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index 955b3e0..cf5612b 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -431,16 +431,16 @@ DoConfig( Pixmap newBmp, oldBmp; if (nullValue) { - newBmp = 0; + newBmp = None; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBmp = Tk_GetBitmap(interp, tkwin, uid); - if (!newBmp) { + if (newBmp == None) { return TCL_ERROR; } } oldBmp = *((Pixmap *) ptr); - if (oldBmp) { + if (oldBmp != None) { Tk_FreeBitmap(Tk_Display(tkwin), oldBmp); } *((Pixmap *) ptr) = newBmp; @@ -454,12 +454,12 @@ DoConfig( } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newBorder = Tk_Get3DBorder(interp, tkwin, uid); - if (!newBorder) { + if (newBorder == NULL) { return TCL_ERROR; } } oldBorder = *((Tk_3DBorder *) ptr); - if (oldBorder) { + if (oldBorder != NULL) { Tk_Free3DBorder(oldBorder); } *((Tk_3DBorder *) ptr) = newBorder; @@ -480,12 +480,12 @@ DoConfig( } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); - if (!newCursor) { + if (newCursor == None) { return TCL_ERROR; } } oldCursor = *((Tk_Cursor *) ptr); - if (oldCursor) { + if (oldCursor != None) { Tk_FreeCursor(Tk_Display(tkwin), oldCursor); } *((Tk_Cursor *) ptr) = newCursor; @@ -794,7 +794,7 @@ FormatConfigValue( case TK_CONFIG_UID: { Tk_Uid uid = *((Tk_Uid *) ptr); - if (uid) { + if (uid != NULL) { result = uid; } break; @@ -802,7 +802,7 @@ FormatConfigValue( case TK_CONFIG_COLOR: { XColor *colorPtr = *((XColor **) ptr); - if (colorPtr) { + if (colorPtr != NULL) { result = Tk_NameOfColor(colorPtr); } break; @@ -810,7 +810,7 @@ FormatConfigValue( case TK_CONFIG_FONT: { Tk_Font tkfont = *((Tk_Font *) ptr); - if (tkfont) { + if (tkfont != NULL) { result = Tk_NameOfFont(tkfont); } break; @@ -818,7 +818,7 @@ FormatConfigValue( case TK_CONFIG_BITMAP: { Pixmap pixmap = *((Pixmap *) ptr); - if (pixmap) { + if (pixmap != None) { result = Tk_NameOfBitmap(Tk_Display(tkwin), pixmap); } break; @@ -826,7 +826,7 @@ FormatConfigValue( case TK_CONFIG_BORDER: { Tk_3DBorder border = *((Tk_3DBorder *) ptr); - if (border) { + if (border != NULL) { result = Tk_NameOf3DBorder(border); } break; @@ -838,7 +838,7 @@ FormatConfigValue( case TK_CONFIG_ACTIVE_CURSOR: { Tk_Cursor cursor = *((Tk_Cursor *) ptr); - if (cursor) { + if (cursor != None) { result = Tk_NameOfCursor(Tk_Display(tkwin), cursor); } break; @@ -995,7 +995,7 @@ Tk_FreeOptions( ptr = widgRec + specPtr->offset; switch (specPtr->type) { case TK_CONFIG_STRING: - if (*((char **) ptr)) { + if (*((char **) ptr) != NULL) { ckfree(*((char **) ptr)); *((char **) ptr) = NULL; } @@ -1011,22 +1011,22 @@ Tk_FreeOptions( *((Tk_Font *) ptr) = NULL; break; case TK_CONFIG_BITMAP: - if (*((Pixmap *) ptr)) { + if (*((Pixmap *) ptr) != None) { Tk_FreeBitmap(display, *((Pixmap *) ptr)); - *((Pixmap *) ptr) = 0; + *((Pixmap *) ptr) = None; } break; case TK_CONFIG_BORDER: - if (*((Tk_3DBorder *) ptr)) { + if (*((Tk_3DBorder *) ptr) != NULL) { Tk_Free3DBorder(*((Tk_3DBorder *) ptr)); *((Tk_3DBorder *) ptr) = NULL; } break; case TK_CONFIG_CURSOR: case TK_CONFIG_ACTIVE_CURSOR: - if (*((Tk_Cursor *) ptr)) { + if (*((Tk_Cursor *) ptr) != None) { Tk_FreeCursor(display, *((Tk_Cursor *) ptr)); - *((Tk_Cursor *) ptr) = 0; + *((Tk_Cursor *) ptr) = NULL; } } } diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c index f37892c..f232889 100644 --- a/generic/tkPanedWindow.c +++ b/generic/tkPanedWindow.c @@ -448,9 +448,9 @@ Tk_PanedWindowObjCmd( pwPtr->optionTable = pwOpts->pwOptions; pwPtr->slaveOpts = pwOpts->slaveOpts; pwPtr->relief = TK_RELIEF_RAISED; - pwPtr->gc = 0; - pwPtr->cursor = 0; - pwPtr->sashCursor = 0; + pwPtr->gc = NULL; + pwPtr->cursor = NULL; + pwPtr->sashCursor = NULL; /* * Keep a hold of the associated tkwin until we destroy the widget, @@ -859,7 +859,7 @@ ConfigureSlaves( index = -1; haveLoc = 0; - if (options.after) { + if (options.after != None) { tkwin = options.after; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -868,7 +868,7 @@ ConfigureSlaves( break; } } - } else if (options.before) { + } else if (options.before != None) { tkwin = options.before; haveLoc = 1; for (i = 0; i < pwPtr->numSlaves; i++) { @@ -1299,7 +1299,7 @@ PanedWindowWorldChanged( gcValues.background = Tk_3DBorderColor(pwPtr->background)->pixel; newGC = Tk_GetGC(pwPtr->tkwin, GCBackground, &gcValues); - if (pwPtr->gc) { + if (pwPtr->gc != None) { Tk_FreeGC(pwPtr->display, pwPtr->gc); } pwPtr->gc = newGC; @@ -2018,10 +2018,10 @@ Unlink( for (i = 0; i < masterPtr->numSlaves; i++) { if (masterPtr->slaves[i]->before == slavePtr->tkwin) { - masterPtr->slaves[i]->before = 0; + masterPtr->slaves[i]->before = NULL; } if (masterPtr->slaves[i]->after == slavePtr->tkwin) { - masterPtr->slaves[i]->after = 0; + masterPtr->slaves[i]->after = NULL; } } diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 00e1328..dd4f7e6 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -179,13 +179,14 @@ GenerateEnterLeave( } else { TkWindow *targetPtr; - if (!lastWinPtr || !lastWinPtr->window) { + if ((lastWinPtr == NULL) + || (lastWinPtr->window == None)) { targetPtr = winPtr; } else { targetPtr = lastWinPtr; } - if (targetPtr && targetPtr->window) { + if (targetPtr && (targetPtr->window != None)) { XEvent event; /* @@ -539,7 +540,7 @@ static void UpdateCursor( TkWindow *winPtr) { - Cursor cursor = 0; + Cursor cursor = None; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -549,8 +550,8 @@ UpdateCursor( */ tsdPtr->cursorWinPtr = winPtr; - while (winPtr) { - if (winPtr->atts.cursor) { + while (winPtr != NULL) { + if (winPtr->atts.cursor != None) { cursor = winPtr->atts.cursor; break; } else if (winPtr->flags & TK_TOP_HIERARCHY) { diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index af94c6f..53ebe61 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -259,10 +259,10 @@ CreateRectOval( rectOvalPtr->fillColor = NULL; rectOvalPtr->activeFillColor = NULL; rectOvalPtr->disabledFillColor = NULL; - rectOvalPtr->fillStipple = 0; - rectOvalPtr->activeFillStipple = 0; - rectOvalPtr->disabledFillStipple = 0; - rectOvalPtr->fillGC = 0; + rectOvalPtr->fillStipple = None; + rectOvalPtr->activeFillStipple = None; + rectOvalPtr->disabledFillStipple = None; + rectOvalPtr->fillGC = NULL; /* * Process the arguments to fill in the item record. @@ -429,11 +429,11 @@ ConfigureRectOval( */ if (rectOvalPtr->outline.activeWidth > rectOvalPtr->outline.width || - rectOvalPtr->outline.activeDash.number || - rectOvalPtr->outline.activeColor || - rectOvalPtr->outline.activeStipple || - rectOvalPtr->activeFillColor || - rectOvalPtr->activeFillStipple) { + rectOvalPtr->outline.activeDash.number != 0 || + rectOvalPtr->outline.activeColor != NULL || + rectOvalPtr->outline.activeStipple != None || + rectOvalPtr->activeFillColor != NULL || + rectOvalPtr->activeFillStipple != None) { itemPtr->redraw_flags |= TK_ITEM_STATE_DEPENDANT; } else { itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT; @@ -467,13 +467,13 @@ ConfigureRectOval( mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(rectOvalPtr->outline)); if (mask && \ - rectOvalPtr->outline.width && \ - rectOvalPtr->outline.color) { + rectOvalPtr->outline.width != 0 && \ + rectOvalPtr->outline.color != NULL) { gcValues.cap_style = CapProjecting; mask |= GCCapStyle; newGC = Tk_GetGC(tkwin, mask, &gcValues); } else { - newGC = 0; + newGC = NULL; } if (rectOvalPtr->outline.gc) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); @@ -494,23 +494,23 @@ ConfigureRectOval( if (rectOvalPtr->activeFillColor!=NULL) { color = rectOvalPtr->activeFillColor; } - if (rectOvalPtr->activeFillStipple) { + if (rectOvalPtr->activeFillStipple!=None) { stipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (rectOvalPtr->disabledFillColor) { + if (rectOvalPtr->disabledFillColor!=NULL) { color = rectOvalPtr->disabledFillColor; } - if (rectOvalPtr->disabledFillStipple) { + if (rectOvalPtr->disabledFillStipple!=None) { stipple = rectOvalPtr->disabledFillStipple; } } if (!color) { - newGC = 0; + newGC = NULL; } else { gcValues.foreground = color->pixel; - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask = GCForeground|GCStipple|GCFillStyle; @@ -583,25 +583,25 @@ DeleteRectOval( RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr; Tk_DeleteOutline(display, &(rectOvalPtr->outline)); - if (rectOvalPtr->fillColor) { + if (rectOvalPtr->fillColor != NULL) { Tk_FreeColor(rectOvalPtr->fillColor); } - if (rectOvalPtr->activeFillColor) { + if (rectOvalPtr->activeFillColor != NULL) { Tk_FreeColor(rectOvalPtr->activeFillColor); } - if (rectOvalPtr->disabledFillColor) { + if (rectOvalPtr->disabledFillColor != NULL) { Tk_FreeColor(rectOvalPtr->disabledFillColor); } - if (rectOvalPtr->fillStipple) { + if (rectOvalPtr->fillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->fillStipple); } - if (rectOvalPtr->activeFillStipple) { + if (rectOvalPtr->activeFillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->activeFillStipple); } - if (rectOvalPtr->disabledFillStipple) { + if (rectOvalPtr->disabledFillStipple != None) { Tk_FreeBitmap(display, rectOvalPtr->disabledFillStipple); } - if (rectOvalPtr->fillGC) { + if (rectOvalPtr->fillGC != None) { Tk_FreeGC(display, rectOvalPtr->fillGC); } } @@ -670,7 +670,7 @@ ComputeRectOvalBbox( rectOvalPtr->bbox[0] = tmpX; } - if (!rectOvalPtr->outline.gc) { + if (rectOvalPtr->outline.gc == None) { /* * The Win32 switch was added for 8.3 to solve a problem with ovals * leaving traces on bottom and right of 1 pixel. This may not be the @@ -783,17 +783,17 @@ DisplayRectOval( } fillStipple = rectOvalPtr->fillStipple; if (((TkCanvas *)canvas)->currentItemPtr == (Tk_Item *)rectOvalPtr) { - if (rectOvalPtr->activeFillStipple) { + if (rectOvalPtr->activeFillStipple != None) { fillStipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { - if (rectOvalPtr->disabledFillStipple) { + if (rectOvalPtr->disabledFillStipple != None) { fillStipple = rectOvalPtr->disabledFillStipple; } } - if (rectOvalPtr->fillGC) { - if (fillStipple) { + if (rectOvalPtr->fillGC != None) { + if (fillStipple != None) { Tk_TSOffset *tsoffset; int w = 0, h = 0; @@ -831,12 +831,12 @@ DisplayRectOval( x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), 0, 360*64); } - if (fillStipple) { + if (fillStipple != None) { XSetTSOrigin(display, rectOvalPtr->fillGC, 0, 0); } } - if (rectOvalPtr->outline.gc) { + if (rectOvalPtr->outline.gc != None) { Tk_ChangeOutlineGC(canvas, itemPtr, &(rectOvalPtr->outline)); if (rectOvalPtr->header.typePtr == &tkRectangleType) { XDrawRectangle(display, drawable, rectOvalPtr->outline.gc, @@ -907,7 +907,7 @@ RectToPoint( y1 = rectPtr->bbox[1]; x2 = rectPtr->bbox[2]; y2 = rectPtr->bbox[3]; - if (rectPtr->outline.gc) { + if (rectPtr->outline.gc != None) { inc = width/2.0; x1 -= inc; y1 -= inc; @@ -923,7 +923,7 @@ RectToPoint( if ((pointPtr[0] >= x1) && (pointPtr[0] < x2) && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) { - if (rectPtr->fillGC || !rectPtr->outline.gc) { + if ((rectPtr->fillGC != None) || (rectPtr->outline.gc == None)) { return 0.0; } xDiff = pointPtr[0] - x1; @@ -1019,8 +1019,8 @@ OvalToPoint( } - filled = ovalPtr->fillGC != 0; - if (!ovalPtr->outline.gc) { + filled = ovalPtr->fillGC != None; + if (ovalPtr->outline.gc == None) { width = 0.0; filled = 1; } @@ -1075,7 +1075,7 @@ RectToArea( } halfWidth = width/2.0; - if (!rectPtr->outline.gc) { + if (rectPtr->outline.gc == None) { halfWidth = 0.0; } @@ -1085,7 +1085,7 @@ RectToArea( || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) { return -1; } - if (!rectPtr->fillGC && rectPtr->outline.gc + if ((rectPtr->fillGC == None) && (rectPtr->outline.gc != None) && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth)) && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth)) && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth)) @@ -1154,7 +1154,7 @@ OvalToArea( */ halfWidth = width/2.0; - if (!ovalPtr->outline.gc) { + if (ovalPtr->outline.gc == None) { halfWidth = 0.0; } oval[0] = ovalPtr->bbox[0] - halfWidth; @@ -1171,8 +1171,8 @@ OvalToArea( * return "outside". */ - if ((result == 0) && ovalPtr->outline.gc - && !ovalPtr->fillGC) { + if ((result == 0) && (ovalPtr->outline.gc != None) + && (ovalPtr->fillGC == None)) { double centerX, centerY, height; double xDelta1, yDelta1, xDelta2, yDelta2; @@ -1335,20 +1335,20 @@ RectOvalToPostscript( if (rectOvalPtr->outline.activeColor!=NULL) { color = rectOvalPtr->outline.activeColor; } - if (rectOvalPtr->activeFillColor) { + if (rectOvalPtr->activeFillColor!=NULL) { fillColor = rectOvalPtr->activeFillColor; } - if (rectOvalPtr->activeFillStipple) { + if (rectOvalPtr->activeFillStipple!=None) { fillStipple = rectOvalPtr->activeFillStipple; } } else if (state == TK_STATE_DISABLED) { if (rectOvalPtr->outline.disabledColor!=NULL) { color = rectOvalPtr->outline.disabledColor; } - if (rectOvalPtr->disabledFillColor) { + if (rectOvalPtr->disabledFillColor!=NULL) { fillColor = rectOvalPtr->disabledFillColor; } - if (rectOvalPtr->disabledFillStipple) { + if (rectOvalPtr->disabledFillStipple!=None) { fillStipple = rectOvalPtr->disabledFillStipple; } } @@ -1357,12 +1357,12 @@ RectOvalToPostscript( * First draw the filled area of the rectangle. */ - if (fillColor) { + if (fillColor != NULL) { Tcl_AppendResult(interp, pathCmd, NULL); if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) { return TCL_ERROR; } - if (fillStipple) { + if (fillStipple != None) { Tcl_AppendResult(interp, "clip ", NULL); if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) { return TCL_ERROR; @@ -1379,7 +1379,7 @@ RectOvalToPostscript( * Now draw the outline, if there is one. */ - if (color) { + if (color != NULL) { Tcl_AppendResult(interp, pathCmd, "0 setlinejoin 2 setlinecap\n", NULL); if (Tk_CanvasPsOutline(canvas, itemPtr, diff --git a/generic/tkScale.c b/generic/tkScale.c index 32cb1b2..a804c36 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -264,11 +264,11 @@ Tk_ScaleObjCmd( scalePtr->activeBorder = NULL; scalePtr->sliderRelief = TK_RELIEF_RAISED; scalePtr->troughColorPtr = NULL; - scalePtr->troughGC = 0; - scalePtr->copyGC = 0; + scalePtr->troughGC = NULL; + scalePtr->copyGC = NULL; scalePtr->tkfont = NULL; scalePtr->textColorPtr = NULL; - scalePtr->textGC = 0; + scalePtr->textGC = NULL; scalePtr->relief = TK_RELIEF_FLAT; scalePtr->highlightWidth = 0; scalePtr->highlightBorder = NULL; @@ -285,7 +285,7 @@ Tk_ScaleObjCmd( scalePtr->vertTroughX = 0; scalePtr->vertLabelX = 0; scalePtr->fontHeight = 0; - scalePtr->cursor = 0; + scalePtr->cursor = NULL; scalePtr->takeFocusPtr = NULL; scalePtr->flags = NEVER_SET; @@ -514,13 +514,13 @@ DestroyScale( TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, ScaleVarProc, (ClientData) scalePtr); } - if (scalePtr->troughGC) { + if (scalePtr->troughGC != None) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } - if (scalePtr->copyGC) { + if (scalePtr->copyGC != None) { Tk_FreeGC(scalePtr->display, scalePtr->copyGC); } - if (scalePtr->textGC) { + if (scalePtr->textGC != None) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } Tk_FreeConfigOptions((char *) scalePtr, scalePtr->optionTable, @@ -727,7 +727,7 @@ ScaleWorldChanged( gcValues.foreground = scalePtr->troughColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues); - if (scalePtr->troughGC) { + if (scalePtr->troughGC != None) { Tk_FreeGC(scalePtr->display, scalePtr->troughGC); } scalePtr->troughGC = gc; @@ -735,12 +735,12 @@ ScaleWorldChanged( gcValues.font = Tk_FontId(scalePtr->tkfont); gcValues.foreground = scalePtr->textColorPtr->pixel; gc = Tk_GetGC(scalePtr->tkwin, GCForeground | GCFont, &gcValues); - if (scalePtr->textGC) { + if (scalePtr->textGC != None) { Tk_FreeGC(scalePtr->display, scalePtr->textGC); } scalePtr->textGC = gc; - if (!scalePtr->copyGC) { + if (scalePtr->copyGC == None) { gcValues.graphics_exposures = False; scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures, &gcValues); diff --git a/generic/tkScale.h b/generic/tkScale.h index a19695f..a2c5f2b 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[16]; /* Sprintf conversion specifier computed from + char format[10]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c index 67fdd2b..7e39056 100644 --- a/generic/tkScrollbar.c +++ b/generic/tkScrollbar.c @@ -188,7 +188,7 @@ Tk_ScrollbarCmd( scrollPtr->lastUnit = 0; scrollPtr->firstFraction = 0.0; scrollPtr->lastFraction = 0.0; - scrollPtr->cursor = 0; + scrollPtr->cursor = NULL; scrollPtr->takeFocus = NULL; scrollPtr->flags = 0; diff --git a/generic/tkSelect.c b/generic/tkSelect.c index 2f74172..7c96b94 100644 --- a/generic/tkSelect.c +++ b/generic/tkSelect.c @@ -130,7 +130,7 @@ Tk_CreateSelHandler( register TkSelHandler *selPtr; TkWindow *winPtr = (TkWindow *) tkwin; - if (!winPtr->dispPtr->multipleAtom) { + if (winPtr->dispPtr->multipleAtom == None) { TkSelInit(tkwin); } @@ -362,7 +362,7 @@ Tk_OwnSelection( ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ - if (!dispPtr->multipleAtom) { + if (dispPtr->multipleAtom == None) { TkSelInit(tkwin); } Tk_MakeWindowExist(tkwin); @@ -471,7 +471,7 @@ Tk_ClearSelection( ClientData clearData = NULL;/* Initialization needed only to prevent * compiler warning. */ - if (!dispPtr->multipleAtom) { + if (dispPtr->multipleAtom == None) { TkSelInit(tkwin); } @@ -494,7 +494,7 @@ Tk_ClearSelection( clearData = infoPtr->clearData; ckfree((char *) infoPtr); } - XSetSelectionOwner(winPtr->display, selection, 0, CurrentTime); + XSetSelectionOwner(winPtr->display, selection, None, CurrentTime); if (clearProc != NULL) { (*clearProc)(clearData); @@ -561,7 +561,7 @@ Tk_GetSelection( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (!dispPtr->multipleAtom) { + if (dispPtr->multipleAtom == None) { TkSelInit(tkwin); } diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 305d756..355a447 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -166,7 +166,7 @@ SquareObjCmd( squarePtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(squarePtr->tkwin), SquareWidgetObjCmd, (ClientData) squarePtr, SquareDeletedProc); - squarePtr->gc = 0; + squarePtr->gc = NULL; squarePtr->optionTable = optionTable; if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin) @@ -332,7 +332,7 @@ SquareConfigure( Tk_SetWindowBackground(squarePtr->tkwin, Tk_3DBorderColor(bgBorder)->pixel); Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); - if (!squarePtr->gc && doubleBuffer) { + if ((squarePtr->gc == None) && (doubleBuffer)) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -394,10 +394,10 @@ SquareObjEventProc( squarePtr->updatePending = 1; } } else if (eventPtr->type == DestroyNotify) { - if (squarePtr->tkwin) { + if (squarePtr->tkwin != NULL) { Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, squarePtr->tkwin); - if (squarePtr->gc) { + if (squarePtr->gc != None) { Tk_FreeGC(squarePtr->display, squarePtr->gc); } squarePtr->tkwin = NULL; @@ -472,7 +472,7 @@ SquareDisplay( { Square *squarePtr = (Square *) clientData; Tk_Window tkwin = squarePtr->tkwin; - Pixmap pm = 0; + Pixmap pm = None; Drawable d; int borderWidth, size, relief; Tk_3DBorder bgBorder, fgBorder; diff --git a/generic/tkTest.c b/generic/tkTest.c index 8f54781..d06769d 100644 --- a/generic/tkTest.c +++ b/generic/tkTest.c @@ -1047,7 +1047,7 @@ TestobjconfigObjCmd( recordPtr->index = 0; recordPtr->colorPtr = NULL; recordPtr->tkfont = NULL; - recordPtr->bitmap = 0; + recordPtr->bitmap = None; recordPtr->border = NULL; recordPtr->relief = TK_RELIEF_FLAT; recordPtr->cursor = NULL; @@ -1985,7 +1985,7 @@ TestpropCmd( w, propName, 0, 100000, False, AnyPropertyType, &actualType, &actualFormat, &length, &bytesAfter, &property); - if ((result == Success) && actualType) { + if ((result == Success) && (actualType != None)) { if ((actualFormat == 8) && (actualType == XA_STRING)) { for (p = property; ((unsigned long)(p-property)) < length; p++) { if (*p == 0) { diff --git a/generic/tkText.c b/generic/tkText.c index 425687f..004bcaf 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -568,7 +568,7 @@ CreateWidget( textPtr->state = TK_TEXT_STATE_NORMAL; textPtr->relief = TK_RELIEF_FLAT; - textPtr->cursor = 0; + textPtr->cursor = NULL; textPtr->charWidth = 1; textPtr->charHeight = 10; textPtr->wrapMode = TEXT_WRAPMODE_CHAR; @@ -2186,28 +2186,28 @@ ConfigureText( textPtr->selTagPtr->fgColor = textPtr->selFgColorPtr; textPtr->selTagPtr->affectsDisplay = 0; textPtr->selTagPtr->affectsDisplayGeometry = 0; - if (textPtr->selTagPtr->elideString - || textPtr->selTagPtr->tkfont - || textPtr->selTagPtr->justifyString - || textPtr->selTagPtr->lMargin1String - || textPtr->selTagPtr->lMargin2String - || textPtr->selTagPtr->offsetString - || textPtr->selTagPtr->rMarginString - || textPtr->selTagPtr->spacing1String - || textPtr->selTagPtr->spacing2String - || textPtr->selTagPtr->spacing3String - || textPtr->selTagPtr->tabStringPtr + if ((textPtr->selTagPtr->elideString != NULL) + || (textPtr->selTagPtr->tkfont != None) + || (textPtr->selTagPtr->justifyString != NULL) + || (textPtr->selTagPtr->lMargin1String != NULL) + || (textPtr->selTagPtr->lMargin2String != NULL) + || (textPtr->selTagPtr->offsetString != NULL) + || (textPtr->selTagPtr->rMarginString != NULL) + || (textPtr->selTagPtr->spacing1String != NULL) + || (textPtr->selTagPtr->spacing2String != NULL) + || (textPtr->selTagPtr->spacing3String != NULL) + || (textPtr->selTagPtr->tabStringPtr != NULL) || (textPtr->selTagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { textPtr->selTagPtr->affectsDisplay = 1; textPtr->selTagPtr->affectsDisplayGeometry = 1; } - if (textPtr->selTagPtr->border - || textPtr->selTagPtr->reliefString - || textPtr->selTagPtr->bgStipple - || textPtr->selTagPtr->fgColor - || textPtr->selTagPtr->fgStipple - || textPtr->selTagPtr->overstrikeString - || textPtr->selTagPtr->underlineString) { + if ((textPtr->selTagPtr->border != NULL) + || (textPtr->selTagPtr->reliefString != NULL) + || (textPtr->selTagPtr->bgStipple != None) + || (textPtr->selTagPtr->fgColor != NULL) + || (textPtr->selTagPtr->fgStipple != None) + || (textPtr->selTagPtr->overstrikeString != NULL) + || (textPtr->selTagPtr->underlineString != NULL)) { textPtr->selTagPtr->affectsDisplay = 1; } TkTextRedrawTag(NULL, textPtr, NULL, NULL, textPtr->selTagPtr, 1); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cc304de..904fa1a 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -632,7 +632,7 @@ TkTextCreateDInfo( dInfoPtr = (TextDInfo *) ckalloc(sizeof(TextDInfo)); Tcl_InitHashTable(&dInfoPtr->styleTable, sizeof(StyleValues)/sizeof(int)); dInfoPtr->dLinePtr = NULL; - dInfoPtr->copyGC = 0; + dInfoPtr->copyGC = NULL; gcValues.graphics_exposures = True; dInfoPtr->scrollGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); @@ -696,19 +696,19 @@ TkTextFreeDInfo( FreeDLines(textPtr, dInfoPtr->dLinePtr, NULL, DLINE_UNLINK); Tcl_DeleteHashTable(&dInfoPtr->styleTable); - if (dInfoPtr->copyGC) { + if (dInfoPtr->copyGC != None) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } Tk_FreeGC(textPtr->display, dInfoPtr->scrollGC); if (dInfoPtr->flags & REDRAW_PENDING) { Tcl_CancelIdleCall(DisplayText, (ClientData) textPtr); } - if (dInfoPtr->lineUpdateTimer) { + if (dInfoPtr->lineUpdateTimer != NULL) { Tcl_DeleteTimerHandler(dInfoPtr->lineUpdateTimer); textPtr->refCount--; dInfoPtr->lineUpdateTimer = NULL; } - if (dInfoPtr->scrollbarTimer) { + if (dInfoPtr->scrollbarTimer != NULL) { Tcl_DeleteTimerHandler(dInfoPtr->scrollbarTimer); textPtr->refCount--; dInfoPtr->scrollbarTimer = NULL; @@ -827,70 +827,70 @@ GetStyle( styleValues.relief = tagPtr->relief; reliefPrio = tagPtr->priority; } - if ((tagPtr->bgStipple) + if ((tagPtr->bgStipple != None) && (tagPtr->priority > bgStipplePrio)) { styleValues.bgStipple = tagPtr->bgStipple; bgStipplePrio = tagPtr->priority; } - if ((tagPtr->fgColor) && (tagPtr->priority > fgPrio)) { + if ((tagPtr->fgColor != None) && (tagPtr->priority > fgPrio)) { styleValues.fgColor = tagPtr->fgColor; fgPrio = tagPtr->priority; } - if ((tagPtr->tkfont) && (tagPtr->priority > fontPrio)) { + if ((tagPtr->tkfont != None) && (tagPtr->priority > fontPrio)) { styleValues.tkfont = tagPtr->tkfont; fontPrio = tagPtr->priority; } - if ((tagPtr->fgStipple) + if ((tagPtr->fgStipple != None) && (tagPtr->priority > fgStipplePrio)) { styleValues.fgStipple = tagPtr->fgStipple; fgStipplePrio = tagPtr->priority; } - if ((tagPtr->justifyString) + if ((tagPtr->justifyString != NULL) && (tagPtr->priority > justifyPrio)) { styleValues.justify = tagPtr->justify; justifyPrio = tagPtr->priority; } - if ((tagPtr->lMargin1String) + if ((tagPtr->lMargin1String != NULL) && (tagPtr->priority > lMargin1Prio)) { styleValues.lMargin1 = tagPtr->lMargin1; lMargin1Prio = tagPtr->priority; } - if ((tagPtr->lMargin2String) + if ((tagPtr->lMargin2String != NULL) && (tagPtr->priority > lMargin2Prio)) { styleValues.lMargin2 = tagPtr->lMargin2; lMargin2Prio = tagPtr->priority; } - if ((tagPtr->offsetString) + if ((tagPtr->offsetString != NULL) && (tagPtr->priority > offsetPrio)) { styleValues.offset = tagPtr->offset; offsetPrio = tagPtr->priority; } - if ((tagPtr->overstrikeString) + if ((tagPtr->overstrikeString != NULL) && (tagPtr->priority > overstrikePrio)) { styleValues.overstrike = tagPtr->overstrike; overstrikePrio = tagPtr->priority; } - if ((tagPtr->rMarginString) + if ((tagPtr->rMarginString != NULL) && (tagPtr->priority > rMarginPrio)) { styleValues.rMargin = tagPtr->rMargin; rMarginPrio = tagPtr->priority; } - if ((tagPtr->spacing1String) + if ((tagPtr->spacing1String != NULL) && (tagPtr->priority > spacing1Prio)) { styleValues.spacing1 = tagPtr->spacing1; spacing1Prio = tagPtr->priority; } - if ((tagPtr->spacing2String) + if ((tagPtr->spacing2String != NULL) && (tagPtr->priority > spacing2Prio)) { styleValues.spacing2 = tagPtr->spacing2; spacing2Prio = tagPtr->priority; } - if ((tagPtr->spacing3String) + if ((tagPtr->spacing3String != NULL) && (tagPtr->priority > spacing3Prio)) { styleValues.spacing3 = tagPtr->spacing3; spacing3Prio = tagPtr->priority; } - if ((tagPtr->tabStringPtr) + if ((tagPtr->tabStringPtr != NULL) && (tagPtr->priority > tabPrio)) { styleValues.tabArrayPtr = tagPtr->tabArrayPtr; tabPrio = tagPtr->priority; @@ -900,12 +900,12 @@ GetStyle( styleValues.tabStyle = tagPtr->tabStyle; tabStylePrio = tagPtr->priority; } - if ((tagPtr->underlineString) + if ((tagPtr->underlineString != NULL) && (tagPtr->priority > underlinePrio)) { styleValues.underline = tagPtr->underline; underlinePrio = tagPtr->priority; } - if ((tagPtr->elideString) + if ((tagPtr->elideString != NULL) && (tagPtr->priority > elidePrio)) { styleValues.elide = tagPtr->elide; elidePrio = tagPtr->priority; @@ -916,7 +916,7 @@ GetStyle( wrapPrio = tagPtr->priority; } } - if (tagPtrs) { + if (tagPtrs != NULL) { ckfree((char *) tagPtrs); } @@ -941,20 +941,20 @@ GetStyle( if (styleValues.border != NULL) { gcValues.foreground = Tk_3DBorderColor(styleValues.border)->pixel; mask = GCForeground; - if (styleValues.bgStipple) { + if (styleValues.bgStipple != None) { gcValues.stipple = styleValues.bgStipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; } stylePtr->bgGC = Tk_GetGC(textPtr->tkwin, mask, &gcValues); } else { - stylePtr->bgGC = 0; + stylePtr->bgGC = NULL; } mask = GCFont; gcValues.font = Tk_FontId(styleValues.tkfont); mask |= GCForeground; gcValues.foreground = styleValues.fgColor->pixel; - if (styleValues.fgStipple) { + if (styleValues.fgStipple != None) { gcValues.stipple = styleValues.fgStipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -994,10 +994,10 @@ FreeStyle( { stylePtr->refCount--; if (stylePtr->refCount == 0) { - if (stylePtr->bgGC) { + if (stylePtr->bgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->bgGC); } - if (stylePtr->fgGC) { + if (stylePtr->fgGC != None) { Tk_FreeGC(textPtr->display, stylePtr->fgGC); } Tcl_DeleteHashEntry(stylePtr->hPtr); @@ -2578,7 +2578,7 @@ DisplayLineBackground( if ((chunkPtr->nextPtr == NULL) && (rightX < maxX)) { rightX = maxX; } - if (chunkPtr->stylePtr->bgGC) { + if (chunkPtr->stylePtr->bgGC != None) { /* * Not visible - bail out now. */ @@ -4335,7 +4335,7 @@ DisplayText( dlPtr->spaceAbove, dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, NULL, - 0, dlPtr->y + dlPtr->spaceAbove); + (Drawable) None, dlPtr->y + dlPtr->spaceAbove); } } @@ -4970,7 +4970,7 @@ TkTextRelayoutWindow( gcValues.graphics_exposures = False; newGC = Tk_GetGC(textPtr->tkwin, GCGraphicsExposures, &gcValues); - if (dInfoPtr->copyGC) { + if (dInfoPtr->copyGC != None) { Tk_FreeGC(textPtr->display, dInfoPtr->copyGC); } dInfoPtr->copyGC = newGC; @@ -7708,7 +7708,7 @@ CharDisplayProc( */ if (!sValuePtr->elide && (numBytes > offsetBytes) - && stylePtr->fgGC) { + && (stylePtr->fgGC != None)) { #if TK_DRAW_IN_CONTEXT int start = ciPtr->baseOffset + offsetBytes; int len = ciPtr->numBytes - offsetBytes; diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index 5bf1899..a310dd7 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -489,29 +489,29 @@ TkTextTagCmd( tagPtr->affectsDisplay = 0; tagPtr->affectsDisplayGeometry = 0; - if (tagPtr->elideString - || tagPtr->tkfont - || tagPtr->justifyString - || tagPtr->lMargin1String - || tagPtr->lMargin2String - || tagPtr->offsetString - || tagPtr->rMarginString - || tagPtr->spacing1String - || tagPtr->spacing2String - || tagPtr->spacing3String - || tagPtr->tabStringPtr + if ((tagPtr->elideString != NULL) + || (tagPtr->tkfont != None) + || (tagPtr->justifyString != NULL) + || (tagPtr->lMargin1String != NULL) + || (tagPtr->lMargin2String != NULL) + || (tagPtr->offsetString != NULL) + || (tagPtr->rMarginString != NULL) + || (tagPtr->spacing1String != NULL) + || (tagPtr->spacing2String != NULL) + || (tagPtr->spacing3String != NULL) + || (tagPtr->tabStringPtr != NULL) || (tagPtr->tabStyle != TK_TEXT_TABSTYLE_NONE) || (tagPtr->wrapMode != TEXT_WRAPMODE_NULL)) { tagPtr->affectsDisplay = 1; tagPtr->affectsDisplayGeometry = 1; } - if (tagPtr->border - || tagPtr->reliefString - || tagPtr->bgStipple - || tagPtr->fgColor - || tagPtr->fgStipple - || tagPtr->overstrikeString - || tagPtr->underlineString) { + if ((tagPtr->border != NULL) + || (tagPtr->reliefString != NULL) + || (tagPtr->bgStipple != None) + || (tagPtr->fgColor != NULL) + || (tagPtr->fgStipple != None) + || (tagPtr->overstrikeString != NULL) + || (tagPtr->underlineString != NULL)) { tagPtr->affectsDisplay = 1; } if (!newTag) { @@ -987,10 +987,10 @@ TkTextCreateTag( tagPtr->borderWidthPtr = NULL; tagPtr->reliefString = NULL; tagPtr->relief = TK_RELIEF_FLAT; - tagPtr->bgStipple = 0; + tagPtr->bgStipple = None; tagPtr->fgColor = NULL; tagPtr->tkfont = NULL; - tagPtr->fgStipple = 0; + tagPtr->fgStipple = None; tagPtr->justifyString = NULL; tagPtr->justify = TK_JUSTIFY_LEFT; tagPtr->lMargin1String = NULL; @@ -1556,7 +1556,7 @@ TkTextPickCurrent( textPtr->pickEvent.xcrossing.display = eventPtr->xmotion.display; textPtr->pickEvent.xcrossing.window = eventPtr->xmotion.window; textPtr->pickEvent.xcrossing.root = eventPtr->xmotion.root; - textPtr->pickEvent.xcrossing.subwindow = 0; + textPtr->pickEvent.xcrossing.subwindow = None; textPtr->pickEvent.xcrossing.time = eventPtr->xmotion.time; textPtr->pickEvent.xcrossing.x = eventPtr->xmotion.x; textPtr->pickEvent.xcrossing.y = eventPtr->xmotion.y; diff --git a/generic/tkVisual.c b/generic/tkVisual.c index fe3e447..ec8be11 100644 --- a/generic/tkVisual.c +++ b/generic/tkVisual.c @@ -398,18 +398,18 @@ Tk_GetColormap( */ other = Tk_NameToWindow(interp, string, tkwin); - if (!other) { - return 0; + if (other == NULL) { + return None; } if (Tk_Screen(other) != Tk_Screen(tkwin)) { Tcl_AppendResult(interp, "can't use colormap for ", string, ": not on same screen", NULL); - return 0; + return None; } if (Tk_Visual(other) != Tk_Visual(tkwin)) { Tcl_AppendResult(interp, "can't use colormap for ", string, ": incompatible visuals", NULL); - return 0; + return None; } colormap = Tk_Colormap(other); diff --git a/generic/tkWindow.c b/generic/tkWindow.c index c122128..1257e22 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -73,7 +73,7 @@ static const XWindowChanges defChanges = { EnterWindowMask|LeaveWindowMask|PointerMotionMask|ExposureMask| \ VisibilityChangeMask|PropertyChangeMask|ColormapChangeMask static const XSetWindowAttributes defAtts= { - 0, /* background_pixmap */ + None, /* background_pixmap */ 0, /* background_pixel */ CopyFromParent, /* border_pixmap */ 0, /* border_pixel */ @@ -87,7 +87,7 @@ static const XSetWindowAttributes defAtts= { 0, /* do_not_propagate_mask */ False, /* override_redirect */ CopyFromParent, /* colormap */ - 0 /* cursor */ + None /* cursor */ }; /* @@ -504,9 +504,9 @@ GetScreen( dispPtr->lastEventTime = CurrentTime; dispPtr->bindInfoStale = 1; - dispPtr->cursorFont = 0; - dispPtr->warpWindow = 0; - dispPtr->multipleAtom = 0; + dispPtr->cursorFont = None; + dispPtr->warpWindow = None; + dispPtr->multipleAtom = None; /* * By default we do want to collapse motion events in @@ -667,7 +667,7 @@ TkAllocWindow( winPtr->visual = DefaultVisual(dispPtr->display, screenNum); winPtr->depth = DefaultDepth(dispPtr->display, screenNum); } - winPtr->window = 0; + winPtr->window = None; winPtr->childList = NULL; winPtr->lastChildPtr = NULL; winPtr->parentPtr = NULL; @@ -1403,7 +1403,7 @@ Tk_DestroyWindow( winPtr->pathName != NULL && !(winPtr->flags & TK_ANONYMOUS_WINDOW)) { halfdeadPtr->flags |= HD_DESTROY_EVENT; - if (!winPtr->window) { + if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } event.type = DestroyNotify; @@ -1449,7 +1449,7 @@ Tk_DestroyWindow( } else if (winPtr->flags & TK_WM_COLORMAP_WINDOW) { TkWmRemoveFromColormapWindows(winPtr); } - if (winPtr->window) { + if (winPtr->window != None) { #if defined(MAC_OSX_TK) || defined(__WIN32__) XDestroyWindow(winPtr->display, winPtr->window); #else @@ -1469,7 +1469,7 @@ Tk_DestroyWindow( TkFreeWindowId(dispPtr, winPtr->window); Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->winTable, (char *) winPtr->window)); - winPtr->window = 0; + winPtr->window = None; } dispPtr->destroyCount--; UnlinkWindow(winPtr); @@ -1642,7 +1642,7 @@ Tk_MapWindow( if (winPtr->flags & TK_MAPPED) { return; } - if (!winPtr->window) { + if (winPtr->window == None) { Tk_MakeWindowExist(tkwin); } /* @@ -1704,21 +1704,21 @@ Tk_MakeWindowExist( Tk_ClassCreateProc *createProc; int isNew; - if (winPtr->window) { + if (winPtr->window != None) { return; } if ((winPtr->parentPtr == NULL) || (winPtr->flags & TK_TOP_HIERARCHY)) { parent = XRootWindow(winPtr->display, winPtr->screenNum); } else { - if (!winPtr->parentPtr->window) { + if (winPtr->parentPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr->parentPtr); } parent = winPtr->parentPtr->window; } createProc = Tk_GetClassProc(winPtr->classProcsPtr, createProc); - if (createProc != NULL && parent) { + if (createProc != NULL && parent != None) { winPtr->window = (*createProc)(tkwin, parent, winPtr->instanceData); } else { winPtr->window = TkpMakeWindow(winPtr, parent); @@ -1744,7 +1744,7 @@ Tk_MakeWindowExist( for (winPtr2 = winPtr->nextPtr; winPtr2 != NULL; winPtr2 = winPtr2->nextPtr) { - if (winPtr2->window + if ((winPtr2->window != None) && !(winPtr2->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))) { XWindowChanges changes; changes.sibling = winPtr2->window; @@ -1863,7 +1863,7 @@ Tk_ConfigureWindow( Tcl_Panic("Can't set sibling or stack mode from Tk_ConfigureWindow."); } - if (winPtr->window) { + if (winPtr->window != None) { XConfigureWindow(winPtr->display, winPtr->window, valueMask, valuePtr); TkDoConfigureNotify(winPtr); @@ -1882,7 +1882,7 @@ Tk_MoveWindow( winPtr->changes.x = x; winPtr->changes.y = y; - if (winPtr->window) { + if (winPtr->window != None) { XMoveWindow(winPtr->display, winPtr->window, x, y); TkDoConfigureNotify(winPtr); } else { @@ -1900,7 +1900,7 @@ Tk_ResizeWindow( winPtr->changes.width = (unsigned) width; winPtr->changes.height = (unsigned) height; - if (winPtr->window) { + if (winPtr->window != None) { XResizeWindow(winPtr->display, winPtr->window, (unsigned) width, (unsigned) height); TkDoConfigureNotify(winPtr); @@ -1922,7 +1922,7 @@ Tk_MoveResizeWindow( winPtr->changes.y = y; winPtr->changes.width = (unsigned) width; winPtr->changes.height = (unsigned) height; - if (winPtr->window) { + if (winPtr->window != None) { XMoveResizeWindow(winPtr->display, winPtr->window, x, y, (unsigned) width, (unsigned) height); TkDoConfigureNotify(winPtr); @@ -1940,7 +1940,7 @@ Tk_SetWindowBorderWidth( register TkWindow *winPtr = (TkWindow *) tkwin; winPtr->changes.border_width = width; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowBorderWidth(winPtr->display, winPtr->window, (unsigned) width); TkDoConfigureNotify(winPtr); @@ -2007,7 +2007,7 @@ Tk_ChangeWindowAttributes( winPtr->atts.cursor = attsPtr->cursor; } - if (winPtr->window) { + if (winPtr->window != None) { XChangeWindowAttributes(winPtr->display, winPtr->window, valueMask, attsPtr); } else { @@ -2025,7 +2025,7 @@ Tk_SetWindowBackground( winPtr->atts.background_pixel = pixel; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowBackground(winPtr->display, winPtr->window, pixel); } else { winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBackPixmap) @@ -2042,7 +2042,7 @@ Tk_SetWindowBackgroundPixmap( winPtr->atts.background_pixmap = pixmap; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowBackgroundPixmap(winPtr->display, winPtr->window, pixmap); } else { @@ -2060,7 +2060,7 @@ Tk_SetWindowBorder( winPtr->atts.border_pixel = pixel; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowBorder(winPtr->display, winPtr->window, pixel); } else { winPtr->dirtyAtts = (winPtr->dirtyAtts & (unsigned) ~CWBorderPixmap) @@ -2077,7 +2077,7 @@ Tk_SetWindowBorderPixmap( winPtr->atts.border_pixmap = pixmap; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowBorderPixmap(winPtr->display, winPtr->window, pixmap); } else { @@ -2099,7 +2099,7 @@ Tk_DefineCursor( winPtr->atts.cursor = (Cursor) cursor; #endif - if (winPtr->window) { + if (winPtr->window != None) { XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor); } else { winPtr->dirtyAtts = winPtr->dirtyAtts | CWCursor; @@ -2110,7 +2110,7 @@ void Tk_UndefineCursor( Tk_Window tkwin) /* Window to manipulate. */ { - Tk_DefineCursor(tkwin, 0); + Tk_DefineCursor(tkwin, NULL); } void @@ -2122,7 +2122,7 @@ Tk_SetWindowColormap( winPtr->atts.colormap = colormap; - if (winPtr->window) { + if (winPtr->window != None) { XSetWindowColormap(winPtr->display, winPtr->window, colormap); if (!(winPtr->flags & TK_WIN_MANAGED)) { TkWmAddToColormapWindows(winPtr); @@ -2162,7 +2162,7 @@ Tk_SetWindowVisual( { register TkWindow *winPtr = (TkWindow *) tkwin; - if (winPtr->window) { + if (winPtr->window != None) { /* Too late! */ return 0; } @@ -2222,7 +2222,7 @@ TkDoConfigureNotify( if (winPtr->changes.stack_mode == Above) { event.xconfigure.above = winPtr->changes.sibling; } else { - event.xconfigure.above = 0; + event.xconfigure.above = None; } event.xconfigure.override_redirect = winPtr->atts.override_redirect; Tk_HandleEvent(&event); @@ -2585,7 +2585,7 @@ Tk_RestackWindow( * will be handled properly when the window is finally created. */ - if (winPtr->window) { + if (winPtr->window != None) { XWindowChanges changes; unsigned int mask; @@ -2593,7 +2593,7 @@ Tk_RestackWindow( changes.stack_mode = Above; for (otherPtr = winPtr->nextPtr; otherPtr != NULL; otherPtr = otherPtr->nextPtr) { - if (otherPtr->window + if ((otherPtr->window != None) && !(otherPtr->flags & (TK_TOP_HIERARCHY|TK_REPARENTED))){ changes.sibling = otherPtr->window; changes.stack_mode = Below; diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 48aeb5c..ae43ae6 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -1151,7 +1151,7 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip) mask |= GCForeground; } gc = Tk_GetGC(entryPtr->core.tkwin, mask, &gcValues); - if (clip) { + if (clip != None) { TkSetRegion(Tk_Display(entryPtr->core.tkwin), gc, clip); } return gc; @@ -1256,7 +1256,7 @@ static void EntryDisplay(void *clientData, Drawable d) gc = EntryGetGC(entryPtr, es.insertColorObj, clipRegion); XFillRectangle(Tk_Display(tkwin), d, gc, cursorX-cursorWidth/2, cursorY, cursorWidth, cursorHeight); - XSetClipMask(Tk_Display(tkwin), gc, 0); + XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); } @@ -1267,7 +1267,7 @@ static void EntryDisplay(void *clientData, Drawable d) Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, entryPtr->entry.layoutX, entryPtr->entry.layoutY, leftIndex, rightIndex); - XSetClipMask(Tk_Display(tkwin), gc, 0); + XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); /* Overwrite the selected portion (if any) in the -selectforeground color: @@ -1278,7 +1278,7 @@ static void EntryDisplay(void *clientData, Drawable d) Tk_Display(tkwin), d, gc, entryPtr->entry.textLayout, entryPtr->entry.layoutX, entryPtr->entry.layoutY, selFirst, selLast); - XSetClipMask(Tk_Display(tkwin), gc, 0); + XSetClipMask(Tk_Display(tkwin), gc, None); Tk_FreeGC(Tk_Display(tkwin), gc); } @@ -1286,7 +1286,7 @@ static void EntryDisplay(void *clientData, Drawable d) * it from the Xft guts (if they're being used). */ #ifdef HAVE_XFT - TkUnixSetXftClipRegion(0); + TkUnixSetXftClipRegion(None); #endif TkDestroyRegion(clipRegion); } diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c index 9b80c59..1037840 100644 --- a/generic/ttk/ttkLabel.c +++ b/generic/ttk/ttkLabel.c @@ -183,10 +183,10 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b) if (clipRegion != NULL) { #ifdef HAVE_XFT - TkUnixSetXftClipRegion(0); + TkUnixSetXftClipRegion(None); #endif - XSetClipMask(Tk_Display(tkwin), gc1, 0); - XSetClipMask(Tk_Display(tkwin), gc2, 0); + XSetClipMask(Tk_Display(tkwin), gc1, None); + XSetClipMask(Tk_Display(tkwin), gc2, None); TkDestroyRegion(clipRegion); } Tk_FreeGC(Tk_Display(tkwin), gc1); @@ -305,7 +305,7 @@ static void StippleOver( Pixmap stipple = Tk_AllocBitmapFromObj(NULL, tkwin, image->stippleObj); XColor *color = Tk_GetColorFromObj(tkwin, image->backgroundObj); - if (stipple) { + if (stipple != None) { unsigned long mask = GCFillStyle | GCStipple | GCForeground; XGCValues gcvalues; GC gc; diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 60d6cda..b80a3cf 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -37,7 +37,7 @@ #define ACTIVE_BG "systemButtonFacePressed" #define ACTIVE_FG "systemPushButtonPressedText" #define SELECT_BG "systemHighlight" -#define SELECT_FG None +#define SELECT_FG NULL #define INACTIVE_SELECT_BG "systemHighlightSecondary" #define TROUGH "#c3c3c3" #define INDICATOR "#b03060" @@ -281,7 +281,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG ((char *) NULL) #define DEF_MENU_ENTRY_ACCELERATOR ((char *) NULL) #define DEF_MENU_ENTRY_BG ((char *) NULL) -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND ((char *) NULL) #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index bd7e0a8..03a724d 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -491,7 +491,7 @@ TkMacOSXContainerId( } } Tcl_Panic("TkMacOSXContainerId couldn't find window"); - return None; + return NULL; } /* @@ -527,8 +527,8 @@ TkMacOSXGetHostToplevel( * TODO: Here we should handle out of process embedding. */ - if (contWinPtr == NULL) { - return None; + if (!contWinPtr) { + return NULL; } return TkMacOSXGetHostToplevel(contWinPtr); } diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 8f20447..6b957dc 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1460,10 +1460,10 @@ TkpMenuInit(void) #undef observe [NSMenuItem setUsesUserKeyEquivalents:NO]; - tkColPtr = TkpGetColor(None, DEF_MENU_BG_COLOR); + tkColPtr = TkpGetColor(NULL, DEF_MENU_BG_COLOR); defaultBg = tkColPtr->color.pixel; ckfree((char *) tkColPtr); - tkColPtr = TkpGetColor(None, DEF_MENU_FG); + tkColPtr = TkpGetColor(NULL, DEF_MENU_FG); defaultFg = tkColPtr->color.pixel; ckfree((char *) tkColPtr); diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 7dde501..ea0fdd0 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -104,8 +104,8 @@ TkpCreateScrollbar( MacScrollbar *scrollPtr = (MacScrollbar *)ckalloc(sizeof(MacScrollbar)); - scrollPtr->troughGC = None; - scrollPtr->copyGC = None; + scrollPtr->troughGC = NULL; + scrollPtr->copyGC = NULL; Tk_CreateEventHandler(tkwin,ExposureMask|StructureNotifyMask|FocusChangeMask|ButtonPressMask|VisibilityChangeMask, ScrollbarEventProc, scrollPtr); diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index e928298..a541945 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -1371,7 +1371,7 @@ void Tk_ResetUserInactiveTime( Display *dpy) { - IOGPoint loc; + IOGPoint loc = {0}; kern_return_t kr; NXEvent nullEvent = {NX_NULLEVENT, {0, 0}, 0, -1, 0}; enum { kNULLEventPostThrottle = 10 }; diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 417866b..14f5827 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -47,7 +47,7 @@ TkBorder * TkpGetBorder(void) { UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder)); - borderPtr->solidGC = None; + borderPtr->solidGC = NULL; return (TkBorder *) borderPtr; } @@ -215,7 +215,7 @@ Tk_3DHorizontalBevel( Display *display = Tk_Display(tkwin); int bottom, halfway, x1, x2, x1Delta, x2Delta; UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; - GC topGC = None, bottomGC = None; + GC topGC = NULL, bottomGC = NULL; /* Initializations needed only to prevent * compiler warnings. */ diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index a8ecdc1..7663903 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -243,7 +243,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG (char *) NULL #define DEF_MENU_ENTRY_ACCELERATOR (char *) NULL #define DEF_MENU_ENTRY_BG (char *) NULL -#define DEF_MENU_ENTRY_BITMAP None +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND (char *) NULL #define DEF_MENU_ENTRY_COMPOUND "none" diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 7f48703..cc561ec 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -246,7 +246,7 @@ #define DEF_MENU_ENTRY_ACTIVE_FG (char *) NULL #define DEF_MENU_ENTRY_ACCELERATOR (char *) NULL #define DEF_MENU_ENTRY_BG (char *) NULL -#define DEF_MENU_ENTRY_BITMAP 0 +#define DEF_MENU_ENTRY_BITMAP NULL #define DEF_MENU_ENTRY_COLUMN_BREAK "0" #define DEF_MENU_ENTRY_COMMAND (char *) NULL #define DEF_MENU_ENTRY_COMPOUND "none" -- cgit v0.12 From 26ed73cf110821f07dc61cb0e6d0b0b19977a3f4 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 31 Dec 2018 16:58:27 +0000 Subject: Make GenerateWidgetSyncEvent save the sync state whenever it sends an event, and not send an event unless the requested state differs from the saved state. --- generic/tkText.c | 1 + generic/tkText.h | 3 ++- generic/tkTextDisp.c | 20 ++++++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 2dabe4c..5f2abb2 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -533,6 +533,7 @@ CreateWidget( textPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(textPtr->tkwin), TextWidgetObjCmd, textPtr, TextCmdDeletedProc); + textPtr->inSync = 1; if (sharedPtr == NULL) { sharedPtr = ckalloc(sizeof(TkSharedText)); diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..91abb73 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -785,7 +785,8 @@ typedef struct TkText { * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ - + int inSync; /* The last value sent as a <> + event. Initialized to 1.*/ /* * Copies of information from the shared section relating to the undo/redo * functonality diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 03546af..f63cb0c 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3115,8 +3115,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkTest structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3147,8 +3153,11 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (InSync != textPtr->inSync) { + textPtr->inSync = InSync; + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(InSync)); + } } /* @@ -3531,9 +3540,8 @@ TextInvalidateLineMetrics( /* * The widget is now out of sync: send a <> event. */ - - GenerateWidgetViewSyncEvent(textPtr, 0); + GenerateWidgetViewSyncEvent(textPtr, 0); } /* -- cgit v0.12 From f2e772a44b42b74f577a9811522b025ebaae6eb1 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 1 Jan 2019 01:22:53 +0000 Subject: Correct the call to GenerateWidgetViewSync in TkTextRelayoutWindow. Make TkTextUpdateLineMetrics send a < if it updates all lines. --- generic/tkTextDisp.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index f63cb0c..b974758 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3091,7 +3091,6 @@ AsyncUpdateLineMetrics( * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ - GenerateWidgetViewSyncEvent(textPtr, 1); if (textPtr->refCount-- <= 1) { @@ -3200,7 +3199,10 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); - + int fullSync = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); + if (totalLines == 0) { /* * Empty peer widget. @@ -3367,6 +3369,9 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } + if (fullSync) { + GenerateWidgetViewSyncEvent(textPtr, 1); + } return lineNum; } @@ -3538,9 +3543,8 @@ TextInvalidateLineMetrics( } /* - * The widget is now out of sync: send a <> event. + * The widget is out of sync: send a <> event. */ - GenerateWidgetViewSyncEvent(textPtr, 0); } @@ -5283,9 +5287,7 @@ TkTextRelayoutWindow( inSync = 0; } - if (!inSync) { - GenerateWidgetViewSyncEvent(textPtr, 0); - } + GenerateWidgetViewSyncEvent(textPtr, inSync); } } -- cgit v0.12 From 9d46acafed8ba7109f4c1b49eff4b12b7009f1fc Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 1 Jan 2019 16:30:11 +0000 Subject: Better fix for [509cafafae]: ttk::treeview tag options ignored in 8.6.9. This solution was suggested by cjmcdonald: Revert [d378ad72], partially revert [07b0114e] (keep documentation of tag priority order), and remove the {!disabled !selected} statespec from the -background and -foreground state map of the ttk::treeview since they are not needed and provide regressions. --- doc/ttk_treeview.n | 5 ++--- generic/ttk/ttkTreeview.c | 13 ++----------- library/ttk/altTheme.tcl | 2 -- library/ttk/aquaTheme.tcl | 2 -- library/ttk/clamTheme.tcl | 2 -- library/ttk/classicTheme.tcl | 2 -- library/ttk/defaults.tcl | 2 -- library/ttk/vistaTheme.tcl | 2 -- library/ttk/winTheme.tcl | 2 -- library/ttk/xpTheme.tcl | 2 -- 10 files changed, 4 insertions(+), 30 deletions(-) diff --git a/doc/ttk_treeview.n b/doc/ttk_treeview.n index 6cb801e..96565a3 100644 --- a/doc/ttk_treeview.n +++ b/doc/ttk_treeview.n @@ -432,9 +432,8 @@ Specifies the font to use when drawing text. .\" ??? Maybe: .IP \-text .IP \fB\-image\fR Specifies the item image, in case the item's \fB\-image\fR option is empty. -.PP -Tag options \fB\-foreground\fR and \fB\-background\fR take precedence over -the style, except in the \fBselected\fR state. +.\" .PP +.\" \fI(@@@ TODO: sort out order of precedence for options)\fR .PP Tag priority is decided by the creation order: tags created first receive higher priority. diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index a1ee325..bef84f3 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1709,17 +1709,8 @@ static void PrepareItem( Ttk_Style style = Ttk_LayoutStyle(tv->core.layout); Ttk_State state = ItemState(tv, item); - /* - * Tag options have precedence over the style, unless in selected state. - */ - - if (state & TTK_STATE_SELECTED) { - Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); - Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); - } else { - Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); - Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); - } + Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem); + Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem); } /* + DrawCells -- diff --git a/library/ttk/altTheme.tcl b/library/ttk/altTheme.tcl index 6fc76f8..80ef415 100644 --- a/library/ttk/altTheme.tcl +++ b/library/ttk/altTheme.tcl @@ -96,10 +96,8 @@ namespace eval ttk::theme::alt { ttk::style configure Treeview -background $colors(-window) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ - {!disabled !selected} $colors(-window) \ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ - {!disabled !selected} black \ selected $colors(-selectfg)] ttk::style configure TScale \ diff --git a/library/ttk/aquaTheme.tcl b/library/ttk/aquaTheme.tcl index d6be5a3..a548d65 100644 --- a/library/ttk/aquaTheme.tcl +++ b/library/ttk/aquaTheme.tcl @@ -42,11 +42,9 @@ namespace eval ttk::theme::aqua { ttk::style configure Treeview -rowheight 18 -background White ttk::style map Treeview \ -background [list disabled systemDialogBackgroundInactive \ - {!disabled !selected} systemWindowBody \ {selected background} systemHighlightSecondary \ selected systemHighlight] \ -foreground [list disabled systemModelessDialogInactiveText \ - {!disabled !selected} black \ selected systemModelessDialogActiveText] # Enable animation for ttk::progressbar widget: diff --git a/library/ttk/clamTheme.tcl b/library/ttk/clamTheme.tcl index 3c6f5c3..6935fc7 100644 --- a/library/ttk/clamTheme.tcl +++ b/library/ttk/clamTheme.tcl @@ -132,10 +132,8 @@ namespace eval ttk::theme::clam { ttk::style configure Treeview -background $colors(-window) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ - {!disabled !selected} $colors(-window) \ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ - {!disabled !selected} black \ selected $colors(-selectfg)] ttk::style configure TLabelframe \ diff --git a/library/ttk/classicTheme.tcl b/library/ttk/classicTheme.tcl index fefdb99..f237fba 100644 --- a/library/ttk/classicTheme.tcl +++ b/library/ttk/classicTheme.tcl @@ -99,10 +99,8 @@ namespace eval ttk::theme::classic { ttk::style configure Treeview -background $colors(-window) ttk::style map Treeview \ -background [list disabled $colors(-frame)\ - {!disabled !selected} $colors(-window) \ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ - {!disabled !selected} black \ selected $colors(-selectfg)] # diff --git a/library/ttk/defaults.tcl b/library/ttk/defaults.tcl index 4c1753d..a15d1d9 100644 --- a/library/ttk/defaults.tcl +++ b/library/ttk/defaults.tcl @@ -111,10 +111,8 @@ namespace eval ttk::theme::default { -foreground $colors(-text) ; ttk::style map Treeview \ -background [list disabled $colors(-frame)\ - {!disabled !selected} $colors(-window) \ selected $colors(-selectbg)] \ -foreground [list disabled $colors(-disabledfg) \ - {!disabled !selected} black \ selected $colors(-selectfg)] # Combobox popdown frame diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl index ecb39c9..094288c 100644 --- a/library/ttk/vistaTheme.tcl +++ b/library/ttk/vistaTheme.tcl @@ -48,10 +48,8 @@ namespace eval ttk::theme::vista { ttk::style configure Treeview -background SystemWindow ttk::style map Treeview \ -background [list disabled SystemButtonFace \ - {!disabled !selected} SystemWindow \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ - {!disabled !selected} SystemWindowText \ selected SystemHighlightText] # Label and Toolbutton diff --git a/library/ttk/winTheme.tcl b/library/ttk/winTheme.tcl index a7a2c79..db05b45 100644 --- a/library/ttk/winTheme.tcl +++ b/library/ttk/winTheme.tcl @@ -74,10 +74,8 @@ namespace eval ttk::theme::winnative { ttk::style configure Treeview -background SystemWindow ttk::style map Treeview \ -background [list disabled SystemButtonFace \ - {!disabled !selected} SystemWindow \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ - {!disabled !selected} SystemWindowText \ selected SystemHighlightText] ttk::style configure TProgressbar \ diff --git a/library/ttk/xpTheme.tcl b/library/ttk/xpTheme.tcl index 5d8d09b..4c4f680 100644 --- a/library/ttk/xpTheme.tcl +++ b/library/ttk/xpTheme.tcl @@ -67,10 +67,8 @@ namespace eval ttk::theme::xpnative { ttk::style configure Treeview -background SystemWindow ttk::style map Treeview \ -background [list disabled SystemButtonFace \ - {!disabled !selected} SystemWindow \ selected SystemHighlight] \ -foreground [list disabled SystemGrayText \ - {!disabled !selected} SystemWindowText \ selected SystemHighlightText]; } } -- cgit v0.12 From 95905874bab74564f6acab0f3092d0142c307f4b Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 1 Jan 2019 16:36:17 +0000 Subject: Update the TextDinfo when the sync command runs, so that pendingsync will know that the widget is in sync, as expected by the tests. --- generic/tkTextDisp.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index b974758..cc0a1e1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3370,6 +3370,9 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } if (fullSync) { + TextDInfo *dInfoPtr = textPtr->dInfoPtr; + dInfoPtr->lastMetricUpdateLine = lineNum; + dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); } return lineNum; -- cgit v0.12 From e43d3df502249e8b7e104bb575aa7fdb3cf40144 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 1 Jan 2019 19:03:49 +0000 Subject: The sync command needs to ensure that no redraw is pending before updating the line metrics. Otherwise pendingsync will remain true after the sync. --- generic/tkText.c | 1 + 1 file changed, 1 insertion(+) diff --git a/generic/tkText.c b/generic/tkText.c index 5f2abb2..5f248a8 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -1560,6 +1560,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; -- cgit v0.12 From a16300f3515fc588292543bc2d44af9a332fb84d Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 1 Jan 2019 19:07:32 +0000 Subject: In the tests, always update after packing; sync and clear the queue before binding to WidgetViewSync; make 11a.12 work harder so it is meaningful. --- tests/text.test | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/tests/text.test b/tests/text.test index ae45e5e..311d531 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2936,11 +2936,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -2978,9 +2980,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3053,19 +3057,18 @@ test text-11a.31 {"<>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <> events before binding. + .top.yt sync update bind .top.yt <> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3081,26 +3084,26 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { } -body { toplevel .top pack [text .top.yt] - # make initial sync state known update - .top.yt sync set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } - bind .top.yt <> {lappend res Sync:%d} + # Sync the widget and process all <> events before binding. + .top.yt sync update + bind .top.yt <> {lappend res Sync:%d} set res {} - # the next line triggers <> with %d==0 i.e. we're out of sync + # The next line triggers <> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content vwait res - # ensure the test is relevant: the line metrics are not up-to-date (pendingsync is 1) + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # wait for the end of line metrics update by calling the sync command - # <> fires when sync returns with %d==1 i.e. we're in sync again - # at this time line metrics are up-to-date (pendingsync is 0) + # Update all line metrics by calling the sync command. .top.yt sync + # <> should fire with %d==1 i.e. back in sync. vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3115,6 +3118,7 @@ test text-11a.51 {<> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } -- cgit v0.12 From 78c241039c466793240f3f8bac5bb032d52da99a Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 1 Jan 2019 23:20:01 +0000 Subject: Change variable name for something clearer. --- generic/tkTextDisp.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cc0a1e1..6604579 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3117,7 +3117,7 @@ AsyncUpdateLineMetrics( * line metrics asynchronous update. These events should only * be sent when the sync status has changed. So this function * compares the requested state with the state saved in the - * TkTest structure, and only generates the event if they are + * TkText structure, and only generates the event if they are * different. This means that it is safe to call this function * at any time when the state is known. * @@ -3199,9 +3199,9 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); - int fullSync = (lineNum == 0 && - endLine == totalLines && - doThisMuch == -1); + int fullUpdateRequested = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); if (totalLines == 0) { /* @@ -3369,8 +3369,9 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } - if (fullSync) { + if (fullUpdateRequested) { TextDInfo *dInfoPtr = textPtr->dInfoPtr; + dInfoPtr->lastMetricUpdateLine = lineNum; dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); -- cgit v0.12 From 27d71c8a9216f3fd97537b0f3aaa6a7650aca3e1 Mon Sep 17 00:00:00 2001 From: fvogel Date: Tue, 1 Jan 2019 23:21:58 +0000 Subject: Clarify comment --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 6604579..4ff9307 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3363,7 +3363,7 @@ TkTextUpdateLineMetrics( } if (doThisMuch == -1) { /* - * If we were requested to provide a full update, then also update the + * If we were requested to update the entire range, then also update the * scrollbar. */ -- cgit v0.12 From dac8c5e71bad36669aaecfc25e3e82cefef6c1ed Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 2 Jan 2019 01:21:48 +0000 Subject: Use a flag bit instead of an int to store the sync state. Avoid running idle tasks in the sync command if possible. --- generic/tkText.c | 2 -- generic/tkText.h | 3 +-- generic/tkTextDisp.c | 18 ++++++++++++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 5f248a8..2dabe4c 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -533,7 +533,6 @@ CreateWidget( textPtr->widgetCmd = Tcl_CreateObjCommand(interp, Tk_PathName(textPtr->tkwin), TextWidgetObjCmd, textPtr, TextCmdDeletedProc); - textPtr->inSync = 1; if (sharedPtr == NULL) { sharedPtr = ckalloc(sizeof(TkSharedText)); @@ -1560,7 +1559,6 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; diff --git a/generic/tkText.h b/generic/tkText.h index 91abb73..5d88784 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -785,8 +785,7 @@ typedef struct TkText { * refering to us. */ int insertCursorType; /* 0 = standard insertion cursor, 1 = block * cursor. */ - int inSync; /* The last value sent as a <> - event. Initialized to 1.*/ + /* * Copies of information from the shared section relating to the undo/redo * functonality diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4ff9307..ae452c5 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -497,13 +497,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -3152,8 +3154,12 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - if (InSync != textPtr->inSync) { - textPtr->inSync = InSync; + if (InSync == !!(textPtr->dInfoPtr->flags & OUT_OF_SYNC)) { + if (InSync) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", Tcl_NewBooleanObj(InSync)); } @@ -3202,7 +3208,11 @@ TkTextUpdateLineMetrics( int fullUpdateRequested = (lineNum == 0 && endLine == totalLines && doThisMuch == -1); - + + if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + } + if (totalLines == 0) { /* * Empty peer widget. -- cgit v0.12 From 2545df09cd8f14a1f0d39d6de65a68279b0f1c4a Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Jan 2019 10:16:38 +0000 Subject: Add an explanatory comment, and slightly optimize (in the case of the empty peer). --- generic/tkTextDisp.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ae452c5..7e1836f 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3209,10 +3209,6 @@ TkTextUpdateLineMetrics( endLine == totalLines && doThisMuch == -1); - if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} - } - if (totalLines == 0) { /* * Empty peer widget. @@ -3221,6 +3217,16 @@ TkTextUpdateLineMetrics( return endLine; } + /* + * When called by the sync command we need to ensure that no redraw is + * pending before updating the line metrics. Otherwise pendingsync + * would remain true after the sync. + */ + + if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) { + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} + } + while (1) { /* * Get a suitable line. -- cgit v0.12 From bc7779a0108961d4985a9a0160c1fac9f2611658 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Jan 2019 10:17:59 +0000 Subject: Simplify TkTextPendingsync by using the new OUT_OF_SYNC flag --- generic/tkTextDisp.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7e1836f..4aa3235 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -6332,11 +6332,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return ( - (!(dInfoPtr->flags & REDRAW_PENDING) && - (dInfoPtr->metricEpoch == -1) && - (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? - 0 : 1); + return dInfoPtr->flags & OUT_OF_SYNC; } /* -- cgit v0.12 From 02947d3dd6f1eee77ddeb7dc2e78dc4378d1d8ba Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Jan 2019 11:54:46 +0000 Subject: Fix tests order according to their numbering --- tests/text.test | 188 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 94 insertions(+), 94 deletions(-) diff --git a/tests/text.test b/tests/text.test index 311d531..aaddc2c 100644 --- a/tests/text.test +++ b/tests/text.test @@ -7365,6 +7365,100 @@ test text-32.1 {line heights on creation} -setup { destroy .t } -result {1} +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7497,100 +7591,6 @@ test text-34.1 {peer widget -start, -end and selection} -setup { destroy .t } -result {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}} -test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result {1} - -test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { #puts "KK: $key, $value" -- cgit v0.12 From 03dff5fd63941102495689b01b05bcea39d73912 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 2 Jan 2019 15:12:28 +0000 Subject: It is no longer necessary to run any idle tasks before updating all line metrics, since pendingsync is independent of REDRAW_PENDING now. --- generic/tkTextDisp.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 4aa3235..2bfb359 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3217,17 +3217,8 @@ TkTextUpdateLineMetrics( return endLine; } - /* - * When called by the sync command we need to ensure that no redraw is - * pending before updating the line metrics. Otherwise pendingsync - * would remain true after the sync. - */ - - if (fullUpdateRequested && (textPtr->dInfoPtr->flags & REDRAW_PENDING)) { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)) {} - } - while (1) { + /* * Get a suitable line. */ @@ -3254,6 +3245,7 @@ TkTextUpdateLineMetrics( */ if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) { + /* * We have looped over all lines, so we're done. */ @@ -3277,10 +3269,12 @@ TkTextUpdateLineMetrics( if (TkBTreeLinePixelEpoch(textPtr, linePtr) == textPtr->dInfoPtr->lineMetricUpdateEpoch) { + /* * This line is already up to date. That means there's nothing * to do here. */ + } else if (doThisMuch == -1) { count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0); } else { @@ -3302,6 +3296,7 @@ TkTextUpdateLineMetrics( indexPtr = &textPtr->dInfoPtr->metricIndex; pixelHeight = textPtr->dInfoPtr->metricPixelHeight; } else { + /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. @@ -3325,6 +3320,7 @@ TkTextUpdateLineMetrics( pixelHeight, indexPtr, 1); if (indexPtr->linePtr == linePtr) { + /* * We didn't complete the logical line, because it * produced very many display lines, which must be because @@ -3333,6 +3329,7 @@ TkTextUpdateLineMetrics( */ if (pixelHeight == 0) { + /* * These have already been stored, unless we just * started the new line. @@ -3354,6 +3351,7 @@ TkTextUpdateLineMetrics( textPtr->dInfoPtr->metricEpoch = -1; } } else { + /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will @@ -3378,9 +3376,10 @@ TkTextUpdateLineMetrics( } } if (doThisMuch == -1) { + /* - * If we were requested to update the entire range, then also update the - * scrollbar. + * If we were requested to update the entire range, then also update + * the scrollbar. */ GetYView(textPtr->interp, textPtr, 1); -- cgit v0.12 From 19deb1cb04936981e905f5985497e4386dde5f9c Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 2 Jan 2019 18:17:39 +0000 Subject: Make AsyncUpdateLineMetrics cancel any idle tasks for the afterSyncCmd before running it, to protect against bug [0a9c91951b]. --- generic/tkText.c | 9 ++++----- generic/tkText.h | 4 ++-- generic/tkTextDisp.c | 5 ++++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 2dabe4c..6c1512d 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, static void GenerateModifiedEvent(TkText *textPtr); static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); -static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, Tcl_Obj *undoString, int insert, const TkTextIndex *index1Ptr, @@ -1547,7 +1546,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -5506,7 +5505,7 @@ UpdateDirtyFlag( /* *---------------------------------------------------------------------- * - * RunAfterSyncCmd -- + * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. @@ -5520,8 +5519,8 @@ UpdateDirtyFlag( *---------------------------------------------------------------------- */ -static void -RunAfterSyncCmd( +void +TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { register TkText *textPtr = (TkText *) clientData; diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..4703703 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1070,7 +1070,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, TkTextIndex *indexPtr); -MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, +MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *objPtr); MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *stringPtr); @@ -1159,7 +1159,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); - +MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 2bfb359..ecd2427 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -683,7 +683,7 @@ TkTextCreateDInfo( dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = 0; dInfoPtr->dLinesInvalidated = 0; - dInfoPtr->flags = DINFO_OUT_OF_DATE; + dInfoPtr->flags = 0; dInfoPtr->topPixelOffset = 0; dInfoPtr->newTopPixelOffset = 0; dInfoPtr->currentMetricUpdateLine = -1; @@ -3072,9 +3072,12 @@ AsyncUpdateLineMetrics( * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. + * Cancel any pending idle task which would try to run the command + * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); int code; Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, -- cgit v0.12 From 0eeed8ea89fe5aaab65b470f3ab9915d8ae9ce8f Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 2 Jan 2019 18:25:29 +0000 Subject: Fix the build for Windows with MSVC --- generic/tkTextDisp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index ecd2427..38c63a2 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3077,8 +3077,8 @@ AsyncUpdateLineMetrics( */ if (textPtr->afterSyncCmd) { - Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); int code; + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); -- cgit v0.12 From b6eb3654e101439f170418eb6eab11065e196a06 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 3 Jan 2019 14:13:09 +0000 Subject: Be careful about Bool types. --- generic/tkTextDisp.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 38c63a2..7f9d13f 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3143,8 +3143,11 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* true if in sync, false otherwise */ + Bool NewSyncState) /* true if becoming in sync, false otherwise */ { + NewSyncState = (NewSyncState != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = ((textPtr->dInfoPtr->flags & OUT_OF_SYNC) == 0); + /* * OSX 10.14 needs to be told to display the window when the Text Widget * is in sync. (That is, to run DisplayText inside of the drawRect @@ -3157,14 +3160,14 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - if (InSync == !!(textPtr->dInfoPtr->flags & OUT_OF_SYNC)) { - if (InSync) { + if (NewSyncState != OldSyncState) { + if (NewSyncState) { textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; } else { textPtr->dInfoPtr->flags |= OUT_OF_SYNC; } TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + Tcl_NewBooleanObj(NewSyncState)); } } @@ -6334,7 +6337,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return dInfoPtr->flags & OUT_OF_SYNC; + return ((dInfoPtr->flags & OUT_OF_SYNC) != 0); } /* -- cgit v0.12 From d15feac70552dc770fae1d628e7b465c2cae7726 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 3 Jan 2019 14:45:12 +0000 Subject: Fix the build for MSVC once more. --- generic/tkTextDisp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 7f9d13f..cde30e1 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3142,11 +3142,11 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( - TkText *textPtr, /* Information about text widget. */ - Bool NewSyncState) /* true if becoming in sync, false otherwise */ + TkText *textPtr, /* Information about text widget. */ + Bool InSync) /* true if becoming in sync, false otherwise */ { - NewSyncState = (NewSyncState != 0); /* ensure 0 or 1 value */ - Bool OldSyncState = ((textPtr->dInfoPtr->flags & OUT_OF_SYNC) == 0); + Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC); /* * OSX 10.14 needs to be told to display the window when the Text Widget -- cgit v0.12 From c5533b50401ae20076e2f06f0fe531aa1eabc626 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 3 Jan 2019 16:20:11 +0000 Subject: Fix two compiler warnings about format string buffers being too small. --- generic/tkEntry.h | 2 +- generic/tkScale.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 52535c8..15b4c21 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -221,7 +221,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[14]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkScale.h b/generic/tkScale.h index 4fd9995..73678ed 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -73,7 +73,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[14]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ -- cgit v0.12 From db428d2e19e35d38ecf47ca6d08a83c318576d40 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 3 Jan 2019 19:45:29 +0000 Subject: Remove 3 lines of code in tkTextDisp.c which had become obsolete but were accidentally left in the file. --- generic/tkTextDisp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index cde30e1..4fb30e0 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3391,10 +3391,6 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } if (fullUpdateRequested) { - TextDInfo *dInfoPtr = textPtr->dInfoPtr; - - dInfoPtr->lastMetricUpdateLine = lineNum; - dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); } return lineNum; -- cgit v0.12 From d2747a371058fa4128dbd7896fe040f0b3ee6be7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 20:53:24 +0000 Subject: Bring back more original "None" usages, and fix other warnings which gradually slipped in. Wherever possible, pragma's are used in MSVC to silence useless compiler warnings. --- generic/tk3d.c | 8 ++++---- generic/tk3d.h | 4 ++-- generic/tkBind.c | 2 +- generic/tkButton.h | 2 +- generic/tkCanvArc.c | 4 +++- generic/tkCanvBmap.c | 2 +- generic/tkCanvLine.c | 6 +++--- generic/tkCanvPoly.c | 6 +++--- generic/tkCanvText.c | 8 ++++---- generic/tkCanvas.h | 2 +- generic/tkColor.c | 6 +++--- generic/tkColor.h | 2 +- generic/tkConfig.c | 6 +++--- generic/tkCursor.c | 6 +++--- generic/tkEntry.c | 2 +- generic/tkEntry.h | 6 +++--- generic/tkEvent.c | 2 +- generic/tkImgBmap.c | 12 ++++++------ generic/tkMenu.h | 8 ++++---- generic/tkMenubutton.h | 2 +- generic/tkOldConfig.c | 2 +- generic/tkPlace.c | 2 +- generic/tkRectOval.c | 8 ++++---- generic/tkScale.h | 4 ++-- generic/tkScrollbar.h | 2 +- generic/tkText.h | 2 +- generic/tkTextDisp.c | 2 +- generic/ttk/ttkEntry.c | 4 ++-- generic/ttk/ttkLayout.c | 2 +- generic/ttk/ttkTreeview.c | 2 +- generic/ttk/ttkWidget.c | 2 +- unix/tkUnix3d.c | 4 ++-- unix/tkUnixMenubu.c | 12 ++++++------ win/stubs.c | 2 +- win/tkWin3d.c | 12 ++++++------ win/tkWinButton.c | 15 ++++++++------- win/tkWinDraw.c | 14 +++++++------- win/tkWinEmbed.c | 6 +++--- win/tkWinFont.c | 12 ++++++------ win/tkWinImage.c | 2 +- win/tkWinMenu.c | 4 ++-- win/tkWinPixmap.c | 2 +- win/tkWinPointer.c | 6 +++--- win/tkWinPort.h | 9 +++++++-- win/tkWinScrlbr.c | 2 +- win/tkWinWindow.c | 6 +++--- win/tkWinWm.c | 42 +++++++++++++++++++++--------------------- win/tkWinX.c | 18 +++++++++--------- win/ttkWinXPTheme.c | 2 +- xlib/X11/X.h | 12 +++++++++--- xlib/xgc.c | 22 +++++++++++----------- xlib/ximage.c | 2 +- 52 files changed, 174 insertions(+), 160 deletions(-) diff --git a/generic/tk3d.c b/generic/tk3d.c index eebe122..ddb48b3 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -237,9 +237,9 @@ Tk_Get3DBorder( borderPtr->darkColorPtr = NULL; borderPtr->lightColorPtr = NULL; borderPtr->shadow = None; - borderPtr->bgGC = 0; - borderPtr->darkGC = 0; - borderPtr->lightGC = 0; + borderPtr->bgGC = NULL; + borderPtr->darkGC = NULL; + borderPtr->lightGC = NULL; borderPtr->hashPtr = hashPtr; borderPtr->nextPtr = existingBorderPtr; Tcl_SetHashValue(hashPtr, borderPtr); @@ -392,7 +392,7 @@ Tk_3DBorderGC( * compilers happy. */ - return (GC) None; + return NULL; } /* diff --git a/generic/tk3d.h b/generic/tk3d.h index 5e0a0cf..30a35c5 100644 --- a/generic/tk3d.h +++ b/generic/tk3d.h @@ -60,10 +60,10 @@ typedef struct TkBorder { GC bgGC; /* Used (if necessary) to draw areas in the * background color. */ GC darkGC; /* Used to draw darker parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet.*/ GC lightGC; /* Used to draw lighter parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet. */ Tcl_HashEntry *hashPtr; /* Entry in borderTable (needed in order to * delete structure). */ diff --git a/generic/tkBind.c b/generic/tkBind.c index c4f8226..98c491a 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3870,7 +3870,7 @@ DoWarp( { TkDisplay *dispPtr = (TkDisplay *) clientData; - XWarpPointer(dispPtr->display, (Window) None, (Window) dispPtr->warpWindow, + XWarpPointer(dispPtr->display, None, (Window) dispPtr->warpWindow, 0, 0, 0, 0, (int) dispPtr->warpX, (int) dispPtr->warpY); XForceScreenSaver(dispPtr->display, ScreenSaverReset); dispPtr->flags &= ~TK_DISPLAY_IN_WARP; diff --git a/generic/tkButton.h b/generic/tkButton.h index 09aaee2..d669b02 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -235,7 +235,7 @@ typedef struct { * Miscellaneous information: */ - Tk_Cursor cursor; /* Value of -cursor option: if not None, + Tk_Cursor cursor; /* Value of -cursor option: if not NULL, * specifies current cursor for window. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 33367de..ae62147 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -526,7 +526,9 @@ ConfigureArc( } } - if ((arcPtr->style == ARC_STYLE) || (!color)) { + if (arcPtr->style == ARC_STYLE) { + newGC = NULL; + } else if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 5f97ef2..59e2494 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -376,7 +376,7 @@ ConfigureBitmap( } } - if (!bitmap) { + if (bitmap == None) { newGC = NULL; } else { gcValues.foreground = fgColor->pixel; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index fea2103..5f67175 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -533,10 +533,10 @@ ConfigureLine( } else { newGC = arrowGC = NULL; } - if (linePtr->outline.gc) { + if (linePtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc); } - if (linePtr->arrowGC) { + if (linePtr->arrowGC != None) { Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC); } linePtr->outline.gc = newGC; @@ -2251,7 +2251,7 @@ LineToPostscript( * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; - char buffer[64 + TCL_INTEGER_SPACE]; + char buffer[64 + 4*TCL_INTEGER_SPACE]; char *style; double width; diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 0810ab6..4ab4339 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -486,7 +486,7 @@ ConfigurePolygon( } else { newGC = NULL; } - if (polyPtr->outline.gc) { + if (polyPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc); } polyPtr->outline.gc = newGC; @@ -509,12 +509,12 @@ ConfigurePolygon( } } - if (!color) { + if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; mask = GCForeground; - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 187ec40..6dd1c9f 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -446,7 +446,7 @@ ConfigureText( if (textPtr->tkfont != NULL) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; - if (color) { + if (color != NULL) { gcValues.foreground = color->pixel; mask |= GCForeground; if (stipple != None) { @@ -457,7 +457,7 @@ ConfigureText( newGC = Tk_GetGC(tkwin, mask, &gcValues); } mask &= ~(GCTile|GCFillStyle|GCStipple); - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -467,7 +467,7 @@ ConfigureText( } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } - if (textPtr->gc) { + if (textPtr->gc != None) { Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; @@ -488,7 +488,7 @@ ConfigureText( } else { newGC = NULL; } - if (textPtr->cursorOffGC) { + if (textPtr->cursorOffGC != None) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); } textPtr->cursorOffGC = newGC; diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index d009cfa..5e784e3 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -206,7 +206,7 @@ typedef struct TkCanvas { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkColor.c b/generic/tkColor.c index bde08cf..c2b7732 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -242,7 +242,7 @@ Tk_GetColor( */ tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = 0; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = Tk_Colormap(tkwin); tkColPtr->visual = Tk_Visual(tkwin); @@ -323,7 +323,7 @@ Tk_GetColorByValue( tkColPtr = TkpGetColorByValue(tkwin, colorPtr); tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = 0; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = valueKey.colormap; tkColPtr->visual = Tk_Visual(tkwin); @@ -471,7 +471,7 @@ Tk_FreeColor( if (tkColPtr->gc != None) { XFreeGC(DisplayOfScreen(screen), tkColPtr->gc); - tkColPtr->gc = 0; + tkColPtr->gc = NULL; } TkpFreeColor(tkColPtr); diff --git a/generic/tkColor.h b/generic/tkColor.h index d4679cf..12c6662 100644 --- a/generic/tkColor.h +++ b/generic/tkColor.h @@ -37,7 +37,7 @@ typedef struct TkColor { * COLOR_MAGIC. */ GC gc; /* Simple gc with this color as foreground * color and all other fields defaulted. May - * be None. */ + * be NULL. */ Screen *screen; /* Screen where this color is valid. Used to * delete it, and to find its display. */ Colormap colormap; /* Colormap from which this entry was diff --git a/generic/tkConfig.c b/generic/tkConfig.c index ace7135..1a49026 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -854,7 +854,7 @@ DoObjConfig( Tk_Cursor newCursor; if (nullOK && ObjectIsEmpty(valuePtr)) { - newCursor = 0; + newCursor = NULL; valuePtr = NULL; } else { newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr); @@ -916,7 +916,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newWin = 0; + newWin = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, valuePtr, &newWin) != TCL_OK) { @@ -1702,7 +1702,7 @@ FreeResources( if (internalFormExists) { if (*((Tk_Cursor *) internalPtr) != None) { Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr)); - *((Tk_Cursor *) internalPtr) = 0; + *((Tk_Cursor *) internalPtr) = NULL; } } else if (objPtr != NULL) { Tk_FreeCursorFromObj(tkwin, objPtr); diff --git a/generic/tkCursor.c b/generic/tkCursor.c index a1c2723..e5b5df5 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -149,7 +149,7 @@ Tk_AllocCursorFromObj( cursorPtr = TkcGetCursor(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = (void *) cursorPtr; if (cursorPtr == NULL) { - return 0; + return NULL; } cursorPtr->objRefCount++; return cursorPtr->cursor; @@ -188,7 +188,7 @@ Tk_GetCursor( { TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); if (cursorPtr == NULL) { - return 0; + return NULL; } return cursorPtr->cursor; } @@ -382,7 +382,7 @@ Tk_GetCursorFromData( error: Tcl_DeleteHashEntry(dataHashPtr); - return 0; + return NULL; } /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index f5b4339..7b95fc9 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -2453,7 +2453,7 @@ EntryEventProc( } else { cursor = NULL; } - if (cursor) { + if (cursor != None) { Tk_DefineCursor(entryPtr->tkwin, cursor); } else { Tk_UndefineCursor(entryPtr->tkwin); diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 7f8aa1f..da06408 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -87,7 +87,7 @@ typedef struct { * in readonly state, plus used for * background. */ int borderWidth; /* Width of 3-D border around window. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ Tk_Font tkfont; /* Information about text font, or NULL. */ @@ -197,7 +197,7 @@ typedef struct { Tk_3DBorder activeBorder; /* Used for drawing border around active * buttons. */ Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */ - Tk_Cursor bCursor; /* cursor for buttons, or None. */ + Tk_Cursor bCursor; /* cursor for buttons, or NULL. */ int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ char *command; /* Command to invoke for spin buttons. NULL @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 9b001e1..9758dbe 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -1436,7 +1436,7 @@ TkEventDeadWindow( ipPtr->nextHandler = NULL; } if (ipPtr->winPtr == winPtr) { - ipPtr->winPtr = 0; + ipPtr->winPtr = NULL; } } ckfree((char *) handlerPtr); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index fab6afb..b37e7d5 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -400,18 +400,18 @@ ImgBmapConfigureInstance( (unsigned) masterPtr->height); } - if (oldMask) { + if (oldMask != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } - if (oldBitmap) { + if (oldBitmap != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap); } - if (masterPtr->data) { + if (masterPtr->data != NULL) { gcValues.foreground = instancePtr->fg->pixel; gcValues.graphics_exposures = False; mask = GCForeground|GCGraphicsExposures; - if (instancePtr->bg) { + if (instancePtr->bg != NULL) { gcValues.background = instancePtr->bg->pixel; mask |= GCBackground; if (instancePtr->mask != None) { @@ -426,7 +426,7 @@ ImgBmapConfigureInstance( } else { gc = NULL; } - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = gc; @@ -438,7 +438,7 @@ ImgBmapConfigureInstance( * it clear that this instance cannot be displayed. Then report the error. */ - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = NULL; diff --git a/generic/tkMenu.h b/generic/tkMenu.h index e8470ca..b1536df 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -80,8 +80,8 @@ typedef struct TkMenuEntry { * of character to underline (<0 means don't * underline anything). */ Tcl_Obj *underlinePtr; /* Index of character to underline. */ - Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None. - * If not None then label is ignored. */ + Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL. + * If not NULL then label is ignored. */ Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not * NULL, bitmap, text, and textVarName are * ignored. */ @@ -180,7 +180,7 @@ typedef struct TkMenuEntry { * NULL means use overall disabledGC from menu * structure. See comments for disabledFg in * menu structure for more information. */ - GC indicatorGC; /* For drawing indicators. None means use GC + GC indicatorGC; /* For drawing indicators. NULL means use GC * from menu. */ /* @@ -347,7 +347,7 @@ typedef struct TkMenu { Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ - Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */ + Tcl_Obj *cursorPtr; /* Current cursor for window, or NULL. */ Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy * trees when preprocessing postcommands on * some platforms. See PostMenu for more diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 41af675..f190c81 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -175,7 +175,7 @@ typedef struct { * "left" and "right" will pop the menu left * or right, and the active item will be next * to the button. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index cf5612b..8f4c234 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -476,7 +476,7 @@ DoConfig( Tk_Cursor newCursor, oldCursor; if (nullValue) { - newCursor = 0; + newCursor = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); diff --git a/generic/tkPlace.c b/generic/tkPlace.c index c435b12..19af02c 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -397,7 +397,7 @@ CreateSlave( slavePtr = (Slave *) ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); slavePtr->tkwin = tkwin; - slavePtr->inTkwin = 0; + slavePtr->inTkwin = NULL; slavePtr->anchor = TK_ANCHOR_NW; slavePtr->borderMode = BM_INSIDE; slavePtr->optionTable = table; diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index 53ebe61..0e73dd3 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -475,7 +475,7 @@ ConfigureRectOval( } else { newGC = NULL; } - if (rectOvalPtr->outline.gc) { + if (rectOvalPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); } rectOvalPtr->outline.gc = newGC; @@ -506,7 +506,7 @@ ConfigureRectOval( } } - if (!color) { + if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; @@ -522,13 +522,13 @@ ConfigureRectOval( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = rectOvalPtr->outline.gc ? + gcValues.line_width = rectOvalPtr->outline.gc != None ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (rectOvalPtr->fillGC) { + if (rectOvalPtr->fillGC != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC); } rectOvalPtr->fillGC = newGC; diff --git a/generic/tkScale.h b/generic/tkScale.h index a2c5f2b..079e02c 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[16]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ @@ -156,7 +156,7 @@ typedef struct TkScale { */ int fontHeight; /* Height of scale font. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. May be NULL. */ diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index 126d590..fa0426f 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -119,7 +119,7 @@ typedef struct TkScrollbar { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkText.h b/generic/tkText.h index 6f5f153..464bed5 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -654,7 +654,7 @@ typedef struct TkText { /* Color for drawing traversal highlight area * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ XColor *fgColor; /* Default foreground color for text. */ Tk_Font tkfont; /* Default font for displaying text. */ int charWidth; /* Width of average character in default diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 904fa1a..73abffb 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4335,7 +4335,7 @@ DisplayText( dlPtr->spaceAbove, dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, NULL, - (Drawable) None, dlPtr->y + dlPtr->spaceAbove); + None, dlPtr->y + dlPtr->spaceAbove); } } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index ae43ae6..61bf31b 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -332,7 +332,7 @@ EntryFetchSelection( ClientData clientData, int offset, char *buffer, int maxBytes) { Entry *entryPtr = (Entry *) clientData; - size_t byteCount; + int byteCount; const char *string; const char *selStart, *selEnd; @@ -345,7 +345,7 @@ EntryFetchSelection( selEnd = Tcl_UtfAtIndex(selStart, entryPtr->entry.selectLast - entryPtr->entry.selectFirst); byteCount = selEnd - selStart - offset; - if (byteCount > (size_t)maxBytes) { + if (byteCount > maxBytes) { /* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */ byteCount = maxBytes; } diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 58c99eb..04dd86f 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -7,7 +7,7 @@ */ #include -#include +#include "tkInt.h" #include "ttkThemeInt.h" #define MAX(a,b) (a > b ? a : b) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index f0a3003..473d1e6 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -6,7 +6,7 @@ #include #include -#include +#include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index d5e0484..557ca8f 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -5,7 +5,7 @@ */ #include -#include +#include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 14f5827..417866b 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -47,7 +47,7 @@ TkBorder * TkpGetBorder(void) { UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder)); - borderPtr->solidGC = NULL; + borderPtr->solidGC = None; return (TkBorder *) borderPtr; } @@ -215,7 +215,7 @@ Tk_3DHorizontalBevel( Display *display = Tk_Display(tkwin); int bottom, halfway, x1, x2, x1Delta, x2Delta; UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; - GC topGC = NULL, bottomGC = NULL; + GC topGC = None, bottomGC = None; /* Initializations needed only to prevent * compiler warnings. */ diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index 95bee0a..48d3fb9 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -103,10 +103,10 @@ TkpDisplayMenuButton( border = mbPtr->normalBorder; } - if (mbPtr->image) { + if (mbPtr->image != None) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } @@ -194,7 +194,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { XSetClipOrigin(mbPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -214,7 +214,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { XSetClipOrigin(mbPtr->display, gc, x, y); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -369,10 +369,10 @@ TkpComputeMenuButtonGeometry( txtHeight = 0; avgWidth = 0; - if (mbPtr->image) { + if (mbPtr->image != None) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } diff --git a/win/stubs.c b/win/stubs.c index 7e791b5..4564639 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -397,7 +397,7 @@ XGetWindowProperty( unsigned long *bytes_after_return, unsigned char **prop_return) { - *actual_type_return = 0; + *actual_type_return = None; *actual_format_return = 0; *nitems_return = 0; *bytes_after_return = 0; diff --git a/win/tkWin3d.c b/win/tkWin3d.c index aa026e8..df6aa95 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -127,7 +127,7 @@ Tk_3DVerticalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int half; - if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -222,7 +222,7 @@ Tk_3DHorizontalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int topColor, bottomColor; - if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -339,7 +339,7 @@ TkpGetShadows( int r, g, b; XGCValues gcValues; - if (borderPtr->lightGC) { + if (borderPtr->lightGC != None) { return; } @@ -465,10 +465,10 @@ TkpGetShadows( return; } - if (!borderPtr->shadow) { + if (borderPtr->shadow == None) { borderPtr->shadow = Tk_GetBitmap((Tcl_Interp *) NULL, tkwin, Tk_GetUid("gray50")); - if (!borderPtr->shadow) { + if (borderPtr->shadow == None) { Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border"); } } @@ -540,7 +540,7 @@ TkWinGetBorderPixels( { WinBorder *borderPtr = (WinBorder *) border; - if (!borderPtr->info.lightGC) { + if (borderPtr->info.lightGC == None) { TkpGetShadows(&borderPtr->info, tkwin); } switch (which) { diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 0a11a20..c36932d 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -127,7 +127,7 @@ InitBoxes(void) HRSRC hrsrc; HGLOBAL hblk; LPBITMAPINFOHEADER newBitmap; - DWORD size; + size_t size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -146,8 +146,9 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { - size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + size = tsdPtr->boxesPtr->biSize + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount) + + tsdPtr->boxesPtr->biSizeImage; newBitmap = (LPBITMAPINFOHEADER) ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; @@ -156,7 +157,7 @@ InitBoxes(void) tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) - + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount); } else { tsdPtr->boxesPtr = NULL; } @@ -433,10 +434,10 @@ TkpDisplayButton( * Display image or bitmap or text for button. */ - if (butPtr->image) { + if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; - } else if (butPtr->bitmap) { + } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } @@ -839,7 +840,7 @@ TkpComputeButtonGeometry( if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &imgWidth, &imgHeight); haveImage = 1; - } else if (butPtr->bitmap) { + } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &imgWidth, &imgHeight); haveImage = 1; diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index e94c893..1897bc8 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -631,7 +631,7 @@ XFillRectangles( TkWinDCState state; HBRUSH brush, oldBrush; - if (!d) { + if (d == None) { return BadDrawable; } @@ -641,7 +641,7 @@ XFillRectangles( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH stipple; HBITMAP oldBitmap, bitmap; @@ -756,7 +756,7 @@ RenderObject( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HDC dcMem; @@ -882,7 +882,7 @@ XDrawLines( TkWinDCState state; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -927,7 +927,7 @@ XFillPolygon( TkWinDCState state; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -969,7 +969,7 @@ XDrawRectangle( HBRUSH oldBrush; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -1085,7 +1085,7 @@ DrawOrFillArc( int xstart, ystart, xend, yend; double radian_start, radian_end, xr, yr; - if (!d) { + if (d == None) { return BadDrawable; } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 539349f..1b0d2cf 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -242,7 +242,7 @@ TkpUseWindow( */ /* - if (winPtr->window) { + if (winPtr->window != None) { Tcl_AppendResult(interp, "can't modify container after widget is created", NULL); return TCL_ERROR; @@ -298,9 +298,9 @@ TkpUseWindow( * order to avoid bug 1096074 in future. */ - char msg[260]; + char msg[256]; - sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + sprintf(msg, "Unable to get information of window \"%.79s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC); diff --git a/win/tkWinFont.c b/win/tkWinFont.c index b60a918..1292772 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -519,7 +519,7 @@ TkpGetFontFromAttributes( tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); /* @@ -631,7 +631,7 @@ TkpGetFontFamilies( Window window; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); /* @@ -1095,7 +1095,7 @@ Tk_DrawChars( fontPtr = (WinFont *) gc->font; display->request++; - if (!drawable) { + if (drawable == None) { return; } @@ -1103,14 +1103,14 @@ Tk_DrawChars( SetROP2(dc, tkpWinRopModes[gc->function]); - if (gc->clip_mask && + if ((gc->clip_mask != None) && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { SelectClipRgn(dc, (HRGN)((TkpClipMask*)gc->clip_mask)->value.region); } if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; @@ -1395,7 +1395,7 @@ InitFont( char buf[LF_FACESIZE * sizeof(WCHAR)]; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); diff --git a/win/tkWinImage.c b/win/tkWinImage.c index 8e6ef38..07aa1d3 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -348,7 +348,7 @@ XGetImageZPixmap( size = sizeof(BITMAPINFO); if (depth <= 8) { - size += sizeof(unsigned short) * (1 << depth); + size += sizeof(unsigned short) << depth; } bmInfo = (BITMAPINFO *) ckalloc((unsigned)size); diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 6240ceb..9a35266 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2345,7 +2345,7 @@ DrawMenuEntryLabel( XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y, (unsigned) width, (unsigned) height); } else if ((mePtr->image != NULL) - && menuPtr->disabledImageGC) { + && (menuPtr->disabledImageGC != None)) { XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC, leftEdge + imageXOffset, (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset), @@ -2990,7 +2990,7 @@ MenuSelectEvent( Tk_MakeWindowExist(menuPtr->tkwin); event.event = Tk_WindowId(menuPtr->tkwin); event.root = XRootWindow(menuPtr->display, 0); - event.subwindow = 0; + event.subwindow = None; event.time = TkpGetMS(); root.msgpos = GetMessagePos(); diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index 60e218d..51f0f59 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -115,7 +115,7 @@ Tk_GetPixmap( if (newTwdPtr->bitmap.handle == NULL) { ckfree((char *) newTwdPtr); - return 0; + return None; } return (Pixmap) newTwdPtr; diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index d5706ac..dcddb8f 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -387,7 +387,7 @@ XGetInputFocus( { Tk_Window tkwin = Tk_HWNDToWindow(GetFocus()); - *focus_return = tkwin ? Tk_WindowId(tkwin) : 0; + *focus_return = tkwin ? Tk_WindowId(tkwin) : None; *revert_to_return = RevertToParent; display->request++; return Success; @@ -418,7 +418,7 @@ XSetInputFocus( Time time) { display->request++; - if (focus) { + if (focus != None) { SetFocus(Tk_GetHWND(focus)); } return Success; @@ -465,7 +465,7 @@ TkpChangeFocus( } } - if (!winPtr->window) { + if (winPtr->window == None) { Tcl_Panic("ChangeXFocus got null X window"); } diff --git a/win/tkWinPort.h b/win/tkWinPort.h index aec5a66..2925dae 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -83,6 +83,11 @@ * See ticket [916c1095438eae56]: GetVersionExW triggers warnings */ #if defined(_MSC_VER) +# pragma warning(disable:4047) +# pragma warning(disable:4267) +# pragma warning(disable:4244) +# pragma warning(disable:4311) +# pragma warning(disable:4312) # pragma warning(disable:4996) #endif @@ -118,7 +123,7 @@ */ #define TkpDefineNativeBitmaps() -#define TkpCreateNativeBitmap(display, source) 0 -#define TkpGetNativeAppBitmap(display, name, w, h) 0 +#define TkpCreateNativeBitmap(display, source) None +#define TkpGetNativeAppBitmap(display, name, w, h) None #endif /* _WINPORT */ diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index f30a957..fc9685d 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -238,7 +238,7 @@ CreateProc( for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL; winPtr = winPtr->nextPtr) { - if ((winPtr->window) && !(winPtr->flags & TK_TOP_HIERARCHY)) { + if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) { TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window), Below); break; diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 0675bc6..3dfc078 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -228,7 +228,7 @@ TkpScanWindowId( if (tkwin) { *idPtr = Tk_WindowId(tkwin); } else { - *idPtr = 0; + *idPtr = None; } return TCL_OK; } @@ -259,7 +259,7 @@ TkpMakeWindow( int style; HWND hwnd; - if (parent) { + if (parent != None) { parentWin = Tk_GetHWND(parent); style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; } else { @@ -657,7 +657,7 @@ XConfigureWindow( if (valueMask & CWStackMode) { HWND sibling; - if ((valueMask & CWSibling) && values->sibling) { + if ((valueMask & CWSibling) && (values->sibling != None)) { sibling = Tk_GetHWND(values->sibling); } else { sibling = NULL; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 8e6683f..9d706fa 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -1035,7 +1035,7 @@ WinSetIcon( "\" isn't a top-level window", NULL); return TCL_ERROR; } - if (!Tk_WindowId(tkw)) { + if (Tk_WindowId(tkw) == None) { Tk_MakeWindowExist(tkw); } @@ -1198,7 +1198,7 @@ TkWinGetIcon( } } - if (!Tk_WindowId(tkwin)) { + if (Tk_WindowId(tkwin) == None) { Tk_MakeWindowExist(tkwin); } @@ -1977,11 +1977,11 @@ TkWmNewWindow( wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; - wmPtr->hints.icon_pixmap = 0; - wmPtr->hints.icon_window = 0; + wmPtr->hints.icon_pixmap = None; + wmPtr->hints.icon_window = None; wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; - wmPtr->hints.icon_mask = 0; - wmPtr->hints.window_group = 0; + wmPtr->hints.icon_mask = None; + wmPtr->hints.window_group = None; /* * Default the maximum dimensions to the size of the display. @@ -2062,7 +2062,7 @@ UpdateWrapper( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (!winPtr->window) { + if (winPtr->window == None) { /* * Ensure existence of the window to update the wrapper for. */ @@ -2683,7 +2683,7 @@ TkWmDeadWindow( VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, (ClientData) wmPtr2->winPtr); wmPtr2->masterPtr = NULL; - if (wmPtr2->wrapper + if ((wmPtr2->wrapper != None) && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { UpdateWrapper(wmPtr2->winPtr); } @@ -3474,7 +3474,7 @@ WmColormapwindowsCmd( if (winPtr2 == winPtr) { gotToplevel = 1; } - if (!winPtr2->window) { + if (winPtr2->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr2); } cmapList[i] = winPtr2; @@ -3750,7 +3750,7 @@ WmFrameCmd( Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (!Tk_WindowId((Tk_Window) winPtr)) { + if (Tk_WindowId((Tk_Window) winPtr) == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } hwnd = wmPtr->wrapper; @@ -4044,9 +4044,9 @@ WmIconbitmapCmd( string = Tcl_GetString(objv[objc-1]); if (*string == '\0') { - if (wmPtr->hints.icon_pixmap) { + if (wmPtr->hints.icon_pixmap != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); - wmPtr->hints.icon_pixmap = 0; + wmPtr->hints.icon_pixmap = None; } wmPtr->hints.flags &= ~IconPixmapHint; if (WinSetIcon(interp, NULL, (Tk_Window) useWinPtr) != TCL_OK) { @@ -4098,7 +4098,7 @@ WmIconbitmapCmd( Pixmap pixmap; Tcl_ResetResult(interp); pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string); - if (!pixmap) { + if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; @@ -4217,13 +4217,13 @@ WmIconmaskCmd( } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { - if (wmPtr->hints.icon_mask) { + if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } wmPtr->hints.flags &= ~IconMaskHint; } else { pixmap = Tk_GetBitmap(interp, tkwin, argv3); - if (!pixmap) { + if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_mask = pixmap; @@ -6388,7 +6388,7 @@ Tk_GetRootCoords( * If the window is mapped, let Windows figure out the translation. */ - if (winPtr->window) { + if (winPtr->window != None) { HWND hwnd = Tk_GetHWND(winPtr->window); POINT point; @@ -6816,7 +6816,7 @@ TkWmRestackToplevel( * (mapping it may give it a reparent window). */ - if (!winPtr->window) { + if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6826,7 +6826,7 @@ TkWmRestackToplevel( ? winPtr->wmInfoPtr->wrapper : Tk_GetHWND(winPtr->window); if (otherPtr != NULL) { - if (!otherPtr->window) { + if (otherPtr->window == None) { Tk_MakeWindowExist((Tk_Window) otherPtr); } if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6877,7 +6877,7 @@ TkWmAddToColormapWindows( TkWindow **oldPtr, **newPtr; int count, i; - if (!winPtr->window) { + if (winPtr->window == None) { return; } @@ -7312,7 +7312,7 @@ GenerateConfigureNotify( event.xconfigure.y = winPtr->changes.y; event.xconfigure.width = winPtr->changes.width; event.xconfigure.height = winPtr->changes.height; - event.xconfigure.above = 0; + event.xconfigure.above = None; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } @@ -8586,7 +8586,7 @@ TkpWinToplevelDetachWindow( SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); winPtr->flags &= ~TK_EMBEDDED; winPtr->privatePtr = NULL; - wmPtr->wrapper = 0; + wmPtr->wrapper = NULL; if (state >= 0 && state <= 3) { wmPtr->hints.initial_state = state; } diff --git a/win/tkWinX.c b/win/tkWinX.c index ce639a0..2f9565d 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -573,10 +573,10 @@ TkWinDisplayChanged( screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); - if (screen->cmap) { + if (screen->cmap != None) { XFreeColormap(display, screen->cmap); } - screen->cmap = XCreateColormap(display, 0, screen->root_visual, + screen->cmap = XCreateColormap(display, None, screen->root_visual, AllocNone); } @@ -636,7 +636,7 @@ TkpOpenDisplay( twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable)); if (twdPtr == NULL) { - return 0; + return NULL; } twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = NULL; @@ -649,7 +649,7 @@ TkpOpenDisplay( screen->white_pixel = RGB(255, 255, 255); screen->black_pixel = RGB(0, 0, 0); - screen->cmap = 0; + screen->cmap = None; display->screens = screen; display->nscreens = 1; @@ -704,10 +704,10 @@ TkpCloseDisplay( if (display->screens->root_visual != NULL) { ckfree((char *) display->screens->root_visual); } - if (display->screens->root) { + if (display->screens->root != None) { ckfree((char *) display->screens->root); } - if (display->screens->cmap) { + if (display->screens->cmap != None) { XFreeColormap(display, display->screens->cmap); } ckfree((char *) display->screens); @@ -1018,7 +1018,7 @@ GenerateXEvent( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd); - if (!winPtr || !winPtr->window) { + if (!winPtr || winPtr->window == None) { return; } @@ -1146,7 +1146,7 @@ GenerateXEvent( */ event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xbutton.subwindow = 0; + event.xbutton.subwindow = None; event.xbutton.x = clientPoint.x; event.xbutton.y = clientPoint.y; event.xbutton.x_root = root.point.x; @@ -1654,7 +1654,7 @@ HandleIMEComposition( event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xkey.subwindow = 0; + event.xkey.subwindow = None; event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 65b7240..6359891 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -453,7 +453,7 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) { Window win = Tk_WindowId(tkwin); - if (win) { + if (win != None) { elementData->hwnd = Tk_GetHWND(win); } else { elementData->hwnd = elementData->procs->stubWindow; diff --git a/xlib/X11/X.h b/xlib/X11/X.h index 316683b..b43967e 100644 --- a/xlib/X11/X.h +++ b/xlib/X11/X.h @@ -73,7 +73,9 @@ typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ -/* define None 0L See bug [9e31fd9449] and below */ +#ifndef _WIN32 +# define None 0L /* See bug [9e31fd9449] and below */ +#endif #define ParentRelative 1L /* background pixmap in CreateWindow and ChangeWindowAttributes */ @@ -179,7 +181,9 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -/* define ControlMask (1<<2) See bug [9e31fd9449] and below */ +#ifndef _WIN32 +# define ControlMask (1<<2) /* See bug [9e31fd9449] and below */ +#endif #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) @@ -187,7 +191,9 @@ are reserved in the protocol for errors and replies. */ #define Mod5Mask (1<<7) /* See bug [9e31fd9449], this way prevents conflicts with Win32 headers */ +#ifdef _WIN32 enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; +#endif /* modifier names. Used to build a SetModifierMapping request or to read a GetModifierMapping request. These correspond to the @@ -297,7 +303,7 @@ enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; /* Used in SetInputFocus, GetInputFocus */ -#define RevertToNone 0 +#define RevertToNone (int)None #define RevertToPointerRoot (int)PointerRoot #define RevertToParent 2 diff --git a/xlib/xgc.c b/xlib/xgc.c index e62f0de..a6f2611 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -50,7 +50,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; - if (!clip_mask) { + if (clip_mask == None) { clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK @@ -78,14 +78,14 @@ static TkpClipMask *AllocClipMask(GC gc) { */ static void FreeClipMask(GC gc) { - if (gc->clip_mask) { + if (gc->clip_mask != None) { #ifdef MAC_OSX_TK if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif ckfree((char*) gc->clip_mask); - gc->clip_mask = 0; + gc->clip_mask = None; } } @@ -126,7 +126,7 @@ XCreateGC( gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { - return 0; + return NULL; } #define InitField(name,maskbit,default) \ @@ -145,11 +145,11 @@ XCreateGC( InitField(fill_style, GCFillStyle, FillSolid); InitField(fill_rule, GCFillRule, WindingRule); InitField(arc_mode, GCArcMode, ArcPieSlice); - InitField(tile, GCTile, 0); - InitField(stipple, GCStipple, 0); + InitField(tile, GCTile, None); + InitField(stipple, GCStipple, None); InitField(ts_x_origin, GCTileStipXOrigin, 0); InitField(ts_y_origin, GCTileStipYOrigin, 0); - InitField(font, GCFont, 0); + InitField(font, GCFont, None); InitField(subwindow_mode, GCSubwindowMode, ClipByChildren); InitField(graphics_exposures, GCGraphicsExposures, True); InitField(clip_x_origin, GCClipXOrigin, 0); @@ -158,7 +158,7 @@ XCreateGC( InitField(dashes, GCDashList, 4); (&(gp->dashes))[1] = 0; - gp->clip_mask = 0; + gp->clip_mask = None; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); @@ -269,7 +269,7 @@ int XFreeGC( Display *d, GC gc) { - if (gc) { + if (gc != None) { FreeClipMask(gc); TkpFreeGCCache(gc); ckfree((char *) gc); @@ -465,7 +465,7 @@ TkSetRegion( GC gc, TkRegion r) { - if (!r) { + if (r == None) { Tcl_Panic("must not pass None to TkSetRegion for compatibility with X11; use XSetClipMask instead"); } else { TkpClipMask *clip_mask = AllocClipMask(gc); @@ -484,7 +484,7 @@ XSetClipMask( GC gc, Pixmap pixmap) { - if (!pixmap) { + if (pixmap == None) { FreeClipMask(gc); } else { TkpClipMask *clip_mask = AllocClipMask(gc); diff --git a/xlib/ximage.c b/xlib/ximage.c index f7bf1cc..aaab946 100644 --- a/xlib/ximage.c +++ b/xlib/ximage.c @@ -47,7 +47,7 @@ XCreateBitmapFromData( pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1); gc = XCreateGC(display, pix, 0, NULL); if (gc == NULL) { - return 0; + return None; } ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width, height, 8, (width + 7) / 8); -- cgit v0.12 From 19864dca1d60859c5428554215450a8e7e54f947 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:08:14 +0000 Subject: Let's see if we can build something with Travis-CI --- .travis.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2095d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +sudo: required +language: c +addons: + apt: + packages: + - tcl-dev + - libx11-dev +matrix: + include: + - os: linux + dist: trusty + compiler: clang + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: clang + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-4.9 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-5 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-7 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - BUILD_DIR=unix +before_install: + - export ERROR_ON_FAILURES=1 + - cd ${BUILD_DIR} +install: + - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT} +script: + - make + # The styles=develop avoids some weird problems on OSX + #- test -n "$NO_DIRECT_TEST" || make test styles=develop -- cgit v0.12 From 7e88cb3d95e4e109025330d5a72cc2710e9944d9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:09:14 +0000 Subject: Fix bug [b2dd3b4fe8] (text-11a.41 sometimes hangs) by reworking how the <> event is handled. --- generic/tkText.c | 11 ++- generic/tkText.h | 4 +- generic/tkTextDisp.c | 77 +++++++++++++----- tests/text.test | 221 +++++++++++++++++++++++++++------------------------ 4 files changed, 179 insertions(+), 134 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 4c536a2..3d9977f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, static void GenerateModifiedEvent(TkText *textPtr); static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); -static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, Tcl_Obj *undoString, int insert, const TkTextIndex *index1Ptr, @@ -1547,7 +1546,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -1559,7 +1558,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, + TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; } @@ -5506,7 +5505,7 @@ UpdateDirtyFlag( /* *---------------------------------------------------------------------- * - * RunAfterSyncCmd -- + * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. @@ -5520,8 +5519,8 @@ UpdateDirtyFlag( *---------------------------------------------------------------------- */ -static void -RunAfterSyncCmd( +void +TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { register TkText *textPtr = (TkText *) clientData; diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..4703703 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1070,7 +1070,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, TkTextIndex *indexPtr); -MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, +MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *objPtr); MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *stringPtr); @@ -1159,7 +1159,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); - +MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 8d60754..5903dfb 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -497,13 +497,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -681,7 +683,7 @@ TkTextCreateDInfo( dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = 0; dInfoPtr->dLinesInvalidated = 0; - dInfoPtr->flags = DINFO_OUT_OF_DATE; + dInfoPtr->flags = 0; dInfoPtr->topPixelOffset = 0; dInfoPtr->newTopPixelOffset = 0; dInfoPtr->currentMetricUpdateLine = -1; @@ -3070,10 +3072,13 @@ AsyncUpdateLineMetrics( * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. + * Cancel any pending idle task which would try to run the command + * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); @@ -3091,7 +3096,6 @@ AsyncUpdateLineMetrics( * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ - GenerateWidgetViewSyncEvent(textPtr, 1); if (textPtr->refCount-- <= 1) { @@ -3115,8 +3119,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkText structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3132,9 +3142,12 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( - TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* true if in sync, false otherwise */ + TkText *textPtr, /* Information about text widget. */ + Bool InSync) /* true if becoming in sync, false otherwise */ { + Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC); + /* * OSX 10.14 needs to be told to display the window when the Text Widget * is in sync. (That is, to run DisplayText inside of the drawRect @@ -3147,8 +3160,15 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (NewSyncState != OldSyncState) { + if (NewSyncState) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(NewSyncState)); + } } /* @@ -3191,6 +3211,9 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); + int fullUpdateRequested = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); if (totalLines == 0) { /* @@ -3201,6 +3224,7 @@ TkTextUpdateLineMetrics( } while (1) { + /* * Get a suitable line. */ @@ -3227,6 +3251,7 @@ TkTextUpdateLineMetrics( */ if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) { + /* * We have looped over all lines, so we're done. */ @@ -3250,10 +3275,12 @@ TkTextUpdateLineMetrics( if (TkBTreeLinePixelEpoch(textPtr, linePtr) == textPtr->dInfoPtr->lineMetricUpdateEpoch) { + /* * This line is already up to date. That means there's nothing * to do here. */ + } else if (doThisMuch == -1) { count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0); } else { @@ -3275,6 +3302,7 @@ TkTextUpdateLineMetrics( indexPtr = &textPtr->dInfoPtr->metricIndex; pixelHeight = textPtr->dInfoPtr->metricPixelHeight; } else { + /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. @@ -3298,6 +3326,7 @@ TkTextUpdateLineMetrics( pixelHeight, indexPtr, 1); if (indexPtr->linePtr == linePtr) { + /* * We didn't complete the logical line, because it * produced very many display lines, which must be because @@ -3306,6 +3335,7 @@ TkTextUpdateLineMetrics( */ if (pixelHeight == 0) { + /* * These have already been stored, unless we just * started the new line. @@ -3327,6 +3357,7 @@ TkTextUpdateLineMetrics( textPtr->dInfoPtr->metricEpoch = -1; } } else { + /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will @@ -3351,13 +3382,21 @@ TkTextUpdateLineMetrics( } } if (doThisMuch == -1) { + /* - * If we were requested to provide a full update, then also update the - * scrollbar. + * If we were requested to update the entire range, then also update + * the scrollbar. */ GetYView(textPtr->interp, textPtr, 1); } + if (fullUpdateRequested) { + TextDInfo *dInfoPtr = textPtr->dInfoPtr; + + dInfoPtr->lastMetricUpdateLine = lineNum; + dInfoPtr->currentMetricUpdateLine = lineNum; + GenerateWidgetViewSyncEvent(textPtr, 1); + } return lineNum; } @@ -3526,8 +3565,12 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); } + + /* + * The widget is out of sync: send a <> event. + */ + GenerateWidgetViewSyncEvent(textPtr, 0); } /* @@ -5269,9 +5312,7 @@ TkTextRelayoutWindow( inSync = 0; } - if (!inSync) { - GenerateWidgetViewSyncEvent(textPtr, 0); - } + GenerateWidgetViewSyncEvent(textPtr, inSync); } } @@ -6296,11 +6337,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return ( - (!(dInfoPtr->flags & REDRAW_PENDING) && - (dInfoPtr->metricEpoch == -1) && - (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? - 0 : 1); + return ((dInfoPtr->flags & OUT_OF_SYNC) != 0); } /* diff --git a/tests/text.test b/tests/text.test index 988417e..aaddc2c 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2936,11 +2936,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -2978,9 +2980,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3053,19 +3057,18 @@ test text-11a.31 {"<>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <> events before binding. + .top.yt sync update bind .top.yt <> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3079,7 +3082,6 @@ test text-11a.31 {"<>" event} -setup { test text-11a.41 {"sync" "pendingsync" and <>} -setup { destroy .top.yt .top } -body { - set res {} toplevel .top pack [text .top.yt] update @@ -3087,15 +3089,21 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } + # Sync the widget and process all <> events before binding. + .top.yt sync + update bind .top.yt <> {lappend res Sync:%d} + set res {} + # The next line triggers <> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content - vwait res ; # event dealt with by the event loop, with %d==0 i.e. we're out of sync - # ensure the test is relevant + vwait res + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # - <> fires when sync returns if there was pending syncs - # - there is no more any pending sync after running 'sync' + # Update all line metrics by calling the sync command. .top.yt sync - vwait res ; # event dealt with by the event loop, with %d==1 i.e. we're in sync again + # <> should fire with %d==1 i.e. back in sync. + vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3110,6 +3118,7 @@ test text-11a.51 {<> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } @@ -7356,6 +7365,100 @@ test text-32.1 {line heights on creation} -setup { destroy .t } -result {1} +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7488,100 +7591,6 @@ test text-34.1 {peer widget -start, -end and selection} -setup { destroy .t } -result {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}} -test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result {1} - -test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { #puts "KK: $key, $value" -- cgit v0.12 From 9997531222f9a5ea6e8da18ca5eb0241f06c0c61 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:14:00 +0000 Subject: Remove 3 lines of code in tkTextDisp.c which had become obsolete but were accidentally left in the file. --- generic/tkTextDisp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 5903dfb..356e8b7 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3391,10 +3391,6 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } if (fullUpdateRequested) { - TextDInfo *dInfoPtr = textPtr->dInfoPtr; - - dInfoPtr->lastMetricUpdateLine = lineNum; - dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); } return lineNum; -- cgit v0.12 From 4fff34682702364b64cbc5aaa430f811d31204ff Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:26:41 +0000 Subject: Let's see if we can build something with Travis-CI --- .travis.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2095d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +sudo: required +language: c +addons: + apt: + packages: + - tcl-dev + - libx11-dev +matrix: + include: + - os: linux + dist: trusty + compiler: clang + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: clang + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-4.9 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-5 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-7 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - BUILD_DIR=unix +before_install: + - export ERROR_ON_FAILURES=1 + - cd ${BUILD_DIR} +install: + - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT} +script: + - make + # The styles=develop avoids some weird problems on OSX + #- test -n "$NO_DIRECT_TEST" || make test styles=develop -- cgit v0.12 From 22f0e0114d35f2b30c12a9937d64bd95b51ece6c Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:29:38 +0000 Subject: Fix bug [b2dd3b4fe8] (text-11a.41 sometimes hangs) by reworking how the <> event is handled. --- generic/tkText.c | 11 ++- generic/tkText.h | 4 +- generic/tkTextDisp.c | 77 +++++++++++++----- tests/text.test | 221 +++++++++++++++++++++++++++------------------------ 4 files changed, 179 insertions(+), 134 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 280eec8..b0aec04 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, static void GenerateModifiedEvent(TkText *textPtr); static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); -static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, Tcl_Obj *undoString, int insert, const TkTextIndex *index1Ptr, @@ -1544,7 +1543,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -1556,7 +1555,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, + TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; } @@ -5587,7 +5586,7 @@ UpdateDirtyFlag( /* *---------------------------------------------------------------------- * - * RunAfterSyncCmd -- + * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. @@ -5601,8 +5600,8 @@ UpdateDirtyFlag( *---------------------------------------------------------------------- */ -static void -RunAfterSyncCmd( +void +TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { register TkText *textPtr = clientData; diff --git a/generic/tkText.h b/generic/tkText.h index 5e84fd5..8bdb193 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1080,7 +1080,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, TkTextIndex *indexPtr); -MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, +MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *objPtr); MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *stringPtr); @@ -1169,7 +1169,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); - +MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 0ad9ead..e1b4987 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -491,13 +491,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -675,7 +677,7 @@ TkTextCreateDInfo( dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = 0; dInfoPtr->dLinesInvalidated = 0; - dInfoPtr->flags = DINFO_OUT_OF_DATE; + dInfoPtr->flags = 0; dInfoPtr->topPixelOffset = 0; dInfoPtr->newTopPixelOffset = 0; dInfoPtr->currentMetricUpdateLine = -1; @@ -3063,10 +3065,13 @@ AsyncUpdateLineMetrics( * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. + * Cancel any pending idle task which would try to run the command + * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); @@ -3084,7 +3089,6 @@ AsyncUpdateLineMetrics( * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ - GenerateWidgetViewSyncEvent(textPtr, 1); if (textPtr->refCount-- <= 1) { @@ -3108,8 +3112,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkText structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3125,9 +3135,12 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( - TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* true if in sync, false otherwise */ + TkText *textPtr, /* Information about text widget. */ + Bool InSync) /* true if becoming in sync, false otherwise */ { + Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC); + /* * OSX 10.14 needs to be told to display the window when the Text Widget * is in sync. (That is, to run DisplayText inside of the drawRect @@ -3140,8 +3153,15 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (NewSyncState != OldSyncState) { + if (NewSyncState) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(NewSyncState)); + } } /* @@ -3184,6 +3204,9 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); + int fullUpdateRequested = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); if (totalLines == 0) { /* @@ -3194,6 +3217,7 @@ TkTextUpdateLineMetrics( } while (1) { + /* * Get a suitable line. */ @@ -3220,6 +3244,7 @@ TkTextUpdateLineMetrics( */ if (textPtr->dInfoPtr->metricEpoch == TCL_AUTO_LENGTH && lineNum == endLine) { + /* * We have looped over all lines, so we're done. */ @@ -3243,10 +3268,12 @@ TkTextUpdateLineMetrics( if (TkBTreeLinePixelEpoch(textPtr, linePtr) == textPtr->dInfoPtr->lineMetricUpdateEpoch) { + /* * This line is already up to date. That means there's nothing * to do here. */ + } else if (doThisMuch == -1) { count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0); } else { @@ -3268,6 +3295,7 @@ TkTextUpdateLineMetrics( indexPtr = &textPtr->dInfoPtr->metricIndex; pixelHeight = textPtr->dInfoPtr->metricPixelHeight; } else { + /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. @@ -3291,6 +3319,7 @@ TkTextUpdateLineMetrics( pixelHeight, indexPtr, 1); if (indexPtr->linePtr == linePtr) { + /* * We didn't complete the logical line, because it * produced very many display lines, which must be because @@ -3299,6 +3328,7 @@ TkTextUpdateLineMetrics( */ if (pixelHeight == 0) { + /* * These have already been stored, unless we just * started the new line. @@ -3320,6 +3350,7 @@ TkTextUpdateLineMetrics( textPtr->dInfoPtr->metricEpoch = -1; } } else { + /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will @@ -3344,13 +3375,21 @@ TkTextUpdateLineMetrics( } } if (doThisMuch == -1) { + /* - * If we were requested to provide a full update, then also update the - * scrollbar. + * If we were requested to update the entire range, then also update + * the scrollbar. */ GetYView(textPtr->interp, textPtr, 1); } + if (fullUpdateRequested) { + TextDInfo *dInfoPtr = textPtr->dInfoPtr; + + dInfoPtr->lastMetricUpdateLine = lineNum; + dInfoPtr->currentMetricUpdateLine = lineNum; + GenerateWidgetViewSyncEvent(textPtr, 1); + } return lineNum; } @@ -3519,8 +3558,12 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); } + + /* + * The widget is out of sync: send a <> event. + */ + GenerateWidgetViewSyncEvent(textPtr, 0); } /* @@ -5262,9 +5305,7 @@ TkTextRelayoutWindow( inSync = 0; } - if (!inSync) { - GenerateWidgetViewSyncEvent(textPtr, 0); - } + GenerateWidgetViewSyncEvent(textPtr, inSync); } } @@ -6289,11 +6330,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return ( - (!(dInfoPtr->flags & REDRAW_PENDING) && - (dInfoPtr->metricEpoch == TCL_AUTO_LENGTH) && - (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? - 0 : 1); + return ((dInfoPtr->flags & OUT_OF_SYNC) != 0); } /* diff --git a/tests/text.test b/tests/text.test index 621a9eb..c79d818 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2948,11 +2948,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -2990,9 +2992,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3065,19 +3069,18 @@ test text-11a.31 {"<>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <> events before binding. + .top.yt sync update bind .top.yt <> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3091,7 +3094,6 @@ test text-11a.31 {"<>" event} -setup { test text-11a.41 {"sync" "pendingsync" and <>} -setup { destroy .top.yt .top } -body { - set res {} toplevel .top pack [text .top.yt] update @@ -3099,15 +3101,21 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } + # Sync the widget and process all <> events before binding. + .top.yt sync + update bind .top.yt <> {lappend res Sync:%d} + set res {} + # The next line triggers <> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content - vwait res ; # event dealt with by the event loop, with %d==0 i.e. we're out of sync - # ensure the test is relevant + vwait res + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # - <> fires when sync returns if there was pending syncs - # - there is no more any pending sync after running 'sync' + # Update all line metrics by calling the sync command. .top.yt sync - vwait res ; # event dealt with by the event loop, with %d==1 i.e. we're in sync again + # <> should fire with %d==1 i.e. back in sync. + vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3122,6 +3130,7 @@ test text-11a.51 {<> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } @@ -7429,6 +7438,100 @@ test text-32.1 {line heights on creation} -setup { destroy .t } -result {1} +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7561,100 +7664,6 @@ test text-34.1 {peer widget -start, -end and selection} -setup { destroy .t } -result {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}} -test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result {1} - -test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { #puts "KK: $key, $value" -- cgit v0.12 From b30dbf0b32451060c56d0c58f2d5c908c55f402f Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:30:51 +0000 Subject: Remove 3 lines of code in tkTextDisp.c which had become obsolete but were accidentally left in the file. --- generic/tkTextDisp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index e1b4987..5dd0532 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3384,10 +3384,6 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } if (fullUpdateRequested) { - TextDInfo *dInfoPtr = textPtr->dInfoPtr; - - dInfoPtr->lastMetricUpdateLine = lineNum; - dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); } return lineNum; -- cgit v0.12 From 726546cf2742672ce6de89b0500b3e750c6fe3b7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Jan 2019 22:41:10 +0000 Subject: Fix a few minor compiler warnings, occurring in later gcc/clang versions. --- generic/tkEntry.h | 2 +- generic/tkScale.h | 2 +- macosx/tkMacOSXXStubs.c | 2 +- win/tkWinButton.c | 9 +++++---- win/tkWinEmbed.c | 2 +- win/tkWinImage.c | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 7f8aa1f..2ea7936 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkScale.h b/generic/tkScale.h index a2c5f2b..a19695f 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[16]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index e928298..a541945 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -1371,7 +1371,7 @@ void Tk_ResetUserInactiveTime( Display *dpy) { - IOGPoint loc; + IOGPoint loc = {0}; kern_return_t kr; NXEvent nullEvent = {NX_NULLEVENT, {0, 0}, 0, -1, 0}; enum { kNULLEventPostThrottle = 10 }; diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 9e1960d..c36932d 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -127,7 +127,7 @@ InitBoxes(void) HRSRC hrsrc; HGLOBAL hblk; LPBITMAPINFOHEADER newBitmap; - DWORD size; + size_t size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -146,8 +146,9 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { - size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + size = tsdPtr->boxesPtr->biSize + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount) + + tsdPtr->boxesPtr->biSizeImage; newBitmap = (LPBITMAPINFOHEADER) ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; @@ -156,7 +157,7 @@ InitBoxes(void) tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) - + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount); } else { tsdPtr->boxesPtr = NULL; } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index a0670cc..1b0d2cf 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -300,7 +300,7 @@ TkpUseWindow( char msg[256]; - sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + sprintf(msg, "Unable to get information of window \"%.79s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC); diff --git a/win/tkWinImage.c b/win/tkWinImage.c index 8e6ef38..07aa1d3 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -348,7 +348,7 @@ XGetImageZPixmap( size = sizeof(BITMAPINFO); if (depth <= 8) { - size += sizeof(unsigned short) * (1 << depth); + size += sizeof(unsigned short) << depth; } bmInfo = (BITMAPINFO *) ckalloc((unsigned)size); -- cgit v0.12 From 0ff9be54ab18ebef3aecc29024da14d34940d45a Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 5 Jan 2019 17:00:15 +0000 Subject: Implement local grabs for Aqua. --- generic/tkGrab.c | 7 +------ macosx/tkMacOSXKeyEvent.c | 23 ++++++++++++++++------- macosx/tkMacOSXMouseEvent.c | 27 ++++++++++++++++++--------- 3 files changed, 35 insertions(+), 22 deletions(-) diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 00d4511..5ea2906 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -426,12 +426,7 @@ Tk_Grab( } Tk_MakeWindowExist(tkwin); -#ifndef MAC_OSX_TK - if (!grabGlobal) -#else - if (0) -#endif /* MAC_OSX_TK */ - { + if (!grabGlobal) { Window dummy1, dummy2; int dummy3, dummy4, dummy5, dummy6; unsigned int state; diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index a153797..3327f0a 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -139,18 +139,26 @@ unsigned short releaseCode; } /* - * The focus must be in the FrontWindow on the Macintosh. We then query Tk - * to determine the exact Tk window that owns the focus. + * Events are only received for the front Window on the Macintosh. + * So to build an XEvent we look up the Tk window associated to the + * Front window. If a different window has a local grab we ignore + * the event. */ TkWindow *winPtr = TkMacOSXGetTkWindow(w); Tk_Window tkwin = (Tk_Window) winPtr; - if (!tkwin) { - TkMacOSXDbgMsg("tkwin == NULL"); - return theEvent; - } - tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + if (tkwin) { + TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && + grabWinPtr != winPtr && + !winPtr->dispPtr->grabFlags && /* this means the grab is local. */ + grabWinPtr->mainPtr == winPtr->mainPtr) { + return theEvent; + } + } else { + tkwin = (Tk_Window) winPtr->dispPtr->focusPtr; + } if (!tkwin) { TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; /* Give up. No window for this event. */ @@ -160,6 +168,7 @@ unsigned short releaseCode; * If it's a function key, or we have modifiers other than Shift or Alt, * pass it straight to Tk. Otherwise we'll send for input processing. */ + int code = (len == 0) ? 0 : [charactersIgnoringModifiers characterAtIndex: 0]; if (type != NSKeyDown || isFunctionKey(code) diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 828d874..f02df1d 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -106,23 +106,32 @@ enum { } } - Window window = TkMacOSXGetXWindow(eventWindow); - Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display, - window) : NULL; - if (!tkwin) { + TkWindow *winPtr = TkMacOSXGetTkWindow(eventWindow); + Tk_Window tkwin = (Tk_Window) winPtr; + + if (tkwin) { + TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr; + if (grabWinPtr && + grabWinPtr != winPtr && + !winPtr->dispPtr->grabFlags && /* this means the grab is local. */ + grabWinPtr->mainPtr == winPtr->mainPtr) { + return theEvent; + } + } else { tkwin = TkMacOSXGetCapture(); } if (!tkwin) { + TkMacOSXDbgMsg("tkwin == NULL"); return theEvent; /* Give up. No window for this event. */ - } - - TkWindow *winPtr = (TkWindow *) tkwin; + } else { + winPtr = (TkWindow *)tkwin; + } + local.x -= winPtr->wmInfoPtr->xInParent; local.y -= winPtr->wmInfoPtr->yInParent; int win_x, win_y; - tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, - &win_x, &win_y); + tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y); unsigned int state = 0; NSInteger button = [theEvent buttonNumber]; -- cgit v0.12 From 1615a89ab7456071e1091399dbe169c8f1d7d757 Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 5 Jan 2019 19:34:32 +0000 Subject: Document the behavior of local and global grabs on macOS. --- doc/grab.n | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/grab.n b/doc/grab.n index a6d0d19..c45e26a 100644 --- a/doc/grab.n +++ b/doc/grab.n @@ -61,6 +61,16 @@ The \fBfocus\fR command is still used to determine which window in the application receives the keyboard events. The keyboard grab is released when the grab is released. .PP +On macOS a global grab affects all windows created by one Tk process. +No window in that process other than the grab window can even be +focused, hence no other window receives key or mouse events. A local +grab on macOS affects all windows created by one Tcl interpreter. It +is possible to focus any window belonging to the Tk process during a +local grab but the grab window is the only window created by its +interpreter which receives key or mouse events. Windows belonging to the +same process but created by different interpreters continue to receive +key and mouse events normally. +.PP Grabs apply to particular displays. If an application has windows on multiple displays then it can establish a separate grab on each display. -- cgit v0.12 From 79864b3cecd15cecaaeeded2d301de7b1d96511c Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 5 Jan 2019 20:55:12 +0000 Subject: Fix [3003895fff] and [1899040fff]: TkRoundToResolution doesn't account for -from --- generic/tkScale.c | 56 ++++++++++++++++++++++++++++++++++-------------------- generic/tkScale.h | 3 ++- tests/scale.test | 46 ++++++++++++++++++++++++++++++++------------ unix/tkUnixScale.c | 8 ++++---- 4 files changed, 75 insertions(+), 38 deletions(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index af45afa..547f698 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -611,7 +611,7 @@ ConfigureScale( TCL_GLOBAL_ONLY); if ((valuePtr != NULL) && (Tcl_GetDoubleFromObj(NULL, valuePtr, &value) == TCL_OK)) { - scalePtr->value = TkRoundToResolution(scalePtr, value); + scalePtr->value = TkRoundValueToResolution(scalePtr, value); } } @@ -620,10 +620,10 @@ ConfigureScale( * orientation and creating GCs. */ - scalePtr->fromValue = TkRoundToResolution(scalePtr, + scalePtr->fromValue = TkRoundValueToResolution(scalePtr, scalePtr->fromValue); - scalePtr->toValue = TkRoundToResolution(scalePtr, scalePtr->toValue); - scalePtr->tickInterval = TkRoundToResolution(scalePtr, + scalePtr->toValue = TkRoundValueToResolution(scalePtr, scalePtr->toValue); + scalePtr->tickInterval = TkRoundIntervalToResolution(scalePtr, scalePtr->tickInterval); /* @@ -1119,10 +1119,14 @@ TkEventuallyRedrawScale( /* *-------------------------------------------------------------- * - * TkRoundToResolution -- + * TkRoundValueToResolution, TkRoundIntervalToResolution -- * * Round a given floating-point value to the nearest multiple of the * scale's resolution. + * TkRoundValueToResolution rounds an absolute value based on the from + * value as a reference. + * TkRoundIntervalToResolution rounds a relative value without + * reference, i.e. it rounds an interval. * * Results: * The return value is the rounded result. @@ -1134,28 +1138,38 @@ TkEventuallyRedrawScale( */ double -TkRoundToResolution( +TkRoundValueToResolution( TkScale *scalePtr, /* Information about scale widget. */ double value) /* Value to round. */ { - double rem, rounded, tick; + double rem, start; if (scalePtr->resolution <= 0) { return value; } - tick = floor(value/scalePtr->resolution); - rounded = scalePtr->resolution * tick; - rem = value - rounded; + start = fmod(scalePtr->fromValue, scalePtr->resolution); + rem = fmod(value - start + scalePtr->resolution/2, scalePtr->resolution); if (rem < 0) { - if (rem <= -scalePtr->resolution/2) { - rounded = (tick - 1.0) * scalePtr->resolution; - } - } else { - if (rem >= scalePtr->resolution/2) { - rounded = (tick + 1.0) * scalePtr->resolution; - } + rem += scalePtr->resolution; + } + return value + scalePtr->resolution/2 - rem; +} + +double +TkRoundIntervalToResolution( + TkScale *scalePtr, /* Information about scale widget. */ + double value) /* Value to round. */ +{ + double rem; + + if (scalePtr->resolution <= 0) { + return value; + } + rem = fmod(value + scalePtr->resolution/2, scalePtr->resolution); + if (rem < 0) { + rem += scalePtr->resolution; } - return rounded; + return value + scalePtr->resolution/2 - rem; } /* @@ -1238,7 +1252,7 @@ ScaleVarProc( resultStr = "can't assign non-numeric value to scale variable"; ScaleSetVariable(scalePtr); } else { - scalePtr->value = TkRoundToResolution(scalePtr, value); + scalePtr->value = TkRoundValueToResolution(scalePtr, value); /* * This code is a bit tricky because it sets the scale's value before @@ -1282,7 +1296,7 @@ TkScaleSetValue( int invokeCommand) /* Non-zero means invoked -command option to * notify of new value, 0 means don't. */ { - value = TkRoundToResolution(scalePtr, value); + value = TkRoundValueToResolution(scalePtr, value); if ((value < scalePtr->fromValue) ^ (scalePtr->toValue < scalePtr->fromValue)) { value = scalePtr->fromValue; @@ -1402,7 +1416,7 @@ TkScalePixelToValue( } value = scalePtr->fromValue + value * (scalePtr->toValue - scalePtr->fromValue); - return TkRoundToResolution(scalePtr, value); + return TkRoundValueToResolution(scalePtr, value); } /* diff --git a/generic/tkScale.h b/generic/tkScale.h index aa0feff..6756e73 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -219,7 +219,8 @@ typedef struct TkScale { */ MODULE_SCOPE void TkEventuallyRedrawScale(TkScale *scalePtr, int what); -MODULE_SCOPE double TkRoundToResolution(TkScale *scalePtr, double value); +MODULE_SCOPE double TkRoundValueToResolution(TkScale *scalePtr, double value); +MODULE_SCOPE double TkRoundIntervalToResolution(TkScale *scalePtr, double value); MODULE_SCOPE TkScale * TkpCreateScale(Tk_Window tkwin); MODULE_SCOPE void TkpDestroyScale(TkScale *scalePtr); MODULE_SCOPE void TkpDisplayScale(ClientData clientData); diff --git a/tests/scale.test b/tests/scale.test index 79524eb..6344eef 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -1104,78 +1104,78 @@ test scale-13.6 {SetScaleValue procedure} -body { destroy .s pack [scale .s] update -test scale-14.1 {RoundToResolution procedure} -body { +test scale-14.1 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 84 152 } -result 72 -test scale-14.2 {RoundToResolution procedure} -body { +test scale-14.2 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 } -result 76 -test scale-14.3 {RoundToResolution procedure} -body { +test scale-14.3 {RoundValueToResolution procedure} -body { .s configure -from 100 -to 0 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 84 152 } -result 28 -test scale-14.4 {RoundToResolution procedure} -body { +test scale-14.4 {RoundValueToResolution procedure} -body { .s configure -from 100 -to 0 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 } -result 24 -test scale-14.5 {RoundToResolution procedure} -body { +test scale-14.5 {RoundValueToResolution procedure} -body { .s configure -from -100 -to 0 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 84 152 } -result {-28} -test scale-14.6 {RoundToResolution procedure} -body { +test scale-14.6 {RoundValueToResolution procedure} -body { .s configure -from -100 -to 0 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 } -result {-24} -test scale-14.7 {RoundToResolution procedure} -body { +test scale-14.7 {RoundValueToResolution procedure} -body { .s configure -from 0 -to -100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 84 152 } -result {-72} -test scale-14.8 {RoundToResolution procedure} -body { +test scale-14.8 {RoundValueToResolution procedure} -body { .s configure -from 0 -to -100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 } -result {-76} -test scale-14.9 {RoundToResolution procedure} -body { +test scale-14.9 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 2.25 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 0 update .s get 84 152 } -result {1.64} -test scale-14.10 {RoundToResolution procedure} -body { +test scale-14.10 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 2.25 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 0 update .s get 86 152 } -result {1.69} -test scale-14.11 {RoundToResolution procedure} -body { +test scale-14.11 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 225 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 0 -digits 5 update .s get 84 152 } -result {164.25} -test scale-14.12 {RoundToResolution procedure} -body { +test scale-14.12 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 225 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 0 -digits 5 update @@ -1183,6 +1183,28 @@ test scale-14.12 {RoundToResolution procedure} -body { } -result {168.75} destroy .s +test scale-14a.1 {RoundValueToResolution, RoundIntervalToResolution procedures} -setup { + pack [scale .s -orient horizontal] + update +} -body { + .s configure -length 400 -bd 0 -from 1 -to 9 -resolution 2 -tickinterval 1 + update + .s get 200 0 +} -cleanup { + destroy .s +} -result {5} +test scale-14a.2 {RoundValueToResolution, RoundIntervalToResolution procedures} -setup { + pack [scale .s -orient horizontal] + update +} -body { + .s configure -length 400 -bd 0 -from -1.5 -to 1.5 -resolution 1 \ + -tickinterval 1 -digits 2 + update + .s get 250 0 +} -cleanup { + destroy .s +} -result {0.5} + test scale-15.1 {ScaleVarProc procedure} -setup { deleteWindows diff --git a/unix/tkUnixScale.c b/unix/tkUnixScale.c index 8f88018..2009288 100644 --- a/unix/tkUnixScale.c +++ b/unix/tkUnixScale.c @@ -150,11 +150,11 @@ DisplayVerticalScale( for (tickValue = scalePtr->fromValue; ; tickValue += tickInterval) { /* - * The TkRoundToResolution call gets rid of accumulated + * The TkRoundValueToResolution call gets rid of accumulated * round-off errors, if any. */ - tickValue = TkRoundToResolution(scalePtr, tickValue); + tickValue = TkRoundValueToResolution(scalePtr, tickValue); if (scalePtr->toValue >= scalePtr->fromValue) { if (tickValue > scalePtr->toValue) { break; @@ -370,11 +370,11 @@ DisplayHorizontalScale( for (tickValue = scalePtr->fromValue; ; tickValue += tickInterval) { /* - * The TkRoundToResolution call gets rid of accumulated + * The TkRoundValueToResolution call gets rid of accumulated * round-off errors, if any. */ - tickValue = TkRoundToResolution(scalePtr, tickValue); + tickValue = TkRoundValueToResolution(scalePtr, tickValue); if (scalePtr->toValue >= scalePtr->fromValue) { if (tickValue > scalePtr->toValue) { break; -- cgit v0.12 From 4461111c77163d5fad79721108a7d52f83ed3e49 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 8 Jan 2019 22:53:29 +0000 Subject: Update the demos to give a more complete explanation of local and global grabs. --- library/demos/dialog1.tcl | 14 +++++++++++++- library/demos/dialog2.tcl | 3 ++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/library/demos/dialog1.tcl b/library/demos/dialog1.tcl index 5c572be..976e955 100644 --- a/library/demos/dialog1.tcl +++ b/library/demos/dialog1.tcl @@ -2,8 +2,16 @@ # # This demonstration script creates a dialog box with a local grab. +interp create slave +load {} Tk slave +slave eval { + wm title . slave + wm geometry . +700+30 + pack [text .t -width 30 -height 10] +} + after idle {.dialog1.msg configure -wraplength 4i} -set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any pointer-related events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications.} \ +set i [tk_dialog .dialog1 "Dialog with local grab" {This is a modal dialog box. It uses Tk's "grab" command to create a "local grab" on the dialog box. The grab prevents any mouse or keyboard events from getting to any other windows in the application until you have answered the dialog by invoking one of the buttons below. However, you can still interact with other applications. For example, you should be able to edit text in the window named "slave" which was created by a slave interpreter.} \ info 0 OK Cancel {Show Code}] switch $i { @@ -11,3 +19,7 @@ switch $i { 1 {puts "You pressed Cancel"} 2 {showCode .dialog1} } + +if {[interp exists slave]} { + interp delete slave +} diff --git a/library/demos/dialog2.tcl b/library/demos/dialog2.tcl index 2f45da8..6ae27a8 100644 --- a/library/demos/dialog2.tcl +++ b/library/demos/dialog2.tcl @@ -8,7 +8,8 @@ after idle { after 100 { grab -global .dialog2 } -set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab, so it prevents you from interacting with anything on your display until you invoke one of the buttons below. Global grabs are almost always a bad idea; don't use them unless you're truly desperate.} warning 0 OK Cancel {Show Code}] +set i [tk_dialog .dialog2 "Dialog with global grab" {This dialog box uses a global grab. If you are using an X11 window manager you will be prevented from interacting with anything on your display until you invoke one of the buttons below. This is almost always a bad idea; don't use global grabs with X11 unless you're truly desperate. On macOS systems you will not be able to interact with any window belonging to this process, but interaction with other macOS Applications will still be possible.}\ +warning 0 OK Cancel {Show Code}] switch $i { 0 {puts "You pressed OK"} -- cgit v0.12 From d155557faa7d1e039c912fc21ffccaf160c26b8e Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 9 Jan 2019 14:28:09 +0000 Subject: Fix bug [70e531918e]: geometry issues with menubuttons on macOS --- library/menu.tcl | 19 +++- macosx/tkMacOSXDefault.h | 8 +- macosx/tkMacOSXMenu.c | 55 ++++-------- macosx/tkMacOSXMenubutton.c | 208 +++++++++++++++++++------------------------- tests/menubut.test | 26 +++--- 5 files changed, 142 insertions(+), 174 deletions(-) diff --git a/library/menu.tcl b/library/menu.tcl index ba66b92..a406ae3 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -274,8 +274,13 @@ proc ::tk::MbPost {w {x {}} {y {}}} { if {[tk windowingsystem] ne "aqua"} { set Priv(relief) [$w cget -relief] $w configure -relief raised + set xoffset {0 0 0 0 0} + set yoffset {0 0 0 0 0} } else { $w configure -state active + # Compensate for offsets created by the macOS window manager. + set xoffset {9 9 18 9 0} + set yoffset {6 13 13 13 9} } set Priv(postedMb) $w @@ -291,22 +296,26 @@ proc ::tk::MbPost {w {x {}} {y {}}} { if {[catch { switch [$w cget -direction] { above { - set x [winfo rootx $w] + set x [expr {[winfo rootx $w]}] set y [expr {[winfo rooty $w] - [winfo reqheight $menu]}] # if we go offscreen to the top, show as 'below' if {$y < [winfo vrooty $w]} { set y [expr {[winfo vrooty $w] + [winfo rooty $w] + [winfo reqheight $w]}] } + incr x [lindex $xoffset 0] + incr y [lindex $yoffset 0] PostOverPoint $menu $x $y } below { - set x [winfo rootx $w] + set x [expr {[winfo rootx $w]}] set y [expr {[winfo rooty $w] + [winfo height $w]}] # if we go offscreen to the bottom, show as 'above' set mh [winfo reqheight $menu] if {($y + $mh) > ([winfo vrooty $w] + [winfo vrootheight $w])} { set y [expr {[winfo vrooty $w] + [winfo vrootheight $w] + [winfo rooty $w] - $mh}] } + incr x [lindex $xoffset 1] + incr y [lindex $yoffset 1] PostOverPoint $menu $x $y } left { @@ -325,6 +334,8 @@ proc ::tk::MbPost {w {x {}} {y {}}} { + [$menu yposition [expr {$entry+1}]])/2}] } } + incr x [lindex $xoffset 2] + incr y [lindex $yoffset 2] PostOverPoint $menu $x $y if {$entry ne "" \ && [$menu entrycget $entry -state] ne "disabled"} { @@ -348,6 +359,8 @@ proc ::tk::MbPost {w {x {}} {y {}}} { + [$menu yposition [expr {$entry+1}]])/2}] } } + incr x [lindex $xoffset 3] + incr y [lindex $yoffset 3] PostOverPoint $menu $x $y if {$entry ne "" \ && [$menu entrycget $entry -state] ne "disabled"} { @@ -356,6 +369,8 @@ proc ::tk::MbPost {w {x {}} {y {}}} { } } default { + incr x [lindex $xoffset 4] + incr y [lindex $yoffset 4] if {[$w cget -indicatoron]} { if {$y eq ""} { set x [expr {[winfo rootx $w] + [winfo width $w]/2}] diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index b749673..48ddd66 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -334,7 +334,7 @@ * Defaults for menubuttons: */ -#define DEF_MENUBUTTON_ANCHOR "center" +#define DEF_MENUBUTTON_ANCHOR "w" #define DEF_MENUBUTTON_ACTIVE_BG_COLOR ACTIVE_BG #define DEF_MENUBUTTON_ACTIVE_BG_MONO BLACK #define DEF_MENUBUTTON_ACTIVE_FG_COLOR ACTIVE_FG @@ -342,7 +342,7 @@ #define DEF_MENUBUTTON_BG_COLOR NORMAL_BG #define DEF_MENUBUTTON_BG_MONO WHITE #define DEF_MENUBUTTON_BITMAP "" -#define DEF_MENUBUTTON_BORDER_WIDTH "2" +#define DEF_MENUBUTTON_BORDER_WIDTH "0" #define DEF_MENUBUTTON_CURSOR "" #define DEF_MENUBUTTON_DIRECTION "below" #define DEF_MENUBUTTON_DISABLED_FG_COLOR DISABLED @@ -358,8 +358,8 @@ #define DEF_MENUBUTTON_INDICATOR "1" #define DEF_MENUBUTTON_JUSTIFY "left" #define DEF_MENUBUTTON_MENU "" -#define DEF_MENUBUTTON_PADX "4" -#define DEF_MENUBUTTON_PADY "3" +#define DEF_MENUBUTTON_PADX "0" +#define DEF_MENUBUTTON_PADY "0" #define DEF_MENUBUTTON_RELIEF "flat" #define DEF_MENUBUTTON_STATE "normal" #define DEF_MENUBUTTON_TAKE_FOCUS "0" diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index ec32a78..6315638 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -799,7 +799,7 @@ TkpPostMenu( int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); NSView *view = [win contentView]; - NSRect frame = NSMakeRect(x + 9, tkMacOSXZeroScreenHeight - y - 9, 1, 1); + NSRect frame = NSMakeRect(x, tkMacOSXZeroScreenHeight - y, 1, 1); frame.origin = [view convertPoint: [win tkConvertPointFromScreen:frame.origin] fromView:nil]; @@ -1092,9 +1092,9 @@ TkpComputeStandardMenuGeometry( int modifierCharWidth, menuModifierCharWidth; int x, y, modifierWidth, labelWidth, indicatorSpace; int windowWidth, windowHeight, accelWidth; - int i, j, lastColumnBreak, maxWidth; + int i, maxWidth; int entryWidth, maxIndicatorSpace, borderWidth, activeBorderWidth; - TkMenuEntry *mePtr, *columnEntryPtr; + TkMenuEntry *mePtr; int haveAccel = 0; if (menuPtr->tkwin == NULL) { @@ -1106,7 +1106,7 @@ TkpComputeStandardMenuGeometry( Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, &activeBorderWidth); x = y = borderWidth; - windowHeight = maxWidth = lastColumnBreak = 0; + windowHeight = maxWidth = 0; maxIndicatorSpace = 0; /* @@ -1130,9 +1130,12 @@ TkpComputeStandardMenuGeometry( break; } } - + for (i = 0; i < menuPtr->numEntries; i++) { mePtr = menuPtr->entries[i]; + if (mePtr->type == TEAROFF_ENTRY) { + continue; + } if (mePtr->fontPtr == NULL) { tkfont = menuFont; fmPtr = &menuMetrics; @@ -1143,26 +1146,8 @@ TkpComputeStandardMenuGeometry( fmPtr = &entryMetrics; modifierCharWidth = ModifierCharWidth(tkfont); } - - if ((i > 0) && mePtr->columnBreak) { - if (maxIndicatorSpace != 0) { - maxIndicatorSpace += 2; - } - for (j = lastColumnBreak; j < i; j++) { - columnEntryPtr = menuPtr->entries[j]; - columnEntryPtr->indicatorSpace = maxIndicatorSpace; - columnEntryPtr->width = maxIndicatorSpace + maxWidth - + 2 * activeBorderWidth; - columnEntryPtr->x = x; - columnEntryPtr->entryFlags &= ~ENTRY_LAST_COLUMN; - } - x += maxIndicatorSpace + maxWidth + 2 * activeBorderWidth; - maxWidth = maxIndicatorSpace = 0; - lastColumnBreak = i; - y = borderWidth; - } accelWidth = modifierWidth = indicatorSpace = 0; - if (mePtr->type == SEPARATOR_ENTRY || mePtr->type == TEAROFF_ENTRY) { + if (mePtr->type == SEPARATOR_ENTRY) { mePtr->height = menuSeparatorHeight; } else { /* @@ -1176,16 +1161,16 @@ TkpComputeStandardMenuGeometry( NSMenuItem *menuItem = (NSMenuItem *) mePtr->platformEntryData; int haveImage = 0, width = 0, height = 0; - if (mePtr->image) { Tk_SizeOfImage(mePtr->image, &width, &height); haveImage = 1; + height += 2; /* tweak */ } else if (mePtr->bitmapPtr) { Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr); - Tk_SizeOfBitmap(menuPtr->display, bitmap, &width, &height); haveImage = 1; + height += 2; /* tweak */ } if (!haveImage || (mePtr->compound != COMPOUND_NONE)) { NSAttributedString *attrTitle = [menuItem attributedTitle]; @@ -1197,11 +1182,8 @@ TkpComputeStandardMenuGeometry( size = [[menuItem title] sizeWithAttributes: TkMacOSXNSFontAttributesForFont(tkfont)]; } - size.width += menuTextLeadingEdgeMargin + - menuTextTrailingEdgeMargin; - if (size.height < fmPtr->linespace) { - size.height = fmPtr->linespace; - } + size.width += menuTextLeadingEdgeMargin + menuTextTrailingEdgeMargin; + size.height -= 1; /* tweak */ if (haveImage && (mePtr->compound != COMPOUND_NONE)) { int margin = width + menuIconTrailingEdgeMargin; @@ -1219,7 +1201,6 @@ TkpComputeStandardMenuGeometry( } labelWidth = width + menuItemExtraWidth; mePtr->height = height + menuItemExtraHeight; - if (mePtr->type == CASCADE_ENTRY) { modifierWidth = modifierCharWidth; } else if (mePtr->accelLength == 0) { @@ -1250,8 +1231,10 @@ TkpComputeStandardMenuGeometry( if (entryWidth > maxWidth) { maxWidth = entryWidth; } + menuPtr->entries[i]->width = entryWidth; mePtr->height += 2 * activeBorderWidth; } + mePtr->x = x; mePtr->y = y; y += menuPtr->entries[i]->height + borderWidth; if (y > windowHeight) { @@ -1259,14 +1242,6 @@ TkpComputeStandardMenuGeometry( } } - for (j = lastColumnBreak; j < menuPtr->numEntries; j++) { - columnEntryPtr = menuPtr->entries[j]; - columnEntryPtr->indicatorSpace = maxIndicatorSpace; - columnEntryPtr->width = maxIndicatorSpace + maxWidth - + 2 * activeBorderWidth; - columnEntryPtr->x = x; - columnEntryPtr->entryFlags |= ENTRY_LAST_COLUMN; - } windowWidth = x + maxIndicatorSpace + maxWidth + 2 * activeBorderWidth + borderWidth; windowHeight += borderWidth; diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 1acefe5..4df23b4 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -47,17 +47,23 @@ typedef struct MacMenuButton { } MacMenuButton; /* - * Forward declarations for procedures defined later in this file: + * Forward declarations for static functions defined later in this file: */ static void MenuButtonEventProc(ClientData clientData, XEvent *eventPtr); -static void MenuButtonBackgroundDrawCB ( MacMenuButton *ptr, SInt16 depth, Boolean isColorDev); -static void MenuButtonContentDrawCB ( ThemeButtonKind kind, const HIThemeButtonDrawInfo * info, MacMenuButton *ptr, SInt16 depth, Boolean isColorDev); +static void MenuButtonBackgroundDrawCB (MacMenuButton *ptr, SInt16 depth, + Boolean isColorDev); +static void MenuButtonContentDrawCB (ThemeButtonKind kind, + const HIThemeButtonDrawInfo * info, + MacMenuButton *ptr, SInt16 depth, + Boolean isColorDev); static void MenuButtonEventProc ( ClientData clientData, XEvent *eventPtr); -static void TkMacOSXComputeMenuButtonParams (TkMenuButton * butPtr, ThemeButtonKind* btnkind, HIThemeButtonDrawInfo* drawinfo); -static int TkMacOSXComputeMenuButtonDrawParams (TkMenuButton * butPtr, DrawParams * dpPtr); -static void TkMacOSXDrawMenuButton (MacMenuButton *butPtr, - GC gc, Pixmap pixmap); +static void TkMacOSXComputeMenuButtonParams (TkMenuButton * butPtr, + ThemeButtonKind* btnkind, + HIThemeButtonDrawInfo* drawinfo); +static void TkMacOSXComputeMenuButtonDrawParams (TkMenuButton * butPtr, + DrawParams * dpPtr); +static void TkMacOSXDrawMenuButton (MacMenuButton *butPtr, GC gc, Pixmap pixmap); static void DrawMenuButtonImageAndText(TkMenuButton* butPtr); /* @@ -70,11 +76,46 @@ Tk_ClassProcs tkpMenubuttonClass = { TkMenuButtonWorldChanged, /* worldChangedProc */ }; +/* + * We use Apple's Pop-Up Button widget to represent the Tk Menubutton. + * However, we do not use the NSPopUpButton class for this control. Instead we + * render the Pop-Up Button using the HITheme library. This imposes some + * constraints on what can be done. The HITheme renderer allows only specific + * dimensions for the button. + * + * The HITheme library allows drawing a Pop-Up Button with an arbitrary bounds + * rectangle. However the button is always drawn as a rounded box which is 22 + * pixels high. If the bounds rectangle is less than 22 pixels high, the + * button is drawn at the top of the rectangle and the bottom of the button is + * clipped away. So we set a minimum height of 22 pixels for a Menubutton. If + * the bounds rectangle is more than 22 pixels high, then the button is drawn + * centered vertically in the bounds rectangle. + * + * The content rectangle of the button is inset by 14 pixels on the left and 28 + * pixels on the right. The rightmost part of the button contains the blue + * double-arrow symbol which is 28 pixels wide. + * + * To maintain compatibility with code that runs on multiple operating systems, + * the width and height of the content rectangle includes the borderWidth, the + * highlightWidth and the padX and padY dimensions of the Menubutton. However, + * to be consistent with the standard Apple appearance, the content is always + * be drawn at the left side of the content rectangle. All of the excess space + * appears on the right side of the content, and the anchor property is + * ignored. The easiest way to comply with Apple's Human Interface Guidelines + * would be to set bd = highlightthickness = padx = 0 and to specify an + * explicit width for the button. Apple also recommends using the same width + * for all Pop-Up Buttons in a given window. + */ + +#define LEFT_INSET 8 +#define RIGHT_INSET 28 +#define MIN_HEIGHT 22 + /* *---------------------------------------------------------------------- * - * TkpCreateMenuButton -- + * TkpCreateMenuButton -- * * Allocate a new TkMenuButton structure. * @@ -93,13 +134,12 @@ TkpCreateMenuButton( { MacMenuButton *mbPtr = (MacMenuButton *) ckalloc(sizeof(MacMenuButton)); - Tk_CreateEventHandler(tkwin, ActivateMask, - MenuButtonEventProc, (ClientData) mbPtr); + Tk_CreateEventHandler(tkwin, ActivateMask, MenuButtonEventProc, + (ClientData) mbPtr); mbPtr->flags = FIRST_DRAW; mbPtr->btnkind = kThemePopupButton; bzero(&mbPtr->drawinfo, sizeof(mbPtr->drawinfo)); bzero(&mbPtr->lastdrawinfo, sizeof(mbPtr->lastdrawinfo)); - return (TkMenuButton *) mbPtr; } @@ -165,12 +205,13 @@ TkpDisplayMenuButton( * TkpDestroyMenuButton -- * * Free data structures associated with the menubutton control. + * This is a no-op on the Mac. * * Results: * None. * * Side effects: - * Restores the default control state. + * None. * *---------------------------------------------------------------------- */ @@ -204,15 +245,12 @@ TkpComputeMenuButtonGeometry(butPtr) register TkMenuButton *butPtr; /* Widget record for menu button. */ { int width, height, avgWidth, haveImage = 0, haveText = 0; - MacMenuButton *mbPtr = (MacMenuButton*)butPtr; int txtWidth, txtHeight; Tk_FontMetrics fm; - DrawParams drawParams; - int paddingx = 0; - int paddingy = 0; + int highlightWidth = butPtr->highlightWidth > 0 ? butPtr->highlightWidth : 0; /* - * First figure out the size of the contents of the button. + * First compute the size of the contents of the button. */ width = 0; @@ -221,8 +259,6 @@ TkpComputeMenuButtonGeometry(butPtr) txtHeight = 0; avgWidth = 0; - TkMacOSXComputeMenuButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); - if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; @@ -241,7 +277,7 @@ TkpComputeMenuButtonGeometry(butPtr) txtHeight = butPtr->textHeight; avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); Tk_GetFontMetrics(butPtr->tkfont, &fm); - haveText = (txtWidth != 0 && txtHeight != 0); + haveText = (txtWidth != 0 && txtHeight != 2); } /* @@ -304,65 +340,18 @@ TkpComputeMenuButtonGeometry(butPtr) width = txtWidth; height = txtHeight; if (butPtr->width > 0) { - width = butPtr->width * avgWidth; + width = butPtr->width * avgWidth + 2*butPtr->padX; } if (butPtr->height > 0) { - height = butPtr->height * fm.linespace; + height = butPtr->height * fm.linespace + 2*butPtr->padY; } } } - width += 2 * butPtr->padX - 2; - height += 2 * butPtr->padY - 2; - - /*Add padding for button arrows.*/ - width += 22; - - /* - * Now figure out the size of the border decorations for the button. - */ - - if (butPtr->highlightWidth < 0) { - butPtr->highlightWidth = 0; - } - butPtr->inset = 0; - butPtr->inset += butPtr->highlightWidth; - - TkMacOSXComputeMenuButtonDrawParams(butPtr,&drawParams); - - HIRect tmpRect; - HIRect contBounds; - - tmpRect = CGRectMake(0, 0, width, height); - - HIThemeGetButtonContentBounds(&tmpRect, &mbPtr->drawinfo, &contBounds); - - - - /* If the content region has a minimum height, match it. */ - if (height < contBounds.size.height) { - height = contBounds.size.height; - } - - /* If the content region has a minimum width, match it. */ - if (width < contBounds.size.width) { - width = contBounds.size.width; - } - - /* Pad to fill difference between content bounds and button bounds. */ - paddingx = tmpRect.origin.x - contBounds.origin.x; - paddingy = tmpRect.origin.y - contBounds.origin.y; - - if (paddingx > 0) { - width += paddingx; - } - if (paddingy > 0) { - height += paddingy; - } - - width += butPtr->inset*2; - height += butPtr->inset*2; - - + + butPtr->inset = highlightWidth + butPtr->borderWidth; + width += LEFT_INSET + RIGHT_INSET + 2*butPtr->inset; + height += 2*butPtr->inset; + height = height < MIN_HEIGHT ? MIN_HEIGHT : height; Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } @@ -446,8 +435,8 @@ DrawMenuButtonImageAndText( imageYOffset = butPtr->textHeight + butPtr->padY; } fullHeight = height + butPtr->textHeight + butPtr->padY; - fullWidth = (width > butPtr->textWidth ? width : - butPtr->textWidth); + fullWidth = (width > butPtr->textWidth ? + width : butPtr->textWidth); textXOffset = (fullWidth - butPtr->textWidth)/2; imageXOffset = (fullWidth - width)/2; break; @@ -489,10 +478,10 @@ DrawMenuButtonImageAndText( } TkComputeAnchor(butPtr->anchor, tkwin, - butPtr->padX + butPtr->borderWidth, - butPtr->padY + butPtr->borderWidth, + butPtr->padX + butPtr->inset, + butPtr->padY + butPtr->inset, fullWidth, fullHeight, &x, &y); - imageXOffset += x; + imageXOffset = LEFT_INSET; imageYOffset += y; textYOffset -= 1; @@ -517,36 +506,32 @@ DrawMenuButtonImageAndText( butPtr->underline); } else { if (haveImage) { - int x = 0; - int y; + int x, y; TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX + butPtr->borderWidth, butPtr->padY + butPtr->borderWidth, width, height, &x, &y); - imageXOffset += x; - imageYOffset += y; - - if (butPtr->image != NULL) { - Tk_RedrawImage(butPtr->image, 0, 0, width, height, - pixmap, imageXOffset, imageYOffset); + imageXOffset = LEFT_INSET; + imageYOffset += y; + if (butPtr->image != NULL) { + Tk_RedrawImage(butPtr->image, 0, 0, width, height, + pixmap, imageXOffset, imageYOffset); } else { XSetClipOrigin(butPtr->display, dpPtr->gc, x, y); XCopyPlane(butPtr->display, butPtr->bitmap, - pixmap, dpPtr->gc, - 0, 0, (unsigned int) width, - (unsigned int) height, - imageXOffset, imageYOffset, 1); + pixmap, dpPtr->gc, + 0, 0, (unsigned int) width, + (unsigned int) height, + imageXOffset, imageYOffset, 1); XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } } else { - /*Move x back by eight pixels to give the menubutton arrows room.*/ - int x = 0; - int y; - textXOffset = 8; + int x, y; + textXOffset = LEFT_INSET; TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY, butPtr->textWidth, butPtr->textHeight, &x, &y); Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, - butPtr->textLayout, x - textXOffset, y, 0, -1); + butPtr->textLayout, textXOffset, y, 0, -1); y += butPtr->textHeight/2; } } @@ -578,7 +563,6 @@ TkMacOSXDrawMenuButton( * the bevel button */ Pixmap pixmap) /* The pixmap we are drawing into - needed * for the bevel button */ - { TkMenuButton * butPtr = ( TkMenuButton *)mbPtr; TkWindow * winPtr; @@ -591,10 +575,9 @@ TkMacOSXDrawMenuButton( TkMacOSXComputeMenuButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); - cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff, Tk_Width(butPtr->tkwin),Tk_Height(butPtr->tkwin)); - - cntrRect = CGRectInset(cntrRect, butPtr->inset, butPtr->inset); - + cntrRect = CGRectMake(winPtr->privatePtr->xOff, winPtr->privatePtr->yOff, + Tk_Width(butPtr->tkwin), + Tk_Height(butPtr->tkwin)); if (useNewerHITools == 1) { HIRect contHIRec; @@ -618,16 +601,12 @@ TkMacOSXDrawMenuButton( } HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, kHIThemeOrientationNormal, &contHIRec); - TkMacOSXRestoreDrawingContext(&dc); - MenuButtonContentDrawCB( mbPtr->btnkind, &mbPtr->drawinfo, (MacMenuButton *)mbPtr, 32, true); } else { if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { return; } - - TkMacOSXRestoreDrawingContext(&dc); } mbPtr->lastdrawinfo = mbPtr->drawinfo; @@ -696,8 +675,7 @@ MenuButtonContentDrawCB ( if (tkwin == NULL || !Tk_IsMapped(tkwin)) { return; } - - DrawMenuButtonImageAndText( butPtr); + DrawMenuButtonImageAndText(butPtr); } /* @@ -812,24 +790,22 @@ TkMacOSXComputeMenuButtonParams(TkMenuButton * butPtr, ThemeButtonKind* btnkind, * * TkMacOSXComputeMenuButtonDrawParams -- * - * This procedure computes the various parameters used - * when drawing a button - * These are determined by the various tk button parameters + * This procedure selects an appropriate drawing context for + * drawing a menubutton. * * Results: - * 1 if control will be used, 0 otherwise. + * None. * * Side effects: - * Sets the button draw parameters + * Sets the button draw parameters. * *---------------------------------------------------------------------- */ -static int +static void TkMacOSXComputeMenuButtonDrawParams(TkMenuButton * butPtr, DrawParams * dpPtr) { - dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) - || (butPtr->bitmap != None)); + dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None)); dpPtr->border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { dpPtr->gc = butPtr->disabledGC; @@ -839,8 +815,6 @@ TkMacOSXComputeMenuButtonDrawParams(TkMenuButton * butPtr, DrawParams * dpPtr) } else { dpPtr->gc = butPtr->normalTextGC; } - - return 1; } /* diff --git a/tests/menubut.test b/tests/menubut.test index 6efdb0f..88f4330 100644 --- a/tests/menubut.test +++ b/tests/menubut.test @@ -542,7 +542,11 @@ test menubutton-6.1 {MenuButtonCmdDeletedProc procedure} -setup { deleteWindows } -result {{} {}} - +if {[tk windowingsystem] == "aqua"} { + set extraWidth 36 +} else { + set extraWidth 0 +} test menubutton-7.1 {ComputeMenuButtonGeometry procedure} -constraints { testImageType } -setup { @@ -555,33 +559,33 @@ test menubutton-7.1 {ComputeMenuButtonGeometry procedure} -constraints { } -cleanup { deleteWindows imageCleanup -} -result {38 23} +} -result [list [expr {38 + $extraWidth}] 23] test menubutton-7.2 {ComputeMenuButtonGeometry procedure} -constraints { testImageType } -setup { deleteWindows image create test image1 } -body { - menubutton .mb -image image1 -bd 1 -highlightthickness 2 + menubutton .mb -image image1 -bd 3 -highlightthickness 1 pack .mb list [winfo reqwidth .mb] [winfo reqheight .mb] } -cleanup { deleteWindows imageCleanup -} -result {36 21} +} -result [list [expr {38 + $extraWidth}] 23] test menubutton-7.3 {ComputeMenuButtonGeometry procedure} -constraints { testImageType } -setup { deleteWindows image create test image1 } -body { - menubutton .mb -image image1 -bd 0 -highlightthickness 2 -padx 5 -pady 5 + menubutton .mb -image image1 -bd 1 -highlightthickness 3 -padx 5 -pady 5 pack .mb list [winfo reqwidth .mb] [winfo reqheight .mb] } -cleanup { deleteWindows imageCleanup -} -result {34 19} +} -result [list [expr {38 + $extraWidth}] 23] test menubutton-7.4 {ComputeMenuButtonGeometry procedure} -constraints { testImageType } -setup { @@ -595,7 +599,7 @@ test menubutton-7.4 {ComputeMenuButtonGeometry procedure} -constraints { } -cleanup { deleteWindows imageCleanup -} -result {48 23} +} -result [list [expr {48 + $extraWidth}] 23] test menubutton-7.5 {ComputeMenuButtonGeometry procedure} -constraints { testImageType } -setup { @@ -609,7 +613,7 @@ test menubutton-7.5 {ComputeMenuButtonGeometry procedure} -constraints { } -cleanup { deleteWindows imageCleanup -} -result {38 38} +} -result [list [expr {38 + $extraWidth}] 38] test menubutton-7.6 {ComputeMenuButtonGeometry procedure} -setup { deleteWindows } -body { @@ -619,7 +623,7 @@ test menubutton-7.6 {ComputeMenuButtonGeometry procedure} -setup { list [winfo reqwidth .mb] [winfo reqheight .mb] } -cleanup { deleteWindows -} -result {25 35} +} -result [list [expr {25 + $extraWidth}] 35] test menubutton-7.7 {ComputeMenuButtonGeometry procedure} -setup { deleteWindows } -body { @@ -629,7 +633,7 @@ test menubutton-7.7 {ComputeMenuButtonGeometry procedure} -setup { list [winfo reqwidth .mb] [winfo reqheight .mb] } -cleanup { deleteWindows -} -result {46 33} +} -result [list [expr {46 + $extraWidth}] 33] test menubutton-7.8 {ComputeMenuButtonGeometry procedure} -setup { deleteWindows } -body { @@ -639,7 +643,7 @@ test menubutton-7.8 {ComputeMenuButtonGeometry procedure} -setup { list [winfo reqwidth .mb] [winfo reqheight .mb] } -cleanup { deleteWindows -} -result {23 56} +} -result [list [expr {23 + $extraWidth}] 56] test menubutton-7.9 {ComputeMenuButtonGeometry procedure} -constraints { fonts } -setup { -- cgit v0.12 From 3866cadb1cfcaf4145fed26ace23efb3a0d16254 Mon Sep 17 00:00:00 2001 From: fvogel Date: Wed, 9 Jan 2019 21:58:56 +0000 Subject: Add new test scale-14.13 to guard against regressions with [220665ffff], and duplicates [220265ffff] and [779559ffff]. This test currently fails in the present bugfix branch but passes in core-8-6-branch --- tests/scale.test | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/scale.test b/tests/scale.test index 6344eef..7fa3a62 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -1183,6 +1183,19 @@ test scale-14.12 {RoundValueToResolution procedure} -body { } -result {168.75} destroy .s +test scale-14.13 {RoundValueToResolution procedure, round-off errors} -setup { + # see [220665ffff], and duplicates [220265ffff] and [779559ffff] + set x NotSet + pack [scale .s -orient horizontal -resolution .1 -from -180 -to 180 -command "set x"] + update +} -body { + .s configure -background red + update + set x +} -cleanup { + destroy .s +} -result {NotSet} + test scale-14a.1 {RoundValueToResolution, RoundIntervalToResolution procedures} -setup { pack [scale .s -orient horizontal] update -- cgit v0.12 From 587df2a3c0d221979267d8549003fa2dda184a38 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 10 Jan 2019 11:28:33 +0000 Subject: Missed 2 spots in previous commit (only relevant for test-suite) --- generic/tkSquare.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 39083d4..40d5e8f 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -335,7 +335,7 @@ SquareConfigure( Tk_SetWindowBackground(squarePtr->tkwin, Tk_3DBorderColor(bgBorder)->pixel); Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); - if ((squarePtr->gc == None) && (doubleBuffer)) { + if ((squarePtr->gc == NULL) && (doubleBuffer)) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -400,7 +400,7 @@ SquareObjEventProc( if (squarePtr->tkwin != NULL) { Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, squarePtr->tkwin); - if (squarePtr->gc != None) { + if (squarePtr->gc != NULL) { Tk_FreeGC(squarePtr->display, squarePtr->gc); } squarePtr->tkwin = NULL; -- cgit v0.12 From da7c298f108280140fbbec81f67705f684bf5fe6 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 11 Jan 2019 21:47:27 +0000 Subject: Fix related menubutton issues on linux and Windows. --- doc/menu.n | 21 +++-- generic/tkMenu.c | 32 +++++-- generic/tkMenu.h | 2 +- library/menu.tcl | 257 ++++++++++++++++++++++++++------------------------ macosx/tkMacOSXMenu.c | 73 +++++++------- tests/menu.test | 2 +- unix/tkUnixMenu.c | 14 ++- win/tkWinMenu.c | 18 ++-- 8 files changed, 231 insertions(+), 188 deletions(-) diff --git a/doc/menu.n b/doc/menu.n index ac60e65..338ce6a 100644 --- a/doc/menu.n +++ b/doc/menu.n @@ -470,18 +470,19 @@ a menu entry does not automatically unpost the menu; the default bindings normally take care of this before invoking the \fBinvoke\fR widget command. .TP -\fIpathName \fBpost \fIx y\fR +\fIpathName \fBpost \fIx y\fR ?\fIindex\fR? . Arrange for the menu to be displayed on the screen at the root-window -coordinates given by \fIx\fR and \fIy\fR. These coordinates are -adjusted if necessary to guarantee that the entire menu is visible on -the screen. This command normally returns an empty string. -If the \fB\-postcommand\fR option has been specified, then its value is -executed as a Tcl script before posting the menu and the result of -that script is returned as the result of the \fBpost\fR widget -command. -If an error returns while executing the command, then the error is -returned without posting the menu. +coordinates given by \fIx\fR and \fIy\fR. If an index is specified +the menu will be located so that the entry with that index is +displayed at the point. These coordinates are adjusted if necessary to +guarantee that the entire menu is visible on the screen. This command +normally returns an empty string. If the \fB\-postcommand\fR option +has been specified, then its value is executed as a Tcl script before +posting the menu and the result of that script is returned as the +result of the \fBpost\fR widget command. If an error returns while +executing the command, then the error is returned without posting the +menu. .TP \fIpathName \fBpostcascade \fIindex\fR . diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 26ffc88..f1ea8ff 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -870,32 +870,46 @@ MenuWidgetObjCmd( break; } case MENU_POST: { - int x, y; + int x, y, entry = -1; - if (objc != 4) { - Tcl_WrongNumArgs(interp, 2, objv, "x y"); + if (objc != 4 && objc != 5) { + Tcl_WrongNumArgs(interp, 2, objv, "x y ?entry?"); goto error; } if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) || (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) { goto error; } + if (objc == 5) { + if (menuPtr->menuType == TEAROFF_MENU) { + Tcl_AppendResult(interp, + "the index option is invalid for tearoff menus", NULL); + return TCL_ERROR; + } + if (Tcl_GetIntFromObj(interp, objv[4], &entry) != TCL_OK) { + goto error; + } + } /* - * Tearoff menus are posted differently on Mac and Windows than - * non-tearoffs. TkpPostMenu does not actually map the menu's window - * on those platforms, and popup menus have to be handled specially. - * Also, menubar menues are not intended to be posted (bug 1567681, - * 2160206). + * Tearoff menus are the same as ordinary menus on the Mac and are + * posted differently on Windows than non-tearoffs. TkpPostMenu + * does not actually map the menu's window on those platforms, and + * popup menus have to be handled specially. Also, menubar menus are + * not intended to be posted (bug 1567681, 2160206). */ if (menuPtr->menuType == MENUBAR) { Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); return TCL_ERROR; } else if (menuPtr->menuType != TEAROFF_MENU) { - result = TkpPostMenu(interp, menuPtr, x, y); + result = TkpPostMenu(interp, menuPtr, x, y, entry); } else { +#ifdef TK_MAC_OSX + result = TkpPostMenu(interp, menuPtr, x, y, entry); +#else result = TkPostTearoffMenu(interp, menuPtr, x, y); +#endif } break; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index bac51aa..92bf8b2 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -543,7 +543,7 @@ MODULE_SCOPE void TkpMenuInit(void); MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y); + int x, int y, int entry); MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); #endif /* _TKMENU */ diff --git a/library/menu.tcl b/library/menu.tcl index a406ae3..cdfcc13 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -234,6 +234,7 @@ proc ::tk::MbLeave w { } } + # ::tk::MbPost -- # Given a menubutton, this procedure does all the work of posting # its associated menu and unposting any other menu that is currently @@ -274,124 +275,25 @@ proc ::tk::MbPost {w {x {}} {y {}}} { if {[tk windowingsystem] ne "aqua"} { set Priv(relief) [$w cget -relief] $w configure -relief raised - set xoffset {0 0 0 0 0} - set yoffset {0 0 0 0 0} } else { $w configure -state active - # Compensate for offsets created by the macOS window manager. - set xoffset {9 9 18 9 0} - set yoffset {6 13 13 13 9} } set Priv(postedMb) $w set Priv(focus) [focus] $menu activate none GenerateMenuSelect $menu - - # If this looks like an option menubutton then post the menu so - # that the current entry is on top of the mouse. Otherwise post - # the menu just below the menubutton, as for a pull-down. - update idletasks - if {[catch { - switch [$w cget -direction] { - above { - set x [expr {[winfo rootx $w]}] - set y [expr {[winfo rooty $w] - [winfo reqheight $menu]}] - # if we go offscreen to the top, show as 'below' - if {$y < [winfo vrooty $w]} { - set y [expr {[winfo vrooty $w] + [winfo rooty $w] + [winfo reqheight $w]}] - } - incr x [lindex $xoffset 0] - incr y [lindex $yoffset 0] - PostOverPoint $menu $x $y - } - below { - set x [expr {[winfo rootx $w]}] - set y [expr {[winfo rooty $w] + [winfo height $w]}] - # if we go offscreen to the bottom, show as 'above' - set mh [winfo reqheight $menu] - if {($y + $mh) > ([winfo vrooty $w] + [winfo vrootheight $w])} { - set y [expr {[winfo vrooty $w] + [winfo vrootheight $w] + [winfo rooty $w] - $mh}] - } - incr x [lindex $xoffset 1] - incr y [lindex $yoffset 1] - PostOverPoint $menu $x $y - } - left { - set x [expr {[winfo rootx $w] - [winfo reqwidth $menu]}] - set y [expr {(2 * [winfo rooty $w] + [winfo height $w]) / 2}] - set entry [MenuFindName $menu [$w cget -text]] - if {$entry eq ""} { - set entry 0 - } - if {[$w cget -indicatoron]} { - if {$entry == [$menu index last]} { - incr y [expr {-([$menu yposition $entry] \ - + [winfo reqheight $menu])/2}] - } else { - incr y [expr {-([$menu yposition $entry] \ - + [$menu yposition [expr {$entry+1}]])/2}] - } - } - incr x [lindex $xoffset 2] - incr y [lindex $yoffset 2] - PostOverPoint $menu $x $y - if {$entry ne "" \ - && [$menu entrycget $entry -state] ne "disabled"} { - $menu activate $entry - GenerateMenuSelect $menu - } - } - right { - set x [expr {[winfo rootx $w] + [winfo width $w]}] - set y [expr {(2 * [winfo rooty $w] + [winfo height $w]) / 2}] - set entry [MenuFindName $menu [$w cget -text]] - if {$entry eq ""} { - set entry 0 - } - if {[$w cget -indicatoron]} { - if {$entry == [$menu index last]} { - incr y [expr {-([$menu yposition $entry] \ - + [winfo reqheight $menu])/2}] - } else { - incr y [expr {-([$menu yposition $entry] \ - + [$menu yposition [expr {$entry+1}]])/2}] - } - } - incr x [lindex $xoffset 3] - incr y [lindex $yoffset 3] - PostOverPoint $menu $x $y - if {$entry ne "" \ - && [$menu entrycget $entry -state] ne "disabled"} { - $menu activate $entry - GenerateMenuSelect $menu - } - } - default { - incr x [lindex $xoffset 4] - incr y [lindex $yoffset 4] - if {[$w cget -indicatoron]} { - if {$y eq ""} { - set x [expr {[winfo rootx $w] + [winfo width $w]/2}] - set y [expr {[winfo rooty $w] + [winfo height $w]/2}] - } - PostOverPoint $menu $x $y [MenuFindName $menu [$w cget -text]] - } else { - PostOverPoint $menu [winfo rootx $w] [expr {[winfo rooty $w]+[winfo height $w]}] - } - } - } - } msg opt]} { + + if {[catch {PostMenubuttonMenu $w $menu} msg opt]} { # Error posting menu (e.g. bogus -postcommand). Unpost it and # reflect the error. - MenuUnpost {} return -options $opt $msg } set Priv(tearoff) $tearoff - if {$tearoff != 0} { + if {$tearoff != 0 && [tk windowingsystem] ne "aqua"} { focus $menu if {[winfo viewable $w]} { SaveGrabInfo $w @@ -1223,10 +1125,118 @@ proc ::tk::MenuFindName {menu s} { return "" } +# ::tk::PostMenubuttonMenu -- +# +# Given a menubutton and a menu, this procedure posts the menu at the +# appropriate location. If the menubutton looks like an option +# menubutton, meaning that the indicator is on and the direction is +# neither above nor below, then the menu is posted so that the current +# entry is vertically aligned with the menubutton. On the Mac this +# will expose a small amount of the blue indicator on the right hand +# side. On other platforms the entry is centered over the button. + +if {[tk windowingsystem] eq "aqua"} { + proc ::tk::PostMenubuttonMenu {button menu} { + set entry "" + if {[$button cget -indicatoron]} { + set entry [MenuFindName $menu [$button cget -text]] + if {$entry eq ""} { + set entry 0 + } + } + set x [winfo rootx $button] + set y [expr {2 + [winfo rooty $button]}] + switch [$button cget -direction] { + above { + set entry "" + incr y [expr {4 - [winfo reqheight $menu]}] + } + below { + set entry "" + incr y [expr {2 + [winfo height $button]}] + } + left { + incr x [expr {-[winfo reqwidth $menu]}] + } + right { + incr x [winfo width $button] + } + default { + incr x [expr {[winfo width $button] - [winfo reqwidth $menu] - 5}] + } + } + PostOverPoint $menu $x $y $entry + } +} else { + proc ::tk::PostMenubuttonMenu {button menu} { + set entry "" + if {[$button cget -indicatoron]} { + set entry [MenuFindName $menu [$button cget -text]] + if {$entry eq ""} { + set entry 0 + } + } + if {$entry ne ""} { + if {$entry == [$menu index last]} { + set entryHeight [expr {[winfo reqheight $menu] \ + - [$menu yposition $entry]}] + } else { + set entryHeight [expr {[$menu yposition [expr {$entry+1}]] \ + - [$menu yposition $entry]}] + } + } + set x [winfo rootx $button] + set y [winfo rooty $button] + switch [$button cget -direction] { + above { + incr y [expr {-[winfo reqheight $menu]}] + # if we go offscreen to the top, show as 'below' + if {$y < [winfo vrooty $button]} { + set y [expr {[winfo vrooty $button] + [winfo rooty $button]\ + + [winfo reqheight $button]}] + } + set entry {} + } + below { + incr y [winfo height $button] + # if we go offscreen to the bottom, show as 'above' + set mh [winfo reqheight $menu] + if {($y + $mh) > ([winfo vrooty $button] + [winfo vrootheight $button])} { + set y [expr {[winfo vrooty $button] + [winfo vrootheight $button] \ + + [winfo rooty $button] - $mh}] + } + set entry {} + } + left { + # It is not clear why this is needed. + if {[tk windowingsystem] eq "win32"} { + incr x [expr {-4 - [winfo reqwidth $button] / 2}] + } + incr x [expr {- [winfo reqwidth $menu]}] + } + right { + incr x [expr {[winfo width $button]}] + } + default { + if {[$button cget -indicatoron]} { + incr x [expr {([winfo width $button] - \ + [winfo reqwidth $menu])/ 2}] + } else { + incr y [winfo height $button] + } + } + } + PostOverPoint $menu $x $y $entry + } +} + # ::tk::PostOverPoint -- -# This procedure posts a given menu such that a given entry in the -# menu is centered over a given point in the root window. It also -# activates the given entry. +# +# This procedure posts a menu on the screen so that a given entry in +# the menu is positioned with its upper left corner at a given point +# in the root window. The procedure also activates that entry. If no +# entry is specified the upper left corner of the entire menu is +# placed at the point. # # Arguments: # menu - Menu to post. @@ -1235,19 +1245,24 @@ proc ::tk::MenuFindName {menu s} { # If omitted or specified as {}, then the menu's # upper-left corner goes at (x,y). -proc ::tk::PostOverPoint {menu x y {entry {}}} { - if {$entry ne ""} { - if {$entry == [$menu index last]} { - incr y [expr {-([$menu yposition $entry] \ - + [winfo reqheight $menu])/2}] +if {[tk windowingsystem] ne "win32"} { + proc ::tk::PostOverPoint {menu x y {entry {}}} { + if {$entry ne ""} { + $menu post $x $y $entry + if {[$menu entrycget $entry -state] ne "disabled"} { + $menu activate $entry + GenerateMenuSelect $menu + } } else { - incr y [expr {-([$menu yposition $entry] \ - + [$menu yposition [expr {$entry+1}]])/2}] + $menu post $x $y } - incr x [expr {-[winfo reqwidth $menu]/2}] + return } - - if {[tk windowingsystem] eq "win32"} { +} else { + proc ::tk::PostOverPoint {menu x y {entry {}}} { + if {$entry ne ""} { + incr y [expr {-[$menu yposition $entry]}] + } # osVersion is not available in safe interps set ver 5 if {[info exists ::tcl_platform(osVersion)]} { @@ -1263,7 +1278,7 @@ proc ::tk::PostOverPoint {menu x y {entry {}}} { # manager provided with Vista and Windows 7. if {$ver < 6} { set yoffset [expr {[winfo screenheight $menu] \ - - $y - [winfo reqheight $menu] - 10}] + - $y - [winfo reqheight $menu] - 10}] if {$yoffset < [winfo vrooty $menu]} { # The bottom of the menu is offscreen, so adjust upwards incr y [expr {$yoffset - [winfo vrooty $menu]}] @@ -1275,11 +1290,11 @@ proc ::tk::PostOverPoint {menu x y {entry {}}} { set y [winfo vrooty $menu] } } - } - $menu post $x $y - if {$entry ne "" && [$menu entrycget $entry -state] ne "disabled"} { - $menu activate $entry - GenerateMenuSelect $menu + $menu post $x $y + if {$entry ne "" && [$menu entrycget $entry -state] ne "disabled"} { + $menu activate $entry + GenerateMenuSelect $menu + } } } diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 6315638..c7610fc 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -755,7 +755,10 @@ TkpDestroyMenuEntry( * * TkpPostMenu -- * - * Posts a menu on the screen + * Posts a menu on the screen. If entry is < 0 then the menu is + * drawn so its top left corner is located at the point with + * screen coordinates (x, y). Otherwise the top left corner of + * the specified entry is located at that point. * * Results: * None. @@ -770,49 +773,47 @@ int TkpPostMenu( Tcl_Interp *interp, /* The interpreter this menu lives in */ TkMenu *menuPtr, /* The menu we are posting */ - int x, /* The global x-coordinate of the top, left- - * hand corner of where the menu is supposed - * to be posted. */ - int y) /* The global y-coordinate */ + int x, int y, /* The screen coordinates where the top left + * corner of the menu, or of the specified + * entry, will be located. */ + int entry) { - - /* Get the object that holds this Tk Window.*/ - Tk_Window root; - root = Tk_MainWindow(interp); + Tk_Window root = Tk_MainWindow(interp); + if (root == NULL) { return TCL_ERROR; } + if (menuPtr->menuType == TEAROFF_MENU) { + entry -= 1; + } Drawable d = Tk_WindowId(root); NSView *rootview = TkMacOSXGetRootControl(d); NSWindow *win = [rootview window]; - int result; + NSView *view = [win contentView]; + NSMenu *menu = (NSMenu *) menuPtr->platformData; + NSMenuItem *item = nil; + NSInteger index = entry; + NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); + int result, oldMode; inPostMenu = 1; - result = TkPreprocessMenu(menuPtr); if (result != TCL_OK) { inPostMenu = 0; return result; } - - int oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); - NSView *view = [win contentView]; - NSRect frame = NSMakeRect(x, tkMacOSXZeroScreenHeight - y, 1, 1); - - frame.origin = [view convertPoint: - [win tkConvertPointFromScreen:frame.origin] fromView:nil]; - - NSMenu *menu = (NSMenu *) menuPtr->platformData; - NSPopUpButtonCell *popUpButtonCell = [[NSPopUpButtonCell alloc] - initTextCell:@"" pullsDown:NO]; - - [popUpButtonCell setAltersStateOfSelectedItem:NO]; - [popUpButtonCell setMenu:menu]; - [popUpButtonCell selectItem:nil]; - [popUpButtonCell performClickWithFrame:frame inView:view]; - [popUpButtonCell release]; + if (index >= [menu numberOfItems]) { + index = [menu numberOfItems] - 1; + } + if (index >= 0) { + item = [menu itemAtIndex:index]; + } + oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); + [menu popUpMenuPositioningItem:item + atLocation:[win tkConvertPointFromScreen:location] + inView:view]; Tcl_SetServiceMode(oldMode); inPostMenu = 0; return TCL_OK; @@ -1087,6 +1088,7 @@ void TkpComputeStandardMenuGeometry( TkMenu *menuPtr) /* Structure describing menu. */ { + NSSize menuSize = [(NSMenu *)menuPtr->platformData size]; Tk_Font tkfont, menuFont; Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr; int modifierCharWidth, menuModifierCharWidth; @@ -1130,7 +1132,7 @@ TkpComputeStandardMenuGeometry( break; } } - + for (i = 0; i < menuPtr->numEntries; i++) { mePtr = menuPtr->entries[i]; if (mePtr->type == TEAROFF_ENTRY) { @@ -1199,6 +1201,9 @@ TkpComputeStandardMenuGeometry( height = size.height; } } + else { + /* image only. */ + } labelWidth = width + menuItemExtraWidth; mePtr->height = height + menuItemExtraHeight; if (mePtr->type == CASCADE_ENTRY) { @@ -1237,18 +1242,12 @@ TkpComputeStandardMenuGeometry( mePtr->x = x; mePtr->y = y; y += menuPtr->entries[i]->height + borderWidth; - if (y > windowHeight) { - windowHeight = y; - } } - - windowWidth = x + maxIndicatorSpace + maxWidth - + 2 * activeBorderWidth + borderWidth; - windowHeight += borderWidth; - + windowWidth = menuSize.width; if (windowWidth <= 0) { windowWidth = 1; } + windowHeight = menuSize.height; if (windowHeight <= 0) { windowHeight = 1; } diff --git a/tests/menu.test b/tests/menu.test index 95699ff..dcc578f 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -1606,7 +1606,7 @@ test menu-3.47 {MenuWidgetCmd procedure, "post" option} -setup { .m1 post } -cleanup { destroy .m1 -} -returnCodes error -result {wrong # args: should be ".m1 post x y"} +} -returnCodes error -result {wrong # args: should be ".m1 post x y ?entry?"} test menu-3.48 {MenuWidgetCmd procedure, "post" option} -setup { destroy .m1 } -body { diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index 38b6c58..f701819 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -889,7 +889,10 @@ DrawMenuUnderline( * * TkpPostMenu -- * - * Posts a menu on the screen + * Posts a menu on the screen so that the top left corner of the + * specified entry is located at the point (x, y) in screen coordinates. + * If the entry parameter is negative, the upper left corner of the + * menu itself is placed at the point. * * Results: * None. @@ -904,8 +907,14 @@ int TkpPostMenu( Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y) + int x, int y, int entry) { + if (entry >= menuPtr->numEntries) { + entry = menuPtr->numEntries - 1; + } + if (entry >= 0) { + y -= menuPtr->entries[entry]->y; + } return TkPostTearoffMenu(interp, menuPtr, x, y); } @@ -1721,7 +1730,6 @@ TkpComputeStandardMenuGeometry( } windowWidth = x + indicatorSpace + labelWidth + accelWidth + 2 * activeBorderWidth + borderWidth; - windowHeight += borderWidth; /* diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index a409764..2957b0e 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -743,7 +743,10 @@ ReconfigureWindowsMenu( * * TkpPostMenu -- * - * Posts a menu on the screen + * Posts a menu on the screen so that the top left corner of the + * specified entry is located at the point (x, y) in screen coordinates. + * If the entry parameter is negative, the upper left corner of the + * menu itself is placed at the point. * * Results: * None. @@ -758,7 +761,7 @@ int TkpPostMenu( Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y) + int x, int y, int entry) { HMENU winMenuHdl = (HMENU) menuPtr->platformData; int result, flags; @@ -770,7 +773,6 @@ TkpPostMenu( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); tsdPtr->inPostMenu++; - CallPendingReconfigureImmediately(menuPtr); result = TkPreprocessMenu(menuPtr); @@ -779,6 +781,13 @@ TkpPostMenu( return result; } + if (entry >= menuPtr->numEntries) { + entry = menuPtr->numEntries - 1; + } + if (entry >= 0) { + y -= menuPtr->entries[entry]->y; + } + /* * The post commands could have deleted the menu, which means * we are dead and should go away. @@ -2897,7 +2906,6 @@ TkpComputeStandardMenuGeometry( GetTearoffEntryGeometry(menuPtr, menuPtr->entries[i], tkfont, fmPtr, &width, &height); menuPtr->entries[i]->height = height; - } else { /* * For each entry, compute the height required by that particular @@ -2955,8 +2963,6 @@ TkpComputeStandardMenuGeometry( } windowWidth = x + indicatorSpace + labelWidth + accelWidth + 2 * activeBorderWidth + borderWidth; - - windowHeight += borderWidth; /* -- cgit v0.12 From cff021b2dc7bf601b37714ae36bfa4fd510dbd1d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 13 Jan 2019 14:35:13 +0000 Subject: Fix [3003895fff] and [1899040fff] with a different fix, this time it does not resurrect [220665ffff] or duplicates [220265ffff] [779559ffff]. All scale.test tests do pass now. --- generic/tkScale.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/generic/tkScale.c b/generic/tkScale.c index 547f698..979d39d 100644 --- a/generic/tkScale.c +++ b/generic/tkScale.c @@ -1142,17 +1142,8 @@ TkRoundValueToResolution( TkScale *scalePtr, /* Information about scale widget. */ double value) /* Value to round. */ { - double rem, start; - - if (scalePtr->resolution <= 0) { - return value; - } - start = fmod(scalePtr->fromValue, scalePtr->resolution); - rem = fmod(value - start + scalePtr->resolution/2, scalePtr->resolution); - if (rem < 0) { - rem += scalePtr->resolution; - } - return value + scalePtr->resolution/2 - rem; + return TkRoundIntervalToResolution(scalePtr, value - scalePtr->fromValue) + + scalePtr->fromValue; } double @@ -1160,16 +1151,24 @@ TkRoundIntervalToResolution( TkScale *scalePtr, /* Information about scale widget. */ double value) /* Value to round. */ { - double rem; + double rem, rounded, tick; if (scalePtr->resolution <= 0) { return value; } - rem = fmod(value + scalePtr->resolution/2, scalePtr->resolution); + tick = floor(value/scalePtr->resolution); + rounded = scalePtr->resolution * tick; + rem = value - rounded; if (rem < 0) { - rem += scalePtr->resolution; + if (rem <= -scalePtr->resolution/2) { + rounded = (tick - 1.0) * scalePtr->resolution; + } + } else { + if (rem >= scalePtr->resolution/2) { + rounded = (tick + 1.0) * scalePtr->resolution; + } } - return value + scalePtr->resolution/2 - rem; + return rounded; } /* -- cgit v0.12 From c5018a98c472597e3f6e1bb4717bdf89b89c2cf2 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Sun, 13 Jan 2019 14:44:54 +0000 Subject: Not actually necessary to fix those (they don't give warnings because those are switched off), but while on it it's better to correct those ill-usages of 'None' too --- generic/tkCanvPoly.c | 2 +- generic/tkRectOval.c | 2 +- generic/tkSquare.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 630400f..7171e9f 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -524,7 +524,7 @@ ConfigurePolygon( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = polyPtr->outline.gc != None ? + gcValues.line_width = polyPtr->outline.gc != NULL ? polyPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index 4431341..55c2a61 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -522,7 +522,7 @@ ConfigureRectOval( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = rectOvalPtr->outline.gc != None ? + gcValues.line_width = rectOvalPtr->outline.gc != NULL ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif diff --git a/generic/tkSquare.c b/generic/tkSquare.c index 355a447..b8a4fad 100644 --- a/generic/tkSquare.c +++ b/generic/tkSquare.c @@ -332,7 +332,7 @@ SquareConfigure( Tk_SetWindowBackground(squarePtr->tkwin, Tk_3DBorderColor(bgBorder)->pixel); Tcl_GetBooleanFromObj(NULL, squarePtr->doubleBufferPtr, &doubleBuffer); - if ((squarePtr->gc == None) && (doubleBuffer)) { + if ((squarePtr->gc == NULL) && doubleBuffer) { XGCValues gcValues; gcValues.function = GXcopy; gcValues.graphics_exposures = False; @@ -397,7 +397,7 @@ SquareObjEventProc( if (squarePtr->tkwin != NULL) { Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable, squarePtr->tkwin); - if (squarePtr->gc != None) { + if (squarePtr->gc != NULL) { Tk_FreeGC(squarePtr->display, squarePtr->gc); } squarePtr->tkwin = NULL; -- cgit v0.12 From 2d798f8f6006c84bc6f4042e618ce5d7e905412c Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 13 Jan 2019 16:43:19 +0000 Subject: Avoid errors when a menu is destroyed before its postcommand is run. --- library/menu.tcl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/menu.tcl b/library/menu.tcl index cdfcc13..8d06868 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -493,11 +493,13 @@ proc ::tk::MenuMotion {menu x y state} { if {[string is false $mode]} { set delay [expr {[$menu cget -type] eq "menubar" ? 0 : 50}] if {[$menu type $index] eq "cascade"} { + # Catch these postcascade commands since the menu could be + # destroyed before they run. set Priv(menuActivatedTimer) \ - [after $delay [list $menu postcascade active]] + [after $delay "catch {$menu postcascade active}"] } else { set Priv(menuDeactivatedTimer) \ - [after $delay [list $menu postcascade none]] + [after $delay "catch {$menu postcascade none}"] } } } -- cgit v0.12 From 2f5b18681b5ac4100ef19d65ae31babbc0e840b4 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 13 Jan 2019 18:02:47 +0000 Subject: Add TkpPostTearoffMenu, called by TkPostTearoffMenu and used in the menu post command; eliminates #ifdef in the generic code. --- generic/tkMenu.c | 11 +----- generic/tkMenu.h | 4 ++- generic/tkMenuDraw.c | 64 ++--------------------------------- macosx/tkMacOSXMenu.c | 21 ++++++++---- unix/tkUnixMenu.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++- win/tkWinMenu.c | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 206 insertions(+), 79 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index f1ea8ff..e798337 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -881,11 +881,6 @@ MenuWidgetObjCmd( goto error; } if (objc == 5) { - if (menuPtr->menuType == TEAROFF_MENU) { - Tcl_AppendResult(interp, - "the index option is invalid for tearoff menus", NULL); - return TCL_ERROR; - } if (Tcl_GetIntFromObj(interp, objv[4], &entry) != TCL_OK) { goto error; } @@ -905,11 +900,7 @@ MenuWidgetObjCmd( } else if (menuPtr->menuType != TEAROFF_MENU) { result = TkpPostMenu(interp, menuPtr, x, y, entry); } else { -#ifdef TK_MAC_OSX - result = TkpPostMenu(interp, menuPtr, x, y, entry); -#else - result = TkPostTearoffMenu(interp, menuPtr, x, y); -#endif + result = TkpPostTearoffMenu(interp, menuPtr, x, y, entry); } break; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 92bf8b2..2c4e051 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -520,7 +520,7 @@ MODULE_SCOPE int TkPostCommand(TkMenu *menuPtr); MODULE_SCOPE int TkPostSubmenu(Tcl_Interp *interp, TkMenu *menuPtr, TkMenuEntry *mePtr); MODULE_SCOPE int TkPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y); + int x, int y); MODULE_SCOPE int TkPreprocessMenu(TkMenu *menuPtr); MODULE_SCOPE void TkRecomputeMenu(TkMenu *menuPtr); @@ -544,6 +544,8 @@ MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, int x, int y, int entry); +MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, + int x, int y, int entry); MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); #endif /* _TKMENU */ diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c index 3f492db..e954559 100644 --- a/generic/tkMenuDraw.c +++ b/generic/tkMenuDraw.c @@ -807,9 +807,8 @@ TkMenuImageProc( * * TkPostTearoffMenu -- * - * Posts a menu on the screen. Used to post tearoff menus. On Unix, all - * menus are posted this way. Adjusts the menu's position so that it fits - * on the screen, and maps and raises the menu. + * Posts a tearoff menu on the screen. Adjusts the menu's position so + * that it fits on the screen, and maps and raises the menu. * * Results: * Returns a standard Tcl Error. @@ -827,64 +826,7 @@ TkPostTearoffMenu( int x, int y) /* The root X,Y coordinates where we are * posting */ { - int vRootX, vRootY, vRootWidth, vRootHeight; - int result; - - TkActivateMenuEntry(menuPtr, -1); - TkRecomputeMenu(menuPtr); - result = TkPostCommand(menuPtr); - if (result != TCL_OK) { - return result; - } - - /* - * The post commands could have deleted the menu, which means we are dead - * and should go away. - */ - - if (menuPtr->tkwin == NULL) { - return TCL_OK; - } - - /* - * Adjust the position of the menu if necessary to keep it visible on the - * screen. There are two special tricks to make this work right: - * - * 1. If a virtual root window manager is being used then the coordinates - * are in the virtual root window of menuPtr's parent; since the menu - * uses override-redirect mode it will be in the *real* root window for - * the screen, so we have to map the coordinates from the virtual root - * (if any) to the real root. Can't get the virtual root from the menu - * itself (it will never be seen by the wm) so use its parent instead - * (it would be better to have an an option that names a window to use - * for this...). - * 2. The menu may not have been mapped yet, so its current size might be - * the default 1x1. To compute how much space it needs, use its - * requested size, not its actual size. - */ - - Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY, - &vRootWidth, &vRootHeight); - vRootWidth -= Tk_ReqWidth(menuPtr->tkwin); - if (x > vRootX + vRootWidth) { - x = vRootX + vRootWidth; - } - if (x < vRootX) { - x = vRootX; - } - vRootHeight -= Tk_ReqHeight(menuPtr->tkwin); - if (y > vRootY + vRootHeight) { - y = vRootY + vRootHeight; - } - if (y < vRootY) { - y = vRootY; - } - Tk_MoveToplevelWindow(menuPtr->tkwin, x, y); - if (!Tk_IsMapped(menuPtr->tkwin)) { - Tk_MapWindow(menuPtr->tkwin); - } - TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL); - return TCL_OK; + return TkpPostTearoffMenu(interp, menuPtr, x, y, -1); } /* diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index c7610fc..044b20c 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -753,9 +753,10 @@ TkpDestroyMenuEntry( /* *---------------------------------------------------------------------- * - * TkpPostMenu -- + * TkpPostMenu, TkPostTearoffMenu -- * - * Posts a menu on the screen. If entry is < 0 then the menu is + * Posts a menu on the screen. (Tearoff menus are the same as + * ordinary menus on the mac.) If entry is < 0 then the menu is * drawn so its top left corner is located at the point with * screen coordinates (x, y). Otherwise the top left corner of * the specified entry is located at that point. @@ -784,10 +785,6 @@ TkpPostMenu( if (root == NULL) { return TCL_ERROR; } - if (menuPtr->menuType == TEAROFF_MENU) { - entry -= 1; - } - Drawable d = Tk_WindowId(root); NSView *rootview = TkMacOSXGetRootControl(d); NSWindow *win = [rootview window]; @@ -818,6 +815,18 @@ TkpPostMenu( inPostMenu = 0; return TCL_OK; } + +int +TkpPostTearoffMenu( + Tcl_Interp *interp, /* The interpreter this menu lives in */ + TkMenu *menuPtr, /* The menu we are posting */ + int x, int y, /* The screen coordinates where the top left + * corner of the menu, or of the specified + * entry, will be located. */ + int entry) +{ + return TkpPostMenu(interp, menuPtr, x, y, entry); +} /* *---------------------------------------------------------------------- diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index f701819..c5c83ce 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -909,13 +909,102 @@ TkpPostMenu( TkMenu *menuPtr, int x, int y, int entry) { + return TkpPostTearoffMenu(interp, menuPtr, x, y, entry); +} + +/* + *---------------------------------------------------------------------- + * + * TkpPostTearoffMenu -- + * + * Posts a tearoff menu on the screen so that the top left corner of the + * specified entry is located at the point (x, y) in screen coordinates. + * If the entry parameter is negative, the upper left corner of the menu + * itself is placed at the point. On unix this is called when posting + * any menu. Adjusts the menu's position so that it fits on the screen, + * and maps and raises the menu. + * + * Results: + * Returns a standard Tcl Error. + * + * Side effects: + * The menu is posted. + * + *---------------------------------------------------------------------- + */ + +int +TkpPostTearoffMenu( + Tcl_Interp *interp, /* The interpreter of the menu */ + TkMenu *menuPtr, /* The menu we are posting */ + int x, int y, int entry) /* The root X,Y coordinates where the + * specified entry will be posted */ +{ + int vRootX, vRootY, vRootWidth, vRootHeight; + int result; + if (entry >= menuPtr->numEntries) { entry = menuPtr->numEntries - 1; } if (entry >= 0) { y -= menuPtr->entries[entry]->y; } - return TkPostTearoffMenu(interp, menuPtr, x, y); + + TkActivateMenuEntry(menuPtr, -1); + TkRecomputeMenu(menuPtr); + result = TkPostCommand(menuPtr); + if (result != TCL_OK) { + return result; + } + + /* + * The post commands could have deleted the menu, which means we are dead + * and should go away. + */ + + if (menuPtr->tkwin == NULL) { + return TCL_OK; + } + + /* + * Adjust the position of the menu if necessary to keep it visible on the + * screen. There are two special tricks to make this work right: + * + * 1. If a virtual root window manager is being used then the coordinates + * are in the virtual root window of menuPtr's parent; since the menu + * uses override-redirect mode it will be in the *real* root window for + * the screen, so we have to map the coordinates from the virtual root + * (if any) to the real root. Can't get the virtual root from the menu + * itself (it will never be seen by the wm) so use its parent instead + * (it would be better to have an an option that names a window to use + * for this...). + * 2. The menu may not have been mapped yet, so its current size might be + * the default 1x1. To compute how much space it needs, use its + * requested size, not its actual size. + */ + + Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY, + &vRootWidth, &vRootHeight); + vRootWidth -= Tk_ReqWidth(menuPtr->tkwin); + if (x > vRootX + vRootWidth) { + x = vRootX + vRootWidth; + } + if (x < vRootX) { + x = vRootX; + } + vRootHeight -= Tk_ReqHeight(menuPtr->tkwin); + if (y > vRootY + vRootHeight) { + y = vRootY + vRootHeight; + } + if (y < vRootY) { + y = vRootY; + } + Tk_MoveToplevelWindow(menuPtr->tkwin, x, y); + if (!Tk_IsMapped(menuPtr->tkwin)) { + Tk_MapWindow(menuPtr->tkwin); + } + TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL); + return TCL_OK; } /* diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 2957b0e..f1ac9b7 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -850,6 +850,100 @@ TkpPostMenu( /* *---------------------------------------------------------------------- * + * TkpPostTearoffMenu -- + * + * Posts a tearoff menu on the screen so that the top left corner of the + * specified entry is located at the point (x, y) in screen coordinates. + * If the entry parameter is negative, the upper left corner of the menu + * itself is placed at the point. Adjusts the menu's position so that it + * fits on the screen, and maps and raises the menu. + * + * Results: + * Returns a standard Tcl Error. + * + * Side effects: + * The menu is posted. + * + *---------------------------------------------------------------------- + */ + +int +TkpPostTearoffMenu( + Tcl_Interp *interp, /* The interpreter of the menu */ + TkMenu *menuPtr, /* The menu we are posting */ + int x, int y, int entry) /* The root X,Y coordinates where we are + * posting */ +{ + int vRootX, vRootY, vRootWidth, vRootHeight; + int result; + + if (entry >= menuPtr->numEntries) { + entry = menuPtr->numEntries - 1; + } + if (entry >= 0) { + y -= menuPtr->entries[entry]->y; + } + + TkActivateMenuEntry(menuPtr, -1); + TkRecomputeMenu(menuPtr); + result = TkPostCommand(menuPtr); + if (result != TCL_OK) { + return result; + } + + /* + * The post commands could have deleted the menu, which means we are dead + * and should go away. + */ + + if (menuPtr->tkwin == NULL) { + return TCL_OK; + } + + /* + * Adjust the position of the menu if necessary to keep it visible on the + * screen. There are two special tricks to make this work right: + * + * 1. If a virtual root window manager is being used then the coordinates + * are in the virtual root window of menuPtr's parent; since the menu + * uses override-redirect mode it will be in the *real* root window for + * the screen, so we have to map the coordinates from the virtual root + * (if any) to the real root. Can't get the virtual root from the menu + * itself (it will never be seen by the wm) so use its parent instead + * (it would be better to have an an option that names a window to use + * for this...). + * 2. The menu may not have been mapped yet, so its current size might be + * the default 1x1. To compute how much space it needs, use its + * requested size, not its actual size. + */ + + Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY, + &vRootWidth, &vRootHeight); + vRootWidth -= Tk_ReqWidth(menuPtr->tkwin); + if (x > vRootX + vRootWidth) { + x = vRootX + vRootWidth; + } + if (x < vRootX) { + x = vRootX; + } + vRootHeight -= Tk_ReqHeight(menuPtr->tkwin); + if (y > vRootY + vRootHeight) { + y = vRootY + vRootHeight; + } + if (y < vRootY) { + y = vRootY; + } + Tk_MoveToplevelWindow(menuPtr->tkwin, x, y); + if (!Tk_IsMapped(menuPtr->tkwin)) { + Tk_MapWindow(menuPtr->tkwin); + } + TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL); + return TCL_OK; +} + +/* + *---------------------------------------------------------------------- + * * TkpMenuNewEntry -- * * Adds a pointer to a new menu entry structure with the platform- -- cgit v0.12 From cd265b13ef5f38b99caf9727279b7a68ccceac2a Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 13 Jan 2019 19:24:18 +0000 Subject: Deal with empty menubuttons on the mac. --- macosx/tkMacOSXMenubutton.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 4df23b4..66bb4dd 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -244,7 +244,7 @@ void TkpComputeMenuButtonGeometry(butPtr) register TkMenuButton *butPtr; /* Widget record for menu button. */ { - int width, height, avgWidth, haveImage = 0, haveText = 0; + int width, height, avgWidth, haveImage = 0; int txtWidth, txtHeight; Tk_FontMetrics fm; int highlightWidth = butPtr->highlightWidth > 0 ? butPtr->highlightWidth : 0; @@ -267,6 +267,16 @@ TkpComputeMenuButtonGeometry(butPtr) haveImage = 1; } + /* + * Mac menubuttons do not display correctly with no image and empty text. + */ + + if (haveImage == 0 && strlen(butPtr->text) == 0) { + ckfree(butPtr->text); + butPtr->text = ckalloc(2); + strcpy(butPtr->text, " "); + } + if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, @@ -277,7 +287,6 @@ TkpComputeMenuButtonGeometry(butPtr) txtHeight = butPtr->textHeight; avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); Tk_GetFontMetrics(butPtr->tkfont, &fm); - haveText = (txtWidth != 0 && txtHeight != 2); } /* @@ -287,7 +296,7 @@ TkpComputeMenuButtonGeometry(butPtr) * image, because otherwise it is not really a compound button. */ - if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { + if (butPtr->compound != COMPOUND_NONE && haveImage) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: { -- cgit v0.12 From fe7e4b1e7f825147345d7e42707be7d53b72c904 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 14 Jan 2019 13:57:38 +0000 Subject: Fix the underlying problem with empty menubuttons on the mac, rather than the symptom. --- macosx/tkMacOSXMenubutton.c | 48 +++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 66bb4dd..8e22fd8 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -110,7 +110,6 @@ Tk_ClassProcs tkpMenubuttonClass = { #define LEFT_INSET 8 #define RIGHT_INSET 28 #define MIN_HEIGHT 22 - /* *---------------------------------------------------------------------- @@ -267,22 +266,11 @@ TkpComputeMenuButtonGeometry(butPtr) haveImage = 1; } - /* - * Mac menubuttons do not display correctly with no image and empty text. - */ - - if (haveImage == 0 && strlen(butPtr->text) == 0) { - ckfree(butPtr->text); - butPtr->text = ckalloc(2); - strcpy(butPtr->text, " "); - } - if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, butPtr->text, -1, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); - txtWidth = butPtr->textWidth; txtHeight = butPtr->textHeight; avgWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); @@ -358,8 +346,8 @@ TkpComputeMenuButtonGeometry(butPtr) } butPtr->inset = highlightWidth + butPtr->borderWidth; - width += LEFT_INSET + RIGHT_INSET + 2*butPtr->inset; - height += 2*butPtr->inset; + width += LEFT_INSET + RIGHT_INSET + 2*butPtr->inset; + height += 2*butPtr->inset; height = height < MIN_HEIGHT ? MIN_HEIGHT : height; Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); @@ -425,8 +413,8 @@ DrawMenuButtonImageAndText( pressed = 1; } - haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); - if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { + haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0); + if (butPtr->compound != COMPOUND_NONE && haveImage && haveText) { int x = 0; int y = 0; textXOffset = 0; @@ -609,9 +597,11 @@ TkMacOSXDrawMenuButton( hiinfo.animation.time.start = hiinfo.animation.time.current; } - HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, kHIThemeOrientationNormal, &contHIRec); + HIThemeDrawButton(&cntrRect, &hiinfo, dc.context, + kHIThemeOrientationNormal, &contHIRec); TkMacOSXRestoreDrawingContext(&dc); - MenuButtonContentDrawCB( mbPtr->btnkind, &mbPtr->drawinfo, (MacMenuButton *)mbPtr, 32, true); + MenuButtonContentDrawCB( mbPtr->btnkind, &mbPtr->drawinfo, + (MacMenuButton *)mbPtr, 32, true); } else { if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { return; @@ -748,19 +738,18 @@ MenuButtonEventProc( */ static void -TkMacOSXComputeMenuButtonParams(TkMenuButton * butPtr, ThemeButtonKind* btnkind, HIThemeButtonDrawInfo *drawinfo) +TkMacOSXComputeMenuButtonParams( + TkMenuButton * butPtr, + ThemeButtonKind* btnkind, + HIThemeButtonDrawInfo *drawinfo) { MacMenuButton *mbPtr = (MacMenuButton *)butPtr; - if (butPtr->image || butPtr->bitmap) { + if (butPtr->image || butPtr->bitmap || butPtr->text) { /* TODO: allow for Small and Mini menubuttons. */ *btnkind = kThemePopupButton; - } else { - if (!butPtr->text || !*butPtr->text) { - *btnkind = kThemeArrowButton; - } else { - *btnkind = kThemePopupButton; - } + } else { /* This should never happen. */ + *btnkind = kThemeArrowButton; } drawinfo->value = kThemeButtonOff; @@ -812,9 +801,12 @@ TkMacOSXComputeMenuButtonParams(TkMenuButton * butPtr, ThemeButtonKind* btnkind, */ static void -TkMacOSXComputeMenuButtonDrawParams(TkMenuButton * butPtr, DrawParams * dpPtr) +TkMacOSXComputeMenuButtonDrawParams( + TkMenuButton * butPtr, + DrawParams * dpPtr) { - dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) || (butPtr->bitmap != None)); + dpPtr->hasImageOrBitmap = ((butPtr->image != NULL) || + (butPtr->bitmap != None)); dpPtr->border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { dpPtr->gc = butPtr->disabledGC; -- cgit v0.12 From 4330a830cd514bf17caac0cfe5b29fef47022df7 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 15 Jan 2019 14:00:45 +0000 Subject: Use TkGetMenuIndex to parse the index argument to the post command. --- generic/tkMenu.c | 14 +++++++------- generic/tkMenu.h | 4 ++-- macosx/tkMacOSXMenu.c | 8 ++++---- unix/tkUnixMenu.c | 16 ++++++++-------- win/tkWinMenu.c | 22 +++++++++++----------- 5 files changed, 32 insertions(+), 32 deletions(-) diff --git a/generic/tkMenu.c b/generic/tkMenu.c index e798337..2c0f9a9 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -870,10 +870,10 @@ MenuWidgetObjCmd( break; } case MENU_POST: { - int x, y, entry = -1; + int x, y, index = -1; if (objc != 4 && objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "x y ?entry?"); + Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?"); goto error; } if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK) @@ -881,9 +881,9 @@ MenuWidgetObjCmd( goto error; } if (objc == 5) { - if (Tcl_GetIntFromObj(interp, objv[4], &entry) != TCL_OK) { - goto error; - } + if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) { + goto error; + } } /* @@ -898,9 +898,9 @@ MenuWidgetObjCmd( Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL); return TCL_ERROR; } else if (menuPtr->menuType != TEAROFF_MENU) { - result = TkpPostMenu(interp, menuPtr, x, y, entry); + result = TkpPostMenu(interp, menuPtr, x, y, index); } else { - result = TkpPostTearoffMenu(interp, menuPtr, x, y, entry); + result = TkpPostTearoffMenu(interp, menuPtr, x, y, index); } break; } diff --git a/generic/tkMenu.h b/generic/tkMenu.h index 2c4e051..6d1fe5a 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -543,9 +543,9 @@ MODULE_SCOPE void TkpMenuInit(void); MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr); MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr); MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y, int entry); + int x, int y, int index); MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y, int entry); + int x, int y, int index); MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr); #endif /* _TKMENU */ diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 044b20c..1d3bd34 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -777,7 +777,7 @@ TkpPostMenu( int x, int y, /* The screen coordinates where the top left * corner of the menu, or of the specified * entry, will be located. */ - int entry) + int index) { /* Get the object that holds this Tk Window.*/ Tk_Window root = Tk_MainWindow(interp); @@ -791,7 +791,7 @@ TkpPostMenu( NSView *view = [win contentView]; NSMenu *menu = (NSMenu *) menuPtr->platformData; NSMenuItem *item = nil; - NSInteger index = entry; + NSInteger index = index; NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); int result, oldMode; @@ -823,9 +823,9 @@ TkpPostTearoffMenu( int x, int y, /* The screen coordinates where the top left * corner of the menu, or of the specified * entry, will be located. */ - int entry) + int index) { - return TkpPostMenu(interp, menuPtr, x, y, entry); + return TkpPostMenu(interp, menuPtr, x, y, index); } /* diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c index c5c83ce..d7ed873 100644 --- a/unix/tkUnixMenu.c +++ b/unix/tkUnixMenu.c @@ -907,9 +907,9 @@ int TkpPostMenu( Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y, int entry) + int x, int y, int index) { - return TkpPostTearoffMenu(interp, menuPtr, x, y, entry); + return TkpPostTearoffMenu(interp, menuPtr, x, y, index); } /* @@ -919,7 +919,7 @@ TkpPostMenu( * * Posts a tearoff menu on the screen so that the top left corner of the * specified entry is located at the point (x, y) in screen coordinates. - * If the entry parameter is negative, the upper left corner of the menu + * If the index parameter is negative, the upper left corner of the menu * itself is placed at the point. On unix this is called when posting * any menu. Adjusts the menu's position so that it fits on the screen, * and maps and raises the menu. @@ -937,17 +937,17 @@ int TkpPostTearoffMenu( Tcl_Interp *interp, /* The interpreter of the menu */ TkMenu *menuPtr, /* The menu we are posting */ - int x, int y, int entry) /* The root X,Y coordinates where the + int x, int y, int index) /* The root X,Y coordinates where the * specified entry will be posted */ { int vRootX, vRootY, vRootWidth, vRootHeight; int result; - if (entry >= menuPtr->numEntries) { - entry = menuPtr->numEntries - 1; + if (index >= menuPtr->numEntries) { + index = menuPtr->numEntries - 1; } - if (entry >= 0) { - y -= menuPtr->entries[entry]->y; + if (index >= 0) { + y -= menuPtr->entries[index]->y; } TkActivateMenuEntry(menuPtr, -1); diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index f1ac9b7..af127bf 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -761,7 +761,7 @@ int TkpPostMenu( Tcl_Interp *interp, TkMenu *menuPtr, - int x, int y, int entry) + int x, int y, int index) { HMENU winMenuHdl = (HMENU) menuPtr->platformData; int result, flags; @@ -781,11 +781,11 @@ TkpPostMenu( return result; } - if (entry >= menuPtr->numEntries) { - entry = menuPtr->numEntries - 1; + if (index >= menuPtr->numEntries) { + index = menuPtr->numEntries - 1; } - if (entry >= 0) { - y -= menuPtr->entries[entry]->y; + if (index >= 0) { + y -= menuPtr->entries[index]->y; } /* @@ -854,7 +854,7 @@ TkpPostMenu( * * Posts a tearoff menu on the screen so that the top left corner of the * specified entry is located at the point (x, y) in screen coordinates. - * If the entry parameter is negative, the upper left corner of the menu + * If the index parameter is negative, the upper left corner of the menu * itself is placed at the point. Adjusts the menu's position so that it * fits on the screen, and maps and raises the menu. * @@ -871,17 +871,17 @@ int TkpPostTearoffMenu( Tcl_Interp *interp, /* The interpreter of the menu */ TkMenu *menuPtr, /* The menu we are posting */ - int x, int y, int entry) /* The root X,Y coordinates where we are + int x, int y, int index) /* The root X,Y coordinates where we are * posting */ { int vRootX, vRootY, vRootWidth, vRootHeight; int result; - if (entry >= menuPtr->numEntries) { - entry = menuPtr->numEntries - 1; + if (index >= menuPtr->numEntries) { + index = menuPtr->numEntries - 1; } - if (entry >= 0) { - y -= menuPtr->entries[entry]->y; + if (index >= 0) { + y -= menuPtr->entries[index]->y; } TkActivateMenuEntry(menuPtr, -1); -- cgit v0.12 From c30080a5540a2fd71dae2122cfd926a7ead68461 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 15 Jan 2019 14:48:31 +0000 Subject: Fix name collision on macOS. Clarify some logic in the geometry computation. --- macosx/tkMacOSXMenu.c | 3 +-- macosx/tkMacOSXMenubutton.c | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 1d3bd34..f36da42 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -791,7 +791,6 @@ TkpPostMenu( NSView *view = [win contentView]; NSMenu *menu = (NSMenu *) menuPtr->platformData; NSMenuItem *item = nil; - NSInteger index = index; NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); int result, oldMode; @@ -805,7 +804,7 @@ TkpPostMenu( index = [menu numberOfItems] - 1; } if (index >= 0) { - item = [menu itemAtIndex:index]; + item = [menu itemAtIndex:(NSInteger)index]; } oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); [menu popUpMenuPositioningItem:item diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 8e22fd8..b2b4b76 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -243,7 +243,7 @@ void TkpComputeMenuButtonGeometry(butPtr) register TkMenuButton *butPtr; /* Widget record for menu button. */ { - int width, height, avgWidth, haveImage = 0; + int width, height, avgWidth, haveImage = 0, haveText = 0; int txtWidth, txtHeight; Tk_FontMetrics fm; int highlightWidth = butPtr->highlightWidth > 0 ? butPtr->highlightWidth : 0; @@ -266,7 +266,8 @@ TkpComputeMenuButtonGeometry(butPtr) haveImage = 1; } - if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { + if (butPtr->text && strlen(butPtr->text) > 0) { + haveText = 1; Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, butPtr->text, -1, butPtr->wrapLength, @@ -284,7 +285,7 @@ TkpComputeMenuButtonGeometry(butPtr) * image, because otherwise it is not really a compound button. */ - if (butPtr->compound != COMPOUND_NONE && haveImage) { + if (haveImage && haveText) { switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: { @@ -326,14 +327,14 @@ TkpComputeMenuButtonGeometry(butPtr) } } else { - if (haveImage) { + if (haveImage) { /* Image only */ if (butPtr->width > 0) { width = butPtr->width; } if (butPtr->height > 0) { height = butPtr->height; } - } else { + } else { /* Text only */ width = txtWidth; height = txtHeight; if (butPtr->width > 0) { -- cgit v0.12 From 0108f0519ddb45089bcd6e5e1e1b62112214df24 Mon Sep 17 00:00:00 2001 From: culler Date: Tue, 15 Jan 2019 21:22:45 +0000 Subject: For macOS, guard against a crash in TkpPostMenu and fix TkPostTearoffMenu. Adjust menu.test for the new argument name. --- macosx/tkMacOSXMenu.c | 26 +++++++++++++++----------- tests/menu.test | 2 +- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index f36da42..ed8d0c3 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -779,7 +779,7 @@ TkpPostMenu( * entry, will be located. */ int index) { - /* Get the object that holds this Tk Window.*/ + int result, oldMode; Tk_Window root = Tk_MainWindow(interp); if (root == NULL) { @@ -790,9 +790,10 @@ TkpPostMenu( NSWindow *win = [rootview window]; NSView *view = [win contentView]; NSMenu *menu = (NSMenu *) menuPtr->platformData; + NSInteger itemIndex = index; + NSInteger numItems = [menu numberOfItems]; NSMenuItem *item = nil; NSPoint location = NSMakePoint(x, tkMacOSXZeroScreenHeight - y); - int result, oldMode; inPostMenu = 1; result = TkPreprocessMenu(menuPtr); @@ -800,17 +801,19 @@ TkpPostMenu( inPostMenu = 0; return result; } - if (index >= [menu numberOfItems]) { - index = [menu numberOfItems] - 1; + if (itemIndex >= numItems) { + itemIndex = numItems - 1; + } + if (itemIndex >= 0) { + item = [menu itemAtIndex:itemIndex]; } - if (index >= 0) { - item = [menu itemAtIndex:(NSInteger)index]; + if (menu != nil && item != nil) { + oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); + [menu popUpMenuPositioningItem:item + atLocation:[win tkConvertPointFromScreen:location] + inView:view]; + Tcl_SetServiceMode(oldMode); } - oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); - [menu popUpMenuPositioningItem:item - atLocation:[win tkConvertPointFromScreen:location] - inView:view]; - Tcl_SetServiceMode(oldMode); inPostMenu = 0; return TCL_OK; } @@ -824,6 +827,7 @@ TkpPostTearoffMenu( * entry, will be located. */ int index) { + menuPtr->active = -1; return TkpPostMenu(interp, menuPtr, x, y, index); } diff --git a/tests/menu.test b/tests/menu.test index dcc578f..9ad2a0c 100644 --- a/tests/menu.test +++ b/tests/menu.test @@ -1606,7 +1606,7 @@ test menu-3.47 {MenuWidgetCmd procedure, "post" option} -setup { .m1 post } -cleanup { destroy .m1 -} -returnCodes error -result {wrong # args: should be ".m1 post x y ?entry?"} +} -returnCodes error -result {wrong # args: should be ".m1 post x y ?index?"} test menu-3.48 {MenuWidgetCmd procedure, "post" option} -setup { destroy .m1 } -body { -- cgit v0.12 From c910f94eaaf0390532bf9b6f96c43e89c2e7939d Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 16 Jan 2019 03:41:10 +0000 Subject: Fix bug [e733d3770f]: geometry issues with buttons on macOS --- library/demos/puzzle.tcl | 2 +- macosx/tkMacOSXButton.c | 141 ++++++++++++++++++----------------------------- tests/unixButton.test | 24 ++++++-- 3 files changed, 74 insertions(+), 93 deletions(-) diff --git a/library/demos/puzzle.tcl b/library/demos/puzzle.tcl index 4f7f955..eebe87a 100644 --- a/library/demos/puzzle.tcl +++ b/library/demos/puzzle.tcl @@ -73,7 +73,7 @@ for {set i 0} {$i < 15} {set i [expr {$i+1}]} { set num [lindex $order $i] set xpos($num) [expr {($i%4)*.25}] set ypos($num) [expr {($i/4)*.25}] - button $w.frame.$num -relief raised -text $num -highlightthickness 0 \ + button $w.frame.$num -relief raised -text $num -bd 0 -highlightthickness 0 \ -command "puzzleSwitch $w $num" place $w.frame.$num -relx $xpos($num) -rely $ypos($num) \ -relwidth .25 -relheight .25 diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index ea78d43..d387b83 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -29,19 +29,10 @@ * be allowed when drawing the HITheme button. */ -#define HI_PADX 2 +#define HI_PADX 14 #define HI_PADY 1 /* - * Some defines used to control what type of control is drawn. - */ - -#define DRAW_LABEL 0 /* Labels are treated genericly. */ -#define DRAW_CONTROL 1 /* Draw using the Native control. */ -#define DRAW_CUSTOM 2 /* Make our own button drawing. */ -#define DRAW_BEVEL 3 - -/* * The delay in milliseconds between pulsing default button redraws. */ #define PULSE_TIMER_MSECS 62 /* Largest value that didn't look stuttery */ @@ -52,7 +43,6 @@ typedef struct { - int drawType; Tk_3DBorder border; int relief; int offset; /* 0 means this is a normal widget. 1 means @@ -271,11 +261,7 @@ TkpComputeButtonGeometry( int txtWidth = 0, txtHeight = 0; MacButton *mbPtr = (MacButton*)butPtr; Tk_FontMetrics fm; - DrawParams drawParams; - - /* - * First figure out the size of the contents of the button. - */ + char *text = Tcl_GetString(butPtr->textPtr); TkMacOSXComputeButtonParams(butPtr, &mbPtr->btnkind, &mbPtr->drawinfo); @@ -283,7 +269,7 @@ TkpComputeButtonGeometry( * If the indicator is on, get its size. */ - if ( butPtr->indicatorOn ) { + if (butPtr->indicatorOn) { switch (butPtr->type) { case TYPE_RADIO_BUTTON: GetThemeMetric(kThemeMetricRadioButtonWidth, (SInt32 *)&butPtr->indicatorDiameter); @@ -309,23 +295,22 @@ TkpComputeButtonGeometry( haveImage = 1; } - if (haveImage == 0 || butPtr->compound != COMPOUND_NONE) { + if (strlen(text) > 0) { Tk_FreeTextLayout(butPtr->textLayout); butPtr->textLayout = Tk_ComputeTextLayout(butPtr->tkfont, Tcl_GetString(butPtr->textPtr), -1, butPtr->wrapLength, butPtr->justify, 0, &butPtr->textWidth, &butPtr->textHeight); - txtWidth = butPtr->textWidth; - txtHeight = butPtr->textHeight; - charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); - Tk_GetFontMetrics(butPtr->tkfont, &fm); - haveText = (txtWidth != 0 && txtHeight != 0); + txtWidth = butPtr->textWidth + 2*butPtr->padX; + txtHeight = butPtr->textHeight + 2*butPtr->padY; + haveText = 1; } if (haveImage && haveText) { /* Image and Text */ switch ((enum compound) butPtr->compound) { case COMPOUND_TOP: case COMPOUND_BOTTOM: + /* * Image is above or below text. */ @@ -335,14 +320,16 @@ TkpComputeButtonGeometry( break; case COMPOUND_LEFT: case COMPOUND_RIGHT: + /* * Image is left or right of text. */ - width += txtWidth + butPtr->padX; + width += txtWidth + 2*butPtr->padX; height = (height > txtHeight ? height : txtHeight); break; case COMPOUND_CENTER: + /* * Image and text are superimposed. */ @@ -354,26 +341,27 @@ TkpComputeButtonGeometry( break; } width += butPtr->indicatorSpace; - } else if (haveImage) { /* Image only */ - width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace; - height = butPtr->height > 0 ? butPtr->height : height; - + width = butPtr->width > 0 ? butPtr->width : width + butPtr->indicatorSpace; + height = butPtr->height > 0 ? butPtr->height : height; + if (butPtr->type == TYPE_BUTTON) { + /* Allow room to shift the image. */ + width += 2; + height += 2; + } } else { /* Text only */ width = txtWidth + butPtr->indicatorSpace; height = txtHeight; if (butPtr->width > 0) { - width = butPtr->width * charWidth; + charWidth = Tk_TextWidth(butPtr->tkfont, "0", 1); + width = butPtr->width * charWidth + 2*butPtr->padX; } if (butPtr->height > 0) { - height = butPtr->height * fm.linespace; + Tk_GetFontMetrics(butPtr->tkfont, &fm); + height = butPtr->height * fm.linespace + 2*butPtr->padY; } } - /* Add padding */ - width += 2 * butPtr->padX; - height += 2 * butPtr->padY; - /* * Now figure out the size of the border decorations for the button. */ @@ -382,48 +370,35 @@ TkpComputeButtonGeometry( butPtr->highlightWidth = 0; } - butPtr->inset = 0; - butPtr->inset += butPtr->highlightWidth; + butPtr->inset = butPtr->borderWidth + butPtr->highlightWidth; - if (TkMacOSXComputeButtonDrawParams(butPtr,&drawParams)) { + width += butPtr->inset*2; + height += butPtr->inset*2; + if ([NSApp macMinorVersion] == 6) { + width += 12; + } + if (mbPtr->btnkind == kThemePushButton) { HIRect tmpRect; HIRect contBounds; - int paddingx = 0; - int paddingy = 0; + /* + * A PushButton has a minimum size. We make sure that we + * are not underestimating the size by requesting the content + * size of a Pushbutton whose overall size is our content size + * expanded by the standard padding. + */ + tmpRect = CGRectMake(0, 0, width + 2*HI_PADX, height + 2*HI_PADY); - HIThemeGetButtonContentBounds(&tmpRect, &mbPtr->drawinfo, &contBounds); - /* If the content region has a minimum height, match it. */ if (height < contBounds.size.height) { - height = contBounds.size.height; + height = contBounds.size.height; } - - /* If the content region has a minimum width, match it. */ if (width < contBounds.size.width) { - width = contBounds.size.width; + width = contBounds.size.width; } - - /* Pad to fill difference between content bounds and button bounds. */ - paddingx = contBounds.origin.x; - paddingy = contBounds.origin.y; - - if (height < paddingx - 4) { - /* can't have buttons much shorter than button side diameter. */ - height = paddingx - 4; - } - - } else { - height += butPtr->borderWidth*2; - width += butPtr->borderWidth*2; - } - - width += butPtr->inset*2; - height += butPtr->inset*2; - if ([NSApp macMinorVersion] == 6) { - width += 12; + height += 2*HI_PADY; + width += 2*HI_PADX; } - Tk_GeometryRequest(butPtr->tkwin, width, height); Tk_SetInternalBorder(butPtr->tkwin, butPtr->inset); } @@ -1119,7 +1094,6 @@ TkMacOSXComputeButtonDrawParams( } } - dpPtr->border = butPtr->normalBorder; if ((butPtr->state == STATE_DISABLED) && (butPtr->disabledFg != NULL)) { dpPtr->gc = butPtr->disabledGC; @@ -1149,29 +1123,22 @@ TkMacOSXComputeButtonDrawParams( } } - /* - * Determine the draw type - */ - - if (butPtr->type == TYPE_LABEL) { - dpPtr->drawType = DRAW_LABEL; - } else if (butPtr->type == TYPE_BUTTON) { - if (!dpPtr->hasImageOrBitmap) { - dpPtr->drawType = DRAW_CONTROL; - } else { - dpPtr->drawType = DRAW_BEVEL; - } - } else if (butPtr->indicatorOn) { - dpPtr->drawType = DRAW_CONTROL; - } else if (dpPtr->hasImageOrBitmap) { - dpPtr->drawType = DRAW_BEVEL; - } else { - dpPtr->drawType = DRAW_CUSTOM; - } - - if ((dpPtr->drawType == DRAW_CONTROL) || (dpPtr->drawType == DRAW_BEVEL)) { + if (butPtr->type != TYPE_LABEL && + (butPtr->type == TYPE_BUTTON || + butPtr->indicatorOn || + dpPtr->hasImageOrBitmap)) { + + /* + * Draw this widget as a native control. + */ + return 1; } else { + + /* + * Draw this widget from scratch. + */ + return 0; } } diff --git a/tests/unixButton.test b/tests/unixButton.test index 137ef33..c7b7b1d 100644 --- a/tests/unixButton.test +++ b/tests/unixButton.test @@ -35,7 +35,15 @@ proc bogusTrace args { error "trace aborted" } - +if {[tk windowingsystem] eq "aqua"} { + set smallIndicator 20 + set bigIndicator 20 + set defaultBorder 10 +} else { + set smallIndicator 27 + set bigindicator 40 + set defaultBorder 20 +} test unixbutton-1.1 {TkpComputeButtonGeometry procedure} -constraints { unix testImageType } -setup { @@ -57,7 +65,10 @@ test unixbutton-1.1 {TkpComputeButtonGeometry procedure} -constraints { } -cleanup { deleteWindows image delete image1 -} -result {68 48 74 54 112 52 112 52} +} -result [list 68 48 \ + 74 54 \ + [expr {72 + $bigIndicator}] 52 \ + [expr {72 + $bigIndicator}] 52] test unixbutton-1.2 {TkpComputeButtonGeometry procedure} -constraints { unix } -setup { @@ -75,7 +86,10 @@ test unixbutton-1.2 {TkpComputeButtonGeometry procedure} -constraints { [winfo reqwidth .b4] [winfo reqheight .b4] } -cleanup { deleteWindows -} -result {23 33 29 39 54 37 54 37} +} -result [list 23 33 \ + 29 39 \ + [expr {27 + $smallIndicator}] 37 \ + [expr {27 + $smallIndicator}] 37] test unixbutton-1.3 {TkpComputeButtonGeometry procedure} -constraints { unix } -setup { @@ -186,7 +200,7 @@ test unixbutton-1.9 {TkpComputeButtonGeometry procedure} -constraints { list [winfo reqwidth .b2] [winfo reqheight .b2] } -cleanup { deleteWindows -} -result {37 47} +} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]] test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints { unix } -setup { @@ -196,7 +210,7 @@ test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints { list [winfo reqwidth .b2] [winfo reqheight .b2] } -cleanup { deleteWindows -} -result {37 47} +} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]] test unixbutton-1.11 {TkpComputeButtonGeometry procedure} -constraints { unix } -setup { -- cgit v0.12 From bf838a24f35ee704ccdc9b8538c32a1559f4c3e7 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 16 Jan 2019 14:06:13 +0000 Subject: Tiny adjustment to text position, to match native buttons. --- macosx/tkMacOSXButton.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index d387b83..c0b83f2 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -545,7 +545,6 @@ DrawButtonImageAndText( } imageXOffset += x; imageYOffset += y; - textYOffset -= 1; if (butPtr->image != NULL) { if ((butPtr->selectImage != NULL) && @@ -569,6 +568,7 @@ DrawButtonImageAndText( XSetClipOrigin(butPtr->display, dpPtr->gc, 0, 0); } + y += 1; /* Tweak to match native buttons. */ Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x + textXOffset, y + textYOffset, 0, -1); @@ -621,6 +621,7 @@ DrawButtonImageAndText( butPtr->textWidth + butPtr->indicatorSpace, butPtr->textHeight, &x, &y); x += butPtr->indicatorSpace; + y += 1; /* Tweak to match native buttons */ Tk_DrawTextLayout(butPtr->display, pixmap, dpPtr->gc, butPtr->textLayout, x, y, 0, -1); } -- cgit v0.12 From 397080972af194847060c6c7751204233e16e22f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 20 Jan 2019 08:46:48 +0000 Subject: Remove the last remaining reference to NO_WINRGBFIX --- win/tkWinDraw.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index a396937..6986ef6 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -519,9 +519,7 @@ TkPutImage( BITMAPINFO *infoPtr; HBITMAP bitmap; char *data; -#ifndef NO_WINRGBFIX Visual *visual; -#endif display->request++; -- cgit v0.12 From 32d6e2eb986ea2386dba70fe7a93cb7330a61da4 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 20 Jan 2019 19:32:37 +0000 Subject: Fix typo triggering error when running unixButton tests on Windows and Linux. --- tests/unixButton.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unixButton.test b/tests/unixButton.test index c7b7b1d..325f497 100644 --- a/tests/unixButton.test +++ b/tests/unixButton.test @@ -41,7 +41,7 @@ if {[tk windowingsystem] eq "aqua"} { set defaultBorder 10 } else { set smallIndicator 27 - set bigindicator 40 + set bigIndicator 40 set defaultBorder 20 } test unixbutton-1.1 {TkpComputeButtonGeometry procedure} -constraints { -- cgit v0.12 From 375b837a661f0c2f82e6fc3c530261fedbf065d2 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Jan 2019 17:45:28 +0000 Subject: Fix bug [58665b91dd]: unixEmbed tests fail on macOS due to use of dobg. --- macosx/tkMacOSXEmbed.c | 134 ++++------- macosx/tkMacOSXEvent.c | 38 +-- tests/unixEmbed.test | 619 +++++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 638 insertions(+), 153 deletions(-) diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 589475c..2dbfdc8 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -272,7 +272,14 @@ TkpUseWindow( } usePtr = (TkWindow *) Tk_IdToWindow(winPtr->display, (Window) parent); - if (usePtr != NULL && !(usePtr->flags & TK_CONTAINER)) { + if (usePtr == NULL) { + if (interp != NULL) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "couldn't create child of window \"%s\"", string)); + Tcl_SetErrorCode(interp, "TK", "EMBED", "NO_TARGET", NULL); + } + return TCL_ERROR; + } else if (!(usePtr->flags & TK_CONTAINER)) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "window \"%s\" doesn't have -container option set", usePtr->pathName)); @@ -281,15 +288,9 @@ TkpUseWindow( } /* - * The code below can probably be simplified given we have already - * discovered 'usePtr' above. - */ - - /* - * Save information about the container and the embedded window in a - * Container structure. Currently, there must already be an existing - * Container structure, since we only allow the case where both container - * and embedded app. are in the same process. + * Since we do not allow embedding into windows belonging to a different + * process, we know that a container will exist showing the parent window + * as the parent. This loop finds that container. */ for (containerPtr = firstContainerPtr; containerPtr != NULL; @@ -312,16 +313,6 @@ TkpUseWindow( } macWin->winPtr = winPtr; - winPtr->privatePtr = macWin; - - /* - * The grafPtr will be NULL for a Tk in Tk embedded window. It is none of - * our business what it is for a Tk not in Tk embedded window, but we will - * initialize it to NULL, and let the registerWinProc set it. In any case, - * you must always use TkMacOSXGetDrawablePort to get the portPtr. It will - * correctly find the container's port. - */ - macWin->view = nil; macWin->context = NULL; macWin->size = CGSizeZero; @@ -333,6 +324,7 @@ TkpUseWindow( macWin->toplevel = macWin; macWin->toplevel->referenceCount++; + winPtr->privatePtr = macWin; winPtr->flags |= TK_EMBEDDED; /* @@ -341,64 +333,28 @@ TkpUseWindow( */ macWin->flags |= TK_EMBEDDED; + macWin->xOff = parent->winPtr->privatePtr->xOff + + parent->winPtr->changes.border_width + + winPtr->changes.x; + macWin->yOff = parent->winPtr->privatePtr->yOff + + parent->winPtr->changes.border_width + + winPtr->changes.y; /* - * Now check whether it is embedded in another Tk widget. If not (the - * first case below) we see if there is an in-process embedding handler - * registered, and if so, let that fill in the rest of the macWin. + * Finish filling up the container structure with the embedded + * window's information. */ - if (containerPtr == NULL) { - /* - * If someone has registered an in-process embedding handler, then - * see if it can handle this window... - */ - - if (tkMacOSXEmbedHandler == NULL || - tkMacOSXEmbedHandler->registerWinProc((long) parent, - (Tk_Window) winPtr) != TCL_OK) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "The window ID %s does not correspond to a valid Tk Window", - string)); - Tcl_SetErrorCode(interp, "TK", "EMBED", "HANDLE", NULL); - return TCL_ERROR; - } - - containerPtr = ckalloc(sizeof(Container)); - - containerPtr->parentPtr = NULL; - containerPtr->embedded = (Window) macWin; - containerPtr->embeddedPtr = macWin->winPtr; - containerPtr->nextPtr = firstContainerPtr; - firstContainerPtr = containerPtr; - } else { - /* - * The window is embedded in another Tk window. - */ + containerPtr->embedded = (Window) macWin; + containerPtr->embeddedPtr = macWin->winPtr; - macWin->xOff = parent->winPtr->privatePtr->xOff + - parent->winPtr->changes.border_width + - winPtr->changes.x; - macWin->yOff = parent->winPtr->privatePtr->yOff + - parent->winPtr->changes.border_width + - winPtr->changes.y; - - /* - * Finish filling up the container structure with the embedded - * window's information. - */ - - containerPtr->embedded = (Window) macWin; - containerPtr->embeddedPtr = macWin->winPtr; - - /* - * Create an event handler to clean up the Container structure when - * tkwin is eventually deleted. - */ + /* + * Create an event handler to clean up the Container structure when + * tkwin is eventually deleted. + */ - Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc, - winPtr); - } + Tk_CreateEventHandler(tkwin, StructureNotifyMask, EmbeddedEventProc, + winPtr); return TCL_OK; } @@ -614,6 +570,7 @@ TkpTestembedCmd( Container *containerPtr; Tcl_DString dString; char buffer[50]; + Tcl_Interp *embeddedInterp = NULL, *parentInterp = NULL; if ((objc > 1) && (strcmp(Tcl_GetString(objv[1]), "all") == 0)) { all = 1; @@ -623,30 +580,40 @@ TkpTestembedCmd( Tcl_DStringInit(&dString); for (containerPtr = firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { + if (containerPtr->embeddedPtr != NULL) { + embeddedInterp = containerPtr->embeddedPtr->mainPtr->interp; + } + if (containerPtr->parentPtr != NULL) { + parentInterp = containerPtr->parentPtr->mainPtr->interp; + } + if (embeddedInterp != interp && parentInterp != interp) { + continue; + } Tcl_DStringStartSublist(&dString); + /* Parent id */ if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->parent); + sprintf(buffer, "0x%lx", containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); } - if (containerPtr->parentPtr == NULL) { + /* Parent pathName */ + if (containerPtr->parentPtr == NULL || + parentInterp != interp) { Tcl_DStringAppendElement(&dString, ""); } else { Tcl_DStringAppendElement(&dString, containerPtr->parentPtr->pathName); } - if (containerPtr->embedded == None) { - Tcl_DStringAppendElement(&dString, ""); - } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->embedded); - Tcl_DStringAppendElement(&dString, buffer); - } else { - Tcl_DStringAppendElement(&dString, "XXX"); - } - if (containerPtr->embeddedPtr == NULL) { + /* + * On X11 embedded is a wrapper, which does not exist on macOS. + */ + Tcl_DStringAppendElement(&dString, ""); + /* Embedded window pathName */ + if (containerPtr->embeddedPtr == NULL || + embeddedInterp != interp) { Tcl_DStringAppendElement(&dString, ""); } else { Tcl_DStringAppendElement(&dString, @@ -1094,6 +1061,7 @@ static void EmbedSendConfigure( Container *containerPtr) /* Information about the embedding. */ { + printf("Call to EmbedSendConfigure\n"); } /* diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index d866b02..b9c9b6a 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -114,21 +114,16 @@ enum { * * This routine is a stub called by XSync, which is called during the Tk * update command. The language specification does not require that the - * update command be synchronous but many of the tests assume that is the - * case. It is not naturally the case on macOS since many idle tasks are - * run inside of the drawRect method of a window's contentView, and that - * method will not be called until after this function returns. To make - * the tests work, we attempt to force this to be synchronous by waiting - * until drawRect has been called for each window. The mechanism we use - * for this is to have drawRect post an ApplicationDefined NSEvent on the - * AppKit event queue when it finishes drawing, and wait for it here. + * update command be synchronous but many of the tests implicitly assume + * that it is. It is definitely asynchronous on macOS since many idle + * tasks are run inside of the drawRect method of a window's contentView, + * which will not be called until after this function returns. * * Results: * None. * - * Side effects: - * Calls the drawRect method of the contentView of each visible - * window. + * Side effects: Processes all pending idle events then calls the display + * method of each visible window. * *---------------------------------------------------------------------- */ @@ -136,23 +131,12 @@ enum { MODULE_SCOPE void TkMacOSXFlushWindows(void) { - NSArray *macWindows = [NSApp orderedWindows]; - - if ([macWindows count] > 0) { - while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} + if (Tk_GetNumMainWindows() == 0) { + return; } - if ([NSApp isDrawing]) { - for (NSWindow *w in macWindows) { - if (TkMacOSXGetXWindow(w)) { - [w setViewsNeedDisplay:YES]; - } - } - } else { - for (NSWindow *w in macWindows) { - if (TkMacOSXGetXWindow(w)) { - [w display]; - } - } + while (Tcl_DoOneEvent(TCL_IDLE_EVENTS)){} + for (NSWindow *w in [NSApp orderedWindows]) { + [w display]; } } diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 8aaa3c4..0894365 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1,4 +1,4 @@ -# This file is a Tcl script to test out the procedures in the file +# This file is a Tcl script to test out the procedures in the file # tkUnixEmbed.c. It is organized in the standard fashion for Tcl # tests. # @@ -55,14 +55,14 @@ proc colorsFree {w {red 31} {green 245} {blue 192}} { } test unixEmbed-1.1 {TkpUseWindow procedure, bad window identifier} -constraints { - unix + unix } -setup { deleteWindows } -body { toplevel .t -use xyz } -returnCodes error -result {expected integer but got "xyz"} test unixEmbed-1.2 {TkpUseWindow procedure, bad window identifier} -constraints { - unix + unix } -setup { deleteWindows } -body { @@ -97,7 +97,7 @@ test unixEmbed-1.4 {TkpUseWindow procedure, inheriting colormap} -constraints { } -result {1} test unixEmbed-1.5 {TkpUseWindow procedure, creating Container records} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -113,8 +113,29 @@ test unixEmbed-1.5 {TkpUseWindow procedure, creating Container records} -constra } -cleanup { deleteWindows } -result {{{XXX {} {} .t}} 0} +test unixEmbed-1.5a {TkpUseWindow procedure, creating Container records} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + frame .f2 -container 1 -width 200 -height 50 + pack .f1 .f2 + slave alias w winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t -use [w] + list [testembed] [expr {[lindex [lindex [testembed all] 0] 0] - [w]}] + } +} -cleanup { + interp delete slave + deleteWindows +} -result {{{XXX {} {} .t}} 0} test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -132,6 +153,29 @@ test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constra } -cleanup { deleteWindows } -result {{XXX {} {} .t2} {XXX {} {} .t1}} +test unixEmbed-1.6a {TkpUseWindow procedure, creating Container records} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + frame .f2 -container 1 -width 200 -height 50 + pack .f1 .f2 + slave alias w1 winfo id .f1 + slave alias w2 winfo id .f2 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + toplevel .t2 -use [w2] + testembed + } +} -cleanup { + interp delete slave + deleteWindows +} -result {{XXX {} {} .t2} {XXX {} {} .t1}} test unixEmbed-1.7 {TkpUseWindow procedure, container and embedded in same app} -constraints { unix testembed } -setup { @@ -152,7 +196,7 @@ test unixEmbed-1.7 {TkpUseWindow procedure, container and embedded in same app} test unixEmbed-2.1 {EmbeddedEventProc procedure} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -172,8 +216,32 @@ test unixEmbed-2.1 {EmbeddedEventProc procedure} -constraints { } -cleanup { deleteWindows } -result {} +test unixEmbed-2.1a {EmbeddedEventProc procedure} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + testembed + } + destroy .f1 + update + slave eval { + testembed + } +} -cleanup { + deleteWindows +} -result {} test unixEmbed-2.2 {EmbeddedEventProc procedure} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -190,8 +258,30 @@ test unixEmbed-2.2 {EmbeddedEventProc procedure} -constraints { } -cleanup { deleteWindows } -result {} +test unixEmbed-2.2a {EmbeddedEventProc procedure} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + testembed + destroy .t1 + testembed + } +} -cleanup { + interp delete slave + deleteWindows +} -result {} test unixEmbed-2.3 {EmbeddedEventProc procedure} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -202,26 +292,30 @@ test unixEmbed-2.3 {EmbeddedEventProc procedure} -constraints { destroy .f1 testembed } -result {} +if {[tk windowingsystem] eq "aqua"} { + set wrapperId {{}} +} else { + set wrapperId XXX +} test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints { unix testembed } -setup { deleteWindows } -body { - frame .f1 -container 1 -width 200 -height 50 - pack .f1 + pack [frame .f1 -container 1 -width 200 -height 50] toplevel .t1 -use [winfo id .f1] + set x [testembed] update destroy .t1 - set x [testembed] update - list $x [testembed] + list $x [winfo exists .t1] [winfo exists .f1] [testembed] } -cleanup { deleteWindows -} -result {{{XXX .f1 {} {}}} {}} +} -result "{{XXX .f1 $wrapperId .t1}} 0 0 {}" test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints { - unix testembed nonPortable + unix testembed notPortable } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -236,21 +330,44 @@ test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints } -cleanup { deleteWindows } -result {{{XXX .f1 {} {}}} {{XXX .f1 XXX {}}}} +test unixEmbed-3.1a {ContainerEventProc procedure, detect creation} -constraints { + unix testembed +} -setup { + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + set x [testembed] + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + wm withdraw .t1 + } + list $x [testembed] +} -cleanup { + interp delete slave + deleteWindows +} -result {{{XXX .f1 {} {}}} {{XXX .f1 {} {}}}} test unixEmbed-3.2 {ContainerEventProc procedure, set size on creation} -constraints { - unix + unix } -setup { deleteWindows } -body { toplevel .t1 -container 1 wm geometry .t1 +0+0 toplevel .t2 -use [winfo id .t1] -bg red - update + while {[winfo exists .t2] == 0} { + update + } wm geometry .t2 } -cleanup { deleteWindows } -result {200x200+0+0} test unixEmbed-3.3 {ContainerEventProc procedure, disallow position changes} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -270,8 +387,31 @@ test unixEmbed-3.3 {ContainerEventProc procedure, disallow position changes} -co } -cleanup { deleteWindows } -result {200x200+0+0} +test unixEmbed-3.3a {ContainerEventProc procedure, disallow position changes} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] -bd 2 -relief raised + update + wm geometry .t1 +30+40 + update + wm geometry .t1 + } +} -cleanup { + interp delete slave + deleteWindows +} -result {200x200+0+0} test unixEmbed-3.4 {ContainerEventProc procedure, disallow position changes} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -291,8 +431,31 @@ test unixEmbed-3.4 {ContainerEventProc procedure, disallow position changes} -co } -cleanup { deleteWindows } -result {300x100+0+0} +test unixEmbed-3.4a {ContainerEventProc procedure, disallow position changes} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + update + wm geometry .t1 300x100+30+40 + update + wm geometry .t1 + } +} -cleanup { + interp delete slave + deleteWindows +} -result {300x100+0+0} test unixEmbed-3.5 {ContainerEventProc procedure, geometry requests} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -312,8 +475,30 @@ test unixEmbed-3.5 {ContainerEventProc procedure, geometry requests} -constraint } -cleanup { deleteWindows } -result {300 80 300x80+0+0} +test unixEmbed-3.5a {ContainerEventProc procedure, geometry requests} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + .t1 configure -width 300 -height 80 + update + } + list [winfo width .f1] [winfo height .f1] [slave eval {wm geometry .t1}] +} -cleanup { + interp delete slave + deleteWindows +} -result {300 80 300x80+0+0} test unixEmbed-3.6 {ContainerEventProc procedure, map requests} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -335,8 +520,33 @@ test unixEmbed-3.6 {ContainerEventProc procedure, map requests} -constraints { } -cleanup { deleteWindows } -result {mapped} +test unixEmbed-3.6a {ContainerEventProc procedure, map requests} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + set x unmapped + bind .t1 {set x mapped} + update + after 100 + update + set x + } +} -cleanup { + interp delete slave + deleteWindows +} -result {mapped} test unixEmbed-3.7 {ContainerEventProc procedure, destroy events} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -358,10 +568,34 @@ test unixEmbed-3.7 {ContainerEventProc procedure, destroy events} -constraints { } -cleanup { deleteWindows } -result {dead 0} - +test unixEmbed-3.7a {ContainerEventProc procedure, destroy events} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + bind .f1 {set x dead} + set x alive + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + update + destroy .t1 + } + update + list $x [winfo exists .f1] +} -cleanup { + interp delete slave + deleteWindows +} -result {dead 0} test unixEmbed-4.1 {EmbedStructureProc procedure, configure events} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -383,8 +617,31 @@ test unixEmbed-4.1 {EmbedStructureProc procedure, configure events} -constraints } -cleanup { deleteWindows } -result {180x100+0+0} +test unixEmbed-4.1a {EmbedStructureProc procedure, configure events} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + update + .t1 configure -width 180 -height 100 + update + winfo geometry .t1 + } +} -cleanup { + interp delete slave + deleteWindows +} -result {180x100+0+0} test unixEmbed-4.2 {EmbedStructureProc procedure, destroy events} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { @@ -398,14 +655,38 @@ test unixEmbed-4.2 {EmbedStructureProc procedure, destroy events} -constraints { update set x [testembed] destroy .f1 + update list $x [testembed] } -cleanup { deleteWindows } -result {{{XXX .f1 XXX {}}} {}} +test unixEmbed-4.2a {EmbedStructureProc procedure, destroy events} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + update + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + } + set x [testembed] + destroy .f1 + list $x [testembed] +} -cleanup { + interp delete slave + deleteWindows +} -result "{{XXX .f1 {} {}}} {}" test unixEmbed-5.1 {EmbedFocusProc procedure, FocusIn events} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -425,8 +706,33 @@ test unixEmbed-5.1 {EmbedFocusProc procedure, FocusIn events} -constraints { } -cleanup { deleteWindows } -result {{focus in .t1}} +test unixEmbed-5.1a {EmbedFocusProc procedure, FocusIn events} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + bind .t1 {lappend x "focus in %W"} + bind .t1 {lappend x "focus out %W"} + set x {} + } + focus -force .f1 + update + slave eval {set x} +} -cleanup { + interp delete slave + deleteWindows +} -result {{focus in .t1}} test unixEmbed-5.2 {EmbedFocusProc procedure, focusing on dead window} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -447,8 +753,32 @@ test unixEmbed-5.2 {EmbedFocusProc procedure, focusing on dead window} -constrai } -cleanup { deleteWindows } -result {} +test unixEmbed-5.2a {EmbedFocusProc procedure, focusing on dead window} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + update + after 200 {destroy .t1} + } + after 400 + focus -force .f1 + update +} -cleanup { + interp delete slave + deleteWindows +} -result {} test unixEmbed-5.3 {EmbedFocusProc procedure, FocusOut events} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -471,10 +801,39 @@ test unixEmbed-5.3 {EmbedFocusProc procedure, FocusOut events} -constraints { } -cleanup { deleteWindows } -result {{{focus in .t1}} {{focus in .t1} {focus out .t1}}} +test unixEmbed-5.3a {EmbedFocusProc procedure, FocusOut events} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + set x {} + bind .t1 {lappend x "focus in %W"} + bind .t1 {lappend x "focus out %W"} + update + } + focus -force .f1 + update + set x [slave eval {update; set x }] + focus . + update + list $x [slave eval {update; set x}] +} -cleanup { + interp delete slave + deleteWindows +} -result {{{focus in .t1}} {{focus in .t1} {focus out .t1}}} test unixEmbed-6.1 {EmbedGeometryRequest procedure, window changes size} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -496,8 +855,33 @@ test unixEmbed-6.1 {EmbedGeometryRequest procedure, window changes size} -constr } -cleanup { deleteWindows } -result {{{configure .t1 300 120}} 300x120+0+0} +test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + update + bind .t1 {lappend x {configure .t1 %w %h}} + set x {} + .t1 configure -width 300 -height 120 + update + list $x [winfo geom .t1] + } +} -cleanup { + interp delete slave + deleteWindows +} -result {{{configure .t1 300 120}} 300x120+0+0} test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -514,18 +898,47 @@ test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constr bind .t1 {lappend x {configure .t1 %w %h}} set x {} .t1 configure -width 300 -height 120 - update + after 300 {set y done} + vwait y list $x [winfo geom .t1] } } -cleanup { deleteWindows } -result {{{configure .t1 200 200}} 200x200+0+0} +test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + place .f1 -width 200 -height 200 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + } + after 300 {set x done} + vwait x + slave eval { + bind .t1 {lappend x {configure .t1 %w %h}} + update + set x {} + .t1 configure -width 300 -height 120 + update + list $x [winfo geom .t1] + } +} -cleanup { + interp delete slave + deleteWindows +} -result {{{configure .t1 200 200}} 200x200+0+0} # Can't think up any tests for TkpGetOtherWindow procedure. - test unixEmbed-7.1 {TkpRedirectKeyEvent procedure, forward keystroke} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -553,8 +966,41 @@ test unixEmbed-7.1 {TkpRedirectKeyEvent procedure, forward keystroke} -constrain deleteWindows bind . {} } -result {{{key a 1}} {}} +test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + deleteWindows + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + } + focus -force . + bind . {lappend x {key %A %E}} + set x {} + set y [slave eval { + update + bind .t1 {lappend y {key %A}} + set y {} + event generate .t1 -keysym a + set y + }] + update + list $x $y +} -cleanup { + interp delete slave + deleteWindows + bind . {} +} -result {{{key a 1}} {}} test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width} -constraints { - unix + unix notAqua } -setup { deleteWindows } -body { @@ -583,9 +1029,44 @@ test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width deleteWindows bind . {} } -result {{} {{key b}}} +test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke width} -constraints { + unix +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] + } + update + focus -force .f1 + update + bind . {lappend x {key %A}} + set x {} + set y [slave eval { + update + bind .t1 {lappend y {key %A}} + set y {} + event generate .t1 -keysym b + set y + }] + update + list $x $y +} -cleanup { + interp delete slave + deleteWindows + bind . {} +} -result {{} {{key b}}} - -test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints unix -setup { +test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints { + unix notAqua +} -setup { deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 @@ -609,15 +1090,44 @@ test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints unix -setup { } -cleanup { deleteWindows } -result {{{} .t1} .f1} -test unixEmbed-8.2 {TkpClaimFocus procedure} -constraints unix -setup { - deleteWindows - catch {interp delete child} +test unixEmbed-8.1a {TkpClaimFocus procedure} -constraints unix -setup { deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 frame .f2 -width 200 -height 50 pack .f1 .f2 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken + } + focus -force .f2 + update + list [slave eval { + focus .t1 + set x [list [focus]] + update + after 500 + update + lappend x [focus] + }] [focus] +} -cleanup { + interp delete slave + deleteWindows +} -result {{{} .t1} .f1} +test unixEmbed-8.2 {TkpClaimFocus procedure} -constraints unix -setup { + deleteWindows + catch {interp delete child} interp create child +} -body { + frame .f1 -container 1 -width 200 -height 50 + frame .f2 -width 200 -height 50 + pack .f1 .f2 + update + set w1 [winfo id .f1] child eval "set argv {-use [winfo id .f1]}" load {} Tk child child eval { @@ -636,7 +1146,6 @@ test unixEmbed-8.2 {TkpClaimFocus procedure} -constraints unix -setup { } -result {{{} .} .f1} catch {interp delete child} - test unixEmbed-9.1 {EmbedWindowDeleted procedure, check parentPtr} -constraints { unix testembed } -setup { @@ -658,12 +1167,13 @@ test unixEmbed-9.1 {EmbedWindowDeleted procedure, check parentPtr} -constraints deleteWindows } -result {{{XXX .f4 {} {}} {XXX .f3 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f4 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}}} {}} test unixEmbed-9.2 {EmbedWindowDeleted procedure, check embeddedPtr} -constraints { - unix testembed + unix testembed notAqua } -setup { deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 + update dobg "set w1 [winfo id .f1]" dobg { eval destroy [winfo child .] @@ -676,15 +1186,39 @@ test unixEmbed-9.2 {EmbedWindowDeleted procedure, check embeddedPtr} -constraint } -cleanup { deleteWindows } -result {{{XXX {} {} .t1}} {}} +test unixEmbed-9.2a {EmbedWindowDeleted procedure, check embeddedPtr} -constraints { + unix testembed +} -setup { + deleteWindows + catch {interp delete slave} + interp create slave + load {} Tktest slave +} -body { + frame .f1 -container 1 -width 200 -height 50 + pack .f1 + slave alias w1 winfo id .f1 + slave eval { + destroy [winfo child .] + toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken + set x {} + lappend x [testembed] + destroy .t1 + lappend x [testembed] + } +} -cleanup { + interp delete slave + deleteWindows +} -result {{{XXX {} {} .t1}} {}} test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -constraints { - unix + unix } -setup { deleteWindows } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 + update toplevel .t1 -use [winfo id .f1] -width 150 -height 80 update wm geometry .t1 +40+50 @@ -694,7 +1228,7 @@ test unixEmbed-10.1 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -con deleteWindows } -result {150x80+0+0} test unixEmbed-10.2 {geometry propagation in tkUnixWm.c/UpdateGeometryInfo} -constraints { - unix + unix } -setup { deleteWindows } -body { @@ -714,4 +1248,3 @@ deleteWindows cleanupbg cleanupTests return - -- cgit v0.12 From f917c7ea30852f927140c2e2041d624de5518a11 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Jan 2019 17:55:49 +0000 Subject: Remove debug print statement. --- macosx/tkMacOSXEmbed.c | 1 - 1 file changed, 1 deletion(-) diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 2dbfdc8..8fcbb09 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -1061,7 +1061,6 @@ static void EmbedSendConfigure( Container *containerPtr) /* Information about the embedding. */ { - printf("Call to EmbedSendConfigure\n"); } /* -- cgit v0.12 From 3be37d2e475c04c88fe192c47cc5fcef06024aab Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 23 Jan 2019 20:40:57 +0000 Subject: Constrain send.test tests which are inappropriate for macOS with notAqua. --- macosx/tkMacOSXSend.c | 2 +- tests/send.test | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/macosx/tkMacOSXSend.c b/macosx/tkMacOSXSend.c index 3b24a56..1fdf048 100644 --- a/macosx/tkMacOSXSend.c +++ b/macosx/tkMacOSXSend.c @@ -325,7 +325,7 @@ Tk_SendObjCmd( int objc, /* Number of arguments */ Tcl_Obj *const objv[]) /* The arguments */ { - const char *const sendOptions[] = {"-async", "-displayof", "-", NULL}; + const char *const sendOptions[] = {"-async", "-displayof", "--", NULL}; char *stringRep, *destName; /*int async = 0;*/ int i, index, firstArg; diff --git a/tests/send.test b/tests/send.test index 945d4d0..403a207 100644 --- a/tests/send.test +++ b/tests/send.test @@ -197,7 +197,8 @@ test send-7.4 {Tk_SetAppName procedure, name in use} {secureserver testsend} { list [tk appname foo] [testsend prop root InterpRegistry] } "{foo #4} {$commId foo #4\n$id foo\n$id foo #2\n$id foo #3\n}" -test send-8.1 {Tk_SendCmd procedure, options} {secureserver} { +#macOS does not send to other processes +test send-8.1 {Tk_SendCmd procedure, options} {secureserver notAqua} { setupbg set app [dobg {tk appname}] set a 66 @@ -222,10 +223,11 @@ test send-8.2 {Tk_SendCmd procedure, options} {secureserver altDisplay} { cleanupbg set result } {altDisplay homeDisplay} -test send-8.3 {Tk_SendCmd procedure, options} {secureserver} { +# Since macOS has no registry of interpreters, 8.3, 8.4 and 8.10 will fail. +test send-8.3 {Tk_SendCmd procedure, options} {secureserver notAqua} { list [catch {send -- -async foo bar baz} msg] $msg } {1 {no application named "-async"}} -test send-8.4 {Tk_SendCmd procedure, options} {secureserver} { +test send-8.4 {Tk_SendCmd procedure, options} {secureserver notAqua} { list [catch {send -gorp foo bar baz} msg] $msg } {1 {no application named "-gorp"}} test send-8.5 {Tk_SendCmd procedure, options} {secureserver} { @@ -253,7 +255,7 @@ test send-8.9 {Tk_SendCmd procedure, local execution} {secureserver} { "open bad_file" invoked from within "send [tk appname] open bad_file"} {posix enoent {no such file or directory}}} -test send-8.10 {Tk_SendCmd procedure, no such interpreter} {secureserver} { +test send-8.10 {Tk_SendCmd procedure, no such interpreter} {secureserver notAqua} { list [catch {send bogus_name bogus_command} msg] $msg } {1 {no application named "bogus_name"}} @@ -542,7 +544,8 @@ test send-12.1 {TimeoutProc procedure} {secureserver testsend} { catch {testsend prop root InterpRegistry ""} -test send-12.2 {TimeoutProc procedure} {secureserver} { +#macOS does not send to other processes +test send-12.2 {TimeoutProc procedure} {secureserver notAqua} { winfo interps tk appname tktest update @@ -557,16 +560,17 @@ test send-12.2 {TimeoutProc procedure} {secureserver} { set result } {1 {target application died}} +#macOS does not send to other processes winfo interps tk appname tktest -test send-13.1 {DeleteProc procedure} {secureserver} { +test send-13.1 {DeleteProc procedure} {secureserver notAqua} { setupbg set app [dobg {rename send {}; tk appname}] set result [list [catch {send $app foo} msg] $msg [winfo interps]] cleanupbg set result } {1 {no application named "tktest #2"} tktest} -test send-13.2 {DeleteProc procedure} {secureserver} { +test send-13.2 {DeleteProc procedure} {secureserver notAqua} { winfo interps tk appname tktest rename send {} -- cgit v0.12 From bcbac6d72fa593de9f7ba235102d9eedfdfe526b Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 26 Jan 2019 16:17:49 +0000 Subject: Attempt to make the new unixEmbed tests work when tests are run from the build directory, without installing Tk. --- tests/unixEmbed.test | 73 +++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 52 insertions(+), 21 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 0894365..dabf0a0 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -11,6 +11,37 @@ eval tcltest::configure $argv tcltest::loadTestedCommands namespace import -force tcltest::test +namespace eval ::_test_tmp {} + +# ------------------------------------------------------------------------------ +# Proc ::_test_tmp::testInterp +# ------------------------------------------------------------------------------ +# Command that creates an unsafe child interpreter and tries to load Tk. +# This code is borrowed from safePrimarySelection.test +# This is necessary for loading Tktest if the tests are done in the build +# directory without installing Tk. In that case the usual auto_path loading +# mechanism cannot work because the tk binary is not where pkgIndex.tcl says +# it is. +# ------------------------------------------------------------------------------ + +namespace eval ::_test_tmp { + variable TkLoadCmd +} + +foreach pkg [info loaded] { + if {[lindex $pkg 1] eq "Tktest"} { + set ::_test_tmp::TkLoadCmd [list load {*}$pkg] + break + } +} + +proc ::_test_tmp::testInterp {name} { + variable TkLoadCmd + interp create $name + $name eval [list set argv [list -name $name]] + catch {{*}$TkLoadCmd $name} +} + setupbg dobg {wm withdraw .} @@ -118,7 +149,7 @@ test unixEmbed-1.5a {TkpUseWindow procedure, creating Container records} -constr } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -158,7 +189,7 @@ test unixEmbed-1.6a {TkpUseWindow procedure, creating Container records} -constr } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -221,7 +252,7 @@ test unixEmbed-2.1a {EmbeddedEventProc procedure} -constraints { } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -263,7 +294,7 @@ test unixEmbed-2.2a {EmbeddedEventProc procedure} -constraints { } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -334,7 +365,7 @@ test unixEmbed-3.1a {ContainerEventProc procedure, detect creation} -constraints unix testembed } -setup { catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -392,7 +423,7 @@ test unixEmbed-3.3a {ContainerEventProc procedure, disallow position changes} -c } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -436,7 +467,7 @@ test unixEmbed-3.4a {ContainerEventProc procedure, disallow position changes} -c } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -480,7 +511,7 @@ test unixEmbed-3.5a {ContainerEventProc procedure, geometry requests} -constrain } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -525,7 +556,7 @@ test unixEmbed-3.6a {ContainerEventProc procedure, map requests} -constraints { } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -573,7 +604,7 @@ test unixEmbed-3.7a {ContainerEventProc procedure, destroy events} -constraints } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -622,7 +653,7 @@ test unixEmbed-4.1a {EmbedStructureProc procedure, configure events} -constraint } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -665,7 +696,7 @@ test unixEmbed-4.2a {EmbedStructureProc procedure, destroy events} -constraints } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -711,7 +742,7 @@ test unixEmbed-5.1a {EmbedFocusProc procedure, FocusIn events} -constraints { } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -758,7 +789,7 @@ test unixEmbed-5.2a {EmbedFocusProc procedure, focusing on dead window} -constra } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -806,7 +837,7 @@ test unixEmbed-5.3a {EmbedFocusProc procedure, FocusOut events} -constraints { } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -860,7 +891,7 @@ test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -const } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -910,7 +941,7 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -971,7 +1002,7 @@ test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constrai } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { deleteWindows @@ -1034,7 +1065,7 @@ test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke widt } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -1093,7 +1124,7 @@ test unixEmbed-8.1 {TkpClaimFocus procedure} -constraints { test unixEmbed-8.1a {TkpClaimFocus procedure} -constraints unix -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 @@ -1191,7 +1222,7 @@ test unixEmbed-9.2a {EmbedWindowDeleted procedure, check embeddedPtr} -constrain } -setup { deleteWindows catch {interp delete slave} - interp create slave + ::_test_tmp::testInterp slave load {} Tktest slave } -body { frame .f1 -container 1 -width 200 -height 50 -- cgit v0.12 From f5aac2cbc6abf0f40ed14db7acc4a5bcfd96bce8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sat, 26 Jan 2019 16:58:17 +0000 Subject: Load the Tk package, not Tktest --- tests/unixEmbed.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index dabf0a0..4058058 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -29,7 +29,7 @@ namespace eval ::_test_tmp { } foreach pkg [info loaded] { - if {[lindex $pkg 1] eq "Tktest"} { + if {[lindex $pkg 1] eq "Tk"} { set ::_test_tmp::TkLoadCmd [list load {*}$pkg] break } -- cgit v0.12 From 02aabb7cd260aa61803ba37759a38f1213adda53 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Jan 2019 00:25:43 +0000 Subject: Fix bug [688cd9c9de]: many wm-transient tests fail on macOS --- macosx/tkMacOSXWm.c | 141 +++++++++++++++++++++++++++++++++++++++++++++++++--- macosx/tkMacOSXWm.h | 14 ++++++ 2 files changed, 148 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a5e1564..0418632 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -681,6 +681,7 @@ TkWmNewWindow( wmPtr->masterWindowName = NULL; wmPtr->icon = NULL; wmPtr->iconFor = NULL; + wmPtr->transientPtr = NULL; wmPtr->sizeHintsFlags = 0; wmPtr->minWidth = wmPtr->minHeight = 1; wmPtr->maxWidth = 0; @@ -882,6 +883,7 @@ TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; + TkDisplay *dispPtr = TkGetDisplayList(); if (wmPtr == NULL) { return; @@ -915,7 +917,6 @@ TkWmDeadWindow( } while (wmPtr->protPtr != NULL) { ProtocolHandler *protPtr = wmPtr->protPtr; - wmPtr->protPtr = protPtr->nextPtr; Tcl_EventuallyFree(protPtr, TCL_DYNAMIC); } @@ -930,6 +931,30 @@ TkWmDeadWindow( } /* + * If the dead window has a transient, remove references to it from + * the transient. + */ + + for (Transient *transientPtr = wmPtr->transientPtr; + transientPtr != NULL; transientPtr = transientPtr->nextPtr) { + TkWindow *winPtr2 = transientPtr->winPtr; + Window master = TkGetTransientMaster(winPtr2); + TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + if (masterPtr == winPtr) { + wmPtr2 = winPtr2->wmInfoPtr; + wmPtr2->master = None; + ckfree(wmPtr2->masterWindowName); + wmPtr2->masterWindowName = NULL; + } + } + + while (wmPtr->transientPtr != NULL) { + Transient *transientPtr = wmPtr->transientPtr; + wmPtr->transientPtr = transientPtr->nextPtr; + ckfree(transientPtr); + } + + /* * Delete the Mac window and remove it from the windowTable. The window * could be nil if the window was never mapped. However, we don't do this * for embedded windows, they don't go in the window list, and they do not @@ -1758,6 +1783,7 @@ WmDeiconifyCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + TkDisplay *dispPtr = TkGetDisplayList(); if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -1786,6 +1812,27 @@ WmDeiconifyCmd( if (wmPtr->icon) { Tk_UnmapWindow((Tk_Window)wmPtr->icon); } + + /* + * If this window has a transient, the transient must also be deiconified if + * it was withdrawn by the master. + */ + + for (Transient *transientPtr = wmPtr->transientPtr; + transientPtr != NULL; transientPtr = transientPtr->nextPtr) { + TkWindow *winPtr2 = transientPtr->winPtr; + WmInfo *wmPtr2 = winPtr2->wmInfoPtr; + Window master = TkGetTransientMaster(winPtr2); + TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + if (masterPtr == winPtr) { + if (!(wmPtr2->hints.initial_state == WithdrawnState && + (transientPtr->flags & WITHDRAWN_BY_MASTER) == 0)) { + TkpWmSetState(winPtr2, NormalState); + transientPtr->flags &= ~WITHDRAWN_BY_MASTER; + } + } + } + return TCL_OK; } @@ -2272,6 +2319,7 @@ WmIconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { + TkDisplay *dispPtr = TkGetDisplayList(); register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -2308,6 +2356,24 @@ WmIconifyCmd( if (wmPtr->icon) { Tk_MapWindow((Tk_Window)wmPtr->icon); } + + /* + * If this window has a transient the transient must be withdrawn when + * the master is iconified. + */ + + for (Transient *transientPtr = wmPtr->transientPtr; + transientPtr != NULL; transientPtr = transientPtr->nextPtr) { + TkWindow *winPtr2 = transientPtr->winPtr; + Window master = TkGetTransientMaster(winPtr2); + TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + if (masterPtr == winPtr && + winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) { + TkpWmSetState(winPtr2, WithdrawnState); + transientPtr->flags |= WITHDRAWN_BY_MASTER; + } + } + return TCL_OK; } @@ -3508,6 +3574,7 @@ WmTransientCmd( register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; + TkDisplay *dispPtr = TkGetDisplayList(); char *masterWindowName; int length; @@ -3523,16 +3590,39 @@ WmTransientCmd( return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { - wmPtr->master = None; - if (wmPtr->masterWindowName != NULL) { - ckfree(wmPtr->masterWindowName); + + /* + * Remove the transient from its master's list. + */ + + if (wmPtr->master != None) { + TkWindow *masterPtr = (TkWindow*)Tk_IdToWindow(dispPtr->display, + wmPtr->master); + wmPtr2 = masterPtr->wmInfoPtr; + Transient *transientPtr = wmPtr2->transientPtr; + if (transientPtr->winPtr == winPtr) { + wmPtr2->transientPtr = transientPtr->nextPtr; + } else while (transientPtr->nextPtr != NULL) { + if (transientPtr->nextPtr->winPtr == winPtr) { + transientPtr->nextPtr = transientPtr->nextPtr->nextPtr; + break; + } + transientPtr = transientPtr->nextPtr; + } + if (transientPtr!= NULL) { + ckfree(transientPtr); + } + wmPtr->master = None; + if (wmPtr->masterWindowName != NULL) { + ckfree(wmPtr->masterWindowName); + } + wmPtr->masterWindowName = NULL; } - wmPtr->masterWindowName = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) { return TCL_ERROR; } - TkWindow* masterPtr = (TkWindow*) master; + TkWindow *masterPtr = (TkWindow*) master; while (!Tk_TopWinHierarchy(masterPtr)) { /* @@ -3568,6 +3658,26 @@ WmTransientCmd( return TCL_ERROR; } + /* + * Add the transient to the master's list. + */ + + Transient *transient = ckalloc(sizeof(Transient)); + transient->winPtr = winPtr; + transient->flags = 0; + transient->nextPtr = wmPtr->transientPtr; + wmPtr2->transientPtr = transient; + + /* + * If the master is withdrawn or iconic then withdraw the transient. + */ + if ((wmPtr2->hints.initial_state == WithdrawnState || + wmPtr2->hints.initial_state == IconicState) && + wmPtr->hints.initial_state != WithdrawnState){ + TkpWmSetState(winPtr, WithdrawnState); + transient->flags |= WITHDRAWN_BY_MASTER; + } + wmPtr->master = Tk_WindowId(masterPtr); masterWindowName = masterPtr->pathName; length = strlen(masterWindowName); @@ -3620,11 +3730,29 @@ WmWithdrawCmd( Tcl_SetErrorCode(interp, "TK", "WM", "WITHDRAW", "ICON", NULL); return TCL_ERROR; } + TkpWmSetState(winPtr, WithdrawnState); + NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); + TkDisplay *dispPtr = TkGetDisplayList(); [win orderOut:nil]; [win setExcludedFromWindowsMenu:YES]; + /* + * If this window has a transient, the transient must also be withdrawn. + */ + for (Transient *transientPtr = wmPtr->transientPtr; + transientPtr != NULL; transientPtr = transientPtr->nextPtr) { + TkWindow *winPtr2 = transientPtr->winPtr; + Window master = TkGetTransientMaster(winPtr2); + TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + if (masterPtr == winPtr && + winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) { + TkpWmSetState(winPtr2, WithdrawnState); + transientPtr->flags |= WITHDRAWN_BY_MASTER; + } + } + return TCL_OK; } @@ -4734,7 +4862,6 @@ Tk_MoveToplevelWindow( wmPtr->x = x; wmPtr->y = y; wmPtr->flags |= WM_MOVE_PENDING; - // wmPtr->flags &= ~(WM_NEGATIVE_X|WM_NEGATIVE_Y); if (!(wmPtr->sizeHintsFlags & (USPosition|PPosition))) { wmPtr->sizeHintsFlags |= USPosition; wmPtr->flags |= WM_UPDATE_SIZE_HINTS; diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h index 43f1a7a..a7ea92c 100644 --- a/macosx/tkMacOSXWm.h +++ b/macosx/tkMacOSXWm.h @@ -36,6 +36,17 @@ typedef struct ProtocolHandler { * THE LAST FIELD OF THE STRUCTURE. */ } ProtocolHandler; +/* The following data structure is used in the TkWmInfo to maintain a list of all of the + * transient windows belonging to a given master. + */ + +typedef struct Transient { + TkWindow *winPtr; + int flags; + struct Transient *nextPtr; +} Transient; + +#define WITHDRAWN_BY_MASTER 0x1 /* * A data structure of the following type holds window-manager-related @@ -70,6 +81,9 @@ typedef struct TkWmInfo { * NULL. */ Tk_Window iconFor; /* Window for which this window is icon, or * NULL if this isn't an icon for anyone. */ + Transient *transientPtr; /* First item in a list of all transient windows + * belonging to this window, or NULL if there + * are no transients. */ /* * Information used to construct an XSizeHints structure for the window -- cgit v0.12 From 9aa9f3289047d44aeb99520da7b94bb2cdd5d118 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 09:11:52 +0000 Subject: Make unixEmbed-3.2 pass (revert previous change that introduced a loop on [winfo exists .t2] since this prevents the necessary update to be executed) --- tests/unixEmbed.test | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 4058058..0ab275d 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -390,9 +390,7 @@ test unixEmbed-3.2 {ContainerEventProc procedure, set size on creation} -constra toplevel .t1 -container 1 wm geometry .t1 +0+0 toplevel .t2 -use [winfo id .t1] -bg red - while {[winfo exists .t2] == 0} { - update - } + update wm geometry .t2 } -cleanup { deleteWindows -- cgit v0.12 From 9747a9414bed5cfde9117d6af3dd076cdd21e15a Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 13:38:05 +0000 Subject: Make unixEmbed-3.2 pass on macOS even with the deployment target when unixEmbed-1.5a was run before. --- tests/unixEmbed.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 0ab275d..ecdab0d 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -386,6 +386,7 @@ test unixEmbed-3.2 {ContainerEventProc procedure, set size on creation} -constra unix } -setup { deleteWindows + update } -body { toplevel .t1 -container 1 wm geometry .t1 +0+0 -- cgit v0.12 From 7444c05633a6dd6546d4046e238bec448eb42c9d Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 13:46:01 +0000 Subject: Fix indentation in the -setup and -cleanup sections of the new *a tests --- tests/unixEmbed.test | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index ecdab0d..349449a 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -145,7 +145,7 @@ test unixEmbed-1.5 {TkpUseWindow procedure, creating Container records} -constra deleteWindows } -result {{{XXX {} {} .t}} 0} test unixEmbed-1.5a {TkpUseWindow procedure, creating Container records} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} @@ -162,8 +162,8 @@ test unixEmbed-1.5a {TkpUseWindow procedure, creating Container records} -constr list [testembed] [expr {[lindex [lindex [testembed all] 0] 0] - [w]}] } } -cleanup { - interp delete slave - deleteWindows + interp delete slave + deleteWindows } -result {{{XXX {} {} .t}} 0} test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constraints { unix testembed notAqua @@ -185,7 +185,7 @@ test unixEmbed-1.6 {TkpUseWindow procedure, creating Container records} -constra deleteWindows } -result {{XXX {} {} .t2} {XXX {} {} .t1}} test unixEmbed-1.6a {TkpUseWindow procedure, creating Container records} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} @@ -204,8 +204,8 @@ test unixEmbed-1.6a {TkpUseWindow procedure, creating Container records} -constr testembed } } -cleanup { - interp delete slave - deleteWindows + interp delete slave + deleteWindows } -result {{XXX {} {} .t2} {XXX {} {} .t1}} test unixEmbed-1.7 {TkpUseWindow procedure, container and embedded in same app} -constraints { unix testembed @@ -248,7 +248,7 @@ test unixEmbed-2.1 {EmbeddedEventProc procedure} -constraints { deleteWindows } -result {} test unixEmbed-2.1a {EmbeddedEventProc procedure} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} @@ -269,7 +269,7 @@ test unixEmbed-2.1a {EmbeddedEventProc procedure} -constraints { testembed } } -cleanup { - deleteWindows + deleteWindows } -result {} test unixEmbed-2.2 {EmbeddedEventProc procedure} -constraints { unix testembed notAqua @@ -290,7 +290,7 @@ test unixEmbed-2.2 {EmbeddedEventProc procedure} -constraints { deleteWindows } -result {} test unixEmbed-2.2a {EmbeddedEventProc procedure} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} @@ -418,7 +418,7 @@ test unixEmbed-3.3 {ContainerEventProc procedure, disallow position changes} -co deleteWindows } -result {200x200+0+0} test unixEmbed-3.3a {ContainerEventProc procedure, disallow position changes} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -506,7 +506,7 @@ test unixEmbed-3.5 {ContainerEventProc procedure, geometry requests} -constraint deleteWindows } -result {300 80 300x80+0+0} test unixEmbed-3.5a {ContainerEventProc procedure, geometry requests} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -551,7 +551,7 @@ test unixEmbed-3.6 {ContainerEventProc procedure, map requests} -constraints { deleteWindows } -result {mapped} test unixEmbed-3.6a {ContainerEventProc procedure, map requests} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -599,7 +599,7 @@ test unixEmbed-3.7 {ContainerEventProc procedure, destroy events} -constraints { deleteWindows } -result {dead 0} test unixEmbed-3.7a {ContainerEventProc procedure, destroy events} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -648,7 +648,7 @@ test unixEmbed-4.1 {EmbedStructureProc procedure, configure events} -constraints deleteWindows } -result {180x100+0+0} test unixEmbed-4.1a {EmbedStructureProc procedure, configure events} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -691,7 +691,7 @@ test unixEmbed-4.2 {EmbedStructureProc procedure, destroy events} -constraints { deleteWindows } -result {{{XXX .f1 XXX {}}} {}} test unixEmbed-4.2a {EmbedStructureProc procedure, destroy events} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} @@ -737,7 +737,7 @@ test unixEmbed-5.1 {EmbedFocusProc procedure, FocusIn events} -constraints { deleteWindows } -result {{focus in .t1}} test unixEmbed-5.1a {EmbedFocusProc procedure, FocusIn events} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -784,7 +784,7 @@ test unixEmbed-5.2 {EmbedFocusProc procedure, focusing on dead window} -constrai deleteWindows } -result {} test unixEmbed-5.2a {EmbedFocusProc procedure, focusing on dead window} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -832,7 +832,7 @@ test unixEmbed-5.3 {EmbedFocusProc procedure, FocusOut events} -constraints { deleteWindows } -result {{{focus in .t1}} {{focus in .t1} {focus out .t1}}} test unixEmbed-5.3a {EmbedFocusProc procedure, FocusOut events} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -886,7 +886,7 @@ test unixEmbed-6.1 {EmbedGeometryRequest procedure, window changes size} -constr deleteWindows } -result {{{configure .t1 300 120}} 300x120+0+0} test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -936,7 +936,7 @@ test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constr deleteWindows } -result {{{configure .t1 200 200}} 200x200+0+0} test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -997,7 +997,7 @@ test unixEmbed-7.1 {TkpRedirectKeyEvent procedure, forward keystroke} -constrain bind . {} } -result {{{key a 1}} {}} test unixEmbed-7.1a {TkpRedirectKeyEvent procedure, forward keystroke} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -1060,7 +1060,7 @@ test unixEmbed-7.2 {TkpRedirectKeyEvent procedure, don't forward keystroke width bind . {} } -result {{} {{key b}}} test unixEmbed-7.2a {TkpRedirectKeyEvent procedure, don't forward keystroke width} -constraints { - unix + unix } -setup { deleteWindows catch {interp delete slave} @@ -1217,7 +1217,7 @@ test unixEmbed-9.2 {EmbedWindowDeleted procedure, check embeddedPtr} -constraint deleteWindows } -result {{{XXX {} {} .t1}} {}} test unixEmbed-9.2a {EmbedWindowDeleted procedure, check embeddedPtr} -constraints { - unix testembed + unix testembed } -setup { deleteWindows catch {interp delete slave} -- cgit v0.12 From ff7c0d39fa897fd6a7fe27ed0cb6d424311d5d83 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 14:07:08 +0000 Subject: Reduce the number of unixEmbed test failures on Linux from 10 to 4 by propagating changes in TkpTestembedCmd from macosx/tkMacOSXEmbed.c to the unix version of it in unix/tkUnixEmbed.c --- unix/tkUnixEmbed.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index b170ad0..539cb8a 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -873,6 +873,7 @@ TkpTestembedCmd( Container *containerPtr; Tcl_DString dString; char buffer[50]; + Tcl_Interp *embeddedInterp = NULL, *parentInterp = NULL; ThreadSpecificData *tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -884,21 +885,34 @@ TkpTestembedCmd( Tcl_DStringInit(&dString); for (containerPtr = tsdPtr->firstContainerPtr; containerPtr != NULL; containerPtr = containerPtr->nextPtr) { + if (containerPtr->embeddedPtr != NULL) { + embeddedInterp = containerPtr->embeddedPtr->mainPtr->interp; + } + if (containerPtr->parentPtr != NULL) { + parentInterp = containerPtr->parentPtr->mainPtr->interp; + } + if (embeddedInterp != interp && parentInterp != interp) { + continue; + } Tcl_DStringStartSublist(&dString); + /* Parent id */ if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->parent); + sprintf(buffer, "0x%lx", (int) containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); } - if (containerPtr->parentPtr == NULL) { + /* Parent pathName */ + if (containerPtr->parentPtr == NULL || + parentInterp != interp) { Tcl_DStringAppendElement(&dString, ""); } else { Tcl_DStringAppendElement(&dString, containerPtr->parentPtr->pathName); } + /* Wrapper */ if (containerPtr->wrapper == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { @@ -907,7 +921,9 @@ TkpTestembedCmd( } else { Tcl_DStringAppendElement(&dString, "XXX"); } - if (containerPtr->embeddedPtr == NULL) { + /* Embedded window pathName */ + if (containerPtr->embeddedPtr == NULL || + embeddedInterp != interp) { Tcl_DStringAppendElement(&dString, ""); } else { Tcl_DStringAppendElement(&dString, -- cgit v0.12 From b96636b76f92c8c6cf41a40633db08391560602f Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 16:04:23 +0000 Subject: More changes in the Unix version of TkpTestembedCmd --- unix/tkUnixEmbed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index 539cb8a..e1c4394 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -899,7 +899,7 @@ TkpTestembedCmd( if (containerPtr->parent == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%lx", (int) containerPtr->parent); + sprintf(buffer, "0x%lx", containerPtr->parent); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); @@ -916,7 +916,7 @@ TkpTestembedCmd( if (containerPtr->wrapper == None) { Tcl_DStringAppendElement(&dString, ""); } else if (all) { - sprintf(buffer, "0x%x", (int) containerPtr->wrapper); + sprintf(buffer, "0x%lx", containerPtr->wrapper); Tcl_DStringAppendElement(&dString, buffer); } else { Tcl_DStringAppendElement(&dString, "XXX"); -- cgit v0.12 From 43b8641102c6727136926d0494328292a4c739aa Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Jan 2019 16:26:25 +0000 Subject: Fix bugs that could lead to segfaults when the test interpreter is destroyed. --- macosx/tkMacOSXWm.c | 109 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 73 insertions(+), 36 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 0418632..6a6c254 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -322,6 +322,7 @@ static void GetMaxSize(TkWindow *winPtr, int *maxWidthPtr, int *maxHeightPtr); static void RemapWindows(TkWindow *winPtr, MacDrawable *parentWin); +static void RemoveTransient(TkWindow *winPtr); #pragma mark NSWindow(TKWm) @@ -888,6 +889,13 @@ TkWmDeadWindow( if (wmPtr == NULL) { return; } + + /* + *If the dead window is a transient, remove it from the master's list. + */ + + RemoveTransient(winPtr); + Tk_ManageGeometry((Tk_Window) winPtr, NULL, NULL); Tk_DeleteEventHandler((Tk_Window) winPtr, StructureNotifyMask, TopLevelEventProc, winPtr); @@ -936,15 +944,15 @@ TkWmDeadWindow( */ for (Transient *transientPtr = wmPtr->transientPtr; - transientPtr != NULL; transientPtr = transientPtr->nextPtr) { - TkWindow *winPtr2 = transientPtr->winPtr; - Window master = TkGetTransientMaster(winPtr2); - TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + transientPtr != NULL; transientPtr = transientPtr->nextPtr) { + TkWindow *winPtr2 = transientPtr->winPtr; + Window master = TkGetTransientMaster(winPtr2); + TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); if (masterPtr == winPtr) { - wmPtr2 = winPtr2->wmInfoPtr; - wmPtr2->master = None; - ckfree(wmPtr2->masterWindowName); - wmPtr2->masterWindowName = NULL; + wmPtr2 = winPtr2->wmInfoPtr; + wmPtr2->master = None; + ckfree(wmPtr2->masterWindowName); + wmPtr2->masterWindowName = NULL; } } @@ -3574,7 +3582,6 @@ WmTransientCmd( register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; - TkDisplay *dispPtr = TkGetDisplayList(); char *masterWindowName; int length; @@ -3590,34 +3597,8 @@ WmTransientCmd( return TCL_OK; } if (Tcl_GetString(objv[3])[0] == '\0') { + RemoveTransient(winPtr); - /* - * Remove the transient from its master's list. - */ - - if (wmPtr->master != None) { - TkWindow *masterPtr = (TkWindow*)Tk_IdToWindow(dispPtr->display, - wmPtr->master); - wmPtr2 = masterPtr->wmInfoPtr; - Transient *transientPtr = wmPtr2->transientPtr; - if (transientPtr->winPtr == winPtr) { - wmPtr2->transientPtr = transientPtr->nextPtr; - } else while (transientPtr->nextPtr != NULL) { - if (transientPtr->nextPtr->winPtr == winPtr) { - transientPtr->nextPtr = transientPtr->nextPtr->nextPtr; - break; - } - transientPtr = transientPtr->nextPtr; - } - if (transientPtr!= NULL) { - ckfree(transientPtr); - } - wmPtr->master = None; - if (wmPtr->masterWindowName != NULL) { - ckfree(wmPtr->masterWindowName); - } - wmPtr->masterWindowName = NULL; - } } else { if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) { return TCL_ERROR; @@ -3671,6 +3652,7 @@ WmTransientCmd( /* * If the master is withdrawn or iconic then withdraw the transient. */ + if ((wmPtr2->hints.initial_state == WithdrawnState || wmPtr2->hints.initial_state == IconicState) && wmPtr->hints.initial_state != WithdrawnState){ @@ -3690,6 +3672,61 @@ WmTransientCmd( ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; } + +/* + *---------------------------------------------------------------------- + * + * RemoveTransient -- + * + * Clears the transient's master record and removes the transient + * from the master's list. + * + * Results: + * None + * + * Side effects: + * References to a master are removed from the transient's wmInfo + * structure and references to the transient are removed from its + * master's wmInfo. + * + *---------------------------------------------------------------------- + */ + +static void +RemoveTransient( + TkWindow *winPtr) +{ + WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; + TkDisplay *dispPtr = TkGetDisplayList(); + TkWindow *masterPtr; + if (wmPtr == NULL || wmPtr->master == None) { + return; + } + masterPtr = (TkWindow*)Tk_IdToWindow(dispPtr->display, wmPtr->master); + wmPtr2 = masterPtr->wmInfoPtr; + if (wmPtr2 == NULL) { + return; + } + wmPtr->master = None; + if (wmPtr->masterWindowName != NULL) { + ckfree(wmPtr->masterWindowName); + } + wmPtr->masterWindowName = NULL; + Transient *temp, *cursor = wmPtr2->transientPtr; + if (cursor->winPtr == winPtr) { + temp = cursor->nextPtr; + ckfree(cursor); + cursor = temp; + masterPtr->wmInfoPtr->transientPtr = cursor; + } + while (cursor != NULL) { + if (cursor->winPtr == winPtr) { + temp = cursor->nextPtr; + ckfree(cursor); + cursor = temp; + } + } +} /* *---------------------------------------------------------------------- -- cgit v0.12 From ce11b1ea1514181f1c1c5e7d0b09fce77212dbe3 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 27 Jan 2019 16:56:40 +0000 Subject: Add an update making unixEmbed-5.1a pass on Linux --- tests/unixEmbed.test | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 349449a..1687a29 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -752,6 +752,7 @@ test unixEmbed-5.1a {EmbedFocusProc procedure, FocusIn events} -constraints { toplevel .t1 -use [w1] bind .t1 {lappend x "focus in %W"} bind .t1 {lappend x "focus out %W"} + update set x {} } focus -force .f1 -- cgit v0.12 From 2127d0a3c7f96a8769f3eced53bf5cd1008b768b Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 27 Jan 2019 17:15:08 +0000 Subject: Fix over-correction in the last commit. We must allow item to be nil on macOS. --- macosx/tkMacOSXMenu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index ed8d0c3..0b84891 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -807,7 +807,7 @@ TkpPostMenu( if (itemIndex >= 0) { item = [menu itemAtIndex:itemIndex]; } - if (menu != nil && item != nil) { + if (menu != nil) { oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); [menu popUpMenuPositioningItem:item atLocation:[win tkConvertPointFromScreen:location] -- cgit v0.12 From 8d1aa0f36abad1148d39757b1f9f23b6ea6a5ace Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 28 Jan 2019 14:27:13 +0000 Subject: Use the MENU_DELETION_PENDING flag to guard against crashes when the postcommand deletes the menu. --- macosx/tkMacOSXMenu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 0b84891..ef32738 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -807,12 +807,10 @@ TkpPostMenu( if (itemIndex >= 0) { item = [menu itemAtIndex:itemIndex]; } - if (menu != nil) { - oldMode = Tcl_SetServiceMode(TCL_SERVICE_NONE); + if (menu != nil && !(menuPtr->menuFlags & MENU_DELETION_PENDING)) { [menu popUpMenuPositioningItem:item atLocation:[win tkConvertPointFromScreen:location] inView:view]; - Tcl_SetServiceMode(oldMode); } inPostMenu = 0; return TCL_OK; -- cgit v0.12 From e087bb7d89526c82c0c0fb1e1bf5a6f21cf6d2ab Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 28 Jan 2019 16:39:02 +0000 Subject: Reverting TkpPostTearoffMenu to the unix function, which is equally useless but allows the tests to run without user intervention. --- macosx/tkMacOSXMenu.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 9 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index ef32738..d261add 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -779,7 +779,7 @@ TkpPostMenu( * entry, will be located. */ int index) { - int result, oldMode; + int result; Tk_Window root = Tk_MainWindow(interp); if (root == NULL) { @@ -807,11 +807,19 @@ TkpPostMenu( if (itemIndex >= 0) { item = [menu itemAtIndex:itemIndex]; } - if (menu != nil && !(menuPtr->menuFlags & MENU_DELETION_PENDING)) { - [menu popUpMenuPositioningItem:item - atLocation:[win tkConvertPointFromScreen:location] - inView:view]; + + /* + * The post commands could have deleted the menu, which means we are dead + * and should go away. + */ + + if (menuPtr->tkwin == NULL) { + return TCL_OK; } + + [menu popUpMenuPositioningItem:item + atLocation:[win tkConvertPointFromScreen:location] + inView:view]; inPostMenu = 0; return TCL_OK; } @@ -820,13 +828,78 @@ int TkpPostTearoffMenu( Tcl_Interp *interp, /* The interpreter this menu lives in */ TkMenu *menuPtr, /* The menu we are posting */ - int x, int y, /* The screen coordinates where the top left + int x, int y, int index) /* The screen coordinates where the top left * corner of the menu, or of the specified * entry, will be located. */ - int index) { - menuPtr->active = -1; - return TkpPostMenu(interp, menuPtr, x, y, index); + int vRootX, vRootY, vRootWidth, vRootHeight; + int result; + + if (index >= menuPtr->numEntries) { + index = menuPtr->numEntries - 1; + } + if (index >= 0) { + y -= menuPtr->entries[index]->y; + } + + TkActivateMenuEntry(menuPtr, -1); + TkRecomputeMenu(menuPtr); + result = TkPostCommand(menuPtr); + if (result != TCL_OK) { + return result; + } + + /* + * The post commands could have deleted the menu, which means we are dead + * and should go away. + */ + + if (menuPtr->tkwin == NULL) { + return TCL_OK; + } + + /* + * Adjust the position of the menu if necessary to keep it visible on the + * screen. There are two special tricks to make this work right: + * + * 1. If a virtual root window manager is being used then the coordinates + * are in the virtual root window of menuPtr's parent; since the menu + * uses override-redirect mode it will be in the *real* root window for + * the screen, so we have to map the coordinates from the virtual root + * (if any) to the real root. Can't get the virtual root from the menu + * itself (it will never be seen by the wm) so use its parent instead + * (it would be better to have an an option that names a window to use + * for this...). + * 2. The menu may not have been mapped yet, so its current size might be + * the default 1x1. To compute how much space it needs, use its + * requested size, not its actual size. + */ + + Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY, + &vRootWidth, &vRootHeight); + vRootWidth -= Tk_ReqWidth(menuPtr->tkwin); + if (x > vRootX + vRootWidth) { + x = vRootX + vRootWidth; + } + if (x < vRootX) { + x = vRootX; + } + vRootHeight -= Tk_ReqHeight(menuPtr->tkwin); + if (y > vRootY + vRootHeight) { + y = vRootY + vRootHeight; + } + if (y < vRootY) { + y = vRootY; + } + Tk_MoveToplevelWindow(menuPtr->tkwin, x, y); + if (!Tk_IsMapped(menuPtr->tkwin)) { + Tk_MapWindow(menuPtr->tkwin); + } + TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL); + return TCL_OK; + + // menuPtr->active = -1; + // return TkpPostMenu(interp, menuPtr, x, y, index); } /* -- cgit v0.12 From 41dd35f2c689c31dc23cde598c7828276b3186b7 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 28 Jan 2019 17:06:53 +0000 Subject: Edited comments. --- macosx/tkMacOSXMenu.c | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index d261add..bba2cfd 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -753,16 +753,15 @@ TkpDestroyMenuEntry( /* *---------------------------------------------------------------------- * - * TkpPostMenu, TkPostTearoffMenu -- + * TkpPostMenu -- * - * Posts a menu on the screen. (Tearoff menus are the same as - * ordinary menus on the mac.) If entry is < 0 then the menu is + * Posts a menu on the screen. If entry is < 0 then the menu is * drawn so its top left corner is located at the point with * screen coordinates (x, y). Otherwise the top left corner of * the specified entry is located at that point. * * Results: - * None. + * Returns a standard Tcl result. * * Side effects: * The menu is posted and handled. @@ -823,6 +822,34 @@ TkpPostMenu( inPostMenu = 0; return TCL_OK; } + +/* + *---------------------------------------------------------------------- + * + * TkpPostTearoffMenu -- + * + * Tearoff menus are not supported on the Mac. This placeholder + * function, which is simply a copy of the unix function, posts a + * completely useless window with a black background on the screen. If + * entry is < 0 then the window is positioned so that its top left corner + * is located at the point with screen coordinates (x, y). Otherwise the + * window position is offset so that top left corner of the specified + * entry would be located at that point, if there actually were a menu. + * + * Mac menus steal all mouse or keyboard input from the application until + * the menu is dismissed, with or without a selection, by a mouse or key + * event. Posting a Mac menu in a regression test will cause the test to + * halt waiting for user input. This is why the TkpPostMenu function is + * not being used as the placeholder. + * + * Results: + * None. + * + * Side effects: + * A useless window is posted. + * + *---------------------------------------------------------------------- + */ int TkpPostTearoffMenu( -- cgit v0.12 From a882b53474bbebcce65b5fcbd96dea64e652a44e Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 28 Jan 2019 21:16:44 +0000 Subject: Remove lines that were commented out. --- macosx/tkMacOSXMenu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index bba2cfd..6ed17d5 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -924,9 +924,6 @@ TkpPostTearoffMenu( } TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL); return TCL_OK; - - // menuPtr->active = -1; - // return TkpPostMenu(interp, menuPtr, x, y, index); } /* -- cgit v0.12 From 97d125a390ac2ecb00955aa7bd992f425a7b3aba Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 30 Jan 2019 16:27:08 +0000 Subject: A small change in how ActivateEvents are handled makes unixEmbed-5.3a pass on Aqua. --- macosx/tkMacOSXWindowEvent.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index ad6af30..bed4429 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -523,7 +523,9 @@ GenerateActivateEvents( int activeFlag) { TkGenerateActivateEvents(winPtr, activeFlag); - TkMacOSXGenerateFocusEvent(winPtr, activeFlag); + if (activeFlag) { + TkMacOSXGenerateFocusEvent(winPtr, activeFlag); + } return true; } -- cgit v0.12 From dcf8f65baa1a666ad952e8690b43af762eaaaef1 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 30 Jan 2019 17:04:23 +0000 Subject: Tweak the last commit: generate FocusOut events when the NSApp is deactivated. --- macosx/tkMacOSXWindowEvent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index bed4429..c39f62b 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -523,7 +523,7 @@ GenerateActivateEvents( int activeFlag) { TkGenerateActivateEvents(winPtr, activeFlag); - if (activeFlag) { + if (activeFlag || ![NSApp isActive]) { TkMacOSXGenerateFocusEvent(winPtr, activeFlag); } return true; -- cgit v0.12 From 25dfb62ab6c1f942344631c852e0dfce78f0a360 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 31 Jan 2019 22:00:31 +0000 Subject: Changes which make unixEmbed-8.1a pass on macOS. --- generic/tkFocus.c | 70 ++++++++++++++++++++++++++++++-------------------- macosx/tkMacOSXEmbed.c | 7 ++--- macosx/tkMacOSXWm.c | 6 +++-- tests/unixEmbed.test | 8 +++--- 4 files changed, 52 insertions(+), 39 deletions(-) diff --git a/generic/tkFocus.c b/generic/tkFocus.c index 60f631d..c621bf9 100644 --- a/generic/tkFocus.c +++ b/generic/tkFocus.c @@ -551,12 +551,17 @@ TkSetFocusWin( return; } + /* + * Get the current focus window with the same display and application + * as winPtr. + */ + displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr); /* - * If force is set, we should make sure we grab the focus regardless of - * the current focus window since under Windows, we may need to take - * control away from another application. + * Do nothing if the window already has focus and force is not set. If + * force is set, we need to grab the focus, since under Windows or macOS + * this may involve taking control away from another application. */ if (winPtr == displayFocusPtr->focusWinPtr && !force) { @@ -564,14 +569,15 @@ TkSetFocusWin( } /* - * Find the top-level window for winPtr, then find (or create) a record - * for the top-level. Also see whether winPtr and all its ancestors are + * Find the toplevel window for winPtr, then find (or create) a record + * for the toplevel. Also see whether winPtr and all its ancestors are * mapped. */ allMapped = 1; for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) { if (topLevelPtr == NULL) { + /* * The window is being deleted. No point in worrying about giving * it the focus. @@ -588,11 +594,11 @@ TkSetFocusWin( } /* - * If the new focus window isn't mapped, then we can't focus on it (X will - * generate an error, for example). Instead, create an event handler that - * will set the focus to this window once it gets mapped. At the same - * time, delete any old handler that might be around; it's no longer - * relevant. + * If any ancestor of the new focus window isn't mapped, then we can't set + * focus for it (X will generate an error, for example). Instead, create + * an event handler that will set the focus to this window once it gets + * mapped. At the same time, delete any old handler that might be around; + * it's no longer relevant. */ if (displayFocusPtr->focusOnMapPtr != NULL) { @@ -623,30 +629,38 @@ TkSetFocusWin( } tlFocusPtr->focusWinPtr = winPtr; - /* - * Reset the window system's focus window and generate focus events, with - * two special cases: - * - * 1. If the application is embedded and doesn't currently have the focus, - * don't set the focus directly. Instead, see if the embedding code can - * claim the focus from the enclosing container. - * 2. Otherwise, if the application doesn't currently have the focus, - * don't change the window system's focus unless it was already in this - * application or "force" was specified. - */ + if (topLevelPtr->flags & TK_EMBEDDED) { + + /* + * We are assigning focus to an embedded toplevel. The platform + * specific function TkpClaimFocus needs to handle the job of + * assigning focus to the container, since we have no way to find the + * contaiuner. + */ - if ((topLevelPtr->flags & TK_EMBEDDED) - && (displayFocusPtr->focusWinPtr == NULL)) { TkpClaimFocus(topLevelPtr, force); } else if ((displayFocusPtr->focusWinPtr != NULL) || force) { + /* - * Generate events to shift focus between Tk windows. We do this - * regardless of what TkpChangeFocus does with the real X focus so - * that Tk widgets track focus commands when there is no window - * manager. GenerateFocusEvents will set up a serial number marker so - * we discard focus events that are triggered by the ChangeFocus. + * If we are forcing removal of focus from a container hosting a + * toplevel from a different application, clear the focus in that + * application. */ + + if (force) { + TkWindow *focusPtr = winPtr->dispPtr->focusPtr; + if (focusPtr && focusPtr->mainPtr != winPtr->mainPtr) { + DisplayFocusInfo *displayFocusPtr2 = FindDisplayFocusInfo( + focusPtr->mainPtr, focusPtr->dispPtr); + displayFocusPtr2->focusWinPtr = NULL; + } + } + /* + * Call the platform specific function TkpChangeFocus to move the + * window manager's focus to a new toplevel. + */ + serial = TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force); if (serial != 0) { displayFocusPtr->focusSerial = serial; diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 8fcbb09..3108d4c 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -498,9 +498,7 @@ TkMacOSXGetHostToplevel( * TkpClaimFocus -- * * This procedure is invoked when someone asks for the input focus to be - * put on a window in an embedded application, but the application - * doesn't currently have the focus. It requests the input focus from the - * container application. + * put on a window in an embedded application. * * Results: * None. @@ -539,7 +537,7 @@ TkpClaimFocus( event.xfocus.window = containerPtr->parent; event.xfocus.mode = EMBEDDED_APP_WANTS_FOCUS; event.xfocus.detail = force; - Tk_QueueWindowEvent(&event,TCL_QUEUE_TAIL); + Tk_HandleEvent(&event); } /* @@ -914,7 +912,6 @@ EmbedActivateProc( XEvent *eventPtr) /* ResizeRequest event. */ { Container *containerPtr = clientData; - if (containerPtr->embeddedPtr != NULL) { if (eventPtr->type == ActivateNotify) { TkGenerateActivateEvents(containerPtr->embeddedPtr,1); diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index a5e1564..888705f 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6221,8 +6221,10 @@ XSetInputFocus( * * TkpChangeFocus -- * - * This procedure is a stub on the Mac because we always own the focus if - * we are a front most application. + * This function is called when Tk moves focus from one window to another. + * It should be passed a non-embedded TopLevel. That toplevel gets raised + * to the top of the Tk stacking order and the associated NSWindow is + * ordered Front. * * Results: * The return value is the serial number of the command that changed the diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 1687a29..a736e24 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -1130,19 +1130,19 @@ test unixEmbed-8.1a {TkpClaimFocus procedure} -constraints unix -setup { frame .f1 -container 1 -width 200 -height 50 frame .f2 -width 200 -height 50 pack .f1 .f2 + update slave alias w1 winfo id .f1 slave eval { destroy [winfo child .] toplevel .t1 -use [w1] -highlightthickness 2 -bd 2 -relief sunken } + # This should clear focus from the application embedded in .f1 focus -force .f2 update list [slave eval { - focus .t1 set x [list [focus]] - update - after 500 - update + focus .t1 + update lappend x [focus] }] [focus] } -cleanup { -- cgit v0.12 From 144943f2693109cf7edfca3d9eb1ee99a3aedef5 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 1 Feb 2019 23:38:29 +0000 Subject: Remove unnecessary sleep from unixEmbed-6.2a, which still fails however. --- tests/unixEmbed.test | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index a736e24..9f0ace5 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -946,17 +946,14 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const } -body { frame .f1 -container 1 -width 200 -height 50 place .f1 -width 200 -height 200 + update idletasks slave alias w1 winfo id .f1 slave eval { destroy [winfo child .] + set x {} toplevel .t1 -use [w1] - } - after 300 {set x done} - vwait x - slave eval { - bind .t1 {lappend x {configure .t1 %w %h}} update - set x {} + bind .t1 {lappend x {configure .t1 %w %h}} .t1 configure -width 300 -height 120 update list $x [winfo geom .t1] -- cgit v0.12 From 7ee00057db4a080edfaf39bc921f7eb58d64a459 Mon Sep 17 00:00:00 2001 From: oehhar Date: Sun, 3 Feb 2019 11:21:11 +0000 Subject: gif read not complete on overflow image - information missinterpreted if following subimage is querried [4da2191b] --- generic/tkImgGIF.c | 21 ++++++++++++++++++++- tests/imgPhoto.test | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c index 7c4872b..fa4b728 100644 --- a/generic/tkImgGIF.c +++ b/generic/tkImgGIF.c @@ -1034,7 +1034,7 @@ ReadImage( int transparent) { unsigned char initialCodeSize; - int xpos = 0, ypos = 0, pass = 0, i; + int xpos = 0, ypos = 0, pass = 0, i, count; register unsigned char *pixelPtr; static const int interlaceStep[] = { 8, 8, 4, 2 }; static const int interlaceStart[] = { 0, 4, 2, 1 }; @@ -1252,6 +1252,25 @@ ReadImage( } pixelPtr = imagePtr + (ypos) * len * ((transparent>=0)?4:3); } + + /* + * Now read until the final zero byte. + * It was observed that there might be 1 length blocks + * (test imgPhoto-14.1) which are not read. + * + * The field "stack" is abused for temporary buffer. it has 4096 bytes + * and we need 256. + * + * Loop until we hit a 0 length block which is the end sign. + */ + while ( 0 < (count = GetDataBlock(gifConfPtr, chan, stack))) + { + if (-1 == count ) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "error reading GIF image: %s", Tcl_PosixError(interp))); + return TCL_ERROR; + } + } return TCL_OK; } diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index 97fb7ae..c45c5fb 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -1212,6 +1212,39 @@ test imgPhoto-14.5 {Bug [fbaed1f66b] - GIF decoder with deferred clear code} -se image create photo -file $fileName -format "gif -index 2" } -returnCodes error -result {no image data for this index} +test imgPhoto-14.6 {Access Subimage after Subimage with buffer overflow. Ticket 4da2191b} -setup { + set data { + R0lGODlhYwA5APcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgAysnGy8hKzM + hASs3MTcjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDAwP8AAAD/ + AP//AAAA//8A/wD//////ywAAAAAYwA5AAAI/wAZCBxIsKDBgwgTKlzIsKHD + hxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bN + mzhz6tzJs6fPn0CDCh1KtKhRiwoSKEXAtGlTpUqPGkyagOmCq1edNsWalWkC + BUSXIuDqFepBqFWtZv3KU+zYrkrBSqT6dgECtjOTbu16NwFHvV3lshRLti/J + qlgRCE6ZuO9ik4Dt+k0ZVyZiyVIvXr77ODPEy5g9T4zMWfTEzXdNz1VbWvXn + uqldP1TAOrbshqBb314Y2W7n3Qdpv7UNPCHpycUVbv6dnODy5sqzQldIe8H0 + hciva9/Ovbv37+BzBgE7ACH5BAFkAAMALAAAAAAEAAQAAAMEKLrckgA7 + } +} -body { + image create photo photo1 -data $data -format "GIF -index 1" +} -cleanup { + catch {image delete photo1} +} -result photo1 + test imgPhoto-15.1 {photo images can fail to allocate memory gracefully} -constraints { nonPortable } -body { -- cgit v0.12 From e46d193fc6cc775196c64d70aaa67810c9882844 Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 3 Feb 2019 16:39:31 +0000 Subject: Simplify and uniformize unixEmbed tests 6.1, 6.1a, 6.2, 6.2a. --- tests/unixEmbed.test | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 9f0ace5..0abccc8 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -874,9 +874,7 @@ test unixEmbed-6.1 {EmbedGeometryRequest procedure, window changes size} -constr dobg { eval destroy [winfo child .] toplevel .t1 -use $w1 - } - update - dobg { + update bind .t1 {lappend x {configure .t1 %w %h}} set x {} .t1 configure -width 300 -height 120 @@ -922,15 +920,11 @@ test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constr dobg { eval destroy [winfo child .] toplevel .t1 -use $w1 - } - after 300 {set x done} - vwait x - dobg { + update bind .t1 {lappend x {configure .t1 %w %h}} set x {} .t1 configure -width 300 -height 120 - after 300 {set y done} - vwait y + update list $x [winfo geom .t1] } } -cleanup { @@ -946,14 +940,14 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const } -body { frame .f1 -container 1 -width 200 -height 50 place .f1 -width 200 -height 200 - update idletasks + update slave alias w1 winfo id .f1 slave eval { destroy [winfo child .] - set x {} toplevel .t1 -use [w1] update bind .t1 {lappend x {configure .t1 %w %h}} + set x {} .t1 configure -width 300 -height 120 update list $x [winfo geom .t1] -- cgit v0.12 From b0ae93bd6283a82f95b52bea063cff0e9c4d16a3 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 4 Feb 2019 16:48:52 +0000 Subject: Make the place manager send ConfigureNotify events when size change requests are rejected. This makes unixEmbed-6.2a pass. --- generic/tkPlace.c | 6 ++++++ tests/unixEmbed.test | 15 +++++---------- unix/tkUnixEmbed.c | 8 ++++++++ 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/generic/tkPlace.c b/generic/tkPlace.c index 2c06977..8eee5a1 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -1185,6 +1185,12 @@ PlaceRequestProc( if ((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) && (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) { + /* + * Send a ConfigureNotify to indicate that the size change + * request was rejected. + */ + + TkDoConfigureNotify((TkWindow *)(slavePtr->tkwin)); return; } masterPtr = slavePtr->masterPtr; diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 0abccc8..99f7265 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -323,11 +323,6 @@ test unixEmbed-2.3 {EmbeddedEventProc procedure} -constraints { destroy .f1 testembed } -result {} -if {[tk windowingsystem] eq "aqua"} { - set wrapperId {{}} -} else { - set wrapperId XXX -} test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints { unix testembed } -setup { @@ -342,7 +337,7 @@ test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints { list $x [winfo exists .t1] [winfo exists .f1] [testembed] } -cleanup { deleteWindows -} -result "{{XXX .f1 $wrapperId .t1}} 0 0 {}" +} -result "{{XXX .f1 {} .t1}} 0 0 {}" test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints { @@ -899,7 +894,7 @@ test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -const destroy [winfo child .] toplevel .t1 -use [w1] update - bind .t1 {lappend x {configure .t1 %w %h}} + bind .t1 {set x {configure .t1 %w %h}} set x {} .t1 configure -width 300 -height 120 update @@ -908,7 +903,7 @@ test unixEmbed-6.1a {EmbedGeometryRequest procedure, window changes size} -const } -cleanup { interp delete slave deleteWindows -} -result {{{configure .t1 300 120}} 300x120+0+0} +} -result {{configure .t1 300 120} 300x120+0+0} test unixEmbed-6.2 {EmbedGeometryRequest procedure, window changes size} -constraints { unix notAqua } -setup { @@ -946,7 +941,7 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const destroy [winfo child .] toplevel .t1 -use [w1] update - bind .t1 {lappend x {configure .t1 %w %h}} + bind .t1 {set x {configure .t1 %w %h}} set x {} .t1 configure -width 300 -height 120 update @@ -955,7 +950,7 @@ test unixEmbed-6.2a {EmbedGeometryRequest procedure, window changes size} -const } -cleanup { interp delete slave deleteWindows -} -result {{{configure .t1 200 200}} 200x200+0+0} +} -result {{configure .t1 200 200} 200x200+0+0} # Can't think up any tests for TkpGetOtherWindow procedure. diff --git a/unix/tkUnixEmbed.c b/unix/tkUnixEmbed.c index e1c4394..d9203ca 100644 --- a/unix/tkUnixEmbed.c +++ b/unix/tkUnixEmbed.c @@ -503,7 +503,15 @@ EmbedStructureProc( Tk_ErrorHandler errHandler; if (eventPtr->type == ConfigureNotify) { + /* + * Send a ConfigureNotify to the embedded application. + */ + + if (containerPtr->embeddedPtr != None) { + TkDoConfigureNotify(containerPtr->embeddedPtr); + } if (containerPtr->wrapper != None) { + /* * Ignore errors, since the embedded application could have * deleted its window. -- cgit v0.12 From 20fd9ad0dbfadae62d438616af4c461e39798fa9 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 4 Feb 2019 19:08:50 +0000 Subject: Change tkMacOSXEmbed.c to match the change in tkUnixEmbed.c even though this not needed to pass 6.2a. --- macosx/tkMacOSXEmbed.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/macosx/tkMacOSXEmbed.c b/macosx/tkMacOSXEmbed.c index 3108d4c..932d4cb 100644 --- a/macosx/tkMacOSXEmbed.c +++ b/macosx/tkMacOSXEmbed.c @@ -869,6 +869,14 @@ EmbedStructureProc( Tk_ErrorHandler errHandler; if (eventPtr->type == ConfigureNotify) { + + /* + * Send a ConfigureNotify to the embedded application. + */ + + if (containerPtr->embeddedPtr != None) { + TkDoConfigureNotify(containerPtr->embeddedPtr); + } if (containerPtr->embedded != None) { /* * Ignore errors, since the embedded application could have -- cgit v0.12 From 71775ff27a2673061e31435638f38fa3783868d0 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 7 Feb 2019 17:08:49 +0000 Subject: Also change tkWinEmbed.c to match the change in tkUnixEmbed.c, for consistency. --- win/tkWinEmbed.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 43c5e25..f28508d 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -856,6 +856,15 @@ ContainerEventProc( Tk_Window tkwin = (Tk_Window)containerPtr->parentPtr; if (eventPtr->type == ConfigureNotify) { + + /* + * Send a ConfigureNotify to the embedded application. + */ + + if (containerPtr->embeddedPtr != None) { + TkDoConfigureNotify(containerPtr->embeddedPtr); + } + /* * Resize the embedded window, if there is any. */ -- cgit v0.12 From e4d80b4d45925dc8efdb80b5c9bfa8f2e057d78a Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 8 Feb 2019 16:44:25 +0000 Subject: Fix bug [1529659ff]: Embedded toplevel makes the outer toplevel menu inaccessible. --- macosx/tkMacOSXMenu.c | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index dfa3e53..316a8d7 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -985,26 +985,47 @@ TkpSetMainMenubar( { static Tcl_Interp *currentInterp = NULL; TKMenu *menu = nil; + TkWindow *winPtr = (TkWindow *) tkwin; + + /* + * We will be called when an embedded window receives an ActivationNotify + * event, but we should not change the menubar in that case. + */ + + if (Tk_IsEmbedded(winPtr)) { + return; + } if (menuName) { - TkWindow *winPtr = (TkWindow *) tkwin; + Tk_Window menubar = NULL; + if (winPtr->wmInfoPtr && + winPtr->wmInfoPtr->menuPtr && + winPtr->wmInfoPtr->menuPtr->masterMenuPtr) { + menubar = winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin; + } - if (winPtr->wmInfoPtr && winPtr->wmInfoPtr->menuPtr && - winPtr->wmInfoPtr->menuPtr->masterMenuPtr && - winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin && - !strcmp(menuName, Tk_PathName( - winPtr->wmInfoPtr->menuPtr->masterMenuPtr->tkwin))) { + /* + * Attempt to find the NSMenu directly. If that fails, ask Tk to find it. + */ + + if (menubar != NULL && strcmp(menuName, Tk_PathName(menubar)) == 0) { menu = (TKMenu *) winPtr->wmInfoPtr->menuPtr->platformData; } else { TkMenuReferences *menuRefPtr = TkFindMenuReferences(interp, menuName); - if (menuRefPtr && menuRefPtr->menuPtr && menuRefPtr->menuPtr->platformData) { menu = (TKMenu *) menuRefPtr->menuPtr->platformData; } } } + + /* + * If we couldn't find a menu, do nothing unless the window belongs + * to a different application. In that case, install the default + * menubar. + */ + if (menu || interp != currentInterp) { [NSApp tkSetMainMenu:menu]; } -- cgit v0.12 From 57942e0fd075aa6e841279d4e098b6296d97fecd Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 8 Feb 2019 17:10:18 +0000 Subject: Fix the build for MSVC --- win/tkWinEmbed.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index f28508d..6c80964 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -861,7 +861,7 @@ ContainerEventProc( * Send a ConfigureNotify to the embedded application. */ - if (containerPtr->embeddedPtr != None) { + if (containerPtr->embeddedPtr != NULL) { TkDoConfigureNotify(containerPtr->embeddedPtr); } -- cgit v0.12 From 014209356fa48fa5d181e87c4ebba55dd7ea9a4a Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 9 Feb 2019 18:56:40 +0000 Subject: Fix bug [8814bddf5d]: segfault in [NSMenu size] --- macosx/tkMacOSXMenu.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index 316a8d7..227c379 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -1038,8 +1038,8 @@ TkpSetMainMenubar( * CheckForSpecialMenu -- * * Given a menu, check to see whether or not it is a cascade in a menubar - * with one of the special names .apple, .help or .window If it is, the - * entry that points to this menu will be marked. + * with one of the special names ".apple", ".help" or ".window". If it + * is, the entry that points to this menu will be marked. * * Results: * None. @@ -1216,7 +1216,7 @@ void TkpComputeStandardMenuGeometry( TkMenu *menuPtr) /* Structure describing menu. */ { - NSSize menuSize = [(NSMenu *)menuPtr->platformData size]; + NSSize menuSize; Tk_Font tkfont, menuFont; Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr; int modifierCharWidth, menuModifierCharWidth; @@ -1227,10 +1227,14 @@ TkpComputeStandardMenuGeometry( TkMenuEntry *mePtr; int haveAccel = 0; - if (menuPtr->tkwin == NULL) { + /* + * Do nothing if this menu is a clone. + */ + if (menuPtr->tkwin == NULL || menuPtr->masterMenuPtr != menuPtr) { return; } - + + menuSize = [(NSMenu *)menuPtr->platformData size]; Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr, &borderWidth); Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->activeBorderWidthPtr, -- cgit v0.12 From d7ace80f3a43a83a2ebc55b16ff631aba32a4665 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 13 Feb 2019 03:34:15 +0000 Subject: Fix bug [b389dfcd8f]: Aqua miscalculates window position on secondary display --- macosx/tkMacOSXWindowEvent.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index c39f62b..42979db 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -75,12 +75,11 @@ extern NSString *NSWindowDidOrderOffScreenNotification; if (winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect bounds = [w frame]; - NSRect screenRect = [[w screen] frame]; int x, y, width = -1, height = -1, flags = 0; int minY = 1 + [[NSApp mainMenu] menuBarHeight]; x = bounds.origin.x; - y = screenRect.size.height - (bounds.origin.y + bounds.size.height); + y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height); if (winPtr->changes.x != x || winPtr->changes.y != y) { flags |= TK_LOCATION_CHANGED; } else { @@ -102,7 +101,7 @@ extern NSString *NSWindowDidOrderOffScreenNotification; } /* - * Mac windows cannot go higher than the bottom of the menu bar. The + * Mac windows are not allowed to overlap the menu bar. The * Tk window manager can request that a window be drawn so that it * overlaps the menu bar, but it will actually be drawn immediately * below the menu bar. In such a case it saves a lot of trouble and @@ -682,7 +681,6 @@ TkGenWMConfigureEvent( if (flags & TK_LOCATION_CHANGED) { wmPtr->x = x; wmPtr->y = y; - //wmPtr->flags &= ~(WM_NEGATIVE_X | WM_NEGATIVE_Y); } if ((flags & TK_SIZE_CHANGED) && !(wmPtr->flags & WM_SYNC_PENDING) && ((width != Tk_Width(tkwin)) || (height != Tk_Height(tkwin)))) { -- cgit v0.12 From f0b015abf1cd2457689595d92c44b8993297d19b Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 13 Feb 2019 15:49:19 +0000 Subject: Fix bug [2249e64bdc]: Some unixWm tests expect the impossible on Aqua --- macosx/tkMacOSXWindowEvent.c | 14 -------------- tests/unixWm.test | 39 +++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 42979db..7752780 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -100,20 +100,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; flags |= TK_MACOSX_HANDLE_EVENT_IMMEDIATELY; } - /* - * Mac windows are not allowed to overlap the menu bar. The - * Tk window manager can request that a window be drawn so that it - * overlaps the menu bar, but it will actually be drawn immediately - * below the menu bar. In such a case it saves a lot of trouble and - * causes no harm if we let Tk think that the window is located at the - * requested point. (Many of the the tests assume that this is the - * case, especially for windows with upper left corner at (0,0).) So - * we just tell a harmless white lie here. - */ - - if (y == minY && wmPtr->y < minY) { - y = wmPtr->y; - } TkGenWMConfigureEvent((Tk_Window) winPtr, x, y, width, height, flags); } diff --git a/tests/unixWm.test b/tests/unixWm.test index 12a2142..c147bbf 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -40,8 +40,23 @@ proc makeToplevels {} { } } +# On macOS windows are not allowed to overlap the menubar at the top +# of the screen. So tests which move a window and then check whether +# it got moved to the requested location should use a y coordinate +# larger than the height of the menubar (normally 23 pixels). + +if {[tk windowingsystem] eq "aqua"} { + set Y0 23 + set Y2 25 + set Y5 28 +} else { + set Y0 0 + set Y2 2 + set Y5 5 +} + set i 1 -foreach geom {+20+80 +80+20 +0+0} { +foreach geom "+23+80 +80+23 +0+$Y0" { destroy .t test unixWm-1.$i {initial window position} unix { toplevel .t -width 200 -height 150 @@ -67,7 +82,7 @@ update scan [wm geom .t] %dx%d+%d+%d width height x y set xerr [expr 150-$x] set yerr [expr 150-$y] -foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { +foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { test unixWm-2.$i {moving window while mapped} unix { wm geom .t $geom update @@ -79,7 +94,7 @@ foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { } set i 1 -foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { +foreach geom "+20+80 +80+23 +0+$Y0 -0-0 +0-0 -0+$Y0 -10-5 -10+$Y5 +10-5" { test unixWm-3.$i {moving window while iconified} unix { wm iconify .t sleep 200 @@ -95,7 +110,7 @@ foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { } set i 1 -foreach geom {+20+80 +100+40 +0+0} { +foreach geom "+20+80 +100+40 +0+$Y0" { test unixWm-4.$i {moving window while withdrawn} unix { wm withdraw .t sleep 200 @@ -179,27 +194,27 @@ test unixWm-5.7 {compounded state changes} {unix nonPortable} { destroy .t toplevel .t -width 200 -height 100 -wm geom .t +10+10 +wm geom .t +10+23 wm minsize .t 1 1 update test unixWm-6.1 {size changes} unix { .t config -width 180 -height 150 update wm geom .t -} 180x150+10+10 +} 180x150+10+23 test unixWm-6.2 {size changes} unix { wm geom .t 250x60 .t config -width 170 -height 140 update wm geom .t -} 250x60+10+10 +} 250x60+10+23 test unixWm-6.3 {size changes} unix { wm geom .t 250x60 .t config -width 170 -height 140 wm geom .t {} update wm geom .t -} 170x140+10+10 +} 170x140+10+23 test unixWm-6.4 {size changes} {unix nonPortable userInteraction} { wm minsize .t 1 1 update @@ -1357,14 +1372,14 @@ test unixWm-40.1 {Tk_SetGrid procedure, set grid dimensions before turning on gr test unixWm-40.2 {Tk_SetGrid procedure, turning on grid when dimensions already set} unix { destroy .t toplevel .t - wm geometry .t 200x100+0+0 + wm geometry .t 200x100+0+$Y0 listbox .t.l -height 20 -width 20 pack .t.l -fill both -expand 1 update .t.l configure -setgrid 1 update wm geometry .t -} {20x20+0+0} +} "20x20+0+$Y0" test unixWm-41.1 {ConfigureEvent procedure, internally generated size changes} unix { destroy .t @@ -1559,10 +1574,10 @@ test unixWm-44.8 {UpdateGeometryInfo procedure, computing position} unix { tkwait visibility .t wm overrideredirect .t 1 update - wm geometry .t -30+2 + wm geometry .t -30+$Y2 update list [winfo x .t] [winfo y .t] -} [list [expr [winfo screenwidth .t] - 110] 2] +} [list [expr [winfo screenwidth .t] - 110] $Y2] destroy .t test unixWm-44.9 {UpdateGeometryInfo procedure, updating fixed dimensions} {unix testwrapper} { -- cgit v0.12 From 4266bcfcf2a8caf18483c350a3139a69ac753402 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 13 Feb 2019 16:12:16 +0000 Subject: Two text tests also try to position a window with y = 0. Tweak these for Aqua. --- tests/text.test | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/text.test b/tests/text.test index aaddc2c..be25ca6 100644 --- a/tests/text.test +++ b/tests/text.test @@ -3474,6 +3474,12 @@ test text-14.18 {ConfigureText procedure} -constraints fonts -setup { # minimum size and it was interfering with the size requested by the -setgrid. # The "overrideredirect" gets rid of the titlebar so the toplevel can shrink # to the appropriate size. +# On macOS, however, there is no way to make the window overlap the menubar. +if {[tk windowingsystem] == "aqua"} { + set minY 23 +} else { + set minY 0 +} test text-14.19 {ConfigureText procedure} -setup { toplevel .top text .top.t -font {Courier -12} -borderwidth 2 -highlightthickness 2 @@ -3481,16 +3487,17 @@ test text-14.19 {ConfigureText procedure} -setup { .top.t configure -width 20 -height 10 -setgrid 1 wm overrideredirect .top 1 pack .top.t - wm geometry .top +0+0 + wm geometry .top +0+$minY update wm geometry .top } -cleanup { destroy .top -} -result {20x10+0+0} +} -result "20x10+0+$minY" # This test was failing on Windows because the title bar on .t was a certain # minimum size and it was interfering with the size requested by the -setgrid. # The "overrideredirect" gets rid of the titlebar so the toplevel can shrink # to the appropriate size. +# On macOS we again use minY as a workaround. test text-14.20 {ConfigureText procedure} -setup { toplevel .top text .top.t -font {Courier -12} -borderwidth 2 -highlightthickness 2 @@ -3498,7 +3505,7 @@ test text-14.20 {ConfigureText procedure} -setup { .top.t configure -width 20 -height 10 -setgrid 1 wm overrideredirect .top 1 pack .top.t - wm geometry .top +0+0 + wm geometry .top +0+$minY update set result [wm geometry .top] wm geometry .top 15x8 @@ -3509,7 +3516,7 @@ test text-14.20 {ConfigureText procedure} -setup { lappend result [wm geometry .top] } -cleanup { destroy .top -} -result {20x10+0+0 15x8+0+0 15x8+0+0} +} -result "20x10+0+$minY 15x8+0+$minY 15x8+0+$minY" test text-15.1 {TextWorldChanged procedure, spacing options} -constraints { -- cgit v0.12 From 467268bf38ec0cab6e8c5cc66e44f6953f13b684 Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 13 Feb 2019 21:32:46 +0000 Subject: Remove a missed unused variable. --- macosx/tkMacOSXWindowEvent.c | 1 - 1 file changed, 1 deletion(-) diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 7752780..212381e 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -76,7 +76,6 @@ extern NSString *NSWindowDidOrderOffScreenNotification; WmInfo *wmPtr = winPtr->wmInfoPtr; NSRect bounds = [w frame]; int x, y, width = -1, height = -1, flags = 0; - int minY = 1 + [[NSApp mainMenu] menuBarHeight]; x = bounds.origin.x; y = tkMacOSXZeroScreenHeight - (bounds.origin.y + bounds.size.height); -- cgit v0.12 From ea84e24e8ca7b01f930961973340e0253b5eec49 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 15 Feb 2019 20:05:17 +0000 Subject: Tcl_BackgroundError -> Tcl_BackgroundException. Mark deprecated macro's as such (remove then with -DTCL_NO_DEPRECATED). Change field in Tk_ClassProcs to size_t, when compiling against Tcl 9 headers --- generic/tk.h | 8 +++++++- generic/tkText.c | 2 +- generic/tkTextDisp.c | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/generic/tk.h b/generic/tk.h index 6f1c98a..f106f1c 100644 --- a/generic/tk.h +++ b/generic/tk.h @@ -587,7 +587,11 @@ typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData); typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr); typedef struct Tk_ClassProcs { +#if TCL_MAJOR_VERSION > 8 + size_t size; +#else unsigned int size; +#endif Tk_ClassWorldChangedProc *worldChangedProc; /* Procedure to invoke when the widget needs * to respond in some way to a change in the @@ -617,7 +621,7 @@ typedef struct Tk_ClassProcs { #define Tk_GetClassProc(procs, which) \ (((procs) == NULL) ? NULL : \ - (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which)) + (((procs)->size <= (size_t)Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which)) /* * Each geometry manager (the packer, the placer, etc.) is represented by a @@ -1481,6 +1485,7 @@ typedef struct Tk_ElementSpec { *---------------------------------------------------------------------- */ +#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 #define TK_READABLE TCL_READABLE #define TK_WRITABLE TCL_WRITABLE #define TK_EXCEPTION TCL_EXCEPTION @@ -1514,6 +1519,7 @@ typedef struct Tk_ElementSpec { #define Tk_FreeProc Tcl_FreeProc #define Tk_Preserve Tcl_Preserve #define Tk_Release Tcl_Release +#endif /* Removed Tk_Main, use macro instead */ #if defined(_WIN32) || defined(__CYGWIN__) diff --git a/generic/tkText.c b/generic/tkText.c index c493ef1..fc63992 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5622,7 +5622,7 @@ TkTextRunAfterSyncCmd( code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); - Tcl_BackgroundError(textPtr->interp); + Tcl_BackgroundException(textPtr->interp, TCL_ERROR); } Tcl_Release((ClientData) textPtr->interp); Tcl_DecrRefCount(textPtr->afterSyncCmd); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index bc65d3a..66ff744 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3077,7 +3077,7 @@ AsyncUpdateLineMetrics( TCL_EVAL_GLOBAL); if (code == TCL_ERROR) { Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)"); - Tcl_BackgroundError(textPtr->interp); + Tcl_BackgroundException(textPtr->interp, TCL_ERROR); } Tcl_Release((ClientData) textPtr->interp); Tcl_DecrRefCount(textPtr->afterSyncCmd); -- cgit v0.12 From 26f086b4be1a8a8a559d080ece2f257b19763c17 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 18 Feb 2019 18:48:45 +0000 Subject: Fix bug [56a1823c73]: Aqua toplevels can fail to appear on screen. --- macosx/tkMacOSXInit.c | 10 ++++++++++ macosx/tkMacOSXSubwindows.c | 24 +++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/macosx/tkMacOSXInit.c b/macosx/tkMacOSXInit.c index 9d4d487..e1d56fa 100644 --- a/macosx/tkMacOSXInit.c +++ b/macosx/tkMacOSXInit.c @@ -122,7 +122,17 @@ static char scriptPath[PATH_MAX + 1] = ""; * method is called. Activating too early can cause the menu * bar to be unresponsive. */ + [NSApp activateIgnoringOtherApps: YES]; + + /* + * Process events to ensure that the root window is fully + * initialized. See ticket 56a1823c73. + */ + + [NSApp _lockAutoreleasePool]; + while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {} + [NSApp _unlockAutoreleasePool]; } - (void) _setup: (Tcl_Interp *) interp diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 7bc807a..c3df4d4 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -149,6 +149,7 @@ XMapWindow( if (Tk_IsTopLevel(macWin->winPtr)) { if (!Tk_IsEmbedded(macWin->winPtr)) { NSWindow *win = TkMacOSXDrawableWindow(window); + /* * We want to activate Tk when a toplevel is mapped * but we must not supply YES here. This is because @@ -157,6 +158,7 @@ XMapWindow( * the app to activate too early can make the menu bar * unresponsive. */ + TkMacOSXApplyWindowAttributes(macWin->winPtr, win); [win setExcludedFromWindowsMenu:NO]; [NSApp activateIgnoringOtherApps:NO]; @@ -166,11 +168,22 @@ XMapWindow( } else { [win orderFrontRegardless]; } + + /* + * In some cases the toplevel will not be drawn unless we process + * all pending events now. See ticket 56a1823c73. + */ + + [NSApp _lockAutoreleasePool]; + while (Tcl_DoOneEvent(TCL_WINDOW_EVENTS| TCL_DONT_WAIT)) {} + [NSApp _unlockAutoreleasePool]; } else { + /* * Rebuild the container's clipping region and display * the window. */ + TkWindow *contWinPtr = TkpGetOtherWindow(macWin->winPtr); TkMacOSXInvalClipRgns((Tk_Window)contWinPtr); TkMacOSXInvalidateWindow(macWin, TK_PARENT_WINDOW); @@ -190,7 +203,9 @@ XMapWindow( event.xmap.event = window; event.xmap.override_redirect = macWin->winPtr->atts.override_redirect; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); + } else { + /* * Rebuild the parent's clipping region and display the window. * @@ -211,11 +226,10 @@ XMapWindow( NotifyVisibility(macWin->winPtr, &event); /* - * Make sure that subwindows get displayed. + * This seems to be needed to ensure that all subwindows get displayed. */ GenerateConfigureNotify(macWin->winPtr, 1); - } /* @@ -284,11 +298,7 @@ XUnmapWindow( if (!Tk_IsEmbedded(winPtr) && winPtr->wmInfoPtr->hints.initial_state!=IconicState) { NSWindow *win = TkMacOSXDrawableWindow(window); - - if ([win isVisible]) { - [[win parentWindow] removeChildWindow:win]; - [win orderOut:NSApp]; - } + [win orderOut:nil]; } TkMacOSXInvalClipRgns((Tk_Window) winPtr); -- cgit v0.12 From 1cef9274b60a299bef15c8ddc054701387f9d560 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 22 Feb 2019 18:50:23 +0000 Subject: Fix [30a0fc767a]: spelling error in a comment --- macosx/tkMacOSXSubwindows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index 7bc807a..35002a9 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -1314,7 +1314,7 @@ TkMacOSXWinCGBounds( * UpdateOffsets -- * * Updates the X & Y offsets of the given TkWindow from the TopLevel it is - * a decendant of. + * a descendant of. * * Results: * None. -- cgit v0.12 From 3d2e242f10eb499e845c3b3227040514748cc0de Mon Sep 17 00:00:00 2001 From: culler Date: Sat, 23 Feb 2019 05:44:41 +0000 Subject: Fix bug [9771ae0f0b]: In Aqua, deiconifying a transient of a withdrawn window can create a zombie --- macosx/tkMacOSXWm.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ab5cd8d..67d6ecb 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6871,7 +6871,6 @@ ApplyMasterOverrideChanges( TkDisplay *dispPtr = TkGetDisplayList(); TkWindow *masterWinPtr = (TkWindow *) Tk_IdToWindow(dispPtr->display, wmPtr->master); - if (masterWinPtr && masterWinPtr->window != None && TkMacOSXHostToplevelExists(masterWinPtr)) { NSWindow *masterMacWin = @@ -6882,8 +6881,20 @@ ApplyMasterOverrideChanges( if (parentWindow) { [parentWindow removeChildWindow:macWindow]; } - [masterMacWin addChildWindow:macWindow - ordered:NSWindowAbove]; + + /* + * A child NSWindow retains its relative position with + * respect to the parent when the parent is moved. This is + * pointless if the parent is offscreen, and adding a child + * to an offscreen window causes the parent to be displayed + * as a zombie. So we should only do this if the parent is + * visible. + */ + + if ([masterMacWin isVisible]) { + [masterMacWin addChildWindow:macWindow + ordered:NSWindowAbove]; + } if (wmPtr->flags & WM_TOPMOST) { [macWindow setLevel:kCGUtilityWindowLevel]; } -- cgit v0.12 From 8f55c5985d13b4b7857066df9cd2ac55f9dc14ef Mon Sep 17 00:00:00 2001 From: culler Date: Wed, 27 Feb 2019 23:22:36 +0000 Subject: Adding 1 character fixes two of the three crashes reported in ticket [1951abf33d] --- macosx/tkMacOSXWm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 67d6ecb..31f745a 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -3646,7 +3646,7 @@ WmTransientCmd( Transient *transient = ckalloc(sizeof(Transient)); transient->winPtr = winPtr; transient->flags = 0; - transient->nextPtr = wmPtr->transientPtr; + transient->nextPtr = wmPtr2->transientPtr; wmPtr2->transientPtr = transient; /* -- cgit v0.12 From 33c0644d0f0db1639b351981459ed7a9e4d4270d Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 28 Feb 2019 05:02:10 +0000 Subject: Make sure that we don't create cycles in the parent->child digraph even if there are cycles in the master->transient digraph. --- macosx/tkMacOSXWm.c | 62 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 31f745a..c8e0445 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -6793,6 +6793,7 @@ ApplyMasterOverrideChanges( int oldFlags = wmPtr->flags; unsigned long styleMask; NSRect structureRect; + NSWindow *parentWindow; if (!macWindow && winPtr->window != None && TkMacOSXHostToplevelExists(winPtr)) { @@ -6833,7 +6834,6 @@ ApplyMasterOverrideChanges( } } if (macWindow) { - NSWindow *parentWindow = [macWindow parentWindow]; structureRect = [NSWindow frameRectForContentRect:NSZeroRect styleMask:styleMask]; @@ -6873,35 +6873,51 @@ ApplyMasterOverrideChanges( Tk_IdToWindow(dispPtr->display, wmPtr->master); if (masterWinPtr && masterWinPtr->window != None && TkMacOSXHostToplevelExists(masterWinPtr)) { - NSWindow *masterMacWin = - TkMacOSXDrawableWindow(masterWinPtr->window); + NSWindow *masterMacWin = TkMacOSXDrawableWindow(masterWinPtr->window); + + /* + * Try to add the transient window as a child window of the + * master. A child NSWindow retains its relative position with + * respect to the parent when the parent is moved. This is + * pointless if the parent is offscreen, and adding a child to + * an offscreen window causes the parent to be displayed as a + * zombie. So we only do this if the parent is visible. + */ + + if (masterMacWin && + [masterMacWin isVisible] && + (winPtr->flags & TK_MAPPED)) { - if (masterMacWin && masterMacWin != parentWindow && - (winPtr->flags & TK_MAPPED)) { - if (parentWindow) { - [parentWindow removeChildWindow:macWindow]; - } - /* - * A child NSWindow retains its relative position with - * respect to the parent when the parent is moved. This is - * pointless if the parent is offscreen, and adding a child - * to an offscreen window causes the parent to be displayed - * as a zombie. So we should only do this if the parent is - * visible. + * If the transient is already a child of some other window, + * remove it. */ + + parentWindow = [macWindow parentWindow]; + if (parentWindow && parentWindow != masterMacWin) { + [parentWindow removeChildWindow:macWindow]; + } - if ([masterMacWin isVisible]) { - [masterMacWin addChildWindow:macWindow - ordered:NSWindowAbove]; + /* + * To avoid cycles, if the master is a child of some + other window, remove it. + */ + parentWindow = [masterMacWin parentWindow]; + if (parentWindow) { + [parentWindow removeChildWindow:masterMacWin]; } - if (wmPtr->flags & WM_TOPMOST) { - [macWindow setLevel:kCGUtilityWindowLevel]; + [masterMacWin addChildWindow:macWindow + ordered:NSWindowAbove]; } - } } - } else if (parentWindow) { - [parentWindow removeChildWindow:macWindow]; + } else { + parentWindow = [macWindow parentWindow]; + if (parentWindow) { + [parentWindow removeChildWindow:macWindow]; + } + } + if (wmPtr->flags & WM_TOPMOST) { + [macWindow setLevel:kCGUtilityWindowLevel]; } ApplyWindowAttributeFlagChanges(winPtr, macWindow, oldAttributes, oldFlags, 0, 0); -- cgit v0.12 From 25cab35e68932b15367a751414207d51a502e687 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 28 Feb 2019 06:18:53 +0000 Subject: Remove some bloat from tkMacOSXWm.c. --- generic/tkInt.decls | 2 +- generic/tkIntPlatDecls.h | 4 +- macosx/tkMacOSXWm.c | 98 +++++++++++++++++------------------------------- macosx/tkMacOSXWm.h | 6 +-- 4 files changed, 38 insertions(+), 72 deletions(-) diff --git a/generic/tkInt.decls b/generic/tkInt.decls index d0b7678..a3e1f98 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1009,7 +1009,7 @@ declare 47 aqua { Tk_Window TkMacOSXGetCapture(void) } declare 49 aqua { - Window TkGetTransientMaster(TkWindow *winPtr) + Tk_Window TkGetTransientMaster(TkWindow *winPtr) } declare 50 aqua { int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state) diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h index ded5ac5..26a5f46 100644 --- a/generic/tkIntPlatDecls.h +++ b/generic/tkIntPlatDecls.h @@ -243,7 +243,7 @@ EXTERN int TkpIsWindowFloating(void *window); EXTERN Tk_Window TkMacOSXGetCapture(void); /* Slot 48 is reserved */ /* 49 */ -EXTERN Window TkGetTransientMaster(TkWindow *winPtr); +EXTERN Tk_Window TkGetTransientMaster(TkWindow *winPtr); /* 50 */ EXTERN int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state); @@ -392,7 +392,7 @@ typedef struct TkIntPlatStubs { int (*tkpIsWindowFloating) (void *window); /* 46 */ Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */ void (*reserved48)(void); - Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */ + Tk_Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */ int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */ void (*tkGenWMDestroyEvent) (Tk_Window tkwin); /* 51 */ void (*tkMacOSXSetDrawingEnabled) (TkWindow *winPtr, int flag); /* 52 */ diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index c8e0445..ecb4456 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -669,7 +669,7 @@ TkWmNewWindow( wmPtr->reparent = None; wmPtr->titleUid = NULL; wmPtr->iconName = NULL; - wmPtr->master = None; + wmPtr->master = NULL; wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; @@ -679,7 +679,6 @@ TkWmNewWindow( wmPtr->hints.icon_mask = None; wmPtr->hints.window_group = None; wmPtr->leaderName = NULL; - wmPtr->masterWindowName = NULL; wmPtr->icon = NULL; wmPtr->iconFor = NULL; wmPtr->transientPtr = NULL; @@ -884,18 +883,16 @@ TkWmDeadWindow( TkWindow *winPtr) /* Top-level window that's being deleted. */ { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; - TkDisplay *dispPtr = TkGetDisplayList(); if (wmPtr == NULL) { return; } - - /* + + /* *If the dead window is a transient, remove it from the master's list. */ RemoveTransient(winPtr); - Tk_ManageGeometry((Tk_Window) winPtr, NULL, NULL); Tk_DeleteEventHandler((Tk_Window) winPtr, StructureNotifyMask, TopLevelEventProc, winPtr); @@ -911,9 +908,6 @@ TkWmDeadWindow( if (wmPtr->leaderName != NULL) { ckfree(wmPtr->leaderName); } - if (wmPtr->masterWindowName != NULL) { - ckfree(wmPtr->masterWindowName); - } if (wmPtr->icon != NULL) { wmPtr2 = ((TkWindow *) wmPtr->icon)->wmInfoPtr; wmPtr2->iconFor = NULL; @@ -942,17 +936,14 @@ TkWmDeadWindow( * If the dead window has a transient, remove references to it from * the transient. */ - + for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; - Window master = TkGetTransientMaster(winPtr2); - TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (masterPtr == winPtr) { wmPtr2 = winPtr2->wmInfoPtr; - wmPtr2->master = None; - ckfree(wmPtr2->masterWindowName); - wmPtr2->masterWindowName = NULL; + wmPtr2->master = NULL; } } @@ -1791,7 +1782,6 @@ WmDeiconifyCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - TkDisplay *dispPtr = TkGetDisplayList(); if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -1830,17 +1820,16 @@ WmDeiconifyCmd( transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; WmInfo *wmPtr2 = winPtr2->wmInfoPtr; - Window master = TkGetTransientMaster(winPtr2); - TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (masterPtr == winPtr) { - if (!(wmPtr2->hints.initial_state == WithdrawnState && - (transientPtr->flags & WITHDRAWN_BY_MASTER) == 0)) { + if ((wmPtr2->hints.initial_state == WithdrawnState && + (transientPtr->flags & WITHDRAWN_BY_MASTER) != 0)) { TkpWmSetState(winPtr2, NormalState); transientPtr->flags &= ~WITHDRAWN_BY_MASTER; } } } - + return TCL_OK; } @@ -2327,7 +2316,6 @@ WmIconifyCmd( int objc, /* Number of arguments. */ Tcl_Obj *const objv[]) /* Argument objects. */ { - TkDisplay *dispPtr = TkGetDisplayList(); register WmInfo *wmPtr = winPtr->wmInfoPtr; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "window"); @@ -2341,7 +2329,7 @@ WmIconifyCmd( Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; - } else if (wmPtr->master != None) { + } else if (wmPtr->master != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); Tcl_SetErrorCode(interp, "TK", "WM", "ICONIFY", "TRANSIENT", NULL); @@ -2373,8 +2361,7 @@ WmIconifyCmd( for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; - Window master = TkGetTransientMaster(winPtr2); - TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (masterPtr == winPtr && winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) { TkpWmSetState(winPtr2, WithdrawnState); @@ -3466,7 +3453,7 @@ WmStateCmd( "OVERRIDE_REDIRECT", NULL); return TCL_ERROR; } - if (wmPtr->master != None) { + if (wmPtr->master != NULL) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "can't iconify \"%s\": it is a transient", winPtr->pathName)); @@ -3582,17 +3569,15 @@ WmTransientCmd( register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; - char *masterWindowName; - int length; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); return TCL_ERROR; } if (objc == 3) { - if (wmPtr->master != None) { + if (wmPtr->master != NULL) { Tcl_SetObjResult(interp, - Tcl_NewStringObj(wmPtr->masterWindowName, -1)); + Tcl_NewStringObj(Tk_PathName(wmPtr->master), -1)); } return TCL_OK; } @@ -3648,7 +3633,7 @@ WmTransientCmd( transient->flags = 0; transient->nextPtr = wmPtr2->transientPtr; wmPtr2->transientPtr = transient; - + /* * If the master is withdrawn or iconic then withdraw the transient. */ @@ -3660,14 +3645,7 @@ WmTransientCmd( transient->flags |= WITHDRAWN_BY_MASTER; } - wmPtr->master = Tk_WindowId(masterPtr); - masterWindowName = masterPtr->pathName; - length = strlen(masterWindowName); - if (wmPtr->masterWindowName != NULL) { - ckfree(wmPtr->masterWindowName); - } - wmPtr->masterWindowName = ckalloc(length+1); - strcpy(wmPtr->masterWindowName, masterWindowName); + wmPtr->master = (Tk_Window)masterPtr; } ApplyMasterOverrideChanges(winPtr, NULL); return TCL_OK; @@ -3697,21 +3675,16 @@ RemoveTransient( TkWindow *winPtr) { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; - TkDisplay *dispPtr = TkGetDisplayList(); TkWindow *masterPtr; - if (wmPtr == NULL || wmPtr->master == None) { + if (wmPtr == NULL || wmPtr->master == NULL) { return; } - masterPtr = (TkWindow*)Tk_IdToWindow(dispPtr->display, wmPtr->master); + masterPtr = (TkWindow*)wmPtr->master; wmPtr2 = masterPtr->wmInfoPtr; if (wmPtr2 == NULL) { return; } - wmPtr->master = None; - if (wmPtr->masterWindowName != NULL) { - ckfree(wmPtr->masterWindowName); - } - wmPtr->masterWindowName = NULL; + wmPtr->master = NULL; Transient *temp, *cursor = wmPtr2->transientPtr; if (cursor->winPtr == winPtr) { temp = cursor->nextPtr; @@ -3769,9 +3742,8 @@ WmWithdrawCmd( } TkpWmSetState(winPtr, WithdrawnState); - + NSWindow *win = TkMacOSXDrawableWindow(winPtr->window); - TkDisplay *dispPtr = TkGetDisplayList(); [win orderOut:nil]; [win setExcludedFromWindowsMenu:YES]; @@ -3781,8 +3753,7 @@ WmWithdrawCmd( for (Transient *transientPtr = wmPtr->transientPtr; transientPtr != NULL; transientPtr = transientPtr->nextPtr) { TkWindow *winPtr2 = transientPtr->winPtr; - Window master = TkGetTransientMaster(winPtr2); - TkWindow *masterPtr = (TkWindow *)Tk_IdToWindow(dispPtr->display, master); + TkWindow *masterPtr = (TkWindow *)TkGetTransientMaster(winPtr2); if (masterPtr == winPtr && winPtr2->wmInfoPtr->hints.initial_state != WithdrawnState) { TkpWmSetState(winPtr2, WithdrawnState); @@ -5335,14 +5306,14 @@ TkSetWMName( *---------------------------------------------------------------------- */ -Window +Tk_Window TkGetTransientMaster( TkWindow *winPtr) { if (winPtr->wmInfoPtr != NULL) { - return winPtr->wmInfoPtr->master; + return (Tk_Window)winPtr->wmInfoPtr->master; } - return None; + return NULL; } /* @@ -6579,7 +6550,7 @@ TkMacOSXApplyWindowAttributes( { WmInfo *wmPtr = winPtr->wmInfoPtr; ApplyWindowAttributeFlagChanges(winPtr, macWindow, 0, 0, 0, 1); - if (wmPtr->master != None || winPtr->atts.override_redirect) { + if (wmPtr->master != NULL || winPtr->atts.override_redirect) { ApplyMasterOverrideChanges(winPtr, macWindow); } } @@ -6716,7 +6687,7 @@ ApplyWindowAttributeFlagChanges( */ if ((winPtr->atts.override_redirect) || - (wmPtr->master != None) || + (wmPtr->master != NULL) || (winPtr->wmInfoPtr->macClass == kHelpWindowClass)) { b |= (NSWindowCollectionBehaviorCanJoinAllSpaces | NSWindowCollectionBehaviorFullScreenAuxiliary); @@ -6852,7 +6823,7 @@ ApplyMasterOverrideChanges( if (wmPtr->hints.initial_state == NormalState) { [macWindow orderFront:nil]; } - if (wmPtr->master != None) { + if (wmPtr->master != NULL) { wmPtr->flags |= WM_TOPMOST; } else { wmPtr->flags &= ~WM_TOPMOST; @@ -6868,13 +6839,12 @@ ApplyMasterOverrideChanges( wmPtr->flags &= ~WM_TOPMOST; } if (wmPtr->master != None) { - TkDisplay *dispPtr = TkGetDisplayList(); - TkWindow *masterWinPtr = (TkWindow *) - Tk_IdToWindow(dispPtr->display, wmPtr->master); + TkWindow *masterWinPtr = (TkWindow *)wmPtr->master; if (masterWinPtr && masterWinPtr->window != None && TkMacOSXHostToplevelExists(masterWinPtr)) { - NSWindow *masterMacWin = TkMacOSXDrawableWindow(masterWinPtr->window); - + NSWindow *masterMacWin = TkMacOSXDrawableWindow( + masterWinPtr->window); + /* * Try to add the transient window as a child window of the * master. A child NSWindow retains its relative position with @@ -6892,13 +6862,13 @@ ApplyMasterOverrideChanges( * If the transient is already a child of some other window, * remove it. */ - + parentWindow = [macWindow parentWindow]; if (parentWindow && parentWindow != masterMacWin) { [parentWindow removeChildWindow:macWindow]; } - /* + /* * To avoid cycles, if the master is a child of some other window, remove it. */ diff --git a/macosx/tkMacOSXWm.h b/macosx/tkMacOSXWm.h index a7ea92c..5f07fe6 100644 --- a/macosx/tkMacOSXWm.h +++ b/macosx/tkMacOSXWm.h @@ -65,7 +65,7 @@ typedef struct TkWmInfo { Tk_Uid titleUid; /* Title to display in window caption. If NULL, * use name of widget. */ char *iconName; /* Name to display in icon. */ - Window master; /* Master window for TRANSIENT_FOR property, or + Tk_Window master; /* Master window for TRANSIENT_FOR property, or * None. */ XWMHints hints; /* Various pieces of information for window * manager. */ @@ -73,10 +73,6 @@ typedef struct TkWmInfo { * (corresponds to hints.window_group). * Malloc-ed. Note: this field doesn't get * updated if leader is destroyed. */ - char *masterWindowName; /* Path name of window specified as master in - * "wm transient" command, or NULL. Malloc-ed. - * Note: this field doesn't get updated if - * masterWindowName is destroyed. */ Tk_Window icon; /* Window to use as icon for this window, or * NULL. */ Tk_Window iconFor; /* Window for which this window is icon, or -- cgit v0.12 From 827393fdd0d40c400d800dbf3b042b48c8f3a692 Mon Sep 17 00:00:00 2001 From: culler Date: Thu, 28 Feb 2019 15:29:23 +0000 Subject: Fix bugs in the list management code for the record of transient windows. --- macosx/tkMacOSXWm.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index ecb4456..599455d 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -3569,6 +3569,7 @@ WmTransientCmd( register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; WmInfo *wmPtr2; + Transient *transient; if ((objc != 3) && (objc != 4)) { Tcl_WrongNumArgs(interp, 2, objv, "window ?master?"); @@ -3625,14 +3626,19 @@ WmTransientCmd( } /* - * Add the transient to the master's list. + * Add the transient to the master's list, if it not already there. */ - - Transient *transient = ckalloc(sizeof(Transient)); - transient->winPtr = winPtr; - transient->flags = 0; - transient->nextPtr = wmPtr2->transientPtr; - wmPtr2->transientPtr = transient; + + for (transient = wmPtr2->transientPtr; + transient != NULL && transient->winPtr != winPtr; + transient = transient->nextPtr) {} + if (transient == NULL) { + transient = ckalloc(sizeof(Transient)); + transient->winPtr = winPtr; + transient->flags = 0; + transient->nextPtr = wmPtr2->transientPtr; + wmPtr2->transientPtr = transient; + } /* * If the master is withdrawn or iconic then withdraw the transient. @@ -3676,6 +3682,8 @@ RemoveTransient( { WmInfo *wmPtr = winPtr->wmInfoPtr, *wmPtr2; TkWindow *masterPtr; + Transient *T, *temp; + if (wmPtr == NULL || wmPtr->master == NULL) { return; } @@ -3685,18 +3693,23 @@ RemoveTransient( return; } wmPtr->master = NULL; - Transient *temp, *cursor = wmPtr2->transientPtr; - if (cursor->winPtr == winPtr) { - temp = cursor->nextPtr; - ckfree(cursor); - cursor = temp; - masterPtr->wmInfoPtr->transientPtr = cursor; - } - while (cursor != NULL) { - if (cursor->winPtr == winPtr) { - temp = cursor->nextPtr; - ckfree(cursor); - cursor = temp; + T = wmPtr2->transientPtr; + while (T != NULL) { + if (T->winPtr != winPtr) { + break; + } + temp = T->nextPtr; + ckfree(T); + T = temp; + } + wmPtr2->transientPtr = T; + while (T != NULL) { + if (T->nextPtr && T->nextPtr->winPtr == winPtr) { + temp = T->nextPtr; + T->nextPtr = temp->nextPtr; + ckfree(temp); + } else { + T = T->nextPtr; } } } -- cgit v0.12 From 403f01fa032b477c866cb88915f0604d9d9d0dac Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 1 Mar 2019 15:28:48 +0000 Subject: Make it be an error to create a transient/master cycle on Aqua. Other platforms will be handled in separate check-ins. --- doc/wm.n | 29 +++++++++++++++-------------- macosx/tkMacOSXWm.c | 25 +++++++++++-------------- tests/wm.test | 14 ++++++++++++-- 3 files changed, 38 insertions(+), 30 deletions(-) diff --git a/doc/wm.n b/doc/wm.n index e7aedf7..a137d06 100644 --- a/doc/wm.n +++ b/doc/wm.n @@ -710,20 +710,21 @@ specified then the command returns the current title for the .TP \fBwm transient \fIwindow\fR ?\fImaster\fR? . -If \fImaster\fR is specified, then the window manager is informed -that \fIwindow\fR is a transient window (e.g. pull-down menu) working -on behalf of \fImaster\fR (where \fImaster\fR is the -path name for a top-level window). If \fImaster\fR -is specified as an empty string then \fIwindow\fR is marked as not -being a transient window any more. Otherwise the command -returns the path name of \fIwindow\fR's current master, or an -empty string if \fIwindow\fR is not currently a transient window. -A transient window will mirror state changes in the master and -inherit the state of the master when initially mapped. It is an -error to attempt to make a window a transient of itself. -The window manager may also decorate a transient window differently, removing -some features normally present (e.g., minimize and maximize buttons) though -this is entirely at the discretion of the window manager. +If \fImaster\fR is specified, then the window manager is informed that +\fIwindow\fR is a transient window (e.g. pull-down menu) working on +behalf of \fImaster\fR (where \fImaster\fR is the path name for a +top-level window). If \fImaster\fR is specified as an empty string +then \fIwindow\fR is marked as not being a transient window any more. +Otherwise the command returns the path name of \fIwindow\fR's current +master, or an empty string if \fIwindow\fR is not currently a +transient window. A transient window will mirror state changes in the +master and inherit the state of the master when initially mapped. The +directed graph with an edge from each transient to its master must be +acyclic. In particular, it is an error to attempt to make a window a +transient of itself. The window manager may also decorate a transient +window differently, removing some features normally present (e.g., +minimize and maximize buttons) though this is entirely at the +discretion of the window manager. .TP \fBwm withdraw \fIwindow\fR . diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 599455d..a1fbbde 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -3568,6 +3568,7 @@ WmTransientCmd( { register WmInfo *wmPtr = winPtr->wmInfoPtr; Tk_Window master; + TkWindow *masterPtr, *w; WmInfo *wmPtr2; Transient *transient; @@ -3589,7 +3590,7 @@ WmTransientCmd( if (TkGetWindowFromObj(interp, tkwin, objv[3], &master) != TCL_OK) { return TCL_ERROR; } - TkWindow *masterPtr = (TkWindow*) master; + masterPtr = (TkWindow*) master; while (!Tk_TopWinHierarchy(masterPtr)) { /* @@ -3618,11 +3619,15 @@ WmTransientCmd( return TCL_ERROR; } - if (masterPtr == winPtr) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't make \"%s\" its own master", Tk_PathName(winPtr))); - Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); - return TCL_ERROR; + for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL; + w = (TkWindow *)w->wmInfoPtr->master) { + if (w == winPtr) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "setting \"%s\" as master creates a transient/master cycle", + Tk_PathName(masterPtr))); + Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); + return TCL_ERROR; + } } /* @@ -6881,14 +6886,6 @@ ApplyMasterOverrideChanges( [parentWindow removeChildWindow:macWindow]; } - /* - * To avoid cycles, if the master is a child of some - other window, remove it. - */ - parentWindow = [masterMacWin parentWindow]; - if (parentWindow) { - [parentWindow removeChildWindow:masterMacWin]; - } [masterMacWin addChildWindow:macWindow ordered:NSWindowAbove]; } diff --git a/tests/wm.test b/tests/wm.test index 7b81985..c2bc385 100644 --- a/tests/wm.test +++ b/tests/wm.test @@ -1640,14 +1640,24 @@ test wm-transient-1.7 {usage} -returnCodes error -body { wm transient .master .master } -cleanup { deleteWindows -} -result {can't make ".master" its own master} +} -result {setting ".master" as master creates a transient/master cycle} test wm-transient-1.8 {usage} -returnCodes error -body { + toplevel .t1 + toplevel .t2 + toplevel .t3 + wm transient .t2 .t1 + wm transient .t3 .t2 + wm transient .t1 .t3 +} -cleanup { + deleteWindows +} -result {setting ".t3" as master creates a transient/master cycle} +test wm-transient-1.9 {usage} -returnCodes error -body { toplevel .master frame .master.f wm transient .master .master.f } -cleanup { deleteWindows -} -result {can't make ".master" its own master} +} -result {setting ".master" as master creates a transient/master cycle} test wm-transient-2.1 {basic get/set of master} -setup { set results [list] -- cgit v0.12 From ec1cf983bd80cc43701c88134d9bd94131e6100f Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 1 Mar 2019 15:46:38 +0000 Subject: Make it be an error to create a transient/master cycle on unix. --- unix/tkUnixWm.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 8944ecc..9ed9082 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -3524,7 +3524,7 @@ WmTransientCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; - TkWindow *masterPtr = wmPtr->masterPtr; + TkWindow *masterPtr = wmPtr->masterPtr, *w; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { @@ -3593,12 +3593,18 @@ WmTransientCmd( return TCL_ERROR; } - if (masterPtr == winPtr) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't make \"%s\" its own master", Tk_PathName(winPtr))); - Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); - return TCL_ERROR; - } else if (masterPtr != wmPtr->masterPtr) { + for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL; + w = (TkWindow *)w->wmInfoPtr->masterPtr) { + if (w == winPtr) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "setting \"%s\" as master creates a transient/master cycle", + Tk_PathName(masterPtr))); + Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); + return TCL_ERROR; + } + } + + if (masterPtr != wmPtr->masterPtr) { /* * Remove old master map/unmap binding before setting the new * master. The event handler will ensure that transient states -- cgit v0.12 From 4acf3a1da92f5ef0bc2dbe3ac5fa457ae0ae2836 Mon Sep 17 00:00:00 2001 From: culler Date: Fri, 1 Mar 2019 16:04:19 +0000 Subject: Make it be an error to create a transient/master cycle on Windows. --- win/tkWinWm.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 97cf255..5bb23d1 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -5526,7 +5526,7 @@ WmTransientCmd( Tcl_Obj *const objv[]) /* Argument objects. */ { register WmInfo *wmPtr = winPtr->wmInfoPtr; - TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr; + TkWindow *masterPtr = wmPtr->masterPtr, **masterPtrPtr = &masterPtr, *w; WmInfo *wmPtr2; if ((objc != 3) && (objc != 4)) { @@ -5584,13 +5584,17 @@ WmTransientCmd( Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "ICON", NULL); return TCL_ERROR; } - - if (masterPtr == winPtr) { - Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "can't make \"%s\" its own master", Tk_PathName(winPtr))); - Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); - return TCL_ERROR; - } else if (masterPtr != wmPtr->masterPtr) { + for (w = masterPtr; w != NULL && w->wmInfoPtr != NULL; + w = (TkWindow *)w->wmInfoPtr->masterPtr) { + if (w == winPtr) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "setting \"%s\" as master creates a transient/master cycle", + Tk_PathName(masterPtr))); + Tcl_SetErrorCode(interp, "TK", "WM", "TRANSIENT", "SELF", NULL); + return TCL_ERROR; + } + } + if (masterPtr != wmPtr->masterPtr) { /* * Remove old master map/unmap binding before setting the new * master. The event handler will ensure that transient states -- cgit v0.12 From ffc8760419eff5493bbd2be5f8d8e585c1e8d95c Mon Sep 17 00:00:00 2001 From: culler Date: Sun, 3 Mar 2019 17:04:13 +0000 Subject: Increase the size of the ring buffer for Aqua, and modify bgerror so it doesn't try (and fail) to post a dialog inside [NSView drawRect]. --- generic/tkBind.c | 2 +- library/bgerror.tcl | 17 +++++++++----- macosx/tkMacOSXKeyEvent.c | 56 +++------------------------------------------ macosx/tkMacOSXMouseEvent.c | 51 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 60 deletions(-) diff --git a/generic/tkBind.c b/generic/tkBind.c index 70f10aa..e0971ba 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -84,7 +84,7 @@ typedef union { */ #ifndef TK_MAC_OSX - #define EVENT_BUFFER_SIZE 45 + #define EVENT_BUFFER_SIZE 90 #else #define EVENT_BUFFER_SIZE 30 #endif diff --git a/library/bgerror.tcl b/library/bgerror.tcl index b15387e..574ad8b 100644 --- a/library/bgerror.tcl +++ b/library/bgerror.tcl @@ -97,7 +97,7 @@ proc ::tk::dialog::error::ReturnInDetails w { # Arguments: # err - The error message. # -proc ::tk::dialog::error::bgerror err { +proc ::tk::dialog::error::bgerror {err {flag 1}} { global errorInfo variable button @@ -106,15 +106,20 @@ proc ::tk::dialog::error::bgerror err { set ret [catch {::tkerror $err} msg]; if {$ret != 1} {return -code $ret $msg} - # Ok the application's tkerror either failed or was not found - # we use the default dialog then : + # The application's tkerror either failed or was not found + # so we use the default dialog. But on Aqua we cannot display + # the dialog if the background error occurs in an idle task + # being processed inside of [NSView drawRect]. In that case + # we post the dialog as an after task instead. set windowingsystem [tk windowingsystem] if {$windowingsystem eq "aqua"} { - set ok [mc Ok] - } else { - set ok [mc OK] + if $flag { + after 500 [list bgerror "$err" 0] + return + } } + set ok [mc OK] # Truncate the message if it is too wide (>maxLine characters) or # too tall (>4 lines). Truncation occurs at the first point at # which one of those conditions is met. diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 3327f0a..543e7ab 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -24,9 +24,6 @@ */ #define NS_KEYLOG 0 - -static Tk_Window grabWinPtr = NULL; - /* Current grab window, NULL if no grab. */ static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */ static NSWindow *keyboardGrabNSWindow = nil; @@ -500,11 +497,12 @@ XGrabKeyboard( Time time) { keyboardGrabWinPtr = Tk_IdToWindow(display, grab_window); - if (keyboardGrabWinPtr && grabWinPtr) { + TkWindow *captureWinPtr = (TkWindow *)TkMacOSXGetCapture(); + if (keyboardGrabWinPtr && captureWinPtr) { NSWindow *w = TkMacOSXDrawableWindow(grab_window); MacDrawable *macWin = (MacDrawable *) grab_window; - if (w && macWin->toplevel->winPtr == (TkWindow*) grabWinPtr) { + if (w && macWin->toplevel->winPtr == (TkWindow*) captureWinPtr) { if (modalSession) { Tcl_Panic("XGrabKeyboard: already grabbed"); } @@ -551,26 +549,6 @@ XUngrabKeyboard( /* *---------------------------------------------------------------------- * - * TkMacOSXGetCapture -- - * - * Results: - * Returns the current grab window - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -Tk_Window -TkMacOSXGetCapture(void) -{ - return grabWinPtr; -} - -/* - *---------------------------------------------------------------------- - * * TkMacOSXGetModalSession -- * * Results: @@ -591,34 +569,6 @@ TkMacOSXGetModalSession(void) /* *---------------------------------------------------------------------- * - * TkpSetCapture -- - * - * This function captures the mouse so that all future events will be - * reported to this window, even if the mouse is outside the window. If - * the specified window is NULL, then the mouse is released. - * - * Results: - * None. - * - * Side effects: - * Sets the capture flag and captures the mouse. - * - *---------------------------------------------------------------------- - */ - -void -TkpSetCapture( - TkWindow *winPtr) /* Capture window, or NULL. */ -{ - while (winPtr && !Tk_IsTopLevel(winPtr)) { - winPtr = winPtr->parentPtr; - } - grabWinPtr = (Tk_Window) winPtr; -} - -/* - *---------------------------------------------------------------------- - * * Tk_SetCaretPos -- * * This enables correct placement of the XIM caret. This is called by diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 7b83679..2d5d152 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -24,6 +24,7 @@ typedef struct { Point global; Point local; } MouseEventData; +static Tk_Window captureWinPtr = NULL; /* Current capture window; may be NULL. */ static int GenerateButtonEvent(MouseEventData *medPtr); static unsigned int ButtonModifiers2State(UInt32 buttonState, @@ -581,6 +582,56 @@ TkpWarpPointer( } /* + *---------------------------------------------------------------------- + * + * TkpSetCapture -- + * + * This function captures the mouse so that all future events will be + * reported to this window, even if the mouse is outside the window. If + * the specified window is NULL, then the mouse is released. + * + * Results: + * None. + * + * Side effects: + * Sets the capture flag and captures the mouse. + * + *---------------------------------------------------------------------- + */ + +void +TkpSetCapture( + TkWindow *winPtr) /* Capture window, or NULL. */ +{ + while (winPtr && !Tk_IsTopLevel(winPtr)) { + winPtr = winPtr->parentPtr; + } + captureWinPtr = (Tk_Window) winPtr; +} + +/* + *---------------------------------------------------------------------- + * + * TkMacOSXGetCapture -- + * + * Results: + * Returns the current grab window + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +Tk_Window +TkMacOSXGetCapture(void) +{ + return captureWinPtr; +} + + + +/* * Local Variables: * mode: objc * c-basic-offset: 4 -- cgit v0.12