After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 605678 - Screen ruler doesn't show up (alpha plus undecorated)
Screen ruler doesn't show up (alpha plus undecorated)
Status: RESOLVED FIXED
Product: metacity
Classification: Other
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Metacity maintainers list
Metacity maintainers list
Depends on:
Blocks:
 
 
Reported: 2009-12-29 17:08 UTC by nico.bigeard
Modified: 2014-12-20 23:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Work around Xlib 64-bit "specialness" (1.53 KB, patch)
2010-01-21 15:20 UTC, Dan Winship
reviewed Details | Review
Work around Xlib 64-bit "specialness" (9.12 KB, patch)
2010-01-21 19:33 UTC, Dan Winship
needs-work Details | Review
Work around Xlib 64-bit "specialness" (1.66 KB, patch)
2010-01-25 16:08 UTC, Dan Winship
committed Details | Review

Description nico.bigeard 2009-12-29 17:08:28 UTC
Running gnome shell, when i try to launch screen ruler, this one only appear in the Activities Overview. Invisible in any workspace.
Comment 1 nico.bigeard 2009-12-29 17:09:14 UTC
on karmic x64
Comment 2 Dan Winship 2010-01-04 14:44:45 UTC
(this is the screenruler package in fedora)

the problem seems to be the combination of alpha and lack-of-frame. eg:

    window.decorated = false
    window.opacity = 0.85

changing either of those makes it show up.

seems like probably mutter's fault
Comment 3 Dan Winship 2010-01-21 15:20:20 UTC
Created attachment 151944 [details] [review]
Work around Xlib 64-bit "specialness"

When putting 32-bit properties into longs on 64-bit architectures,
XGetWindowProperty assumes the values are supposed to be signed, and
so it sign-extends values greater than 0x7fffffff. So if they *aren't*
supposed to be signed, we need to chop off the high bits ourselves.

(Most CARDINAL-valued properties only end up using small values
anyway, so it doesn't matter, but _NET_WM_WINDOW_OPACITY uses the full
range, and so was previously failing on 64-bit machines.)
Comment 4 Owen Taylor 2010-01-21 15:34:52 UTC
Review of attachment 151944 [details] [review]:

Good job tracking this down. Patch looks workable

a) Seems like an /* X treats format=32 items as signed-longs */ comment would be useful in the code
b) Maybe it would be cleaner to just always do this? It's a no-op on 32-bit systems. Or to change the cardinal-list functions to take/return guint32, in which case this isn't necessary.
c) Might be good to file a metacity bug pointing to this
Comment 5 Dan Winship 2010-01-21 19:33:46 UTC
Created attachment 151961 [details] [review]
Work around Xlib 64-bit "specialness"

new version, returning guint32 rather than gulong from cardinal-related
functions. This is actually messier because we have to remarshal an
array of gulong into array of guint32 form, but APIwise it seems more
correct, so...
Comment 6 Owen Taylor 2010-01-21 20:10:11 UTC
Review of attachment 151961 [details] [review]:

OK, looking at this, I think I preferred the previous patch. Sorry about that. My reasoning here is that it will just be less confusing if Metacity internally follows the XLib conventions, as screwed up as they are, and uses longs for Window, Cardinal, etc. Reading this, I was worried about the variables that changed type being passed to XChangeProperty(); that doesn't happen, but it could happen in the future.

::: src/core/xprops.c
@@ +274,3 @@
+       */
+      for (i = 0; i < results->n_items; i++)
+        dest[i] = src[i];

C pedanticism for the day - not a C language lawyer, but I believe that GCC is allowed that dest and src don't alias each other (because they have different types, and neither is 'char *'), even though they obviously do. So, it could, rewrite the loop, if it wanted to, to say:

 for (i = 0; i + 4 <= results->n_items; i++)
    {
       dest[0] = src[0];
       dest[2] = src[2];
       dest[1] = src[1];
       dest[3] = src[3];
    }
  while (i < results->n_items)
    {
       dest[i] = src[i];
    }

(Maybe the interleaving optimizes memory access patterns or something...)

I think the correct thing to do is:

  union { gulong[1] src, guint32[1] dest } data = (void *)results->prop;
  for (i = 0; i < results->n_items; i++)
    data.dest[i] = data.src[i];

(or add a typedef to avoid the hacky intermediate (void *) cast.)

If I'm right about this, in one of the few cases where strict-aliasing *would* cause a problem, GCC doesn't warn, despite all the false positives it warns about. Well, anyways, if you go with the first patch, this doesn't matter.
Comment 7 Dan Winship 2010-01-25 16:08:22 UTC
Created attachment 152239 [details] [review]
Work around Xlib 64-bit "specialness"

updated version with comment
Comment 8 Dan Winship 2010-01-25 16:08:52 UTC
Comment on attachment 152239 [details] [review]
Work around Xlib 64-bit "specialness"

Attachment 152239 [details] pushed as 5764176 - Work around Xlib 64-bit "specialness"
Comment 9 Dan Winship 2010-01-25 16:10:14 UTC
reassigning to metacity since the same problem exists there. (with the current set of EWMH properties, it's only noticeable with _NET_WM_WINDOW_OPACITY, but it could potentially cause other problems in the future).
Comment 10 Alberts Muktupāvels 2014-12-20 23:47:32 UTC
This problem has been fixed in the development version. The fix will be available in the next major software release. Thank you for your bug report.