From 76f7d7bc3c060b261589c45df37cf10c69cde3b9 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 11 Jun 2008 02:22:32 +0200 Subject: properly set the hpos/vpos properties in a locale independant way --- src/canberra-gtk.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/canberra-gtk.c b/src/canberra-gtk.c index 9c290a3..b889768 100644 --- a/src/canberra-gtk.c +++ b/src/canberra-gtk.c @@ -221,10 +221,14 @@ int ca_gtk_proplist_set_for_event(ca_proplist *p, GdkEvent *e) { width = gdk_screen_get_width(gtk_widget_get_screen(w)); height = gdk_screen_get_height(gtk_widget_get_screen(w)); - if ((ret = ca_proplist_setf(p, CA_PROP_EVENT_MOUSE_HPOS, "%0.0f", x/width)) < 0) + /* We use these strange format strings here to avoid that + * libc applies locale information on the formatting of + * floating numbers. */ + + if ((ret = ca_proplist_setf(p, CA_PROP_EVENT_MOUSE_HPOS, "%i.%03i", (int) (x/width), (int) (1000.0*x/width) % 1000)) < 0) return ret; - if ((ret = ca_proplist_setf(p, CA_PROP_EVENT_MOUSE_VPOS, "%0.0f", y/height)) < 0) + if ((ret = ca_proplist_setf(p, CA_PROP_EVENT_MOUSE_VPOS, "%i.%03i", (int) (y/height), (int) (1000.0*y/height) % 1000)) < 0) return ret; } } -- cgit