summaryrefslogtreecommitdiff
path: root/xc
diff options
context:
space:
mode:
authorconverse <empty>1995-06-23 22:36:25 +0000
committerconverse <empty>1995-06-23 22:36:25 +0000
commitd9a8e0582d8630b1644d27504c9bd2b92012fd1a (patch)
tree3980289297b77834a9932591fcb048090bd96de0 /xc
parentc7ae9d3c9e4ad5a7d96d69bcc0e2a60f740bc4be (diff)
Reimplement XtGetSelectionParameters. Find the appropriate property
and the requestor's window through the Request record, either passed (if the owner is incremental) or discovered through the owner's Select context. Reuse code from XtGetSelectionRequest. Assume the owner is not dispatching from the conversion procedure in referencing the Request record through the owner context record. #7028 No need for the requestor to wrap calls to set a property on its own window with an error handler.
Diffstat (limited to 'xc')
-rw-r--r--xc/lib/Xt/Selection.c103
1 files changed, 58 insertions, 45 deletions
diff --git a/xc/lib/Xt/Selection.c b/xc/lib/Xt/Selection.c
index 286583c60..1c9f3762f 100644
--- a/xc/lib/Xt/Selection.c
+++ b/xc/lib/Xt/Selection.c
@@ -1,4 +1,4 @@
-/* $XConsortium: Selection.c,v 1.98 95/05/10 21:23:58 kaleb Exp converse $ */
+/* $XConsortium: Selection.c,v 1.100 95/06/23 22:04:24 converse Exp $ */
/***********************************************************
Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
@@ -669,9 +669,7 @@ XtPointer value;
unsigned long length;
int format;
{
- req->requestor = window;
req->type = targetType;
- req->property = property;
req->value = value;
req->bytelength = BYTELENGTH(length,format);
req->format = format;
@@ -711,6 +709,8 @@ Widget widget; /* physical owner (receives events) */
req->ctx = ctx;
req->event = *event;
+ req->property = property;
+ req->requestor = event->requestor;
if (timestamp_target) {
value = XtMalloc(sizeof(long));
@@ -752,9 +752,7 @@ Widget widget; /* physical owner (receives events) */
if (! timestamp_target) {
if (ctx->notify != NULL) {
req->target = target;
- req->property = property;
req->widget = widget;
- req->requestor = event->requestor;
req->allSent = TRUE;
#ifndef DEBUG_WO_TIMERS
{
@@ -1426,8 +1424,10 @@ Atom property;
Atom resulttype;
unsigned long totallength = 0;
+ req->event.type = 0;
req->event.target = target;
- req->event.property = property;
+ req->event.property = req->property = property;
+ req->event.requestor = req->requestor = XtWindow(widget);
if (ctx->incremental) {
unsigned long size = MAX_SELECTION_INCR(ctx->dpy);
@@ -1533,8 +1533,6 @@ Atom property;
RequestRec req;
ctx->req = &req;
req.ctx = ctx;
- req.event.type = 0;
- req.event.requestor = XtWindow(widget);
req.event.time = time;
ctx->ref_count++;
DoLocalTransfer(&req, selection, target, widget,
@@ -1636,8 +1634,6 @@ Atom *properties;
RequestRec req;
ctx->req = &req;
req.ctx = ctx;
- req.event.type = 0;
- req.event.requestor = XtWindow(widget);
req.event.time = time;
ctx->ref_count++;
for (i = 0, j = 0; count; count--, i++, j++ ) {
@@ -1758,16 +1754,14 @@ Time time;
}
-XSelectionRequestEvent *XtGetSelectionRequest( widget, selection, id )
+static Request GetRequestRecord(widget, selection, id)
Widget widget;
Atom selection;
XtRequestId id;
{
Request req = (Request)id;
- Select ctx;
- XtAppContext app = XtWidgetToApplicationContext (widget);
+ Select ctx = NULL;
- LOCK_APP(app);
if ( (req == NULL
&& ((ctx = FindCtx( XtDisplay(widget), selection )) == NULL
|| ctx->req == NULL
@@ -1780,25 +1774,40 @@ XSelectionRequestEvent *XtGetSelectionRequest( widget, selection, id )
{
String params = XtName(widget);
Cardinal num_params = 1;
- XtAppWarningMsg(app,
+ XtAppWarningMsg(XtWidgetToApplicationContext(widget),
"notInConvertSelection", "xtGetSelectionRequest",
XtCXtToolkitError,
- "XtGetSelectionRequest called for widget \"%s\" outside of ConvertSelection proc",
+ "XtGetSelectionRequest or XtGetSelectionParameters called for widget \"%s\" outside of ConvertSelection proc",
&params, &num_params
);
- UNLOCK_APP(app);
return NULL;
}
if (req == NULL) {
/* non-incremental owner; only one request can be
* outstanding at a time, so it's safe to keep ptr in ctx */
-#ifdef lint
- ctx = NULL;
-#endif
req = ctx->req;
}
+ return req;
+}
+
+XSelectionRequestEvent *XtGetSelectionRequest(widget, selection, id)
+ Widget widget;
+ Atom selection;
+ XtRequestId id;
+{
+ Request req = (Request)id;
+ WIDGET_TO_APPCON(widget);
+
+ LOCK_APP(app);
+
+ req = GetRequestRecord(widget, selection, id);
+ if (! req) {
+ UNLOCK_APP(app);
+ return (XSelectionRequestEvent*) NULL;
+ }
+
if (req->event.type == 0) {
/* owner is local; construct the remainder of the event */
req->event.type = SelectionRequest;
@@ -1806,11 +1815,7 @@ XSelectionRequestEvent *XtGetSelectionRequest( widget, selection, id )
req->event.send_event = True;
req->event.display = XtDisplay(widget);
req->event.owner = XtWindow(req->ctx->widget);
- /* req->event.requestor = XtWindow(requesting_widget); */
req->event.selection = selection;
- /* req->event.target = requestors_target; */
- /* req->event.property = None; *//* %%% what to do about side-effects? */
- /* req->event.time = requestors_time; */
}
UNLOCK_APP(app);
return &req->event;
@@ -2141,11 +2146,9 @@ void XtSetSelectionParameters(requestor, selection, type, value, length, format)
AddParamInfo(requestor, selection, property);
}
- StartProtectedSection(dpy, window);
XChangeProperty(dpy, window, property,
type, format, PropModeReplace,
(unsigned char *) value, length);
- EndProtectedSection(dpy);
}
/* Retrieves data passed in a parameter. Data for this is stored
@@ -2160,27 +2163,37 @@ void XtGetSelectionParameters(owner, selection, request_id, type_return,
unsigned long* length_return;
int* format_return;
{
- Display *dpy = XtDisplay(owner);
- XSelectionRequestEvent *xselevent =
- XtGetSelectionRequest(owner, selection, request_id);
- unsigned long max = XMaxRequestSize(dpy);
- unsigned long dummy;
-
- if (xselevent->property != None) {
- StartProtectedSection(dpy, XtWindow(owner));
- XGetWindowProperty(dpy, xselevent->requestor,
- xselevent->property,
- 0, max, False, AnyPropertyType,
- type_return, format_return,
- length_return, &dummy,
- (unsigned char**) value_return);
- EndProtectedSection(dpy);
- } else {
+ Request req;
+ Display *dpy = XtDisplay(owner);
+ WIDGET_TO_APPCON(owner);
+
*value_return = NULL;
- *length_return = 0;
- *format_return = 0;
+ *length_return = *format_return = 0;
*type_return = None;
- }
+
+ LOCK_APP(app);
+
+ req = GetRequestRecord(owner, selection, request_id);
+
+ if (req && req->property) {
+ unsigned long bytes_after; /* unused */
+ StartProtectedSection(dpy, req->requestor);
+ XGetWindowProperty(dpy, req->requestor, req->property, 0L, 10000000,
+ False, AnyPropertyType, type_return, format_return,
+ length_return, &bytes_after,
+ (unsigned char**) value_return);
+ EndProtectedSection(dpy);
+#ifdef XT_COPY_SELECTION
+ if (*value_return) {
+ int size = BYTELENGTH(*length_return, *format_return) + 1;
+ char *tmp = XtMalloc((Cardinal) size);
+ (void) memmove(tmp, *value_return, size);
+ XFree(*value_return);
+ *value_return = tmp;
+ }
+#endif
+ }
+ UNLOCK_APP(app);
}
/* Parameters are temporarily stashed in an XContext. A list is used because