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 d2747a371058fa4128dbd7896fe040f0b3ee6be7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 20:53:24 +0000 Subject: Bring back more original "None" usages, and fix other warnings which gradually slipped in. Wherever possible, pragma's are used in MSVC to silence useless compiler warnings. --- generic/tk3d.c | 8 ++++---- generic/tk3d.h | 4 ++-- generic/tkBind.c | 2 +- generic/tkButton.h | 2 +- generic/tkCanvArc.c | 4 +++- generic/tkCanvBmap.c | 2 +- generic/tkCanvLine.c | 6 +++--- generic/tkCanvPoly.c | 6 +++--- generic/tkCanvText.c | 8 ++++---- generic/tkCanvas.h | 2 +- generic/tkColor.c | 6 +++--- generic/tkColor.h | 2 +- generic/tkConfig.c | 6 +++--- generic/tkCursor.c | 6 +++--- generic/tkEntry.c | 2 +- generic/tkEntry.h | 6 +++--- generic/tkEvent.c | 2 +- generic/tkImgBmap.c | 12 ++++++------ generic/tkMenu.h | 8 ++++---- generic/tkMenubutton.h | 2 +- generic/tkOldConfig.c | 2 +- generic/tkPlace.c | 2 +- generic/tkRectOval.c | 8 ++++---- generic/tkScale.h | 4 ++-- generic/tkScrollbar.h | 2 +- generic/tkText.h | 2 +- generic/tkTextDisp.c | 2 +- generic/ttk/ttkEntry.c | 4 ++-- generic/ttk/ttkLayout.c | 2 +- generic/ttk/ttkTreeview.c | 2 +- generic/ttk/ttkWidget.c | 2 +- unix/tkUnix3d.c | 4 ++-- unix/tkUnixMenubu.c | 12 ++++++------ win/stubs.c | 2 +- win/tkWin3d.c | 12 ++++++------ win/tkWinButton.c | 15 ++++++++------- win/tkWinDraw.c | 14 +++++++------- win/tkWinEmbed.c | 6 +++--- win/tkWinFont.c | 12 ++++++------ win/tkWinImage.c | 2 +- win/tkWinMenu.c | 4 ++-- win/tkWinPixmap.c | 2 +- win/tkWinPointer.c | 6 +++--- win/tkWinPort.h | 9 +++++++-- win/tkWinScrlbr.c | 2 +- win/tkWinWindow.c | 6 +++--- win/tkWinWm.c | 42 +++++++++++++++++++++--------------------- win/tkWinX.c | 18 +++++++++--------- win/ttkWinXPTheme.c | 2 +- xlib/X11/X.h | 12 +++++++++--- xlib/xgc.c | 22 +++++++++++----------- xlib/ximage.c | 2 +- 52 files changed, 174 insertions(+), 160 deletions(-) diff --git a/generic/tk3d.c b/generic/tk3d.c index eebe122..ddb48b3 100644 --- a/generic/tk3d.c +++ b/generic/tk3d.c @@ -237,9 +237,9 @@ Tk_Get3DBorder( borderPtr->darkColorPtr = NULL; borderPtr->lightColorPtr = NULL; borderPtr->shadow = None; - borderPtr->bgGC = 0; - borderPtr->darkGC = 0; - borderPtr->lightGC = 0; + borderPtr->bgGC = NULL; + borderPtr->darkGC = NULL; + borderPtr->lightGC = NULL; borderPtr->hashPtr = hashPtr; borderPtr->nextPtr = existingBorderPtr; Tcl_SetHashValue(hashPtr, borderPtr); @@ -392,7 +392,7 @@ Tk_3DBorderGC( * compilers happy. */ - return (GC) None; + return NULL; } /* diff --git a/generic/tk3d.h b/generic/tk3d.h index 5e0a0cf..30a35c5 100644 --- a/generic/tk3d.h +++ b/generic/tk3d.h @@ -60,10 +60,10 @@ typedef struct TkBorder { GC bgGC; /* Used (if necessary) to draw areas in the * background color. */ GC darkGC; /* Used to draw darker parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet.*/ GC lightGC; /* Used to draw lighter parts of the border. - * None means the shadow colors haven't been + * NULL means the shadow colors haven't been * allocated yet. */ Tcl_HashEntry *hashPtr; /* Entry in borderTable (needed in order to * delete structure). */ diff --git a/generic/tkBind.c b/generic/tkBind.c index c4f8226..98c491a 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -3870,7 +3870,7 @@ DoWarp( { TkDisplay *dispPtr = (TkDisplay *) clientData; - XWarpPointer(dispPtr->display, (Window) None, (Window) dispPtr->warpWindow, + XWarpPointer(dispPtr->display, None, (Window) dispPtr->warpWindow, 0, 0, 0, 0, (int) dispPtr->warpX, (int) dispPtr->warpY); XForceScreenSaver(dispPtr->display, ScreenSaverReset); dispPtr->flags &= ~TK_DISPLAY_IN_WARP; diff --git a/generic/tkButton.h b/generic/tkButton.h index 09aaee2..d669b02 100644 --- a/generic/tkButton.h +++ b/generic/tkButton.h @@ -235,7 +235,7 @@ typedef struct { * Miscellaneous information: */ - Tk_Cursor cursor; /* Value of -cursor option: if not None, + Tk_Cursor cursor; /* Value of -cursor option: if not NULL, * specifies current cursor for window. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c index 33367de..ae62147 100644 --- a/generic/tkCanvArc.c +++ b/generic/tkCanvArc.c @@ -526,7 +526,9 @@ ConfigureArc( } } - if ((arcPtr->style == ARC_STYLE) || (!color)) { + if (arcPtr->style == ARC_STYLE) { + newGC = NULL; + } else if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c index 5f97ef2..59e2494 100644 --- a/generic/tkCanvBmap.c +++ b/generic/tkCanvBmap.c @@ -376,7 +376,7 @@ ConfigureBitmap( } } - if (!bitmap) { + if (bitmap == None) { newGC = NULL; } else { gcValues.foreground = fgColor->pixel; diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index fea2103..5f67175 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -533,10 +533,10 @@ ConfigureLine( } else { newGC = arrowGC = NULL; } - if (linePtr->outline.gc) { + if (linePtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), linePtr->outline.gc); } - if (linePtr->arrowGC) { + if (linePtr->arrowGC != None) { Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC); } linePtr->outline.gc = newGC; @@ -2251,7 +2251,7 @@ LineToPostscript( * being created. */ { LineItem *linePtr = (LineItem *) itemPtr; - char buffer[64 + TCL_INTEGER_SPACE]; + char buffer[64 + 4*TCL_INTEGER_SPACE]; char *style; double width; diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c index 0810ab6..4ab4339 100644 --- a/generic/tkCanvPoly.c +++ b/generic/tkCanvPoly.c @@ -486,7 +486,7 @@ ConfigurePolygon( } else { newGC = NULL; } - if (polyPtr->outline.gc) { + if (polyPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), polyPtr->outline.gc); } polyPtr->outline.gc = newGC; @@ -509,12 +509,12 @@ ConfigurePolygon( } } - if (!color) { + if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; mask = GCForeground; - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c index 187ec40..6dd1c9f 100644 --- a/generic/tkCanvText.c +++ b/generic/tkCanvText.c @@ -446,7 +446,7 @@ ConfigureText( if (textPtr->tkfont != NULL) { gcValues.font = Tk_FontId(textPtr->tkfont); mask = GCFont; - if (color) { + if (color != NULL) { gcValues.foreground = color->pixel; mask |= GCForeground; if (stipple != None) { @@ -457,7 +457,7 @@ ConfigureText( newGC = Tk_GetGC(tkwin, mask, &gcValues); } mask &= ~(GCTile|GCFillStyle|GCStipple); - if (stipple) { + if (stipple != None) { gcValues.stipple = stipple; gcValues.fill_style = FillStippled; mask |= GCStipple|GCFillStyle; @@ -467,7 +467,7 @@ ConfigureText( } newSelGC = Tk_GetGC(tkwin, mask|GCForeground, &gcValues); } - if (textPtr->gc) { + if (textPtr->gc != None) { Tk_FreeGC(Tk_Display(tkwin), textPtr->gc); } textPtr->gc = newGC; @@ -488,7 +488,7 @@ ConfigureText( } else { newGC = NULL; } - if (textPtr->cursorOffGC) { + if (textPtr->cursorOffGC != None) { Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC); } textPtr->cursorOffGC = newGC; diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index d009cfa..5e784e3 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -206,7 +206,7 @@ typedef struct TkCanvas { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkColor.c b/generic/tkColor.c index bde08cf..c2b7732 100644 --- a/generic/tkColor.c +++ b/generic/tkColor.c @@ -242,7 +242,7 @@ Tk_GetColor( */ tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = 0; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = Tk_Colormap(tkwin); tkColPtr->visual = Tk_Visual(tkwin); @@ -323,7 +323,7 @@ Tk_GetColorByValue( tkColPtr = TkpGetColorByValue(tkwin, colorPtr); tkColPtr->magic = COLOR_MAGIC; - tkColPtr->gc = 0; + tkColPtr->gc = NULL; tkColPtr->screen = Tk_Screen(tkwin); tkColPtr->colormap = valueKey.colormap; tkColPtr->visual = Tk_Visual(tkwin); @@ -471,7 +471,7 @@ Tk_FreeColor( if (tkColPtr->gc != None) { XFreeGC(DisplayOfScreen(screen), tkColPtr->gc); - tkColPtr->gc = 0; + tkColPtr->gc = NULL; } TkpFreeColor(tkColPtr); diff --git a/generic/tkColor.h b/generic/tkColor.h index d4679cf..12c6662 100644 --- a/generic/tkColor.h +++ b/generic/tkColor.h @@ -37,7 +37,7 @@ typedef struct TkColor { * COLOR_MAGIC. */ GC gc; /* Simple gc with this color as foreground * color and all other fields defaulted. May - * be None. */ + * be NULL. */ Screen *screen; /* Screen where this color is valid. Used to * delete it, and to find its display. */ Colormap colormap; /* Colormap from which this entry was diff --git a/generic/tkConfig.c b/generic/tkConfig.c index ace7135..1a49026 100644 --- a/generic/tkConfig.c +++ b/generic/tkConfig.c @@ -854,7 +854,7 @@ DoObjConfig( Tk_Cursor newCursor; if (nullOK && ObjectIsEmpty(valuePtr)) { - newCursor = 0; + newCursor = NULL; valuePtr = NULL; } else { newCursor = Tk_AllocCursorFromObj(interp, tkwin, valuePtr); @@ -916,7 +916,7 @@ DoObjConfig( if (nullOK && ObjectIsEmpty(valuePtr)) { valuePtr = NULL; - newWin = 0; + newWin = NULL; } else { if (TkGetWindowFromObj(interp, tkwin, valuePtr, &newWin) != TCL_OK) { @@ -1702,7 +1702,7 @@ FreeResources( if (internalFormExists) { if (*((Tk_Cursor *) internalPtr) != None) { Tk_FreeCursor(Tk_Display(tkwin), *((Tk_Cursor *) internalPtr)); - *((Tk_Cursor *) internalPtr) = 0; + *((Tk_Cursor *) internalPtr) = NULL; } } else if (objPtr != NULL) { Tk_FreeCursorFromObj(tkwin, objPtr); diff --git a/generic/tkCursor.c b/generic/tkCursor.c index a1c2723..e5b5df5 100644 --- a/generic/tkCursor.c +++ b/generic/tkCursor.c @@ -149,7 +149,7 @@ Tk_AllocCursorFromObj( cursorPtr = TkcGetCursor(interp, tkwin, Tcl_GetString(objPtr)); objPtr->internalRep.twoPtrValue.ptr1 = (void *) cursorPtr; if (cursorPtr == NULL) { - return 0; + return NULL; } cursorPtr->objRefCount++; return cursorPtr->cursor; @@ -188,7 +188,7 @@ Tk_GetCursor( { TkCursor *cursorPtr = TkcGetCursor(interp, tkwin, string); if (cursorPtr == NULL) { - return 0; + return NULL; } return cursorPtr->cursor; } @@ -382,7 +382,7 @@ Tk_GetCursorFromData( error: Tcl_DeleteHashEntry(dataHashPtr); - return 0; + return NULL; } /* diff --git a/generic/tkEntry.c b/generic/tkEntry.c index f5b4339..7b95fc9 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -2453,7 +2453,7 @@ EntryEventProc( } else { cursor = NULL; } - if (cursor) { + if (cursor != None) { Tk_DefineCursor(entryPtr->tkwin, cursor); } else { Tk_UndefineCursor(entryPtr->tkwin); diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 7f8aa1f..da06408 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -87,7 +87,7 @@ typedef struct { * in readonly state, plus used for * background. */ int borderWidth; /* Width of 3-D border around window. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ int exportSelection; /* Non-zero means tie internal entry selection * to X selection. */ Tk_Font tkfont; /* Information about text font, or NULL. */ @@ -197,7 +197,7 @@ typedef struct { Tk_3DBorder activeBorder; /* Used for drawing border around active * buttons. */ Tk_3DBorder buttonBorder; /* Used for drawing border around buttons. */ - Tk_Cursor bCursor; /* cursor for buttons, or None. */ + Tk_Cursor bCursor; /* cursor for buttons, or NULL. */ int bdRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ int buRelief; /* 3-D effect: TK_RELIEF_RAISED, etc. */ char *command; /* Command to invoke for spin buttons. NULL @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index 9b001e1..9758dbe 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -1436,7 +1436,7 @@ TkEventDeadWindow( ipPtr->nextHandler = NULL; } if (ipPtr->winPtr == winPtr) { - ipPtr->winPtr = 0; + ipPtr->winPtr = NULL; } } ckfree((char *) handlerPtr); diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c index fab6afb..b37e7d5 100644 --- a/generic/tkImgBmap.c +++ b/generic/tkImgBmap.c @@ -400,18 +400,18 @@ ImgBmapConfigureInstance( (unsigned) masterPtr->height); } - if (oldMask) { + if (oldMask != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldMask); } - if (oldBitmap) { + if (oldBitmap != None) { Tk_FreePixmap(Tk_Display(instancePtr->tkwin), oldBitmap); } - if (masterPtr->data) { + if (masterPtr->data != NULL) { gcValues.foreground = instancePtr->fg->pixel; gcValues.graphics_exposures = False; mask = GCForeground|GCGraphicsExposures; - if (instancePtr->bg) { + if (instancePtr->bg != NULL) { gcValues.background = instancePtr->bg->pixel; mask |= GCBackground; if (instancePtr->mask != None) { @@ -426,7 +426,7 @@ ImgBmapConfigureInstance( } else { gc = NULL; } - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = gc; @@ -438,7 +438,7 @@ ImgBmapConfigureInstance( * it clear that this instance cannot be displayed. Then report the error. */ - if (instancePtr->gc) { + if (instancePtr->gc != None) { Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc); } instancePtr->gc = NULL; diff --git a/generic/tkMenu.h b/generic/tkMenu.h index e8470ca..b1536df 100644 --- a/generic/tkMenu.h +++ b/generic/tkMenu.h @@ -80,8 +80,8 @@ typedef struct TkMenuEntry { * of character to underline (<0 means don't * underline anything). */ Tcl_Obj *underlinePtr; /* Index of character to underline. */ - Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or None. - * If not None then label is ignored. */ + Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL. + * If not NULL then label is ignored. */ Tcl_Obj *imagePtr; /* Name of image to display, or NULL. If not * NULL, bitmap, text, and textVarName are * ignored. */ @@ -180,7 +180,7 @@ typedef struct TkMenuEntry { * NULL means use overall disabledGC from menu * structure. See comments for disabledFg in * menu structure for more information. */ - GC indicatorGC; /* For drawing indicators. None means use GC + GC indicatorGC; /* For drawing indicators. NULL means use GC * from menu. */ /* @@ -347,7 +347,7 @@ typedef struct TkMenu { Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ - Tcl_Obj *cursorPtr; /* Current cursor for window, or None. */ + Tcl_Obj *cursorPtr; /* Current cursor for window, or NULL. */ Tcl_Obj *postCommandPtr; /* Used to detect cycles in cascade hierarchy * trees when preprocessing postcommands on * some platforms. See PostMenu for more diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h index 41af675..f190c81 100644 --- a/generic/tkMenubutton.h +++ b/generic/tkMenubutton.h @@ -175,7 +175,7 @@ typedef struct { * "left" and "right" will pop the menu left * or right, and the active item will be next * to the button. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c index cf5612b..8f4c234 100644 --- a/generic/tkOldConfig.c +++ b/generic/tkOldConfig.c @@ -476,7 +476,7 @@ DoConfig( Tk_Cursor newCursor, oldCursor; if (nullValue) { - newCursor = 0; + newCursor = NULL; } else { uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value); newCursor = Tk_GetCursor(interp, tkwin, uid); diff --git a/generic/tkPlace.c b/generic/tkPlace.c index c435b12..19af02c 100644 --- a/generic/tkPlace.c +++ b/generic/tkPlace.c @@ -397,7 +397,7 @@ CreateSlave( slavePtr = (Slave *) ckalloc(sizeof(Slave)); memset(slavePtr, 0, sizeof(Slave)); slavePtr->tkwin = tkwin; - slavePtr->inTkwin = 0; + slavePtr->inTkwin = NULL; slavePtr->anchor = TK_ANCHOR_NW; slavePtr->borderMode = BM_INSIDE; slavePtr->optionTable = table; diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c index 53ebe61..0e73dd3 100644 --- a/generic/tkRectOval.c +++ b/generic/tkRectOval.c @@ -475,7 +475,7 @@ ConfigureRectOval( } else { newGC = NULL; } - if (rectOvalPtr->outline.gc) { + if (rectOvalPtr->outline.gc != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outline.gc); } rectOvalPtr->outline.gc = newGC; @@ -506,7 +506,7 @@ ConfigureRectOval( } } - if (!color) { + if (color == NULL) { newGC = NULL; } else { gcValues.foreground = color->pixel; @@ -522,13 +522,13 @@ ConfigureRectOval( * Mac OS X CG drawing needs access to the outline linewidth * even for fills (as linewidth controls antialiasing). */ - gcValues.line_width = rectOvalPtr->outline.gc ? + gcValues.line_width = rectOvalPtr->outline.gc != None ? rectOvalPtr->outline.gc->line_width : 0; mask |= GCLineWidth; #endif newGC = Tk_GetGC(tkwin, mask, &gcValues); } - if (rectOvalPtr->fillGC) { + if (rectOvalPtr->fillGC != None) { Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC); } rectOvalPtr->fillGC = newGC; diff --git a/generic/tkScale.h b/generic/tkScale.h index a2c5f2b..079e02c 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[16]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ @@ -156,7 +156,7 @@ typedef struct TkScale { */ int fontHeight; /* Height of scale font. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ Tcl_Obj *takeFocusPtr; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. May be NULL. */ diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h index 126d590..fa0426f 100644 --- a/generic/tkScrollbar.h +++ b/generic/tkScrollbar.h @@ -119,7 +119,7 @@ typedef struct TkScrollbar { * Miscellaneous information: */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ char *takeFocus; /* Value of -takefocus option; not used in the * C code, but used by keyboard traversal * scripts. Malloc'ed, but may be NULL. */ diff --git a/generic/tkText.h b/generic/tkText.h index 6f5f153..464bed5 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -654,7 +654,7 @@ typedef struct TkText { /* Color for drawing traversal highlight area * when highlight is off. */ XColor *highlightColorPtr; /* Color for drawing traversal highlight. */ - Tk_Cursor cursor; /* Current cursor for window, or None. */ + Tk_Cursor cursor; /* Current cursor for window, or NULL. */ XColor *fgColor; /* Default foreground color for text. */ Tk_Font tkfont; /* Default font for displaying text. */ int charWidth; /* Width of average character in default diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 904fa1a..73abffb 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -4335,7 +4335,7 @@ DisplayText( dlPtr->spaceAbove, dlPtr->height-dlPtr->spaceAbove-dlPtr->spaceBelow, dlPtr->baseline - dlPtr->spaceAbove, NULL, - (Drawable) None, dlPtr->y + dlPtr->spaceAbove); + None, dlPtr->y + dlPtr->spaceAbove); } } diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index ae43ae6..61bf31b 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -332,7 +332,7 @@ EntryFetchSelection( ClientData clientData, int offset, char *buffer, int maxBytes) { Entry *entryPtr = (Entry *) clientData; - size_t byteCount; + int byteCount; const char *string; const char *selStart, *selEnd; @@ -345,7 +345,7 @@ EntryFetchSelection( selEnd = Tcl_UtfAtIndex(selStart, entryPtr->entry.selectLast - entryPtr->entry.selectFirst); byteCount = selEnd - selStart - offset; - if (byteCount > (size_t)maxBytes) { + if (byteCount > maxBytes) { /* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */ byteCount = maxBytes; } diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index 58c99eb..04dd86f 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -7,7 +7,7 @@ */ #include -#include +#include "tkInt.h" #include "ttkThemeInt.h" #define MAX(a,b) (a > b ? a : b) diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index f0a3003..473d1e6 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -6,7 +6,7 @@ #include #include -#include +#include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index d5e0484..557ca8f 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -5,7 +5,7 @@ */ #include -#include +#include "tkInt.h" #include "ttkTheme.h" #include "ttkWidget.h" diff --git a/unix/tkUnix3d.c b/unix/tkUnix3d.c index 14f5827..417866b 100644 --- a/unix/tkUnix3d.c +++ b/unix/tkUnix3d.c @@ -47,7 +47,7 @@ TkBorder * TkpGetBorder(void) { UnixBorder *borderPtr = (UnixBorder *) ckalloc(sizeof(UnixBorder)); - borderPtr->solidGC = NULL; + borderPtr->solidGC = None; return (TkBorder *) borderPtr; } @@ -215,7 +215,7 @@ Tk_3DHorizontalBevel( Display *display = Tk_Display(tkwin); int bottom, halfway, x1, x2, x1Delta, x2Delta; UnixBorder *unixBorderPtr = (UnixBorder *) borderPtr; - GC topGC = NULL, bottomGC = NULL; + GC topGC = None, bottomGC = None; /* Initializations needed only to prevent * compiler warnings. */ diff --git a/unix/tkUnixMenubu.c b/unix/tkUnixMenubu.c index 95bee0a..48d3fb9 100644 --- a/unix/tkUnixMenubu.c +++ b/unix/tkUnixMenubu.c @@ -103,10 +103,10 @@ TkpDisplayMenuButton( border = mbPtr->normalBorder; } - if (mbPtr->image) { + if (mbPtr->image != None) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } @@ -194,7 +194,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { XSetClipOrigin(mbPtr->display, gc, imageXOffset, imageYOffset); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -214,7 +214,7 @@ TkpDisplayMenuButton( if (mbPtr->image != NULL) { Tk_RedrawImage(mbPtr->image, 0, 0, width, height, pixmap, imageXOffset, imageYOffset); - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { XSetClipOrigin(mbPtr->display, gc, x, y); XCopyPlane(mbPtr->display, mbPtr->bitmap, pixmap, gc, 0, 0, (unsigned) width, (unsigned) height, @@ -369,10 +369,10 @@ TkpComputeMenuButtonGeometry( txtHeight = 0; avgWidth = 0; - if (mbPtr->image) { + if (mbPtr->image != None) { Tk_SizeOfImage(mbPtr->image, &width, &height); haveImage = 1; - } else if (mbPtr->bitmap) { + } else if (mbPtr->bitmap != None) { Tk_SizeOfBitmap(mbPtr->display, mbPtr->bitmap, &width, &height); haveImage = 1; } diff --git a/win/stubs.c b/win/stubs.c index 7e791b5..4564639 100644 --- a/win/stubs.c +++ b/win/stubs.c @@ -397,7 +397,7 @@ XGetWindowProperty( unsigned long *bytes_after_return, unsigned char **prop_return) { - *actual_type_return = 0; + *actual_type_return = None; *actual_format_return = 0; *nitems_return = 0; *bytes_after_return = 0; diff --git a/win/tkWin3d.c b/win/tkWin3d.c index aa026e8..df6aa95 100644 --- a/win/tkWin3d.c +++ b/win/tkWin3d.c @@ -127,7 +127,7 @@ Tk_3DVerticalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int half; - if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -222,7 +222,7 @@ Tk_3DHorizontalBevel( HDC dc = TkWinGetDrawableDC(display, drawable, &state); int topColor, bottomColor; - if (!borderPtr->lightGC && (relief != TK_RELIEF_FLAT)) { + if ((borderPtr->lightGC == None) && (relief != TK_RELIEF_FLAT)) { TkpGetShadows(borderPtr, tkwin); } @@ -339,7 +339,7 @@ TkpGetShadows( int r, g, b; XGCValues gcValues; - if (borderPtr->lightGC) { + if (borderPtr->lightGC != None) { return; } @@ -465,10 +465,10 @@ TkpGetShadows( return; } - if (!borderPtr->shadow) { + if (borderPtr->shadow == None) { borderPtr->shadow = Tk_GetBitmap((Tcl_Interp *) NULL, tkwin, Tk_GetUid("gray50")); - if (!borderPtr->shadow) { + if (borderPtr->shadow == None) { Tcl_Panic("TkpGetShadows couldn't allocate bitmap for border"); } } @@ -540,7 +540,7 @@ TkWinGetBorderPixels( { WinBorder *borderPtr = (WinBorder *) border; - if (!borderPtr->info.lightGC) { + if (borderPtr->info.lightGC == None) { TkpGetShadows(&borderPtr->info, tkwin); } switch (which) { diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 0a11a20..c36932d 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -127,7 +127,7 @@ InitBoxes(void) HRSRC hrsrc; HGLOBAL hblk; LPBITMAPINFOHEADER newBitmap; - DWORD size; + size_t size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -146,8 +146,9 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { - size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + size = tsdPtr->boxesPtr->biSize + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount) + + tsdPtr->boxesPtr->biSizeImage; newBitmap = (LPBITMAPINFOHEADER) ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; @@ -156,7 +157,7 @@ InitBoxes(void) tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) - + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount); } else { tsdPtr->boxesPtr = NULL; } @@ -433,10 +434,10 @@ TkpDisplayButton( * Display image or bitmap or text for button. */ - if (butPtr->image) { + if (butPtr->image != None) { Tk_SizeOfImage(butPtr->image, &width, &height); haveImage = 1; - } else if (butPtr->bitmap) { + } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height); haveImage = 1; } @@ -839,7 +840,7 @@ TkpComputeButtonGeometry( if (butPtr->image != NULL) { Tk_SizeOfImage(butPtr->image, &imgWidth, &imgHeight); haveImage = 1; - } else if (butPtr->bitmap) { + } else if (butPtr->bitmap != None) { Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &imgWidth, &imgHeight); haveImage = 1; diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index e94c893..1897bc8 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -631,7 +631,7 @@ XFillRectangles( TkWinDCState state; HBRUSH brush, oldBrush; - if (!d) { + if (d == None) { return BadDrawable; } @@ -641,7 +641,7 @@ XFillRectangles( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH stipple; HBITMAP oldBitmap, bitmap; @@ -756,7 +756,7 @@ RenderObject( if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HDC dcMem; @@ -882,7 +882,7 @@ XDrawLines( TkWinDCState state; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -927,7 +927,7 @@ XFillPolygon( TkWinDCState state; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -969,7 +969,7 @@ XDrawRectangle( HBRUSH oldBrush; HDC dc; - if (!d) { + if (d == None) { return BadDrawable; } @@ -1085,7 +1085,7 @@ DrawOrFillArc( int xstart, ystart, xend, yend; double radian_start, radian_end, xr, yr; - if (!d) { + if (d == None) { return BadDrawable; } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index 539349f..1b0d2cf 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -242,7 +242,7 @@ TkpUseWindow( */ /* - if (winPtr->window) { + if (winPtr->window != None) { Tcl_AppendResult(interp, "can't modify container after widget is created", NULL); return TCL_ERROR; @@ -298,9 +298,9 @@ TkpUseWindow( * order to avoid bug 1096074 in future. */ - char msg[260]; + char msg[256]; - sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + sprintf(msg, "Unable to get information of window \"%.79s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC); diff --git a/win/tkWinFont.c b/win/tkWinFont.c index b60a918..1292772 100644 --- a/win/tkWinFont.c +++ b/win/tkWinFont.c @@ -519,7 +519,7 @@ TkpGetFontFromAttributes( tkwin = (Tk_Window) ((TkWindow *) tkwin)->mainPtr->winPtr; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); /* @@ -631,7 +631,7 @@ TkpGetFontFamilies( Window window; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); /* @@ -1095,7 +1095,7 @@ Tk_DrawChars( fontPtr = (WinFont *) gc->font; display->request++; - if (!drawable) { + if (drawable == None) { return; } @@ -1103,14 +1103,14 @@ Tk_DrawChars( SetROP2(dc, tkpWinRopModes[gc->function]); - if (gc->clip_mask && + if ((gc->clip_mask != None) && ((TkpClipMask*)gc->clip_mask)->type == TKP_CLIP_REGION) { SelectClipRgn(dc, (HRGN)((TkpClipMask*)gc->clip_mask)->value.region); } if ((gc->fill_style == FillStippled || gc->fill_style == FillOpaqueStippled) - && gc->stipple) { + && gc->stipple != None) { TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; HBRUSH oldBrush, stipple; HBITMAP oldBitmap, bitmap; @@ -1395,7 +1395,7 @@ InitFont( char buf[LF_FACESIZE * sizeof(WCHAR)]; window = Tk_WindowId(tkwin); - hwnd = window ? TkWinGetHWND(window) : NULL; + hwnd = (window == None) ? NULL : TkWinGetHWND(window); hdc = GetDC(hwnd); oldFont = SelectObject(hdc, hFont); diff --git a/win/tkWinImage.c b/win/tkWinImage.c index 8e6ef38..07aa1d3 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -348,7 +348,7 @@ XGetImageZPixmap( size = sizeof(BITMAPINFO); if (depth <= 8) { - size += sizeof(unsigned short) * (1 << depth); + size += sizeof(unsigned short) << depth; } bmInfo = (BITMAPINFO *) ckalloc((unsigned)size); diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index 6240ceb..9a35266 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -2345,7 +2345,7 @@ DrawMenuEntryLabel( XFillRectangle(menuPtr->display, d, menuPtr->disabledGC, x, y, (unsigned) width, (unsigned) height); } else if ((mePtr->image != NULL) - && menuPtr->disabledImageGC) { + && (menuPtr->disabledImageGC != None)) { XFillRectangle(menuPtr->display, d, menuPtr->disabledImageGC, leftEdge + imageXOffset, (int) (y + (mePtr->height - imageHeight)/2 + imageYOffset), @@ -2990,7 +2990,7 @@ MenuSelectEvent( Tk_MakeWindowExist(menuPtr->tkwin); event.event = Tk_WindowId(menuPtr->tkwin); event.root = XRootWindow(menuPtr->display, 0); - event.subwindow = 0; + event.subwindow = None; event.time = TkpGetMS(); root.msgpos = GetMessagePos(); diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index 60e218d..51f0f59 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -115,7 +115,7 @@ Tk_GetPixmap( if (newTwdPtr->bitmap.handle == NULL) { ckfree((char *) newTwdPtr); - return 0; + return None; } return (Pixmap) newTwdPtr; diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index d5706ac..dcddb8f 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -387,7 +387,7 @@ XGetInputFocus( { Tk_Window tkwin = Tk_HWNDToWindow(GetFocus()); - *focus_return = tkwin ? Tk_WindowId(tkwin) : 0; + *focus_return = tkwin ? Tk_WindowId(tkwin) : None; *revert_to_return = RevertToParent; display->request++; return Success; @@ -418,7 +418,7 @@ XSetInputFocus( Time time) { display->request++; - if (focus) { + if (focus != None) { SetFocus(Tk_GetHWND(focus)); } return Success; @@ -465,7 +465,7 @@ TkpChangeFocus( } } - if (!winPtr->window) { + if (winPtr->window == None) { Tcl_Panic("ChangeXFocus got null X window"); } diff --git a/win/tkWinPort.h b/win/tkWinPort.h index aec5a66..2925dae 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -83,6 +83,11 @@ * See ticket [916c1095438eae56]: GetVersionExW triggers warnings */ #if defined(_MSC_VER) +# pragma warning(disable:4047) +# pragma warning(disable:4267) +# pragma warning(disable:4244) +# pragma warning(disable:4311) +# pragma warning(disable:4312) # pragma warning(disable:4996) #endif @@ -118,7 +123,7 @@ */ #define TkpDefineNativeBitmaps() -#define TkpCreateNativeBitmap(display, source) 0 -#define TkpGetNativeAppBitmap(display, name, w, h) 0 +#define TkpCreateNativeBitmap(display, source) None +#define TkpGetNativeAppBitmap(display, name, w, h) None #endif /* _WINPORT */ diff --git a/win/tkWinScrlbr.c b/win/tkWinScrlbr.c index f30a957..fc9685d 100644 --- a/win/tkWinScrlbr.c +++ b/win/tkWinScrlbr.c @@ -238,7 +238,7 @@ CreateProc( for (winPtr = ((TkWindow*)tkwin)->nextPtr; winPtr != NULL; winPtr = winPtr->nextPtr) { - if ((winPtr->window) && !(winPtr->flags & TK_TOP_HIERARCHY)) { + if ((winPtr->window != None) && !(winPtr->flags & TK_TOP_HIERARCHY)) { TkWinSetWindowPos(scrollPtr->hwnd, Tk_GetHWND(winPtr->window), Below); break; diff --git a/win/tkWinWindow.c b/win/tkWinWindow.c index 0675bc6..3dfc078 100644 --- a/win/tkWinWindow.c +++ b/win/tkWinWindow.c @@ -228,7 +228,7 @@ TkpScanWindowId( if (tkwin) { *idPtr = Tk_WindowId(tkwin); } else { - *idPtr = 0; + *idPtr = None; } return TCL_OK; } @@ -259,7 +259,7 @@ TkpMakeWindow( int style; HWND hwnd; - if (parent) { + if (parent != None) { parentWin = Tk_GetHWND(parent); style = WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; } else { @@ -657,7 +657,7 @@ XConfigureWindow( if (valueMask & CWStackMode) { HWND sibling; - if ((valueMask & CWSibling) && values->sibling) { + if ((valueMask & CWSibling) && (values->sibling != None)) { sibling = Tk_GetHWND(values->sibling); } else { sibling = NULL; diff --git a/win/tkWinWm.c b/win/tkWinWm.c index 8e6683f..9d706fa 100644 --- a/win/tkWinWm.c +++ b/win/tkWinWm.c @@ -1035,7 +1035,7 @@ WinSetIcon( "\" isn't a top-level window", NULL); return TCL_ERROR; } - if (!Tk_WindowId(tkw)) { + if (Tk_WindowId(tkw) == None) { Tk_MakeWindowExist(tkw); } @@ -1198,7 +1198,7 @@ TkWinGetIcon( } } - if (!Tk_WindowId(tkwin)) { + if (Tk_WindowId(tkwin) == None) { Tk_MakeWindowExist(tkwin); } @@ -1977,11 +1977,11 @@ TkWmNewWindow( wmPtr->hints.flags = InputHint | StateHint; wmPtr->hints.input = True; wmPtr->hints.initial_state = NormalState; - wmPtr->hints.icon_pixmap = 0; - wmPtr->hints.icon_window = 0; + wmPtr->hints.icon_pixmap = None; + wmPtr->hints.icon_window = None; wmPtr->hints.icon_x = wmPtr->hints.icon_y = 0; - wmPtr->hints.icon_mask = 0; - wmPtr->hints.window_group = 0; + wmPtr->hints.icon_mask = None; + wmPtr->hints.window_group = None; /* * Default the maximum dimensions to the size of the display. @@ -2062,7 +2062,7 @@ UpdateWrapper( ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); - if (!winPtr->window) { + if (winPtr->window == None) { /* * Ensure existence of the window to update the wrapper for. */ @@ -2683,7 +2683,7 @@ TkWmDeadWindow( VisibilityChangeMask|StructureNotifyMask, WmWaitVisibilityOrMapProc, (ClientData) wmPtr2->winPtr); wmPtr2->masterPtr = NULL; - if (wmPtr2->wrapper + if ((wmPtr2->wrapper != None) && !(wmPtr2->flags & (WM_NEVER_MAPPED))) { UpdateWrapper(wmPtr2->winPtr); } @@ -3474,7 +3474,7 @@ WmColormapwindowsCmd( if (winPtr2 == winPtr) { gotToplevel = 1; } - if (!winPtr2->window) { + if (winPtr2->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr2); } cmapList[i] = winPtr2; @@ -3750,7 +3750,7 @@ WmFrameCmd( Tcl_WrongNumArgs(interp, 2, objv, "window"); return TCL_ERROR; } - if (!Tk_WindowId((Tk_Window) winPtr)) { + if (Tk_WindowId((Tk_Window) winPtr) == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } hwnd = wmPtr->wrapper; @@ -4044,9 +4044,9 @@ WmIconbitmapCmd( string = Tcl_GetString(objv[objc-1]); if (*string == '\0') { - if (wmPtr->hints.icon_pixmap) { + if (wmPtr->hints.icon_pixmap != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_pixmap); - wmPtr->hints.icon_pixmap = 0; + wmPtr->hints.icon_pixmap = None; } wmPtr->hints.flags &= ~IconPixmapHint; if (WinSetIcon(interp, NULL, (Tk_Window) useWinPtr) != TCL_OK) { @@ -4098,7 +4098,7 @@ WmIconbitmapCmd( Pixmap pixmap; Tcl_ResetResult(interp); pixmap = Tk_GetBitmap(interp, (Tk_Window) winPtr, string); - if (!pixmap) { + if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_pixmap = pixmap; @@ -4217,13 +4217,13 @@ WmIconmaskCmd( } argv3 = Tcl_GetString(objv[3]); if (*argv3 == '\0') { - if (wmPtr->hints.icon_mask) { + if (wmPtr->hints.icon_mask != None) { Tk_FreeBitmap(winPtr->display, wmPtr->hints.icon_mask); } wmPtr->hints.flags &= ~IconMaskHint; } else { pixmap = Tk_GetBitmap(interp, tkwin, argv3); - if (!pixmap) { + if (pixmap == None) { return TCL_ERROR; } wmPtr->hints.icon_mask = pixmap; @@ -6388,7 +6388,7 @@ Tk_GetRootCoords( * If the window is mapped, let Windows figure out the translation. */ - if (winPtr->window) { + if (winPtr->window != None) { HWND hwnd = Tk_GetHWND(winPtr->window); POINT point; @@ -6816,7 +6816,7 @@ TkWmRestackToplevel( * (mapping it may give it a reparent window). */ - if (!winPtr->window) { + if (winPtr->window == None) { Tk_MakeWindowExist((Tk_Window) winPtr); } if (winPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6826,7 +6826,7 @@ TkWmRestackToplevel( ? winPtr->wmInfoPtr->wrapper : Tk_GetHWND(winPtr->window); if (otherPtr != NULL) { - if (!otherPtr->window) { + if (otherPtr->window == None) { Tk_MakeWindowExist((Tk_Window) otherPtr); } if (otherPtr->wmInfoPtr->flags & WM_NEVER_MAPPED) { @@ -6877,7 +6877,7 @@ TkWmAddToColormapWindows( TkWindow **oldPtr, **newPtr; int count, i; - if (!winPtr->window) { + if (winPtr->window == None) { return; } @@ -7312,7 +7312,7 @@ GenerateConfigureNotify( event.xconfigure.y = winPtr->changes.y; event.xconfigure.width = winPtr->changes.width; event.xconfigure.height = winPtr->changes.height; - event.xconfigure.above = 0; + event.xconfigure.above = None; Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL); } @@ -8586,7 +8586,7 @@ TkpWinToplevelDetachWindow( SendMessage(wmPtr->wrapper, TK_DETACHWINDOW, 0, 0); winPtr->flags &= ~TK_EMBEDDED; winPtr->privatePtr = NULL; - wmPtr->wrapper = 0; + wmPtr->wrapper = NULL; if (state >= 0 && state <= 3) { wmPtr->hints.initial_state = state; } diff --git a/win/tkWinX.c b/win/tkWinX.c index ce639a0..2f9565d 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -573,10 +573,10 @@ TkWinDisplayChanged( screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); - if (screen->cmap) { + if (screen->cmap != None) { XFreeColormap(display, screen->cmap); } - screen->cmap = XCreateColormap(display, 0, screen->root_visual, + screen->cmap = XCreateColormap(display, None, screen->root_visual, AllocNone); } @@ -636,7 +636,7 @@ TkpOpenDisplay( twdPtr = (TkWinDrawable*) ckalloc(sizeof(TkWinDrawable)); if (twdPtr == NULL) { - return 0; + return NULL; } twdPtr->type = TWD_WINDOW; twdPtr->window.winPtr = NULL; @@ -649,7 +649,7 @@ TkpOpenDisplay( screen->white_pixel = RGB(255, 255, 255); screen->black_pixel = RGB(0, 0, 0); - screen->cmap = 0; + screen->cmap = None; display->screens = screen; display->nscreens = 1; @@ -704,10 +704,10 @@ TkpCloseDisplay( if (display->screens->root_visual != NULL) { ckfree((char *) display->screens->root_visual); } - if (display->screens->root) { + if (display->screens->root != None) { ckfree((char *) display->screens->root); } - if (display->screens->cmap) { + if (display->screens->cmap != None) { XFreeColormap(display, display->screens->cmap); } ckfree((char *) display->screens); @@ -1018,7 +1018,7 @@ GenerateXEvent( Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); winPtr = (TkWindow *)Tk_HWNDToWindow(hwnd); - if (!winPtr || !winPtr->window) { + if (!winPtr || winPtr->window == None) { return; } @@ -1146,7 +1146,7 @@ GenerateXEvent( */ event.xbutton.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xbutton.subwindow = 0; + event.xbutton.subwindow = None; event.xbutton.x = clientPoint.x; event.xbutton.y = clientPoint.y; event.xbutton.x_root = root.point.x; @@ -1654,7 +1654,7 @@ HandleIMEComposition( event.xkey.display = winPtr->display; event.xkey.window = winPtr->window; event.xkey.root = RootWindow(winPtr->display, winPtr->screenNum); - event.xkey.subwindow = 0; + event.xkey.subwindow = None; event.xkey.state = TkWinGetModifierState(); event.xkey.time = TkpGetMS(); event.xkey.same_screen = True; diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 65b7240..6359891 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -453,7 +453,7 @@ InitElementData(ElementData *elementData, Tk_Window tkwin, Drawable d) { Window win = Tk_WindowId(tkwin); - if (win) { + if (win != None) { elementData->hwnd = Tk_GetHWND(win); } else { elementData->hwnd = elementData->procs->stubWindow; diff --git a/xlib/X11/X.h b/xlib/X11/X.h index 316683b..b43967e 100644 --- a/xlib/X11/X.h +++ b/xlib/X11/X.h @@ -73,7 +73,9 @@ typedef unsigned long KeyCode; /* In order to use IME, the Macintosh needs * RESERVED RESOURCE AND CONSTANT DEFINITIONS *****************************************************************/ -/* define None 0L See bug [9e31fd9449] and below */ +#ifndef _WIN32 +# define None 0L /* See bug [9e31fd9449] and below */ +#endif #define ParentRelative 1L /* background pixmap in CreateWindow and ChangeWindowAttributes */ @@ -179,7 +181,9 @@ are reserved in the protocol for errors and replies. */ #define ShiftMask (1<<0) #define LockMask (1<<1) -/* define ControlMask (1<<2) See bug [9e31fd9449] and below */ +#ifndef _WIN32 +# define ControlMask (1<<2) /* See bug [9e31fd9449] and below */ +#endif #define Mod1Mask (1<<3) #define Mod2Mask (1<<4) #define Mod3Mask (1<<5) @@ -187,7 +191,9 @@ are reserved in the protocol for errors and replies. */ #define Mod5Mask (1<<7) /* See bug [9e31fd9449], this way prevents conflicts with Win32 headers */ +#ifdef _WIN32 enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; +#endif /* modifier names. Used to build a SetModifierMapping request or to read a GetModifierMapping request. These correspond to the @@ -297,7 +303,7 @@ enum _Bug9e31fd9449 { None = 0, ControlMask = (1<<2) }; /* Used in SetInputFocus, GetInputFocus */ -#define RevertToNone 0 +#define RevertToNone (int)None #define RevertToPointerRoot (int)PointerRoot #define RevertToParent 2 diff --git a/xlib/xgc.c b/xlib/xgc.c index e62f0de..a6f2611 100644 --- a/xlib/xgc.c +++ b/xlib/xgc.c @@ -50,7 +50,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; - if (!clip_mask) { + if (clip_mask == None) { clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK @@ -78,14 +78,14 @@ static TkpClipMask *AllocClipMask(GC gc) { */ static void FreeClipMask(GC gc) { - if (gc->clip_mask) { + if (gc->clip_mask != None) { #ifdef MAC_OSX_TK if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif ckfree((char*) gc->clip_mask); - gc->clip_mask = 0; + gc->clip_mask = None; } } @@ -126,7 +126,7 @@ XCreateGC( gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { - return 0; + return NULL; } #define InitField(name,maskbit,default) \ @@ -145,11 +145,11 @@ XCreateGC( InitField(fill_style, GCFillStyle, FillSolid); InitField(fill_rule, GCFillRule, WindingRule); InitField(arc_mode, GCArcMode, ArcPieSlice); - InitField(tile, GCTile, 0); - InitField(stipple, GCStipple, 0); + InitField(tile, GCTile, None); + InitField(stipple, GCStipple, None); InitField(ts_x_origin, GCTileStipXOrigin, 0); InitField(ts_y_origin, GCTileStipYOrigin, 0); - InitField(font, GCFont, 0); + InitField(font, GCFont, None); InitField(subwindow_mode, GCSubwindowMode, ClipByChildren); InitField(graphics_exposures, GCGraphicsExposures, True); InitField(clip_x_origin, GCClipXOrigin, 0); @@ -158,7 +158,7 @@ XCreateGC( InitField(dashes, GCDashList, 4); (&(gp->dashes))[1] = 0; - gp->clip_mask = 0; + gp->clip_mask = None; if (mask & GCClipMask) { TkpClipMask *clip_mask = AllocClipMask(gp); @@ -269,7 +269,7 @@ int XFreeGC( Display *d, GC gc) { - if (gc) { + if (gc != None) { FreeClipMask(gc); TkpFreeGCCache(gc); ckfree((char *) gc); @@ -465,7 +465,7 @@ TkSetRegion( GC gc, TkRegion r) { - if (!r) { + if (r == None) { Tcl_Panic("must not pass None to TkSetRegion for compatibility with X11; use XSetClipMask instead"); } else { TkpClipMask *clip_mask = AllocClipMask(gc); @@ -484,7 +484,7 @@ XSetClipMask( GC gc, Pixmap pixmap) { - if (!pixmap) { + if (pixmap == None) { FreeClipMask(gc); } else { TkpClipMask *clip_mask = AllocClipMask(gc); diff --git a/xlib/ximage.c b/xlib/ximage.c index f7bf1cc..aaab946 100644 --- a/xlib/ximage.c +++ b/xlib/ximage.c @@ -47,7 +47,7 @@ XCreateBitmapFromData( pix = Tk_GetPixmap(display, d, (int) width, (int) height, 1); gc = XCreateGC(display, pix, 0, NULL); if (gc == NULL) { - return 0; + return None; } ximage = XCreateImage(display, NULL, 1, XYBitmap, 0, (char*) data, width, height, 8, (width + 7) / 8); -- cgit v0.12 From 19864dca1d60859c5428554215450a8e7e54f947 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:08:14 +0000 Subject: Let's see if we can build something with Travis-CI --- .travis.yml | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f2095d0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,84 @@ +sudo: required +language: c +addons: + apt: + packages: + - tcl-dev + - libx11-dev +matrix: + include: + - os: linux + dist: trusty + compiler: clang + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: clang + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc + env: + - CFGOPT=--disable-shared + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-4.9 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.9 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-5 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-5 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-6 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-6 + env: + - BUILD_DIR=unix + - os: linux + dist: trusty + compiler: gcc-7 + addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-7 + env: + - BUILD_DIR=unix +before_install: + - export ERROR_ON_FAILURES=1 + - cd ${BUILD_DIR} +install: + - test -n "$NO_DIRECT_CONFIGURE" || ./configure ${CFGOPT} +script: + - make + # The styles=develop avoids some weird problems on OSX + #- test -n "$NO_DIRECT_TEST" || make test styles=develop -- cgit v0.12 From 7e88cb3d95e4e109025330d5a72cc2710e9944d9 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:09:14 +0000 Subject: Fix bug [b2dd3b4fe8] (text-11a.41 sometimes hangs) by reworking how the <> event is handled. --- generic/tkText.c | 11 ++- generic/tkText.h | 4 +- generic/tkTextDisp.c | 77 +++++++++++++----- tests/text.test | 221 +++++++++++++++++++++++++++------------------------ 4 files changed, 179 insertions(+), 134 deletions(-) diff --git a/generic/tkText.c b/generic/tkText.c index 4c536a2..3d9977f 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -406,7 +406,6 @@ static Tcl_Obj * TextGetText(const TkText *textPtr, static void GenerateModifiedEvent(TkText *textPtr); static void GenerateUndoStackEvent(TkText *textPtr); static void UpdateDirtyFlag(TkSharedText *sharedPtr); -static void RunAfterSyncCmd(ClientData clientData); static void TextPushUndoAction(TkText *textPtr, Tcl_Obj *undoString, int insert, const TkTextIndex *index1Ptr, @@ -1547,7 +1546,7 @@ TextWidgetObjCmd( textPtr->afterSyncCmd = cmd; } else { textPtr->afterSyncCmd = cmd; - Tcl_DoWhenIdle(RunAfterSyncCmd, (ClientData) textPtr); + Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr); } break; } else if (objc != 2) { @@ -1559,7 +1558,7 @@ TextWidgetObjCmd( Tcl_DecrRefCount(textPtr->afterSyncCmd); } textPtr->afterSyncCmd = NULL; - TkTextUpdateLineMetrics(textPtr, 1, + TkTextUpdateLineMetrics(textPtr, 0, TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr), -1); break; } @@ -5506,7 +5505,7 @@ UpdateDirtyFlag( /* *---------------------------------------------------------------------- * - * RunAfterSyncCmd -- + * TkTextRunAfterSyncCmd -- * * This function is called by the event loop and executes the command * scheduled by [.text sync -command $cmd]. @@ -5520,8 +5519,8 @@ UpdateDirtyFlag( *---------------------------------------------------------------------- */ -static void -RunAfterSyncCmd( +void +TkTextRunAfterSyncCmd( ClientData clientData) /* Information about text widget. */ { register TkText *textPtr = (TkText *) clientData; diff --git a/generic/tkText.h b/generic/tkText.h index 5d88784..4703703 100644 --- a/generic/tkText.h +++ b/generic/tkText.h @@ -1070,7 +1070,7 @@ MODULE_SCOPE int TkTextGetObjIndex(Tcl_Interp *interp, TkText *textPtr, MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp, TkSharedText *sharedTextPtr, Tcl_Obj *idxPtr, TkTextIndex *indexPtr); -MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, +MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *objPtr); MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp, TkText *textPtr, Tcl_Obj *stringPtr); @@ -1159,7 +1159,7 @@ MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr, TkTextEmbWindowClient *client); - +MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData); #endif /* _TKTEXT */ /* diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 8d60754..5903dfb 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -497,13 +497,15 @@ static TkTextDispChunk *baseCharChunkPtr = NULL; * different character might be under the mouse * cursor now). Need to recompute the current * character before the next redisplay. + * OUT_OF_SYNC 1 means that the last <> event had + * value 0, indicating that the widget is out of sync. */ #define DINFO_OUT_OF_DATE 1 #define REDRAW_PENDING 2 #define REDRAW_BORDERS 4 #define REPICK_NEEDED 8 - +#define OUT_OF_SYNC 16 /* * Action values for FreeDLines: * @@ -681,7 +683,7 @@ TkTextCreateDInfo( dInfoPtr->scanTotalYScroll = 0; dInfoPtr->scanMarkY = 0; dInfoPtr->dLinesInvalidated = 0; - dInfoPtr->flags = DINFO_OUT_OF_DATE; + dInfoPtr->flags = 0; dInfoPtr->topPixelOffset = 0; dInfoPtr->newTopPixelOffset = 0; dInfoPtr->currentMetricUpdateLine = -1; @@ -3070,10 +3072,13 @@ AsyncUpdateLineMetrics( * We have looped over all lines, so we're done. We must release our * refCount on the widget (the timer token was already set to NULL * above). If there is a registered aftersync command, run that first. + * Cancel any pending idle task which would try to run the command + * after the afterSyncCmd pointer had been set to NULL. */ if (textPtr->afterSyncCmd) { int code; + Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr); Tcl_Preserve((ClientData) textPtr->interp); code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL); @@ -3091,7 +3096,6 @@ AsyncUpdateLineMetrics( * with its internal data (actually it will be after the next trip * through the event loop, because the widget redraws at idle-time). */ - GenerateWidgetViewSyncEvent(textPtr, 1); if (textPtr->refCount-- <= 1) { @@ -3115,8 +3119,14 @@ AsyncUpdateLineMetrics( * GenerateWidgetViewSyncEvent -- * * Send the <> event related to the text widget - * line metrics asynchronous update. - * This is equivalent to: + * line metrics asynchronous update. These events should only + * be sent when the sync status has changed. So this function + * compares the requested state with the state saved in the + * TkText structure, and only generates the event if they are + * different. This means that it is safe to call this function + * at any time when the state is known. + * + * If an event is sent, the effect is equivalent to: * event generate $textWidget <> -data $s * where $s is the sync status: true (when the widget view is in * sync with its internal data) or false (when it is not). @@ -3132,9 +3142,12 @@ AsyncUpdateLineMetrics( static void GenerateWidgetViewSyncEvent( - TkText *textPtr, /* Information about text widget. */ - Bool InSync) /* true if in sync, false otherwise */ + TkText *textPtr, /* Information about text widget. */ + Bool InSync) /* true if becoming in sync, false otherwise */ { + Bool NewSyncState = (InSync != 0); /* ensure 0 or 1 value */ + Bool OldSyncState = !(textPtr->dInfoPtr->flags & OUT_OF_SYNC); + /* * OSX 10.14 needs to be told to display the window when the Text Widget * is in sync. (That is, to run DisplayText inside of the drawRect @@ -3147,8 +3160,15 @@ GenerateWidgetViewSyncEvent( FORCE_DISPLAY(textPtr->tkwin); } - TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", - Tcl_NewBooleanObj(InSync)); + if (NewSyncState != OldSyncState) { + if (NewSyncState) { + textPtr->dInfoPtr->flags &= ~OUT_OF_SYNC; + } else { + textPtr->dInfoPtr->flags |= OUT_OF_SYNC; + } + TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync", + Tcl_NewBooleanObj(NewSyncState)); + } } /* @@ -3191,6 +3211,9 @@ TkTextUpdateLineMetrics( TkTextLine *linePtr = NULL; int count = 0; int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr); + int fullUpdateRequested = (lineNum == 0 && + endLine == totalLines && + doThisMuch == -1); if (totalLines == 0) { /* @@ -3201,6 +3224,7 @@ TkTextUpdateLineMetrics( } while (1) { + /* * Get a suitable line. */ @@ -3227,6 +3251,7 @@ TkTextUpdateLineMetrics( */ if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) { + /* * We have looped over all lines, so we're done. */ @@ -3250,10 +3275,12 @@ TkTextUpdateLineMetrics( if (TkBTreeLinePixelEpoch(textPtr, linePtr) == textPtr->dInfoPtr->lineMetricUpdateEpoch) { + /* * This line is already up to date. That means there's nothing * to do here. */ + } else if (doThisMuch == -1) { count += 8 * TkTextUpdateOneLine(textPtr, linePtr, 0,NULL,0); } else { @@ -3275,6 +3302,7 @@ TkTextUpdateLineMetrics( indexPtr = &textPtr->dInfoPtr->metricIndex; pixelHeight = textPtr->dInfoPtr->metricPixelHeight; } else { + /* * We must reset the partial line height calculation data * here, so we don't use it when it is out of date. @@ -3298,6 +3326,7 @@ TkTextUpdateLineMetrics( pixelHeight, indexPtr, 1); if (indexPtr->linePtr == linePtr) { + /* * We didn't complete the logical line, because it * produced very many display lines, which must be because @@ -3306,6 +3335,7 @@ TkTextUpdateLineMetrics( */ if (pixelHeight == 0) { + /* * These have already been stored, unless we just * started the new line. @@ -3327,6 +3357,7 @@ TkTextUpdateLineMetrics( textPtr->dInfoPtr->metricEpoch = -1; } } else { + /* * We must never recalculate the height of the last artificial * line. It must stay at zero, and if we recalculate it, it will @@ -3351,13 +3382,21 @@ TkTextUpdateLineMetrics( } } if (doThisMuch == -1) { + /* - * If we were requested to provide a full update, then also update the - * scrollbar. + * If we were requested to update the entire range, then also update + * the scrollbar. */ GetYView(textPtr->interp, textPtr, 1); } + if (fullUpdateRequested) { + TextDInfo *dInfoPtr = textPtr->dInfoPtr; + + dInfoPtr->lastMetricUpdateLine = lineNum; + dInfoPtr->currentMetricUpdateLine = lineNum; + GenerateWidgetViewSyncEvent(textPtr, 1); + } return lineNum; } @@ -3526,8 +3565,12 @@ TextInvalidateLineMetrics( textPtr->refCount++; dInfoPtr->lineUpdateTimer = Tcl_CreateTimerHandler(1, AsyncUpdateLineMetrics, textPtr); - GenerateWidgetViewSyncEvent(textPtr, 0); } + + /* + * The widget is out of sync: send a <> event. + */ + GenerateWidgetViewSyncEvent(textPtr, 0); } /* @@ -5269,9 +5312,7 @@ TkTextRelayoutWindow( inSync = 0; } - if (!inSync) { - GenerateWidgetViewSyncEvent(textPtr, 0); - } + GenerateWidgetViewSyncEvent(textPtr, inSync); } } @@ -6296,11 +6337,7 @@ TkTextPendingsync( { TextDInfo *dInfoPtr = textPtr->dInfoPtr; - return ( - (!(dInfoPtr->flags & REDRAW_PENDING) && - (dInfoPtr->metricEpoch == -1) && - (dInfoPtr->lastMetricUpdateLine == dInfoPtr->currentMetricUpdateLine)) ? - 0 : 1); + return ((dInfoPtr->flags & OUT_OF_SYNC) != 0); } /* diff --git a/tests/text.test b/tests/text.test index 988417e..aaddc2c 100644 --- a/tests/text.test +++ b/tests/text.test @@ -2936,11 +2936,13 @@ test text-11a.1 {TextWidgetCmd procedure, "pendingsync" option} -setup { } -cleanup { destroy .yt } -result {1 {wrong # args: should be ".yt pendingsync"}} + test text-11a.2 {TextWidgetCmd procedure, "pendingsync" option} -setup { destroy .top.yt .top } -body { toplevel .top pack [text .top.yt] + update set content {} for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n @@ -2978,9 +2980,11 @@ test text-11a.12 {TextWidgetCmd procedure, "sync" option} -setup { } -body { toplevel .top pack [text .top.yt] + update set content {} + # Use long lines so the line metrics will need updating. for {set i 1} {$i < 30} {incr i} { - append content [string repeat "$i " 15] \n + append content [string repeat "$i " 200] \n } .top.yt insert 1.0 $content # wait for end of line metrics calculation to get correct $fraction1 @@ -3053,19 +3057,18 @@ test text-11a.31 {"<>" event} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 15] \n } - .top.yt insert 1.0 $content + # Sync the widget and process <> events before binding. + .top.yt sync update bind .top.yt <> { if {%d} {set yud(%W) 1} } - # wait for end of line metrics calculation to get correct $fraction1 - # as a reference - if {[.top.yt pendingsync]} {vwait yud(.top.yt)} + .top.yt insert 1.0 $content .top.yt yview moveto 1 set fraction1 [lindex [.top.yt yview] 0] set res [expr {$fraction1 > 0}] .top.yt delete 1.0 end .top.yt insert 1.0 $content # synchronously wait for completion of line metrics calculation - # and ensure the test is relevant + # and verify that the fractions agree. set waited 0 if {[.top.yt pendingsync]} {set waited 1 ; vwait yud(.top.yt)} lappend res $waited @@ -3079,7 +3082,6 @@ test text-11a.31 {"<>" event} -setup { test text-11a.41 {"sync" "pendingsync" and <>} -setup { destroy .top.yt .top } -body { - set res {} toplevel .top pack [text .top.yt] update @@ -3087,15 +3089,21 @@ test text-11a.41 {"sync" "pendingsync" and <>} -setup { for {set i 1} {$i < 300} {incr i} { append content [string repeat "$i " 50] \n } + # Sync the widget and process all <> events before binding. + .top.yt sync + update bind .top.yt <> {lappend res Sync:%d} + set res {} + # The next line triggers <> with %d==0 i.e. out of sync. .top.yt insert 1.0 $content - vwait res ; # event dealt with by the event loop, with %d==0 i.e. we're out of sync - # ensure the test is relevant + vwait res + # Verify that the line metrics are not up-to-date (pendingsync is 1). lappend res "Pending:[.top.yt pendingsync]" - # - <> fires when sync returns if there was pending syncs - # - there is no more any pending sync after running 'sync' + # Update all line metrics by calling the sync command. .top.yt sync - vwait res ; # event dealt with by the event loop, with %d==1 i.e. we're in sync again + # <> should fire with %d==1 i.e. back in sync. + vwait res + # At this time the line metrics should be up-to-date (pendingsync is 0). lappend res "Pending:[.top.yt pendingsync]" set res } -cleanup { @@ -3110,6 +3118,7 @@ test text-11a.51 {<> calls TkSendVirtualEvent(), set res {} toplevel .top pack [text .top.t] + update for {set i 1} {$i < 10000} {incr i} { .top.t insert end "Hello world!\n" } @@ -7356,6 +7365,100 @@ test text-32.1 {line heights on creation} -setup { destroy .t } -result {1} +test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + # none of the following delete shall crash + # (all did before fixing bug 1630262) + # 1. delete on the same line: line1 == line2 in DeleteIndexRange, + # and resetView is true neither for .t not for .pt + .pt delete 2.0 2.2 + # 2. delete just one line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 3.0 + # 3. delete several lines: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 5.0 + # 4. delete to the end line: line1 < line2 in DeleteIndexRange, + # and resetView is true only for .t, not for .pt + .pt delete 2.0 end + # this test succeeds provided there is no crash + set res 1 +} -cleanup { + destroy .pt +} -result {1} + +test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 + .pt configure -startline 3 + # the following delete shall not crash + # (it did before fixing bug 1630262) + .pt delete 2.0 3.0 + # moreover -startline shall be correct + # (was wrong before fixing bug 1630262) + lappend res [.t cget -start] [.pt cget -start] +} -cleanup { + destroy .pt +} -result {4 3} + +test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { + destroy .t .pt + set res {} +} -body { + text .t + .t peer create .pt + for {set i 1} {$i < 100} {incr i} { + .t insert end "Line $i\n" + } + .t configure -startline 5 -endline 15 + .pt configure -startline 8 -endline 12 + # .pt now shows a range entirely inside the range of .pt + # from .t, delete lines located after [.pt cget -end] + .t delete 9.0 10.0 + # from .t, delete lines straddling [.pt cget -end] + .t delete 6.0 9.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 5 -endline 12 + .pt configure -startline 8 -endline 12 + # .pt now shows again a range entirely inside the range of .pt + # from .t, delete lines located before [.pt cget -start] + .t delete 2.0 3.0 + # from .t, delete lines straddling [.pt cget -start] + .t delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 22 -endline 31 + .pt configure -startline 42 -endline 51 + # .t now shows a range entirely before the range of .pt + # from .t, delete some lines, then do it from .pt + .t delete 2.0 3.0 + .t delete 2.0 5.0 + .pt delete 2.0 5.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] + .t configure -startline 55 -endline 75 + .pt configure -startline 60 -endline 70 + # .pt now shows a range entirely inside the range of .t + # from .t, delete a range straddling the entire range of .pt + .t delete 3.0 18.0 + lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] +} -cleanup { + destroy .pt .t +} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} + test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7488,100 +7591,6 @@ test text-34.1 {peer widget -start, -end and selection} -setup { destroy .t } -result {{10.0 20.0} {6.0 16.0} {6.0 11.0} {1.0 6.0} {1.0 2.0} {} {10.0 20.0}} -test text-32.2 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result {1} - -test text-32.3 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -end and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { #puts "KK: $key, $value" -- cgit v0.12 From 9997531222f9a5ea6e8da18ca5eb0241f06c0c61 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Thu, 3 Jan 2019 21:14:00 +0000 Subject: Remove 3 lines of code in tkTextDisp.c which had become obsolete but were accidentally left in the file. --- generic/tkTextDisp.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index 5903dfb..356e8b7 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -3391,10 +3391,6 @@ TkTextUpdateLineMetrics( GetYView(textPtr->interp, textPtr, 1); } if (fullUpdateRequested) { - TextDInfo *dInfoPtr = textPtr->dInfoPtr; - - dInfoPtr->lastMetricUpdateLine = lineNum; - dInfoPtr->currentMetricUpdateLine = lineNum; GenerateWidgetViewSyncEvent(textPtr, 1); } return lineNum; -- cgit v0.12 From 726546cf2742672ce6de89b0500b3e750c6fe3b7 Mon Sep 17 00:00:00 2001 From: "jan.nijtmans" Date: Fri, 4 Jan 2019 22:41:10 +0000 Subject: Fix a few minor compiler warnings, occurring in later gcc/clang versions. --- generic/tkEntry.h | 2 +- generic/tkScale.h | 2 +- macosx/tkMacOSXXStubs.c | 2 +- win/tkWinButton.c | 9 +++++---- win/tkWinEmbed.c | 2 +- win/tkWinImage.c | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/generic/tkEntry.h b/generic/tkEntry.h index 7f8aa1f..2ea7936 100644 --- a/generic/tkEntry.h +++ b/generic/tkEntry.h @@ -226,7 +226,7 @@ typedef struct { * value that the users requests. Malloc'ed */ char *valueFormat; /* Sprintf conversion specifier used for the * value. */ - char digitFormat[10]; /* Sprintf conversion specifier computed from + char digitFormat[16]; /* Sprintf conversion specifier computed from * digits and other information; used for the * value. */ diff --git a/generic/tkScale.h b/generic/tkScale.h index a2c5f2b..a19695f 100644 --- a/generic/tkScale.h +++ b/generic/tkScale.h @@ -78,7 +78,7 @@ typedef struct TkScale { * values. 0 means we get to choose the number * based on resolution and/or the range of the * scale. */ - char format[10]; /* Sprintf conversion specifier computed from + char format[16]; /* Sprintf conversion specifier computed from * digits and other information. */ double bigIncrement; /* Amount to use for large increments to scale * value. (0 means we pick a value). */ diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index e928298..a541945 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -1371,7 +1371,7 @@ void Tk_ResetUserInactiveTime( Display *dpy) { - IOGPoint loc; + IOGPoint loc = {0}; kern_return_t kr; NXEvent nullEvent = {NX_NULLEVENT, {0, 0}, 0, -1, 0}; enum { kNULLEventPostThrottle = 10 }; diff --git a/win/tkWinButton.c b/win/tkWinButton.c index 9e1960d..c36932d 100644 --- a/win/tkWinButton.c +++ b/win/tkWinButton.c @@ -127,7 +127,7 @@ InitBoxes(void) HRSRC hrsrc; HGLOBAL hblk; LPBITMAPINFOHEADER newBitmap; - DWORD size; + size_t size; ThreadSpecificData *tsdPtr = (ThreadSpecificData *) Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); @@ -146,8 +146,9 @@ InitBoxes(void) if (tsdPtr->boxesPtr != NULL && !(tsdPtr->boxesPtr->biWidth % 4) && !(tsdPtr->boxesPtr->biHeight % 2)) { - size = tsdPtr->boxesPtr->biSize + (1 << tsdPtr->boxesPtr->biBitCount) - * sizeof(RGBQUAD) + tsdPtr->boxesPtr->biSizeImage; + size = tsdPtr->boxesPtr->biSize + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount) + + tsdPtr->boxesPtr->biSizeImage; newBitmap = (LPBITMAPINFOHEADER) ckalloc(size); memcpy(newBitmap, tsdPtr->boxesPtr, size); tsdPtr->boxesPtr = newBitmap; @@ -156,7 +157,7 @@ InitBoxes(void) tsdPtr->boxesPalette = (DWORD*) (((LPSTR) tsdPtr->boxesPtr) + tsdPtr->boxesPtr->biSize); tsdPtr->boxesBits = ((LPSTR) tsdPtr->boxesPalette) - + ((1 << tsdPtr->boxesPtr->biBitCount) * sizeof(RGBQUAD)); + + (sizeof(RGBQUAD) << tsdPtr->boxesPtr->biBitCount); } else { tsdPtr->boxesPtr = NULL; } diff --git a/win/tkWinEmbed.c b/win/tkWinEmbed.c index a0670cc..1b0d2cf 100644 --- a/win/tkWinEmbed.c +++ b/win/tkWinEmbed.c @@ -300,7 +300,7 @@ TkpUseWindow( char msg[256]; - sprintf(msg, "Unable to get information of window \"%.80s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); + sprintf(msg, "Unable to get information of window \"%.79s\". Attach to this\nwindow may have unpredictable results if it is not a valid container.\n\nPress Ok to proceed or Cancel to abort attaching.", string); if (IDCANCEL == MessageBox(hwnd, msg, "Tk Warning", MB_OKCANCEL | MB_ICONWARNING)) { Tcl_SetResult(interp, "Operation has been canceled", TCL_STATIC); diff --git a/win/tkWinImage.c b/win/tkWinImage.c index 8e6ef38..07aa1d3 100644 --- a/win/tkWinImage.c +++ b/win/tkWinImage.c @@ -348,7 +348,7 @@ XGetImageZPixmap( size = sizeof(BITMAPINFO); if (depth <= 8) { - size += sizeof(unsigned short) * (1 << depth); + size += sizeof(unsigned short) << depth; } bmInfo = (BITMAPINFO *) ckalloc((unsigned)size); -- cgit v0.12