summaryrefslogtreecommitdiffstats
path: root/unix/tkUnixButton.c
diff options
context:
space:
mode:
authorhobbs <hobbs>2004-12-02 02:07:28 (GMT)
committerhobbs <hobbs>2004-12-02 02:07:28 (GMT)
commitc042ab3b65f3f2499c722d94c536d1d424589de4 (patch)
treee9ea122e7b73642e0610509655485611db1021a4 /unix/tkUnixButton.c
parentfc70be9d62b928f8d78e39e91b5bf3f8c0a8ce02 (diff)
downloadtk-c042ab3b65f3f2499c722d94c536d1d424589de4.zip
tk-c042ab3b65f3f2499c722d94c536d1d424589de4.tar.gz
tk-c042ab3b65f3f2499c722d94c536d1d424589de4.tar.bz2
* unix/tkUnixButton.c (TkpDisplayButton): constrain coords to
Tk_RedrawImage to display only portion that is valid. * generic/tkImgPhoto.c (ImgPhotoDisplay): add X error suppression around XGetImage to prevent app abort. [Bug 979239]
Diffstat (limited to 'unix/tkUnixButton.c')
-rw-r--r--unix/tkUnixButton.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 1246ece..3b1996f 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixButton.c,v 1.11.2.4 2003/10/10 20:20:47 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.11.2.5 2004/12/02 02:07:43 hobbs Exp $
*/
#include "tkButton.h"
@@ -236,12 +236,12 @@ TkpDisplayButton(clientData)
}
case COMPOUND_NONE: {break;}
}
-
+
TkComputeAnchor(butPtr->anchor, tkwin, butPtr->padX, butPtr->padY,
butPtr->indicatorSpace + fullWidth, fullHeight, &x, &y);
x += butPtr->indicatorSpace;
-
+
x += offset;
y += offset;
if (relief == TK_RELIEF_RAISED) {
@@ -256,6 +256,30 @@ TkpDisplayButton(clientData)
imageYOffset += y;
if (butPtr->image != NULL) {
+ /*
+ * Do boundary clipping, so that Tk_RedrawImage is passed
+ * valid coordinates. [Bug 979239]
+ */
+
+ if (imageXOffset < 0) {
+ imageXOffset = 0;
+ }
+ if (imageYOffset < 0) {
+ imageYOffset = 0;
+ }
+ if (width > Tk_Width(tkwin)) {
+ width = Tk_Width(tkwin);
+ }
+ if (height > Tk_Height(tkwin)) {
+ height = Tk_Height(tkwin);
+ }
+ if ((width + imageXOffset) > Tk_Width(tkwin)) {
+ imageXOffset = Tk_Width(tkwin) - width;
+ }
+ if ((height + imageYOffset) > Tk_Height(tkwin)) {
+ imageYOffset = Tk_Height(tkwin) - height;
+ }
+
if ((butPtr->selectImage != NULL) && (butPtr->flags & SELECTED)) {
Tk_RedrawImage(butPtr->selectImage, 0, 0,
width, height, pixmap, imageXOffset, imageYOffset);
@@ -295,6 +319,30 @@ TkpDisplayButton(clientData)
imageXOffset += x;
imageYOffset += y;
if (butPtr->image != NULL) {
+ /*
+ * Do boundary clipping, so that Tk_RedrawImage is passed
+ * valid coordinates. [Bug 979239]
+ */
+
+ if (imageXOffset < 0) {
+ imageXOffset = 0;
+ }
+ if (imageYOffset < 0) {
+ imageYOffset = 0;
+ }
+ if (width > Tk_Width(tkwin)) {
+ width = Tk_Width(tkwin);
+ }
+ if (height > Tk_Height(tkwin)) {
+ height = Tk_Height(tkwin);
+ }
+ if ((width + imageXOffset) > Tk_Width(tkwin)) {
+ imageXOffset = Tk_Width(tkwin) - width;
+ }
+ if ((height + imageYOffset) > Tk_Height(tkwin)) {
+ imageYOffset = Tk_Height(tkwin) - height;
+ }
+
if ((butPtr->selectImage != NULL) &&
(butPtr->flags & SELECTED)) {
Tk_RedrawImage(butPtr->selectImage, 0, 0, width,