Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
351 changes: 191 additions & 160 deletions generic/shape.c

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions generic/shapeInt.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

#include <shape.h>

#define ShapeApplyToBounding(kind) ((kind) & SHAPE_KIND_BOUNDING)
#define ShapeApplyToClip(kind) ((kind) & SHAPE_KIND_CLIP)
#define ShapeApplyToParent(kind) ((kind) & SHAPE_KIND_TOPLEVEL)
#define ShapeApplyToBounding(kind) ((kind) & SHAPE_KIND_BOUNDING)
#define ShapeApplyToClip(kind) ((kind) & SHAPE_KIND_CLIP)
#define ShapeApplyToParent(kind) ((kind) & SHAPE_KIND_TOPLEVEL)

EXTERN XRectangle *
ShapeRenderTextAsRectangles(Tk_Window tkwin, Tcl_Interp *interp,
Tcl_Obj *string, Tcl_Obj *font,
int *numRects);
EXTERN XRectangle * ShapeRenderTextAsRectangles(Tk_Window tkwin,
Tcl_Interp *interp, Tcl_Obj *string, Tcl_Obj *font,
int *numRects);

#endif
57 changes: 33 additions & 24 deletions include/shape.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,59 @@
#define SHAPE_VERSION STRINGIFY(SHAPE_VERSION_MAJOR) "." STRINGIFY(SHAPE_VERSION_MINOR)
#define SHAPE_PATCHLEVEL SHAPE_VERSION "." STRINGIFY(SHAPE_VERSION_PATCH)

#define SHAPE_KIND_BOUNDING (1 << 0)
#define SHAPE_KIND_CLIP (1 << 1)
#define SHAPE_KIND_BOTH (SHAPE_KIND_BOUNDING | SHAPE_KIND_CLIP)
#define SHAPE_KIND_TOPLEVEL (1 << 8)
#define SHAPE_KIND_ALL (SHAPE_KIND_BOTH | SHAPE_KIND_TOPLEVEL)
#define SHAPE_BOUND_MASK (SHAPE_KIND_BOUNDING | SHAPE_KIND_TOPLEVEL)
#define SHAPE_CLIP_MASK (SHAPE_KIND_CLIP | SHAPE_KIND_TOPLEVEL)
typedef enum ShapeKind {
SHAPE_KIND_BOUNDING = (1 << 0),
SHAPE_KIND_CLIP = (1 << 1),
SHAPE_KIND_BOTH = (SHAPE_KIND_BOUNDING | SHAPE_KIND_CLIP),
SHAPE_KIND_TOPLEVEL = (1 << 8),
SHAPE_KIND_ALL = (SHAPE_KIND_BOTH | SHAPE_KIND_TOPLEVEL),
SHAPE_BOUND_MASK = (SHAPE_KIND_BOUNDING | SHAPE_KIND_TOPLEVEL),
SHAPE_CLIP_MASK = (SHAPE_KIND_CLIP | SHAPE_KIND_TOPLEVEL)
} ShapeKind;

#ifndef ShapeSet
/* Taken from /usr/include/X11/extensions/shape.h */
#define ShapeSet 0
#define ShapeUnion 1
#define ShapeIntersect 2
#define ShapeSubtract 3
#define ShapeInvert 4
enum {
ShapeSet = 0,
ShapeUnion = 1,
ShapeIntersect = 2,
ShapeSubtract = 3,
ShapeInvert = 4
};
#endif /* ShapeSet */

#define SHAPE_OP_SET ShapeSet
#define SHAPE_OP_UNION ShapeUnion
#define SHAPE_OP_INTERSECT ShapeIntersect
#define SHAPE_OP_SUBTRACT ShapeSubtract
#define SHAPE_OP_INVERT ShapeInvert
typedef enum ShapeOps {
SHAPE_OP_SET = ShapeSet,
SHAPE_OP_UNION = ShapeUnion,
SHAPE_OP_INTERSECT = ShapeIntersect,
SHAPE_OP_SUBTRACT = ShapeSubtract,
SHAPE_OP_INVERT = ShapeInvert
} ShapeOps;

EXTERN int Shape_GetBbox(Tcl_Interp *interp, Tk_Window tkwin,
int getClip, int *valid, int *x1, int *y1, int *x2,
int *y2);
EXTERN int Shape_GetShapeRectanglesObj(Tcl_Interp *interp,
Tk_Window tkwin, int getClip);
EXTERN int Shape_MoveShape(Tcl_Interp *interp, Tk_Window tkwin,
int kind, int x, int y);
ShapeKind kind, int x, int y);
EXTERN int Shape_CombineBitmap(Tcl_Interp *interp, Tk_Window tkwin,
int kind, int op, int x, int y, Pixmap bitmap);
ShapeKind kind, ShapeOps op, int x, int y,
Pixmap bitmap);
EXTERN int Shape_CombineRectangles(Tcl_Interp *interp,
Tk_Window tkwin, int kind, int op,
Tk_Window tkwin, ShapeKind kind, ShapeOps op,
int rectc, XRectangle *rectv);
EXTERN int Shape_CombineRectanglesOrdered(Tcl_Interp *interp,
Tk_Window tkwin, int kind, int op,
Tk_Window tkwin, ShapeKind kind, ShapeOps op,
int rectc, XRectangle *rectv);
EXTERN int Shape_CombineWindow(Tcl_Interp *interp, Tk_Window tkwin,
int kind, int op, int x, int y, Tk_Window srcwin);
ShapeKind kind, ShapeOps op, int x, int y,
Tk_Window srcwin);
EXTERN int Shape_CombineRegion(Tcl_Interp *interp, Tk_Window tkwin,
int kind, int op, int x, int y, Region region);
ShapeKind kind, ShapeOps op, int x, int y,
Region region);
EXTERN int Shape_Reset(Tcl_Interp *interp, Tk_Window tkwin,
int kind);
ShapeKind kind);
EXTERN int Shape_QueryVersion(Tk_Window tkwin, int *majorPtr,
int *minorPtr);
EXTERN int Shape_ExtensionPresent(Tk_Window tkwin);
Expand Down
7 changes: 5 additions & 2 deletions unix/pkgIndex.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@
# it needs to be mangled like this to get the names working happily on
# broken OSes like SunOS4. If you have a problem with this, tough!

package ifneeded Shape 0.4 "package require Tk 8\n\
[list tclPkgSetup $dir Shape 0.4 {{libshape04.so.1.0 load shape}}]"
package ifneeded Shape 0.4.4 [apply {{dir} {
package require Tk 8.6-
package provide Shape 0.4.4
load [file join $dir libshape04.so.1.0]
}}]
61 changes: 32 additions & 29 deletions unix/shapeUnixImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ Shape_GetBbox(
unsigned int wbs, hbs, wcs, hcs;

if (win == None) {
Tcl_AppendResult(interp, "window ", Tk_PathName(tkwin),
" doesn't fully exist", NULL);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window %s doesn't fully exist",
Tk_PathName(tkwin)));
Tcl_SetErrorCode(interp, "SHAPE", "X11", "EXIST", NULL);
return TCL_ERROR;
}

Expand All @@ -108,7 +110,9 @@ Shape_GetBbox(
&cShaped, &xcs, &ycs, &wcs, &hcs);

if (!s) {
Tcl_AppendResult(interp, "extents query failed", NULL);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"extents query failed"));
Tcl_SetErrorCode(interp, "SHAPE", "X11", "EXTENTS", NULL);
return TCL_ERROR;
} else if (bShaped && !getClip) {
/* Bounding box of window. */
Expand Down Expand Up @@ -158,12 +162,14 @@ Shape_GetShapeRectanglesObj(
Window win = Tk_WindowId(tkwin);
XRectangle *rects = NULL;
int count = 0;
int order,i;
int order, i;
Tcl_Obj *rect[4], **retvals;

if (win == None) {
Tcl_AppendResult(interp, "window ", Tk_PathName(tkwin),
" doesn't fully exist", NULL);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window %s doesn't fully exist",
Tk_PathName(tkwin)));
Tcl_SetErrorCode(interp, "SHAPE", "X11", "EXIST", NULL);
return TCL_ERROR;
}

Expand Down Expand Up @@ -192,7 +198,7 @@ int
Shape_MoveShape(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
ShapeKind kind,
int x,
int y)
{
Expand Down Expand Up @@ -231,8 +237,8 @@ int
Shape_CombineBitmap(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
int op,
ShapeKind kind,
ShapeOps op,
int x,
int y,
Pixmap bitmap)
Expand Down Expand Up @@ -271,8 +277,8 @@ int
Shape_CombineRectangles(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
int op,
ShapeKind kind,
ShapeOps op,
int rectc,
XRectangle *rectv)
{
Expand Down Expand Up @@ -321,8 +327,8 @@ int
Shape_CombineRectanglesOrdered(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
int op,
ShapeKind kind,
ShapeOps op,
int rectc,
XRectangle *rectv)
{
Expand Down Expand Up @@ -364,8 +370,8 @@ int
Shape_CombineWindow(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
int op,
ShapeKind kind,
ShapeOps op,
int x,
int y,
Tk_Window srcwin)
Expand Down Expand Up @@ -473,8 +479,8 @@ int
Shape_CombineRegion(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind,
int op,
ShapeKind kind,
ShapeOps op,
int x,
int y,
Region region)
Expand Down Expand Up @@ -514,30 +520,27 @@ int
Shape_Reset(
Tcl_Interp *interp,
Tk_Window tkwin,
int kind)
ShapeKind kind)
{
/* Maps to this on X... */
return Shape_CombineBitmap(interp, tkwin, kind, SHAPE_OP_SET, 0, 0, None);
}

int
Shape_QueryVersion(tkwin, majorPtr, minorPtr)
Tk_Window tkwin;
int *majorPtr, *minorPtr;
Shape_QueryVersion(
Tk_Window tkwin,
int *majorPtr,
int *minorPtr)
{
Status result;

result = XShapeQueryVersion(Tk_Display(tkwin), majorPtr, minorPtr);
Status result = XShapeQueryVersion(Tk_Display(tkwin), majorPtr, minorPtr);
return (result == True);
}

int
Shape_ExtensionPresent(tkwin)
Tk_Window tkwin;
Shape_ExtensionPresent(
Tk_Window tkwin)
{
int eventBase, errorBase; /* These are ignored by us! */
Status result;

result = XShapeQueryExtension(Tk_Display(tkwin), &eventBase, &errorBase);
Status result = XShapeQueryExtension(Tk_Display(tkwin), &eventBase, &errorBase);
return (result == True);
}
82 changes: 82 additions & 0 deletions win/Makefile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This Makefile is used to create the example loadable module.
# It also illustrates how to take advantage of configuration
# exported by Tcl to set up Makefiles for shared libraries.
#
# SCCS: @(#) Makefile.in 1.5 97/08/14 19:01:21

DLLFILE = shape04.dll
EXEFILE = shapewish
WIN_OBJS = shapeWinImpl.o
GENERIC_OBJS = shape.o

GENERIC_SRCS = $(GENERIC_DIR)/shape.c
WIN_SRCS = $(WIN_DIR)/shapeWinImpl.c

OBJS = $(GENERIC_OBJS) $(WIN_OBJS)
SRCS = $(GENERIC_SRCS) $(WIN_SRCS)

# The directory containing the Tcl library archive file appropriate
# for this version of Tk:
TCL_BIN_DIR = @TCL_BIN_DIR@

# Libraries to use when linking:
LIBS = @TCL_LIB_SPEC@ @TCL_LIBS@ -lc

#----------------------------------------------------------------
# The information below is modified by the configure script when
# Makefile is generated from Makefile.in. You shouldn't normally
# modify any of this stuff by hand.
#----------------------------------------------------------------

CC = @CC@
SHLIB_CFLAGS = @SHLIB_CFLAGS@
SHLIB_LD = @SHLIB_LD@
SHLIB_SUFFIX = @SHLIB_SUFFIX@
TCL_INCLUDE_DIR = @TCL_INCLUDE@
TK_INCLUDE_DIR = @TK_INCLUDE@
TK_XINCLUDES = @TK_XINCLUDES@
VPATH = @srcdir@
TK_LIB_SPEC = @TK_LIB_SPEC@
TCL_LIB_SPEC = @TCL_LIB_SPEC@
TK_LIBS = @TK_LIBS@
TCL_SRC_DIR = @TCL_SRC_DIR@
TK_SRC_DIR = @TK_SRC_DIR@

SRC_DIR = @srcdir@
TOP_DIR = @srcdir@/..
GENERIC_DIR = $(TOP_DIR)/generic
WIN_DIR = $(TOP_DIR)/win
INCLUDE_DIR = $(TOP_DIR)/include
# ----------------------------------------------------------------------
CFLAGS = -g -DSHAPE_PHOTO=@SHAPE_PHOTO@
CC_SWITCHES = $(CFLAGS) ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \
-I${INCLUDE_DIR} -I${GENERIC_DIR} -I${WIN_DIR} \
-I${TK_INCLUDE_DIR} ${TK_XINCLUDES} -I${TCL_INCLUDE_DIR} \
-I${TCL_SRC_DIR}/generic -I${TCL_SRC_DIR}/unix \
-I${TK_SRC_DIR}/generic -I${TK_SRC_DIR}/unix
# ----------------------------------------------------------------------
all: @PRIMARY_TARGET@

$(OBJS): $(INCLUDE_DIR)/shape.h $(GENERIC_DIR)/shapeInt.h

shape.o: $(GENERIC_DIR)/shape.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/shape.c
tkAppInit.o: $(GENERIC_DIR)/tkAppInit.c
$(CC) -c $(CC_SWITCHES) $(GENERIC_DIR)/tkAppInit.c
shapeWinImpl.o: $(WIN_DIR)/shapeWinImpl.c
$(CC) -c $(CC_SWITCHES) $(WIN_DIR)/shapeWinImpl.c
# ----------------------------------------------------------------------
$(DLLFILE): $(OBJS)
${SHLIB_LD} -o $@ $^ @SHLIB_LD_LIBS@
$(EXEFILE): $(OBJS) tkAppInit.o
$(CC) -o $@ $^ @SHLIB_LD_LIBS@ ${TK_LIB_SPEC} ${TCL_LIB_SPEC} ${TK_LIBS}
# ----------------------------------------------------------------------
clean:
rm -f *.o *.a $(DLLFILE) $(EXEFILE) core
distclean: clean
rm -f Makefile config.cache config.log config.status
# ----------------------------------------------------------------------
Makefile: Makefile.in config.status
./config.status
depend:
makedepend -- $(DEPEND_SWITCHES) -- $(SRCS)
Loading