On 30.09.2010, at 23:12, Ian MacArthur wrote:
> Albrecht Schlosser wrote:
>
>> Yep, I think so too. One click away from your cited article you can
>> find in:
>>
>> http://mail.gnome.org/archives/wm-spec-list/2003-March/msg00067.html
>
>
>> The author has a "Redhat" mail address - I hope he knows what he's
>> talking about. And, after all, it confirms what you (Ian) seemed to
>> remember.
>
> OK - if that's what otaylor says, then we can probably be confident its
> correct... I've encountered his work before, he knows stuff...

OK - and if we trust him, then we must assume that my previous patch
is wrong: it wouldn't work on big-endian machines, and the fact that
it seemed to work on Greg's test box is probably because of good luck
(int's aligned to 8-byte boundaries and the high four bytes (the gap)
being zero).

I'll prepare a better patch with a variant of the SIZEOF_ATOM idea
and post it later (I'm thinking of a static variable to avoid
runtime overhead). Something like the attached patch (untested)
together with some comments explaining why...

Note: The final initialization happens during fl_open_display()
in lines 589/590, and thus we should be able to use it also if
sizeof(Atom) < 4 (but I don't know if this is possible). Do we
have systems where unsigned long can be smaller than 4 bytes?
Better ideas, anybody? Fixing it at 32, maybe?

Albrecht

Index: src/Fl_x.cxx
===================================================================
--- src/Fl_x.cxx        (revision 7709)
+++ src/Fl_x.cxx        (working copy)
@@ -310,6 +310,8 @@
  Atom fl_XaUtf8String;
  Atom fl_XaTextUriList;

+static int atom_bits = 32;
+
  static void fd_callback(int,void *) {
    do_queued_events();
  }
@@ -583,6 +585,9 @@
    fl_XdndURIList        = XInternAtom(d, "text/uri-list",       0);
    fl_XaUtf8String       = XInternAtom(d, "UTF8_STRING",         0);
    fl_XaTextUriList      = XInternAtom(d, "text/uri-list",       0);
+
+  if (sizeof(Atom) < 4)
+    atom_bits = sizeof(Atom) * 8;

    Fl::add_fd(ConnectionNumber(d), POLLIN, fd_callback);

@@ -934,7 +939,7 @@
      if (e.target == TARGETS) {
        Atom a = fl_XaUtf8String; //XA_STRING;
        XChangeProperty(fl_display, e.requestor, e.property,
-                      XA_ATOM, sizeof(Atom)*8, 0, (unsigned char*)&a, 1);
+                      XA_ATOM, atom_bits, 0, (unsigned char*)&a, 1);
      } else if (/*e.target == XA_STRING &&*/ fl_selection_length[clipboard]) {
        XChangeProperty(fl_display, e.requestor, e.property,
                        e.target, 8, 0,

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to