diff options
author | Paolo Borelli <pborelli@gnome.org> | 2016-02-27 10:46:59 +0100 |
---|---|---|
committer | Paolo Borelli <pborelli@gnome.org> | 2016-02-27 10:46:59 +0100 |
commit | f73e7680ed1a29be2f13350b29d180ea9cfbcbec (patch) | |
tree | c07f38eb6c4ca040a41fc37a3ae16665e6eeedc5 /gdk/gdkvisual.c | |
parent | 053e549dbccfb5c4155324546e95be91e3f34d39 (diff) | |
download | gtk+-f73e7680ed1a29be2f13350b29d180ea9cfbcbec.tar.gz |
gdk: factor out utility shared among backends
Removes duplicated code and makes sure we use the version which
is safe against infinite loops
Diffstat (limited to 'gdk/gdkvisual.c')
-rw-r--r-- | gdk/gdkvisual.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/gdk/gdkvisual.c b/gdk/gdkvisual.c index 64d1ce09e9..3539e407c7 100644 --- a/gdk/gdkvisual.c +++ b/gdk/gdkvisual.c @@ -467,3 +467,30 @@ gdk_visual_get_screen (GdkVisual *visual) return visual->screen; } + +void +gdk_visual_decompose_mask (gulong mask, + gint *shift, + gint *prec) +{ + *shift = 0; + *prec = 0; + + if (mask == 0) + { + g_warning ("Mask is 0 in visual. Server bug ?"); + return; + } + + while (!(mask & 0x1)) + { + (*shift)++; + mask >>= 1; + } + + while (mask & 0x1) + { + (*prec)++; + mask >>= 1; + } +} |