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 111269 - Typing fast causes number transposing
Typing fast causes number transposing
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Rich Burridge
Rich Burridge
Depends on:
Blocks:
 
 
Reported: 2003-04-21 15:14 UTC by Steve Fox
Modified: 2004-12-22 21:47 UTC
See Also:
GNOME target: ---
GNOME version: 2.3/2.4


Attachments
Simple Gtk program that seems to replicate the problem. (1.58 KB, text/plain)
2003-04-23 17:53 UTC, Rich Burridge
Details
Proposed fix. (50.16 KB, text/plain)
2003-04-24 20:56 UTC, Rich Burridge
Details
Proposed fix - take 2 - with Solaris numpad keysyms added. (52.72 KB, text/plain)
2003-04-25 15:25 UTC, Rich Burridge
Details

Description Steve Fox 2003-04-21 15:14:38 UTC
If you enter numbers in at a very fast rate, gcalctool will transpose the
numbers. Simply typing 3, then 4 immediately after will display '43'. This
can happen at any point. Typing 31415 yielded 31145 because I typed the 4
faster than the first 1.
Comment 1 Rich Burridge 2003-04-21 19:19:02 UTC
I'm not seeing this problem at all. Which version of 
gcalctool are you using (Help->About will give you this)?
Comment 2 Steve Fox 2003-04-21 19:56:56 UTC
I just knew I was going to forget the version information. Doh!

I'm using gcalctool 4.2.77 on Mandrake Linux Cooker.
Comment 3 Rich Burridge 2003-04-23 16:35:04 UTC
Okay, I've managed to replicate this problem now.
Investigating...
Comment 4 Rich Burridge 2003-04-23 17:11:55 UTC
Adding Dennis to the cc: list for his thoughts.

I added the following debug line:

Index: gtk.c
===================================================================
RCS file: /cvs/gnome/gcalctool/gcalctool/gtk.c,v
retrieving revision 1.82
diff -u -r1.82 gtk.c
--- gtk.c	15 Apr 2003 20:02:29 -0000	1.82
+++ gtk.c	23 Apr 2003 17:04:50 -0000
@@ -516,6 +516,7 @@
	struct button *n;

     n = (struct button *) g_object_get_data(G_OBJECT(widget), "button");
+/**/fprintf(stderr, "bp: n: %c\n", n->func_char);
	if (v->pending) {
	 if (v->current != NULL) {
             free(v->current);

and when compiled and run, and with me alternately
typing "1" and "2" continuously as fast as I can, I get:

% ./gcalctool
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 2
bp: n: 1
bp: n: 2
bp: n: 1
...

It's frightenly consistent. Now this seems to be
showing me that my callback is getting called in the
wrong order (i.e. the problem is lower down in Gtk/gdk).

This seems such a fundemental thing, that I suspect my
conclusion is incorrect.
Comment 5 Rich Burridge 2003-04-23 17:53:13 UTC
Created attachment 15946 [details]
Simple Gtk program that seems to replicate the problem.
Comment 6 Rich Burridge 2003-04-23 17:54:28 UTC
Steve, I've attached a small Gtk+ example
application that seems to replicate the problem.
Could you try it please and give me your feedback?

Thanks.
Comment 7 Rich Burridge 2003-04-23 18:16:44 UTC
Just chatted with Owen on IRC. His comments:

"It's conceivable that the calculator should just 
 connect to key_press_event on the toplevel and go 
 from there.

 If I had to guess about what's causing the misordering, 
 it's the code that:

 a) makes the button depress as long as the key 
    is down (with a timeout if it doesnt' get the key release) 
 b) fires ::clicked when the button pops up

 b) has to happen because otherwise, say, for a close button, 
    you won't see the button press then release.

So, just catching key_press wouldn't have that problem.

It's conceivable that we could record timestamps for the key 
press, and queue up activate to occur in that order for 
multiple accelerators happening in a row, but it would be 
pretty funky and specialized."
Comment 8 Rich Burridge 2003-04-23 22:54:02 UTC
I'm close to a fix for this. Just need to fixup the 
numeric keypad (to work on both Solaris and Linux).
More hopefully tomorrow.
Comment 9 Rich Burridge 2003-04-24 16:07:15 UTC
Well the numeric keypad is a mess because depending
upon the keyboard and the O/S, it's possible to get
back a variety of alternatives for the same key
(GDK_KP_End, GDK_End and GDK_KP_1 all for the number
1 for example).

Because of this, I think I'm going to end up adopting
a similar coding approach to the gcalc application,
where it stores potential alternates for each "button"
as part of the button structure.
Comment 10 Rich Burridge 2003-04-24 20:56:15 UTC
Created attachment 15993 [details]
Proposed fix.
Comment 11 Rich Burridge 2003-04-24 20:59:01 UTC
I've attached a set of diffs for latest CVS gcalctool
that'll hopefully fix the original problem, and also
provide a cleaner more extensible setup for adding
extra key alternatives for the various buttons (if
ever needed).

Steve could you give it a try and let me know if it
fixes the problem please? Dennis, could you give it a
lookover too please, as this is a big change (i.e. it
affects virtually every function that gcalctool does).

Thanks.
Comment 12 Steve Fox 2003-04-24 21:58:57 UTC
Looks good so far! I haven't been able to trip it up yet. 

Sorry I didn't get to testing that earlier patch. Work has had me tied
up this week.

Thanks!
Comment 13 Rich Burridge 2003-04-25 00:05:19 UTC
I found one more slight adjustment that needs to be made
in the handle_menu_selection() function in graphics.c,
about line 35:

if (IS_KEY(v->pending, KEY_LPAR.value)) {   /* Inside parentheses? */

should be:

if (IS_KEY(v->pending, KEY_LPAR.value[0])) {  /* Inside parentheses? */

I'll make sure that gets in the fix that's checked back.
Apart from that, I think it's looking pretty good.
Comment 14 Rich Burridge 2003-04-25 15:25:33 UTC
Created attachment 16007 [details]
Proposed fix - take 2 - with Solaris numpad keysyms added.
Comment 15 Rich Burridge 2003-04-25 15:28:32 UTC
Seems like the keysyms on Solaris are different then
Linux (silly me), so I've added those in as alternates
where needed. Adding the updated diffs here just in
case we ever need 'em.

I'm considering this bug fixed now, so I've checked in
the changes.

Fixed in v4.2.83.
Comment 16 Steve Fox 2003-04-25 17:51:16 UTC
Thanks much Rich.