! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
[PATCH] Disable touchpad while typing Duration doesn't work properly with som...
Status:
RESOLVED: FIXED
Product:
Xfce4-settings
Component:
Xfsettingsd

Comments

Description Adel Belhouane 2015-05-16 20:02:45 CEST
Created attachment 6253 
force using a period as decimal separator in xfsettingsd

since the new feature added after bug 8948, we can now choose the duration of the touchpad disable time, but xfsettingd doesn't handle properly the comma "," separator used instead of a period "." in many European languages, and runs syndaemon with an incorrect value for option "-i" .

the problem is that xfsettingd uses this in pointers.c around line 354:
g_snprintf (disable_duration_string, sizeof (disable_duration_string),"%.1f", disable_duration);

g_snprintf follows "locale" rules. So with my locale fr_FR.utf8, the decimal separator is a comma "," not a period "." . I can now see in my process list:
syndaemon -i 1,4 -K -R
instead of:
syndaemon -i 1.4 -K -R

I think it accepts the input but will truncate it to 1s

If I go below 1s, syndaemon doesn't run. Indeed at hand:
syndaemon -i 0,4 -K -R
doesn't work.

I can see different ways to fix this bug, maybe I missed a simpler way:
1 - use setlocale() immediately before and after g_snprintf, but setlocale() isn't even thread-safe and on my system xfsettingsd uses 3 threads.
2 - consider xfsettingsd doesn't ever use any other language and never enable locales. I think gtk_disable_setlocale() at start in main.c or before gtk_init_check() would do it.
3 - do a trade-off and use just once setlocale(LC_NUMERIC,"C") right after gtk_init_check() in main.c (gtk_init_check() calls setlocale(LC_ALL,"") )
4 - consider xfsettingsd might display other languages someday in some threads and use thread-safe functions: newlocale() / duplocale() but on glibc at least there's a change and its effects to consider (seems it requires #define _XOPEN_SOURCE 700 in sources)


Here's a trivial patch using option 3 (see attachment).

With this patch syndaemon receives the correct "-i 0.4" instead of "-i 0,4" with my French locale fr_FR.utf8 when I set the duration to 0.4s (still displayed correctly in French as "0,4s" by xfce4-mouse-settings)
Comment 1 Git Bot editbugs 2018-09-01 02:20:47 CEST
Sean Davis referenced this bugreport in commit 1f8480dd241164e6b0953f1065a304725371949c

Force using a period as a decimal separator in xfsettingsd (thanks Adel) (bug 11906)

https://git.xfce.org/xfce/xfce4-settings/commit?id=1f8480dd241164e6b0953f1065a304725371949c
Comment 2 Sean Davis editbugs 2018-09-01 02:21:37 CEST
Thanks for the bug report and patch! I've applied your changes to the above commit.

Bug #11906

Reported by:
Adel Belhouane
Reported on: 2015-05-16
Last modified on: 2018-09-01

People

Assignee:
Nick Schermer
CC List:
4 users

Version

Version:
4.12.0

Attachments

Additional information