summaryrefslogtreecommitdiffstats
path: root/unix
diff options
context:
space:
mode:
Diffstat (limited to 'unix')
-rw-r--r--unix/tkUnixButton.c10
-rw-r--r--unix/tkUnixKey.c17
-rw-r--r--unix/tkUnixMenu.c85
-rw-r--r--unix/tkUnixSend.c148
-rw-r--r--unix/tkUnixWm.c183
5 files changed, 216 insertions, 227 deletions
diff --git a/unix/tkUnixButton.c b/unix/tkUnixButton.c
index 1294112..9a0ff1c 100644
--- a/unix/tkUnixButton.c
+++ b/unix/tkUnixButton.c
@@ -8,7 +8,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.22 2005/11/27 02:36:16 das Exp $
+ * RCS: @(#) $Id: tkUnixButton.c,v 1.23 2007/02/27 14:52:56 dkf Exp $
*/
#include "tkButton.h"
@@ -197,7 +197,7 @@ TkpDrawCheckIndicator(
case CHECK_BUTTON:
imgsel = on == 2 ? CHECK_DISON_OFFSET :
on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
- imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
+ imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
imgstart = CHECK_START;
dim = CHECK_BUTTON_DIM;
break;
@@ -205,7 +205,7 @@ TkpDrawCheckIndicator(
case CHECK_MENU:
imgsel = on == 2 ? CHECK_DISOFF_OFFSET :
on == 1 ? CHECK_ON_OFFSET : CHECK_OFF_OFFSET;
- imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
+ imgsel += disabled && on != 2 ? CHECK_DISOFF_OFFSET : 0;
imgstart = CHECK_START + 2;
imgsel += 2;
dim = CHECK_MENU_DIM;
@@ -455,7 +455,7 @@ TkpDisplayButton(
Tk_SizeOfBitmap(butPtr->display, butPtr->bitmap, &width, &height);
haveImage = 1;
}
- imageWidth = width;
+ imageWidth = width;
imageHeight = height;
haveText = (butPtr->textWidth != 0 && butPtr->textHeight != 0);
@@ -702,7 +702,7 @@ TkpDisplayButton(
}
x -= butPtr->indicatorSpace/2;
y = Tk_Height(tkwin)/2;
- TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
+ TkpDrawCheckIndicator(tkwin, butPtr->display, pixmap, x, y,
border, butPtr->normalFg, selColor, butPtr->disabledFg,
((butPtr->flags & SELECTED) ? 1 :
(butPtr->flags & TRISTATED) ? 2 : 0),
diff --git a/unix/tkUnixKey.c b/unix/tkUnixKey.c
index 615ec82..7dc91da 100644
--- a/unix/tkUnixKey.c
+++ b/unix/tkUnixKey.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: tkUnixKey.c,v 1.11 2005/10/21 01:51:45 dkf Exp $
+ * RCS: @(#) $Id: tkUnixKey.c,v 1.12 2007/02/27 14:52:57 dkf Exp $
*/
#include "tkInt.h"
@@ -366,8 +366,8 @@ TkpInitKeymapInfo(
}
dispPtr->numModKeyCodes = 0;
arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = (KeyCode *) ckalloc((unsigned)
- (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
+ dispPtr->modKeyCodes = (KeyCode *)
+ ckalloc((unsigned) (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
if (*codePtr == 0) {
continue;
@@ -386,20 +386,21 @@ TkpInitKeymapInfo(
KeyCode *new;
/*
- * Ran out of space in the array; grow it.
+ * Ran out of space in the array; grow it.
*/
arraySize *= 2;
- new = (KeyCode *) ckalloc((unsigned)
- (arraySize * sizeof(KeyCode)));
- memcpy((VOID *) new, (VOID *) dispPtr->modKeyCodes,
+ new = (KeyCode *)
+ ckalloc((unsigned) (arraySize * sizeof(KeyCode)));
+ memcpy(new, dispPtr->modKeyCodes,
(dispPtr->numModKeyCodes * sizeof(KeyCode)));
ckfree((char *) dispPtr->modKeyCodes);
dispPtr->modKeyCodes = new;
}
dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
dispPtr->numModKeyCodes++;
- nextModCode: continue;
+ nextModCode:
+ continue;
}
XFreeModifiermap(modMapPtr);
}
diff --git a/unix/tkUnixMenu.c b/unix/tkUnixMenu.c
index bc64db5..445d22e 100644
--- a/unix/tkUnixMenu.c
+++ b/unix/tkUnixMenu.c
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixMenu.c,v 1.15 2006/11/24 18:11:32 hobbs Exp $
+ * RCS: @(#) $Id: tkUnixMenu.c,v 1.16 2007/02/27 14:52:57 dkf Exp $
*/
#include "tkPort.h"
@@ -339,22 +339,20 @@ GetMenuIndicatorGeometry(
*widthPtr = (14 * mePtr->height) / 10;
*heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
- mePtr->platformEntryData =
- (TkMenuPlatformEntryData) ((65 * mePtr->height)
- / 100);
+ mePtr->platformEntryData = (TkMenuPlatformEntryData)
+ ((65 * mePtr->height) / 100);
} else {
- mePtr->platformEntryData =
- (TkMenuPlatformEntryData) ((75 * mePtr->height)
- / 100);
+ mePtr->platformEntryData = (TkMenuPlatformEntryData)
+ ((75 * mePtr->height) / 100);
}
} else {
*widthPtr = *heightPtr = mePtr->height;
if (mePtr->type == CHECK_BUTTON_ENTRY) {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
- ((80 * mePtr->height) / 100);
+ ((80 * mePtr->height) / 100);
} else {
mePtr->platformEntryData = (TkMenuPlatformEntryData)
- mePtr->height;
+ mePtr->height;
}
}
} else {
@@ -574,8 +572,7 @@ DrawMenuEntryIndicator(
*/
if ((mePtr->type == CHECK_BUTTON_ENTRY) && mePtr->indicatorOn) {
- int top, left;
- int activeBorderWidth;
+ int top, left, activeBorderWidth;
int disabled = (mePtr->state == ENTRY_DISABLED);
XColor *bg;
@@ -596,8 +593,7 @@ DrawMenuEntryIndicator(
*/
if ((mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn) {
- int top, left;
- int activeBorderWidth;
+ int top, left, activeBorderWidth;
int disabled = (mePtr->state == ENTRY_DISABLED);
XColor *bg;
@@ -638,10 +634,8 @@ DrawMenuSeparator(
GC gc, /* The gc to draw into */
Tk_Font tkfont, /* The font to draw with */
CONST Tk_FontMetrics *fmPtr,/* The font metrics from the font */
- int x,
- int y,
- int width,
- int height)
+ int x, int y,
+ int width, int height)
{
XPoint points[2];
Tk_3DBorder border;
@@ -688,10 +682,8 @@ DrawMenuEntryLabel(
int width, /* width of entry. */
int height) /* height of entry. */
{
- int indicatorSpace = mePtr->indicatorSpace;
- int activeBorderWidth;
- int leftEdge;
- int imageHeight, imageWidth;
+ int indicatorSpace = mePtr->indicatorSpace;
+ int activeBorderWidth, leftEdge, imageHeight, imageWidth;
int textHeight = 0, textWidth = 0; /* stop GCC warning */
int haveImage = 0, haveText = 0;
int imageXOffset = 0, imageYOffset = 0;
@@ -803,6 +795,7 @@ DrawMenuEntryLabel(
}
} else if (mePtr->bitmapPtr != None) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
+
XCopyPlane(menuPtr->display, bitmap, d, gc, 0, 0,
(unsigned) imageWidth, (unsigned) imageHeight,
leftEdge + imageXOffset,
@@ -810,8 +803,10 @@ DrawMenuEntryLabel(
}
if ((mePtr->compound != COMPOUND_NONE) || !haveImage) {
int baseline = y + (height + fmPtr->ascent - fmPtr->descent) / 2;
+
if (mePtr->labelLength > 0) {
char *label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
+
Tk_DrawChars(menuPtr->display, d, gc, tkfont, label,
mePtr->labelLength, leftEdge + textXOffset,
baseline + textYOffset);
@@ -859,19 +854,19 @@ DrawMenuUnderline(
GC gc, /* The gc to draw into */
Tk_Font tkfont, /* The precalculated font */
CONST Tk_FontMetrics *fmPtr,/* The precalculated font metrics */
- int x,
- int y,
- int width,
- int height)
+ int x, int y,
+ int width, int height)
{
if ((mePtr->underline >= 0) && (mePtr->labelPtr != NULL)) {
int len;
- /* do the unicode call just to prevent overruns */
+ /*
+ * Do the unicode call just to prevent overruns.
+ */
+
Tcl_GetUnicodeFromObj(mePtr->labelPtr, &len);
if (mePtr->underline < len) {
- int activeBorderWidth;
- int leftEdge;
+ int activeBorderWidth, leftEdge;
CONST char *label, *start, *end;
label = Tcl_GetStringFromObj(mePtr->labelPtr, NULL);
@@ -912,8 +907,7 @@ int
TkpPostMenu(
Tcl_Interp *interp,
TkMenu *menuPtr,
- int x,
- int y)
+ int x, int y)
{
return TkPostTearoffMenu(interp, menuPtr, x, y);
}
@@ -1003,19 +997,12 @@ void
TkpComputeMenubarGeometry(
TkMenu *menuPtr) /* Structure describing menu. */
{
- Tk_Font tkfont;
+ Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
- int width, height;
- int i, j;
- int x, y, currentRowHeight, maxWidth;
- int maxWindowWidth;
- int lastRowBreak;
- int helpMenuIndex = -1;
+ int width, height, i, j, x, y, currentRowHeight, maxWidth;
+ int maxWindowWidth, lastRowBreak, lastEntry;
+ int borderWidth, activeBorderWidth, helpMenuIndex = -1;
TkMenuEntry *mePtr;
- int lastEntry;
- Tk_Font menuFont;
- int borderWidth;
- int activeBorderWidth;
if (menuPtr->tkwin == NULL) {
return;
@@ -1197,10 +1184,8 @@ DrawTearoffEntry(
GC gc, /* The gc we are drawing with */
Tk_Font tkfont, /* The font we are drawing with */
CONST Tk_FontMetrics *fmPtr,/* The metrics we are drawing with */
- int x,
- int y,
- int width,
- int height)
+ int x, int y,
+ int width, int height)
{
XPoint points[2];
int segmentWidth, maxX;
@@ -1214,7 +1199,7 @@ DrawTearoffEntry(
points[0].y = y + height/2;
points[1].y = points[0].y;
segmentWidth = 6;
- maxX = width - 1;
+ maxX = width - 1;
border = Tk_Get3DBorderFromObj(menuPtr->tkwin, menuPtr->borderPtr);
while (points[0].x < maxX) {
@@ -1339,8 +1324,7 @@ TkpDrawMenuEntry(
* to Windows. */
{
GC gc, indicatorGC;
- XColor *indicatorColor;
- XColor *disableColor = NULL;
+ XColor *indicatorColor, *disableColor = NULL;
TkMenu *menuPtr = mePtr->menuPtr;
Tk_3DBorder bgBorder, activeBorder;
CONST Tk_FontMetrics *fmPtr;
@@ -1489,7 +1473,7 @@ GetMenuLabelGeometry(
if (mePtr->image != NULL) {
Tk_SizeOfImage(mePtr->image, widthPtr, heightPtr);
haveImage = 1;
- } else if (mePtr->bitmapPtr != NULL) {
+ } else if (mePtr->bitmapPtr != NULL) {
Pixmap bitmap = Tk_GetBitmapFromObj(menuPtr->tkwin, mePtr->bitmapPtr);
Tk_SizeOfBitmap(menuPtr->display, bitmap, widthPtr, heightPtr);
haveImage = 1;
@@ -1593,8 +1577,7 @@ TkpComputeStandardMenuGeometry(
Tk_Font tkfont, menuFont;
Tk_FontMetrics menuMetrics, entryMetrics, *fmPtr;
int x, y, height, width, indicatorSpace, labelWidth, accelWidth;
- int windowWidth, windowHeight, accelSpace;
- int i, j, lastColumnBreak = 0;
+ int windowWidth, windowHeight, accelSpace, i, j, lastColumnBreak = 0;
TkMenuEntry *mePtr;
int borderWidth, activeBorderWidth;
diff --git a/unix/tkUnixSend.c b/unix/tkUnixSend.c
index 29deb7e..17d1288 100644
--- a/unix/tkUnixSend.c
+++ b/unix/tkUnixSend.c
@@ -11,7 +11,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixSend.c,v 1.15 2006/07/20 06:25:20 das Exp $
+ * RCS: @(#) $Id: tkUnixSend.c,v 1.16 2007/02/27 14:52:57 dkf Exp $
*/
#include "tkPort.h"
@@ -181,17 +181,21 @@ static Tcl_ThreadDataKey dataKey;
* variable. This option may be omitted; it is ignored unless the
* completion code is TCL_ERROR.
*
- * Options may appear in any order, and only the -s option must be present.
- * As with commands, there may be additional options besides these; unknown
+ * Options may appear in any order, and only the -s option must be present. As
+ * with commands, there may be additional options besides these; unknown
* options are ignored.
*/
/*
- * The following variable is the serial number that was used in the last
- * "send" command.
+ * Other miscellaneous per-process data:
*/
-static int tkSendSerial = 0;
+static struct {
+ int sendSerial; /* The serial number that was used in the last
+ * "send" command. */
+ int sendDebug; /* This can be set while debugging to do
+ * things like skip locking the server. */
+} localData = {0, 0};
/*
* Maximum size property that can be read at one time by this module:
@@ -200,13 +204,6 @@ static int tkSendSerial = 0;
#define MAX_PROP_WORDS 100000
/*
- * The following variable can be set while debugging to do things like skip
- * locking the server.
- */
-
-static int sendDebug = 0;
-
-/*
* Forward declarations for functions defined later in this file:
*/
@@ -244,7 +241,7 @@ static int ValidateName(TkDisplay *dispPtr, CONST char *name,
* The return value is a pointer to the loaded registry.
*
* Side effects:
- * If "lock" is set then the server will be locked. It is the caller's
+ * If "lock" is set then the server will be locked. It is the caller's
* responsibility to call RegClose when finished with the registry, so
* that we can write back the registry if needed, unlock the server if
* needed, and free memory.
@@ -279,7 +276,7 @@ RegOpen(
regPtr->modified = 0;
regPtr->allocedByX = 1;
- if (lock && !sendDebug) {
+ if (lock && !localData.sendDebug) {
XGrabServer(dispPtr->display);
regPtr->locked = 1;
}
@@ -301,7 +298,7 @@ RegOpen(
} else if ((result != Success) || (actualFormat != 8)
|| (actualType != XA_STRING)) {
/*
- * The property is improperly formed; delete it.
+ * The property is improperly formed; delete it.
*/
if (regPtr->property != NULL) {
@@ -354,15 +351,17 @@ RegFindName(
* previous call to RegOpen. */
CONST char *name) /* Name of an application. */
{
- char *p, *entry;
- unsigned int id;
+ char *p;
+
+ for (p=regPtr->property ; p-regPtr->property<(int)regPtr->propLength ;) {
+ char *entry = p;
- for (p = regPtr->property; (p-regPtr->property) < (int) regPtr->propLength; ) {
- entry = p;
while ((*p != 0) && (!isspace(UCHAR(*p)))) {
p++;
}
if ((*p != 0) && (strcmp(name, p+1) == 0)) {
+ unsigned int id;
+
if (sscanf(entry, "%x", &id) == 1) {
/*
* Must cast from an unsigned int to a Window in case we are
@@ -405,11 +404,11 @@ RegDeleteName(
* previous call to RegOpen. */
CONST char *name) /* Name of an application. */
{
- char *p, *entry, *entryName;
- int count;
+ char *p;
+
+ for (p=regPtr->property ; p-regPtr->property<(int)regPtr->propLength ;) {
+ char *entry = p, *entryName;
- for (p = regPtr->property; (p-regPtr->property) < (int) regPtr->propLength; ) {
- entry = p;
while ((*p != 0) && (!isspace(UCHAR(*p)))) {
p++;
}
@@ -421,21 +420,23 @@ RegDeleteName(
p++;
}
p++;
- if ((strcmp(name, entryName) == 0)) {
+ if (strcmp(name, entryName) == 0) {
+ int count;
+
/*
- * Found the matching entry. Copy everything after it
- * down on top of it.
+ * Found the matching entry. Copy everything after it down on top
+ * of it.
*/
count = regPtr->propLength - (p - regPtr->property);
- if (count > 0) {
+ if (count > 0) {
char *src, *dst;
- for (src = p, dst = entry; count > 0; src++, dst++, count--) {
+ for (src=p , dst=entry ; count>0 ; src++, dst++, count--) {
*dst = *src;
}
}
- regPtr->propLength -= p - entry;
+ regPtr->propLength -= p - entry;
regPtr->modified = 1;
return;
}
@@ -453,8 +454,8 @@ RegDeleteName(
* None.
*
* Side effects:
- * The open registry is expanded; it is marked as modified so that
- * it will be written back when closed.
+ * The open registry is expanded; it is marked as modified so that it
+ * will be written back when closed.
*
*----------------------------------------------------------------------
*/
@@ -467,21 +468,19 @@ RegAddName(
* ensure that this name isn't already
* registered. */
Window commWindow) /* X identifier for comm. window of
- * application. */
+ * application. */
{
- char id[30];
- char *newProp;
+ char id[30], *newProp;
int idLength, newBytes;
sprintf(id, "%x ", (unsigned int) commWindow);
idLength = strlen(id);
newBytes = idLength + strlen(name) + 1;
- newProp = (char *) ckalloc((unsigned) (regPtr->propLength + newBytes));
+ newProp = ckalloc((unsigned) (regPtr->propLength + newBytes));
strcpy(newProp, id);
strcpy(newProp+idLength, name);
if (regPtr->property != NULL) {
- memcpy((VOID *) (newProp + newBytes), (VOID *) regPtr->property,
- regPtr->propLength);
+ memcpy(newProp + newBytes, regPtr->property, regPtr->propLength);
if (regPtr->allocedByX) {
XFree(regPtr->property);
} else {
@@ -519,7 +518,7 @@ RegClose(
* previous call to RegOpen. */
{
if (regPtr->modified) {
- if (!regPtr->locked && !sendDebug) {
+ if (!regPtr->locked && !localData.sendDebug) {
Tcl_Panic("The name registry was modified without being locked!");
}
XChangeProperty(regPtr->dispPtr->display,
@@ -628,7 +627,7 @@ ValidateName(
result = 1;
}
} else if ((result == Success) && (actualFormat == 8)
- && (actualType == XA_STRING)) {
+ && (actualType == XA_STRING)) {
result = 0;
if (Tcl_SplitList(NULL, property, &argc, &argv) == TCL_OK) {
for (i = 0; i < argc; i++) {
@@ -719,13 +718,12 @@ ServerSecure(
CONST char *
Tk_SetAppName(
- Tk_Window tkwin, /* Token for any window in the application
- * to be named: it is just used to identify
- * the application and the display. */
- CONST char *name) /* The name that will be used to
- * refer to the interpreter in later
- * "send" commands. Must be globally
- * unique. */
+ Tk_Window tkwin, /* Token for any window in the application to
+ * be named: it is just used to identify the
+ * application and the display. */
+ CONST char *name) /* The name that will be used to refer to the
+ * interpreter in later "send" commands. Must
+ * be globally unique. */
{
RegisteredInterp *riPtr, *riPtr2;
Window w;
@@ -831,7 +829,7 @@ Tk_SetAppName(
RegDeleteName(regPtr, actualName);
break;
}
- nextSuffix:
+ nextSuffix:
continue;
}
@@ -1018,7 +1016,7 @@ Tk_SendCmd(
* window in the communication window.
*/
- tkSendSerial++;
+ localData.sendSerial++;
Tcl_DStringInit(&request);
Tcl_DStringAppend(&request, "\0c\0-n ", 6);
Tcl_DStringAppend(&request, destName, -1);
@@ -1027,7 +1025,7 @@ Tk_SendCmd(
sprintf(buffer, "%x %d",
(unsigned int) Tk_WindowId(dispPtr->commTkwin),
- tkSendSerial);
+ localData.sendSerial);
Tcl_DStringAppend(&request, "\0-r ", 4);
Tcl_DStringAppend(&request, buffer, -1);
}
@@ -1058,7 +1056,7 @@ Tk_SendCmd(
* still alive.
*/
- pending.serial = tkSendSerial;
+ pending.serial = localData.sendSerial;
pending.dispPtr = dispPtr;
pending.target = destName;
pending.commWindow = commWindow;
@@ -1132,8 +1130,8 @@ Tk_SendCmd(
ckfree(pending.errorInfo);
}
if (pending.errorCode != NULL) {
- Tcl_Obj *errorObjPtr;
- errorObjPtr = Tcl_NewStringObj(pending.errorCode, -1);
+ Tcl_Obj *errorObjPtr = Tcl_NewStringObj(pending.errorCode, -1);
+
Tcl_SetObjErrorCode(interp, errorObjPtr);
ckfree(pending.errorCode);
}
@@ -1168,11 +1166,8 @@ TkGetInterpNames(
* lookup. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
- char *p, *entry, *entryName;
NameRegistry *regPtr;
- Window commWindow;
- int count;
- unsigned int id;
+ char *p;
/*
* Read the registry property, then scan through all of its entries.
@@ -1180,10 +1175,13 @@ TkGetInterpNames(
*/
regPtr = RegOpen(interp, winPtr->dispPtr, 1);
- for (p = regPtr->property; (p-regPtr->property) < (int) regPtr->propLength; ) {
- entry = p;
+ for (p=regPtr->property ; p-regPtr->property<(int)regPtr->propLength ;) {
+ char *entry = p, *entryName;
+ Window commWindow;
+ unsigned int id;
+
if (sscanf(p, "%x",(unsigned int *) &id) != 1) {
- commWindow = None;
+ commWindow = None;
} else {
commWindow = id;
}
@@ -1205,13 +1203,15 @@ TkGetInterpNames(
Tcl_AppendElement(interp, entryName);
} else {
+ int count;
+
/*
* This name is bogus (perhaps the application died without
* cleaning up its entry in the registry?). Delete the name.
*/
count = regPtr->propLength - (p - regPtr->property);
- if (count > 0) {
+ if (count > 0) {
char *src, *dst;
for (src = p, dst = entry; count > 0; src++, dst++, count--) {
@@ -1360,9 +1360,8 @@ SendEventProc(
propInfo = NULL;
result = XGetWindowProperty(dispPtr->display,
- Tk_WindowId(dispPtr->commTkwin),
- dispPtr->commProperty, 0, MAX_PROP_WORDS, True,
- XA_STRING, &actualType, &actualFormat,
+ Tk_WindowId(dispPtr->commTkwin), dispPtr->commProperty, 0,
+ MAX_PROP_WORDS, True, XA_STRING, &actualType, &actualFormat,
&numItems, &bytesAfter, (unsigned char **) &propInfo);
/*
@@ -1459,7 +1458,9 @@ SendEventProc(
if (!ServerSecure(dispPtr)) {
if (commWindow != None) {
- Tcl_DStringAppend(&reply, "X server insecure (must use xauth-style authorization); command ignored", -1);
+ Tcl_DStringAppend(&reply,
+ "X server insecure (must use xauth-style "
+ "authorization); command ignored", -1);
}
result = TCL_ERROR;
goto returnResult;
@@ -1871,7 +1872,7 @@ UpdateCommWindow(
* A standard Tcl result.
*
* Side effects:
- * Depends on option; see below.
+ * Depends on option; see below.
*
*----------------------------------------------------------------------
*/
@@ -1887,7 +1888,7 @@ TkpTestsendCmd(
TkWindow *winPtr = (TkWindow *) clientData;
if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
+ Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
" option ?arg ...?\"", NULL);
return TCL_ERROR;
}
@@ -1906,7 +1907,7 @@ TkpTestsendCmd(
Window w;
if ((argc != 4) && (argc != 5)) {
- Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
+ Tcl_AppendResult(interp, "wrong # args; must be \"", argv[0],
" prop window name ?value ?\"", NULL);
return TCL_ERROR;
}
@@ -1920,10 +1921,9 @@ TkpTestsendCmd(
propName = Tk_InternAtom((Tk_Window) winPtr, argv[3]);
if (argc == 4) {
property = NULL;
- result = XGetWindowProperty(winPtr->dispPtr->display,
- w, propName, 0, 100000, False, XA_STRING,
- &actualType, &actualFormat, &length,
- &bytesAfter, (unsigned char **) &property);
+ result = XGetWindowProperty(winPtr->dispPtr->display, w, propName,
+ 0, 100000, False, XA_STRING, &actualType, &actualFormat,
+ &length, &bytesAfter, (unsigned char **) &property);
if ((result == Success) && (actualType != None)
&& (actualFormat == 8) && (actualType == XA_STRING)) {
for (p = property; (unsigned long)(p-property) < length; p++) {
@@ -1957,7 +1957,7 @@ TkpTestsendCmd(
} else if (strcmp(argv[1], "serial") == 0) {
char buf[TCL_INTEGER_SPACE];
- sprintf(buf, "%d", tkSendSerial+1);
+ sprintf(buf, "%d", localData.sendSerial+1);
Tcl_SetResult(interp, buf, TCL_VOLATILE);
} else {
Tcl_AppendResult(interp, "bad option \"", argv[1],
@@ -1966,7 +1966,7 @@ TkpTestsendCmd(
}
return TCL_OK;
}
-
+
/*
* Local Variables:
* mode: c
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c
index 6ee1d0b..f97f0ae 100644
--- a/unix/tkUnixWm.c
+++ b/unix/tkUnixWm.c
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tkUnixWm.c,v 1.54 2007/01/05 00:00:53 nijtmans Exp $
+ * RCS: @(#) $Id: tkUnixWm.c,v 1.55 2007/02/27 14:52:57 dkf Exp $
*/
#include "tkPort.h"
@@ -1215,80 +1215,81 @@ WmAspectCmd(
*
* WmSetAttribute --
*
- * Helper routine for WmAttributesCmd. Sets the value
- * of the specified attribute.
+ * Helper routine for WmAttributesCmd. Sets the value of the specified
+ * attribute.
*
* Returns:
*
- * TCL_OK if successful, TCL_ERROR otherwise. In case of an
- * error, leaves a message in the interpreter's result.
+ * TCL_OK if successful, TCL_ERROR otherwise. In case of an error, leaves
+ * a message in the interpreter's result.
*
*----------------------------------------------------------------------
*/
-static int WmSetAttribute(
- TkWindow *winPtr, /* Toplevel to work with */
+
+static int
+WmSetAttribute(
+ TkWindow *winPtr, /* Toplevel to work with */
Tcl_Interp *interp, /* Current interpreter */
WmAttribute attribute, /* Code of attribute to set */
Tcl_Obj *value) /* New value */
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
switch (attribute) {
- case WMATT_ALPHA:
- {
- unsigned long opacity; /* 0=transparent, 0xFFFFFFFF=opaque */
+ case WMATT_ALPHA: {
+ unsigned long opacity; /* 0=transparent, 0xFFFFFFFF=opaque */
- if (TCL_OK != Tcl_GetDoubleFromObj(
- interp, value, &wmPtr->reqState.alpha)) {
- return TCL_ERROR;
- }
- if (wmPtr->reqState.alpha < 0.0) {
- wmPtr->reqState.alpha = 0.0;
- }
- if (wmPtr->reqState.alpha > 1.0) {
- wmPtr->reqState.alpha = 1.0;
- }
+ if (TCL_OK != Tcl_GetDoubleFromObj(interp, value,
+ &wmPtr->reqState.alpha)) {
+ return TCL_ERROR;
+ }
+ if (wmPtr->reqState.alpha < 0.0) {
+ wmPtr->reqState.alpha = 0.0;
+ }
+ if (wmPtr->reqState.alpha > 1.0) {
+ wmPtr->reqState.alpha = 1.0;
+ }
- if (!wmPtr->wrapperPtr) {
- break;
- }
+ if (!wmPtr->wrapperPtr) {
+ break;
+ }
- opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha;
- XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
- Tk_InternAtom((Tk_Window)winPtr, "_NET_WM_WINDOW_OPACITY"),
- XA_CARDINAL, 32, PropModeReplace,
- (unsigned char *)&opacity, 1L);
- wmPtr->attributes.alpha = wmPtr->reqState.alpha;
+ opacity = 0xFFFFFFFFul * wmPtr->reqState.alpha;
+ XChangeProperty(winPtr->display, wmPtr->wrapperPtr->window,
+ Tk_InternAtom((Tk_Window)winPtr, "_NET_WM_WINDOW_OPACITY"),
+ XA_CARDINAL, 32, PropModeReplace,
+ (unsigned char *)&opacity, 1L);
+ wmPtr->attributes.alpha = wmPtr->reqState.alpha;
- break;
+ break;
+ }
+ case WMATT_TOPMOST:
+ if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.topmost)) {
+ return TCL_ERROR;
}
- case WMATT_TOPMOST:
- if (TCL_OK != Tcl_GetBooleanFromObj(
- interp, value, &wmPtr->reqState.topmost)) {
- return TCL_ERROR;
- }
- SetNetWmState(winPtr,
- "_NET_WM_STATE_ABOVE", wmPtr->reqState.topmost);
- break;
- case WMATT_ZOOMED:
- if (TCL_OK != Tcl_GetBooleanFromObj(
- interp, value, &wmPtr->reqState.zoomed)) {
- return TCL_ERROR;
- }
- SetNetWmState(winPtr,
- "_NET_WM_STATE_MAXIMIZED_VERT", wmPtr->reqState.zoomed);
- SetNetWmState(winPtr,
- "_NET_WM_STATE_MAXIMIZED_HORZ", wmPtr->reqState.zoomed);
- break;
- case WMATT_FULLSCREEN:
- if (TCL_OK != Tcl_GetBooleanFromObj(
- interp, value, &wmPtr->reqState.fullscreen)) {
- return TCL_ERROR;
- }
- SetNetWmState(winPtr,
- "_NET_WM_STATE_FULLSCREEN", wmPtr->reqState.fullscreen);
- break;
- case _WMATT_LAST_ATTRIBUTE: /* NOTREACHED */
+ SetNetWmState(winPtr, "_NET_WM_STATE_ABOVE",
+ wmPtr->reqState.topmost);
+ break;
+ case WMATT_ZOOMED:
+ if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.zoomed)) {
return TCL_ERROR;
+ }
+ SetNetWmState(winPtr, "_NET_WM_STATE_MAXIMIZED_VERT",
+ wmPtr->reqState.zoomed);
+ SetNetWmState(winPtr, "_NET_WM_STATE_MAXIMIZED_HORZ",
+ wmPtr->reqState.zoomed);
+ break;
+ case WMATT_FULLSCREEN:
+ if (TCL_OK != Tcl_GetBooleanFromObj(interp, value,
+ &wmPtr->reqState.fullscreen)) {
+ return TCL_ERROR;
+ }
+ SetNetWmState(winPtr, "_NET_WM_STATE_FULLSCREEN",
+ wmPtr->reqState.fullscreen);
+ break;
+ case _WMATT_LAST_ATTRIBUTE: /* NOTREACHED */
+ return TCL_ERROR;
}
return TCL_OK;
}
@@ -1298,29 +1299,32 @@ static int WmSetAttribute(
*
* WmGetAttribute --
*
- * Helper routine for WmAttributesCmd. Returns the current value
- * of the specified attribute.
+ * Helper routine for WmAttributesCmd. Returns the current value of the
+ * specified attribute.
*
* See also: CheckNetWmState().
*
*----------------------------------------------------------------------
*/
-static Tcl_Obj *WmGetAttribute(
- TkWindow *winPtr, /* Toplevel to work with */
+
+static Tcl_Obj *
+WmGetAttribute(
+ TkWindow *winPtr, /* Toplevel to work with */
WmAttribute attribute) /* Code of attribute to get */
{
WmInfo *wmPtr = winPtr->wmInfoPtr;
+
switch (attribute) {
- case WMATT_ALPHA:
- return Tcl_NewDoubleObj(wmPtr->attributes.alpha);
- case WMATT_TOPMOST:
- return Tcl_NewBooleanObj(wmPtr->attributes.topmost);
- case WMATT_ZOOMED:
- return Tcl_NewBooleanObj(wmPtr->attributes.zoomed);
- case WMATT_FULLSCREEN:
- return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
- case _WMATT_LAST_ATTRIBUTE: /*NOTREACHED*/
- break;
+ case WMATT_ALPHA:
+ return Tcl_NewDoubleObj(wmPtr->attributes.alpha);
+ case WMATT_TOPMOST:
+ return Tcl_NewBooleanObj(wmPtr->attributes.topmost);
+ case WMATT_ZOOMED:
+ return Tcl_NewBooleanObj(wmPtr->attributes.zoomed);
+ case WMATT_FULLSCREEN:
+ return Tcl_NewBooleanObj(wmPtr->attributes.fullscreen);
+ case _WMATT_LAST_ATTRIBUTE: /*NOTREACHED*/
+ break;
}
/*NOTREACHED*/
return NULL;
@@ -1340,10 +1344,10 @@ static Tcl_Obj *WmGetAttribute(
* Notes:
*
* Attributes of mapped windows are set by sending a _NET_WM_STATE
- * ClientMessage to the root window (see SetNetWmState).
- * For withdrawn windows, we keep track of the requested attribute
- * state, and set the _NET_WM_STATE property ourselves immediately
- * prior to mapping the window.
+ * ClientMessage to the root window (see SetNetWmState). For withdrawn
+ * windows, we keep track of the requested attribute state, and set the
+ * _NET_WM_STATE property ourselves immediately prior to mapping the
+ * window.
*
* See also: TIP#231, EWMH.
*
@@ -1359,8 +1363,10 @@ WmAttributesCmd(
Tcl_Obj *CONST objv[]) /* Argument objects. */
{
int attribute = 0;
+
if (objc == 3) { /* wm attributes $win */
Tcl_Obj *result = Tcl_NewListObj(0,0);
+
for (attribute = 0; attribute < _WMATT_LAST_ATTRIBUTE; ++attribute) {
Tcl_ListObjAppendElement(interp, result,
Tcl_NewStringObj(WmAttributeNames[attribute], -1));
@@ -1369,19 +1375,19 @@ WmAttributesCmd(
}
Tcl_SetObjResult(interp, result);
return TCL_OK;
- } else if (objc == 4) { /* wm attributes $win -attribute */
+ } else if (objc == 4) { /* wm attributes $win -attribute */
if (Tcl_GetIndexFromObj(interp, objv[3], WmAttributeNames,
"attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp,
- WmGetAttribute(winPtr, attribute));
+ Tcl_SetObjResult(interp, WmGetAttribute(winPtr, attribute));
return TCL_OK;
} else if ((objc - 3) % 2 == 0) { /* wm attributes $win -att value... */
int i;
+
for (i = 3; i < objc; i += 2) {
if (Tcl_GetIndexFromObj(interp, objv[i], WmAttributeNames,
- "attribute", 0, &attribute) != TCL_OK) {
+ "attribute", 0, &attribute) != TCL_OK) {
return TCL_ERROR;
}
if (WmSetAttribute(winPtr,interp,attribute,objv[i+1]) != TCL_OK) {
@@ -1389,11 +1395,10 @@ WmAttributesCmd(
}
}
return TCL_OK;
- } else {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?-attribute ?value ...??");
- return TCL_ERROR;
}
- return TCL_OK;
+
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?-attribute ?value ...??");
+ return TCL_ERROR;
}
/*
@@ -4956,12 +4961,12 @@ UpdateNetWmState(
* spontaneously by the user. The reason for this is that if the user
* resizes the window we take that as an order to ignore geometry
* requests coming from inside the window hierarchy. If we
- * accidentally interpret a response to our request as a
- * user-initiated action, the window will stop responding to new
- * geometry requests. To make this distinction, (a) this function sets
- * a flag for TopLevelEventProc to indicate that we're waiting to sync
- * with the wm, and (b) all changes to the size of a top-level window
- * are followed by calls to this function.
+ * accidentally interpret a response to our request as a user-
+ * initiated action, the window will stop responding to new geometry
+ * requests. To make this distinction, (a) this function sets a flag
+ * for TopLevelEventProc to indicate that we're waiting to sync with
+ * the wm, and (b) all changes to the size of a top-level window are
+ * followed by calls to this function.
* 2. Races and confusion can come about if there are multiple operations
* outstanding at a time (e.g. two different resizes of the top-level
* window: it's hard to tell which of the ConfigureNotify events