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 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 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 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 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