aboutsummaryrefslogtreecommitdiff
path: root/doc/nx-X11_vs_XOrg69_patches/NXproperty.c.NX.patch
blob: 7327501ac6e886aa4496a0229e0c621ce532a191 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
--- ./nx-X11/programs/Xserver/hw/nxagent/X/NXproperty.c.X.original	2015-02-13 14:03:44.744441510 +0100
+++ ./nx-X11/programs/Xserver/hw/nxagent/X/NXproperty.c	2015-02-10 19:13:13.772687085 +0100
@@ -1,3 +1,20 @@
+/**************************************************************************/
+/*                                                                        */
+/* Copyright (c) 2001, 2011 NoMachine, http://www.nomachine.com/.         */
+/*                                                                        */
+/* NXAGENT, NX protocol compression and NX extensions to this software    */
+/* are copyright of NoMachine. Redistribution and use of the present      */
+/* software is allowed according to terms specified in the file LICENSE   */
+/* which comes in the source distribution.                                */
+/*                                                                        */
+/* Check http://www.nomachine.com/licensing.html for applicability.       */
+/*                                                                        */
+/* NX and NoMachine are trademarks of Medialogic S.p.A.                   */
+/*                                                                        */
+/* All rights reserved.                                                   */
+/*                                                                        */
+/**************************************************************************/
+
 /* $XFree86: xc/programs/Xserver/dix/property.c,v 3.12 2002/02/19 11:09:22 alanh Exp $ */
 /***********************************************************
 
@@ -58,7 +75,7 @@
 #include "windowstr.h"
 #include "propertyst.h"
 #include "dixstruct.h"
-#include "dispatch.h"
+#include "../../dix/dispatch.h"
 #include "swaprep.h"
 #ifdef XCSECURITY
 #define _SECURITY_SERVER
@@ -69,6 +86,11 @@
 #include "lbxtags.h"
 #endif
 
+#include "Options.h"
+#include "Rootless.h"
+#include "Client.h"
+#include "Windows.h"
+
 #if defined(LBX) || defined(LBX_COMPAT)
 #if 0 /* no header in X11 environment, not used in X11 environment */
 int fWriteToClient(ClientPtr client, int len, char *buf)
@@ -78,6 +100,17 @@
 #endif
 #endif
 
+extern Atom clientCutProperty;
+
+#ifdef NXAGENT_SERVER
+typedef struct
+{
+  CARD32 state;
+  Window icon;
+}
+nxagentWMStateRec;
+#endif
+
 /*****************************************************************
  * Property Stuff
  *
@@ -234,6 +267,15 @@
     totalSize = len * sizeInBytes;
     REQUEST_FIXED_SIZE(xChangePropertyReq, totalSize);
 
+#ifdef NXAGENT_CLIPBOARD
+    {
+       extern WindowPtr nxagentGetClipboardWindow(Atom, WindowPtr);
+
+       pWin = nxagentGetClipboardWindow(stuff->property, NULL);
+    }
+
+    if (pWin == NULL)
+#endif
     pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
 					   SecurityWriteAccess);
     if (!pWin)
@@ -261,6 +303,18 @@
     }
 #endif
 
+#ifdef NXAGENT_ARTSD
+    {
+    /* Do not process MCOPGLOBALS property changes,
+      they are already set reflecting the server side settings.
+      Just return success.
+    */
+      extern Atom mcop_local_atom;
+      if (stuff->property == mcop_local_atom)
+        return client->noClientException;
+    }
+#endif
+
 #ifdef LBX
     err = LbxChangeWindowProperty(client, pWin, stuff->property, stuff->type,
 	 (int)format, (int)mode, len, TRUE, (pointer)&stuff[1], TRUE, NULL);
@@ -271,7 +325,23 @@
     if (err != Success)
 	return err;
     else
-	return client->noClientException;
+    {
+      if (nxagentOption(Rootless) == 1)
+      {
+        nxagentExportProperty(pWin, stuff->property, stuff->type, (int) format,
+                                  (int) mode, len, (pointer) &stuff[1]);
+      }
+
+      nxagentGuessClientHint(client, stuff->property, (char *) &stuff[1]);
+
+      nxagentGuessShadowHint(client, stuff->property);
+
+      #ifdef NX_DEBUG_INPUT
+      nxagentGuessDumpInputInfo(client, stuff->property, (char *) &stuff[1]);
+      #endif
+
+      return client->noClientException;
+    }
 }
 
 int
@@ -289,10 +359,23 @@
     int sizeInBytes;
     int totalSize;
     pointer data;
+    int copySize;
 
     sizeInBytes = format>>3;
     totalSize = len * sizeInBytes;
 
+    copySize = nxagentOption(CopyBufferSize);
+
+    if (copySize != COPY_UNLIMITED && property == clientCutProperty)
+    {
+      if (totalSize > copySize)
+      {
+        totalSize = copySize;
+        totalSize = totalSize - (totalSize % sizeInBytes);
+        len = totalSize / sizeInBytes;
+      }
+    }
+
     /* first see if property already exists */
 
     pProp = wUserProps (pWin);
@@ -491,6 +574,11 @@
 int
 ProcGetProperty(ClientPtr client)
 {
+    #ifdef NXAGENT_SERVER
+    nxagentWMStateRec wmState;
+    nxagentWMStateRec *wmsP = &wmState;
+    #endif
+
     PropertyPtr pProp, prevProp;
     unsigned long n, len, ind;
     WindowPtr pWin;
@@ -498,6 +586,7 @@
     REQUEST(xGetPropertyReq);
 
     REQUEST_SIZE_MATCH(xGetPropertyReq);
+
     if (stuff->delete)
 	UpdateCurrentTime();
     pWin = (WindowPtr)SecurityLookupWindow(stuff->window, client,
@@ -533,6 +622,59 @@
 
     reply.type = X_Reply;
     reply.sequenceNumber = client->sequence;
+
+    #ifdef NXAGENT_SERVER
+
+    /*
+     * Creating a reply for WM_STATE property if it doesn't exist.
+     * This is intended to allow drag & drop work in JAva 1.6 when
+     * the agent is connected to NXWin in multiwindow mode.
+     */
+
+    if (nxagentOption(Rootless) &&
+            nxagentWindowTopLevel(pWin) &&
+                (!pProp) &&
+                    strcmp(NameForAtom(stuff->property), "WM_STATE") == 0)
+    {
+      wmState.state = 1;
+      wmState.icon = None;
+
+      if (ChangeWindowProperty(pWin, stuff->property, stuff->property, 32, 0, 2, &wmState, 1) == Success)
+      {
+        nxagentExportProperty(pWin, stuff->property, stuff->property, 32, 0, 2, &wmState);
+      }
+
+      n = 8;
+      ind = stuff->longOffset << 2;        
+
+      if (n < ind)
+      {
+        client->errorValue = stuff->longOffset;
+        return BadValue;
+      }
+
+      len = min(n - ind, 4 * stuff->longLength);
+
+      reply.bytesAfter = n - (ind + len);
+      reply.length = (len + 3) >> 2;
+
+      reply.format = 32;
+      reply.nItems = len / 4;
+      reply.propertyType = stuff->property;
+
+      WriteReplyToClient(client, sizeof(xGenericReply), &reply);
+
+      if (len)
+      {
+        client->pSwapReplyFunc = (ReplySwapPtr)CopySwap32Write;
+
+        WriteSwappedDataToClient(client, len, (char *)wmsP + ind);
+      }
+
+      return(client->noClientException);
+    }
+    #endif
+
     if (!pProp) 
 	return NullPropertyReply(client, None, 0, &reply);
 
@@ -643,6 +785,126 @@
     return(client->noClientException);
 }
 
+#ifdef NXAGENT_CLIPBOARD
+/* GetWindowProperty clipboard use only */
+int
+GetWindowProperty(pWin, property, longOffset, longLength, delete,
+            type, actualType, format, nItems, bytesAfter, propData )
+    WindowPtr	        pWin;
+    Atom		property;
+    long			longOffset;
+    long			longLength;
+    Bool			delete;
+    Atom		type;
+    Atom		*actualType;
+    int			*format;
+    unsigned long	*nItems;
+    unsigned long	*bytesAfter;
+    unsigned char	**propData;
+{
+    PropertyPtr pProp, prevProp;
+    unsigned long n, len, ind;
+
+    if (!pWin)
+	return BadWindow;
+
+
+    if (!ValidAtom(property))
+    {
+	return(BadAtom);
+    }
+    if ((type != AnyPropertyType) && !ValidAtom(type))
+    {
+	return(BadAtom);
+    }
+
+    pProp = wUserProps (pWin);
+    prevProp = (PropertyPtr)NULL;
+
+    while (pProp)
+    {
+	if (pProp->propertyName == property)
+	    break;
+	prevProp = pProp;
+	pProp = pProp->next;
+    }
+
+
+    if (!pProp)
+	return (BadAtom);
+
+    /* If the request type and actual type don't match. Return the
+    property information, but not the data. */
+
+    if (((type != pProp->type) &&
+	 (type != AnyPropertyType))
+       )
+    {
+	*bytesAfter = pProp->size;
+	*format = pProp->format;
+	*nItems = 0;
+	*actualType = pProp->type;
+	return(Success);
+    }
+
+/*
+ *  Return type, format, value to client
+ */
+    n = (pProp->format/8) * pProp->size; /* size (bytes) of prop */
+    ind = longOffset << 2;
+
+   /* If longOffset is invalid such that it causes "len" to
+	    be negative, it's a value error. */
+
+    if (n < ind)
+    {
+	return BadValue;
+    }
+
+    len = min(n - ind, 4 * longLength);
+
+    *bytesAfter = n - (ind + len);
+    *format = pProp->format;
+    *nItems = len / (pProp->format / 8 );
+    *actualType = pProp->type;
+
+    if (delete && (*bytesAfter == 0))
+    { /* send the event */
+	xEvent event;
+
+	event.u.u.type = PropertyNotify;
+	event.u.property.window = pWin->drawable.id;
+	event.u.property.state = PropertyDelete;
+	event.u.property.atom = pProp->propertyName;
+	event.u.property.time = currentTime.milliseconds;
+	DeliverEvents(pWin, &event, 1, (WindowPtr)NULL);
+    }
+
+    if (len)
+    {
+	 *propData = (unsigned char *)(pProp->data) + ind;
+    }
+
+    if (delete && (*bytesAfter == 0))
+    { /* delete the Property */
+#ifdef LBX
+	if (pProp->tag_id)
+	    TagDeleteTag(pProp->tag_id);
+#endif
+	if (prevProp == (PropertyPtr)NULL) /* takes care of head */
+	{
+	    if (!(pWin->optional->userProps = pProp->next))
+		CheckWindowOptionalNeed (pWin);
+	}
+	else
+	    prevProp->next = pProp->next;
+	xfree(pProp->data);
+	xfree(pProp);
+    }
+    return(Success);
+}
+#endif
+
 int
 ProcListProperties(ClientPtr client)
 {
@@ -727,3 +989,4 @@
     else
 	return(result);
 }
+