Merge branches 'wip/edges', 'mikabox/crap', 'mikabox/lock', 'mikabox/maybe' and ...
[mikachu/openbox.git] / obt / prop.c
1 /* -*- indent-tabs-mode: nil; tab-width: 4; c-basic-offset: 4; -*-
2
3    obt/prop.c for the Openbox window manager
4    Copyright (c) 2006        Mikael Magnusson
5    Copyright (c) 2003-2007   Dana Jansens
6
7    This program is free software; you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation; either version 2 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16
17    See the COPYING file for a copy of the GNU General Public License.
18 */
19
20 #include "obt/prop.h"
21 #include "obt/display.h"
22
23 #include <X11/Xatom.h>
24 #ifdef HAVE_STRING_H
25 #  include <string.h>
26 #endif
27
28 Atom prop_atoms[OBT_PROP_NUM_ATOMS];
29 gboolean prop_started = FALSE;
30
31 #define CREATE_NAME(var, name) (prop_atoms[OBT_PROP_##var] = \
32                                 XInternAtom((obt_display), (name), FALSE))
33 #define CREATE(var) CREATE_NAME(var, #var)
34 #define CREATE_(var) CREATE_NAME(var, "_" #var)
35
36 void obt_prop_startup(void)
37 {
38     if (prop_started) return;
39     prop_started = TRUE;
40
41     g_assert(obt_display);
42
43     CREATE(CARDINAL);
44     CREATE(WINDOW);
45     CREATE(PIXMAP);
46     CREATE(ATOM);
47     CREATE(STRING);
48     CREATE(COMPOUND_TEXT);
49     CREATE(UTF8_STRING);
50
51     CREATE(MANAGER);
52
53     CREATE(WM_COLORMAP_WINDOWS);
54     CREATE(WM_PROTOCOLS);
55     CREATE(WM_STATE);
56     CREATE(WM_CHANGE_STATE);
57     CREATE(WM_DELETE_WINDOW);
58     CREATE(WM_TAKE_FOCUS);
59     CREATE(WM_NAME);
60     CREATE(WM_ICON_NAME);
61     CREATE(WM_CLASS);
62     CREATE(WM_WINDOW_ROLE);
63     CREATE(WM_CLIENT_MACHINE);
64     CREATE(WM_COMMAND);
65     CREATE(WM_CLIENT_LEADER);
66     CREATE(WM_TRANSIENT_FOR);
67     CREATE_(MOTIF_WM_HINTS);
68     CREATE_(MOTIF_WM_INFO);
69
70     CREATE(SM_CLIENT_ID);
71
72     CREATE_(NET_WM_FULL_PLACEMENT);
73
74     CREATE_(NET_SUPPORTED);
75     CREATE_(NET_CLIENT_LIST);
76     CREATE_(NET_CLIENT_LIST_STACKING);
77     CREATE_(NET_NUMBER_OF_DESKTOPS);
78     CREATE_(NET_DESKTOP_GEOMETRY);
79     CREATE_(NET_DESKTOP_VIEWPORT);
80     CREATE_(NET_CURRENT_DESKTOP);
81     CREATE_(NET_DESKTOP_NAMES);
82     CREATE_(NET_ACTIVE_WINDOW);
83 /*    CREATE_(NET_RESTACK_WINDOW);*/
84     CREATE_(NET_WORKAREA);
85     CREATE_(NET_SUPPORTING_WM_CHECK);
86     CREATE_(NET_DESKTOP_LAYOUT);
87     CREATE_(NET_SHOWING_DESKTOP);
88
89     CREATE_(NET_CLOSE_WINDOW);
90     CREATE_(NET_WM_MOVERESIZE);
91     CREATE_(NET_MOVERESIZE_WINDOW);
92     CREATE_(NET_REQUEST_FRAME_EXTENTS);
93     CREATE_(NET_RESTACK_WINDOW);
94
95     CREATE_(NET_STARTUP_ID);
96
97     CREATE_(NET_WM_NAME);
98     CREATE_(NET_WM_VISIBLE_NAME);
99     CREATE_(NET_WM_ICON_NAME);
100     CREATE_(NET_WM_VISIBLE_ICON_NAME);
101     CREATE_(NET_WM_DESKTOP);
102     CREATE_(NET_WM_WINDOW_TYPE);
103     CREATE_(NET_WM_STATE);
104     CREATE_(NET_WM_STRUT);
105     CREATE_(NET_WM_STRUT_PARTIAL);
106     CREATE_(NET_WM_ICON);
107     CREATE_(NET_WM_ICON_GEOMETRY);
108     CREATE_(NET_WM_PID);
109     CREATE_(NET_WM_ALLOWED_ACTIONS);
110     CREATE_(NET_WM_WINDOW_OPACITY);
111     CREATE_(NET_WM_USER_TIME);
112 /*  CREATE_(NET_WM_USER_TIME_WINDOW); */
113     CREATE_(KDE_NET_WM_FRAME_STRUT);
114     CREATE_(NET_FRAME_EXTENTS);
115
116     CREATE_(NET_WM_PING);
117 #ifdef SYNC
118     CREATE_(NET_WM_SYNC_REQUEST);
119     CREATE_(NET_WM_SYNC_REQUEST_COUNTER);
120 #endif
121
122     CREATE_(NET_WM_WINDOW_TYPE_DESKTOP);
123     CREATE_(NET_WM_WINDOW_TYPE_DOCK);
124     CREATE_(NET_WM_WINDOW_TYPE_TOOLBAR);
125     CREATE_(NET_WM_WINDOW_TYPE_MENU);
126     CREATE_(NET_WM_WINDOW_TYPE_UTILITY);
127     CREATE_(NET_WM_WINDOW_TYPE_SPLASH);
128     CREATE_(NET_WM_WINDOW_TYPE_DIALOG);
129     CREATE_(NET_WM_WINDOW_TYPE_NORMAL);
130     CREATE_(NET_WM_WINDOW_TYPE_POPUP_MENU);
131
132     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPLEFT] = 0;
133     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOP] = 1;
134     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_TOPRIGHT] = 2;
135     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_RIGHT] = 3;
136     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMRIGHT] = 4;
137     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOM] = 5;
138     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_BOTTOMLEFT] = 6;
139     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_LEFT] = 7;
140     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE] = 8;
141     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_SIZE_KEYBOARD] = 9;
142     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_MOVE_KEYBOARD] = 10;
143     prop_atoms[OBT_PROP_NET_WM_MOVERESIZE_CANCEL] = 11;
144
145     CREATE_(NET_WM_ACTION_MOVE);
146     CREATE_(NET_WM_ACTION_RESIZE);
147     CREATE_(NET_WM_ACTION_MINIMIZE);
148     CREATE_(NET_WM_ACTION_SHADE);
149     CREATE_(NET_WM_ACTION_MAXIMIZE_HORZ);
150     CREATE_(NET_WM_ACTION_MAXIMIZE_VERT);
151     CREATE_(NET_WM_ACTION_FULLSCREEN);
152     CREATE_(NET_WM_ACTION_CHANGE_DESKTOP);
153     CREATE_(NET_WM_ACTION_CLOSE);
154     CREATE_(NET_WM_ACTION_ABOVE);
155     CREATE_(NET_WM_ACTION_BELOW);
156
157     CREATE_(NET_WM_STATE_MODAL);
158 /*    CREATE_(NET_WM_STATE_STICKY);*/
159     CREATE_(NET_WM_STATE_MAXIMIZED_VERT);
160     CREATE_(NET_WM_STATE_MAXIMIZED_HORZ);
161     CREATE_(NET_WM_STATE_SHADED);
162     CREATE_(NET_WM_STATE_SKIP_TASKBAR);
163     CREATE_(NET_WM_STATE_SKIP_PAGER);
164     CREATE_(NET_WM_STATE_HIDDEN);
165     CREATE_(NET_WM_STATE_FULLSCREEN);
166     CREATE_(NET_WM_STATE_ABOVE);
167     CREATE_(NET_WM_STATE_BELOW);
168     CREATE_(NET_WM_STATE_DEMANDS_ATTENTION);
169
170     prop_atoms[OBT_PROP_NET_WM_STATE_ADD] = 1;
171     prop_atoms[OBT_PROP_NET_WM_STATE_REMOVE] = 0;
172     prop_atoms[OBT_PROP_NET_WM_STATE_TOGGLE] = 2;
173
174     prop_atoms[OBT_PROP_NET_WM_ORIENTATION_HORZ] = 0;
175     prop_atoms[OBT_PROP_NET_WM_ORIENTATION_VERT] = 1;
176     prop_atoms[OBT_PROP_NET_WM_TOPLEFT] = 0;
177     prop_atoms[OBT_PROP_NET_WM_TOPRIGHT] = 1;
178     prop_atoms[OBT_PROP_NET_WM_BOTTOMRIGHT] = 2;
179     prop_atoms[OBT_PROP_NET_WM_BOTTOMLEFT] = 3;
180
181     CREATE_(KDE_WM_CHANGE_STATE);
182     CREATE_(KDE_NET_WM_WINDOW_TYPE_OVERRIDE);
183
184 /*
185     CREATE_NAME(ROOTPMAPId, "_XROOTPMAP_ID");
186     CREATE_NAME(ESETROOTId, "ESETROOT_PMAP_ID");
187 */
188
189     CREATE_(OPENBOX_PID);
190     CREATE_(OB_FOCUS);
191     CREATE_(OB_THEME);
192     CREATE_(OB_CONFIG_FILE);
193     CREATE_(OB_WM_ACTION_UNDECORATE);
194     CREATE_(OB_WM_STATE_UNDECORATED);
195     CREATE_(OB_WM_STATE_LOCKED);
196     CREATE_(OB_LAST_DESKTOP);
197     CREATE_(OB_CONTROL);
198     CREATE_(OB_VERSION);
199     CREATE_(OB_APP_ROLE);
200     CREATE_(OB_APP_TITLE);
201     CREATE_(OB_APP_NAME);
202     CREATE_(OB_APP_CLASS);
203     CREATE_(OB_APP_GROUP_NAME);
204     CREATE_(OB_APP_GROUP_CLASS);
205     CREATE_(OB_APP_TYPE);
206     CREATE_(OB_TARGET_WINDOW);
207 }
208
209 Atom obt_prop_atom(ObtPropAtom a)
210 {
211     g_assert(prop_started);
212     g_assert(a < OBT_PROP_NUM_ATOMS);
213     return prop_atoms[a];
214 }
215
216 static gboolean get_prealloc(Window win, Atom prop, Atom type, gint size,
217                              guchar *data, gulong num)
218 {
219     gboolean ret = FALSE;
220     gint res;
221     guchar *xdata = NULL;
222     Atom ret_type;
223     gint ret_size;
224     gulong ret_items, bytes_left;
225     glong num32 = 32 / size * num; /* num in 32-bit elements */
226
227     res = XGetWindowProperty(obt_display, win, prop, 0l, num32,
228                              FALSE, type, &ret_type, &ret_size,
229                              &ret_items, &bytes_left, &xdata);
230     if (res == Success && ret_items && xdata) {
231         if (ret_size == size && ret_items >= num) {
232             guint i;
233             for (i = 0; i < num; ++i)
234                 switch (size) {
235                 case 8:
236                     data[i] = xdata[i];
237                     break;
238                 case 16:
239                     ((guint16*)data)[i] = ((gushort*)xdata)[i];
240                     break;
241                 case 32:
242                     ((guint32*)data)[i] = ((gulong*)xdata)[i];
243                     break;
244                 default:
245                     g_assert_not_reached(); /* unhandled size */
246                 }
247             ret = TRUE;
248         }
249         XFree(xdata);
250     }
251     return ret;
252 }
253
254 static gboolean get_all(Window win, Atom prop, Atom type, gint size,
255                         guchar **data, guint *num)
256 {
257     gboolean ret = FALSE;
258     gint res;
259     guchar *xdata = NULL;
260     Atom ret_type;
261     gint ret_size;
262     gulong ret_items, bytes_left;
263
264     res = XGetWindowProperty(obt_display, win, prop, 0l, G_MAXLONG,
265                              FALSE, type, &ret_type, &ret_size,
266                              &ret_items, &bytes_left, &xdata);
267     if (res == Success) {
268         if (ret_size == size && ret_items > 0) {
269             guint i;
270
271             *data = g_malloc(ret_items * (size / 8));
272             for (i = 0; i < ret_items; ++i)
273                 switch (size) {
274                 case 8:
275                     (*data)[i] = xdata[i];
276                     break;
277                 case 16:
278                     ((guint16*)*data)[i] = ((gushort*)xdata)[i];
279                     break;
280                 case 32:
281                     ((guint32*)*data)[i] = ((gulong*)xdata)[i];
282                     break;
283                 default:
284                     g_assert_not_reached(); /* unhandled size */
285                 }
286             *num = ret_items;
287             ret = TRUE;
288         }
289         XFree(xdata);
290     }
291     return ret;
292 }
293
294 /*! Get a text property from a window, and fill out the XTextProperty with it.
295   @param win The window to read the property from.
296   @param prop The atom of the property to read off the window.
297   @param tprop The XTextProperty to fill out.
298   @param type 0 to get text of any type, or a value from
299     ObtPropTextType to restrict the value to a specific type.
300   @return TRUE if the text was read and validated against the @type, and FALSE
301     otherwise.
302 */
303 static gboolean get_text_property(Window win, Atom prop,
304                                   XTextProperty *tprop, ObtPropTextType type)
305 {
306     if (!(XGetTextProperty(obt_display, win, tprop, prop) && tprop->nitems))
307         return FALSE;
308     if (!type)
309         return TRUE; /* no type checking */
310     switch (type) {
311     case OBT_PROP_TEXT_STRING:
312     case OBT_PROP_TEXT_STRING_XPCS:
313     case OBT_PROP_TEXT_STRING_NO_CC:
314         return tprop->encoding == OBT_PROP_ATOM(STRING);
315     case OBT_PROP_TEXT_COMPOUND_TEXT:
316         return tprop->encoding == OBT_PROP_ATOM(COMPOUND_TEXT);
317     case OBT_PROP_TEXT_UTF8_STRING:
318         return tprop->encoding == OBT_PROP_ATOM(UTF8_STRING);
319     default:
320         g_assert_not_reached();
321         return FALSE;
322     }
323 }
324
325 /*! Returns one or more UTF-8 encoded strings from the text property.
326   @param tprop The XTextProperty to convert into UTF-8 string(s).
327   @param type The type which specifies the format that the text must meet, or
328     0 to allow any valid characters that can be converted to UTF-8 through.
329   @param max The maximum number of strings to return.  -1 to return them all.
330   @return If max is 1, then this returns a gchar* with the single string.
331     Otherwise, this returns a gchar** of no more than max strings (or all
332     strings read, if max is negative). If an error occurs, NULL is returned.
333  */
334 static void* convert_text_property(XTextProperty *tprop,
335                                    ObtPropTextType type, gint max)
336 {
337     enum {
338         LATIN1,
339         UTF8,
340         LOCALE
341     } encoding;
342     const gboolean return_single = (max == 1);
343     gboolean ok = FALSE;
344     gchar **strlist = NULL;
345     gchar *single[1] = { NULL };
346     gchar **retlist = single; /* single is used when max == 1 */
347     gint i, n_strs;
348
349     /* Read each string in the text property and store a pointer to it in
350        retlist.  These pointers point into the X data structures directly.
351
352        Then we will convert them to UTF-8, and replace the retlist pointer with
353        a new one.
354     */
355     if (tprop->encoding == OBT_PROP_ATOM(COMPOUND_TEXT))
356     {
357         encoding = LOCALE;
358         ok = (XmbTextPropertyToTextList(
359                    obt_display, tprop, &strlist, &n_strs) == Success);
360         if (ok) {
361             if (max >= 0)
362                 n_strs = MIN(max, n_strs);
363             if (!return_single)
364                 retlist = g_new0(gchar*, n_strs+1);
365             if (retlist)
366                 for (i = 0; i < n_strs; ++i)
367                     retlist[i] = strlist[i];
368         }
369     }
370     else if (tprop->encoding == OBT_PROP_ATOM(UTF8_STRING) ||
371              tprop->encoding == OBT_PROP_ATOM(STRING))
372     {
373         gchar *p; /* iterator */
374
375         if (tprop->encoding == OBT_PROP_ATOM(STRING))
376             encoding = LATIN1;
377         else
378             encoding = UTF8;
379         ok = TRUE;
380
381         /* First, count the number of strings. Then make a structure for them
382            and copy pointers to them into it. */
383         p = (gchar*)tprop->value;
384         n_strs = 0;
385         while (p < (gchar*)tprop->value + tprop->nitems) {
386             p += strlen(p) + 1; /* next string */
387             ++n_strs;
388         }
389
390         if (max >= 0)
391             n_strs = MIN(max, n_strs);
392         if (!return_single)
393             retlist = g_new0(gchar*, n_strs+1);
394         if (retlist) {
395             p = (gchar*)tprop->value;
396             for (i = 0; i < n_strs; ++i) {
397                 retlist[i] = p;
398                 p += strlen(p) + 1; /* next string */
399             }
400         }
401     }
402
403     if (!(ok && retlist)) {
404         if (strlist) XFreeStringList(strlist);
405         return NULL;
406     }
407
408     /* convert each element in retlist to UTF-8, and replace it. */
409     for (i = 0; i < n_strs; ++i) {
410         if (encoding == UTF8) {
411             const gchar *end; /* the first byte past the valid data */
412
413             g_utf8_validate(retlist[i], -1, &end);
414             retlist[i] = g_strndup(retlist[i], end-retlist[i]);
415         }
416         else if (encoding == LOCALE) {
417             gsize nvalid; /* the number of valid bytes at the front of the
418                              string */
419             gchar *utf; /* the string converted into utf8 */
420
421             utf = g_locale_to_utf8(retlist[i], -1, &nvalid, NULL, NULL);
422             if (!utf)
423                 utf = g_locale_to_utf8(retlist[i], nvalid, NULL, NULL, NULL);
424             g_assert(utf);
425             retlist[i] = utf;
426         }
427         else { /* encoding == LATIN1 */
428             gsize nvalid; /* the number of valid bytes at the front of the
429                              string */
430             gchar *utf; /* the string converted into utf8 */
431             gchar *p; /* iterator */
432
433             /* look for invalid characters */
434             for (p = retlist[i], nvalid = 0; *p; ++p, ++nvalid) {
435                 /* The only valid control characters are TAB(HT)=9 and
436                    NEWLINE(LF)=10.
437                    This is defined in ICCCM section 2:
438                      http://tronche.com/gui/x/icccm/sec-2.html.
439                    See a definition of the latin1 codepage here:
440                      http://en.wikipedia.org/wiki/ISO/IEC_8859-1.
441                    The above page includes control characters in the table,
442                    which we must explicitly exclude, as the g_convert function
443                    will happily take them.
444                 */
445                 const register guchar c = (guchar)*p; /* unsigned value at p */
446                 if ((c < 32 && c != 9 && c != 10) || (c >= 127 && c <= 160))
447                     break; /* found a control character that isn't allowed */
448
449                 if (type == OBT_PROP_TEXT_STRING_NO_CC && c < 32)
450                     break; /* absolutely no control characters are allowed */
451
452                 if (type == OBT_PROP_TEXT_STRING_XPCS) {
453                     const gboolean valid = (
454                         (c >= 32 && c < 128) || c == 9 || c == 10);
455                     if (!valid)
456                         break; /* strict whitelisting for XPCS */
457                 }
458             }
459             /* look for invalid latin1 characters */
460             utf = g_convert(retlist[i], nvalid, "utf-8", "iso-8859-1",
461                             &nvalid, NULL, NULL);
462             if (!utf)
463                 utf = g_convert(retlist[i], nvalid, "utf-8", "iso-8859-1",
464                                 NULL, NULL, NULL);
465             g_assert(utf);
466             retlist[i] = utf;
467         }
468     }
469
470     if (strlist) XFreeStringList(strlist);
471     if (return_single)
472         return retlist[0];
473     else
474         return retlist;
475 }
476
477 gboolean obt_prop_get32(Window win, Atom prop, Atom type, guint32 *ret)
478 {
479     return get_prealloc(win, prop, type, 32, (guchar*)ret, 1);
480 }
481
482 gboolean obt_prop_get_array32(Window win, Atom prop, Atom type, guint32 **ret,
483                               guint *nret)
484 {
485     return get_all(win, prop, type, 32, (guchar**)ret, nret);
486 }
487
488 gboolean obt_prop_get_text(Window win, Atom prop, ObtPropTextType type,
489                            gchar **ret_string)
490 {
491     XTextProperty tprop;
492     gchar *str;
493     gboolean ret = FALSE;
494
495     if (get_text_property(win, prop, &tprop, type)) {
496         str = (gchar*)convert_text_property(&tprop, type, 1);
497
498         if (str) {
499             *ret_string = str;
500             ret = TRUE;
501         }
502     }
503     XFree(tprop.value);
504     return ret;
505 }
506
507 gboolean obt_prop_get_array_text(Window win, Atom prop,
508                                  ObtPropTextType type,
509                                  gchar ***ret_strings)
510 {
511     XTextProperty tprop;
512     gchar **strs;
513     gboolean ret = FALSE;
514
515     if (get_text_property(win, prop, &tprop, type)) {
516         strs = (gchar**)convert_text_property(&tprop, type, -1);
517
518         if (strs) {
519             *ret_strings = strs;
520             ret = TRUE;
521         }
522     }
523     XFree(tprop.value);
524     return ret;
525 }
526
527 void obt_prop_set32(Window win, Atom prop, Atom type, gulong val)
528 {
529     XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
530                     (guchar*)&val, 1);
531 }
532
533 void obt_prop_set_array32(Window win, Atom prop, Atom type, gulong *val,
534                       guint num)
535 {
536     XChangeProperty(obt_display, win, prop, type, 32, PropModeReplace,
537                     (guchar*)val, num);
538 }
539
540 void obt_prop_set_text(Window win, Atom prop, const gchar *val)
541 {
542     XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8_STRING), 8,
543                     PropModeReplace, (const guchar*)val, strlen(val));
544 }
545
546 void obt_prop_set_array_text(Window win, Atom prop, const gchar *const *strs)
547 {
548     GString *str;
549     gchar const *const *s;
550
551     str = g_string_sized_new(0);
552     for (s = strs; *s; ++s) {
553         str = g_string_append(str, *s);
554         str = g_string_append_c(str, '\0');
555     }
556     XChangeProperty(obt_display, win, prop, OBT_PROP_ATOM(UTF8_STRING), 8,
557                     PropModeReplace, (guchar*)str->str, str->len);
558     g_string_free(str, TRUE);
559 }
560
561 void obt_prop_erase(Window win, Atom prop)
562 {
563     XDeleteProperty(obt_display, win, prop);
564 }
565
566 void obt_prop_message(gint screen, Window about, Atom messagetype,
567                       glong data0, glong data1, glong data2, glong data3,
568                       glong data4, glong mask)
569 {
570     obt_prop_message_to(obt_root(screen), about, messagetype,
571                         data0, data1, data2, data3, data4, mask);
572 }
573
574 void obt_prop_message_to(Window to, Window about,
575                          Atom messagetype,
576                          glong data0, glong data1, glong data2, glong data3,
577                          glong data4, glong mask)
578 {
579     XEvent ce;
580     ce.xclient.type = ClientMessage;
581     ce.xclient.message_type = messagetype;
582     ce.xclient.display = obt_display;
583     ce.xclient.window = about;
584     ce.xclient.format = 32;
585     ce.xclient.data.l[0] = data0;
586     ce.xclient.data.l[1] = data1;
587     ce.xclient.data.l[2] = data2;
588     ce.xclient.data.l[3] = data3;
589     ce.xclient.data.l[4] = data4;
590     XSendEvent(obt_display, to, FALSE, mask, &ce);
591 }