From bdb0786dc21dd7ac305129bd1ef8ec7a9bbfc887 Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Mon, 19 Mar 2012 20:49:03 +0000 Subject: [PATCH] Bug #486658: [win32] Cannot use period on decimal keypad in my locale Patch by Sebastien Alborini: On win32, gdk never sends GDK_KP_Decimal, so this key cannot be detected. Work around this by watching the underlying virtual keycode VK_DECIMAL. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@22101 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/gnome-utils/gnc-amount-edit.c | 8 ++++++++ src/register/register-gnome/formulacell-gnome.c | 9 +++++++++ src/register/register-gnome/gnucash-sheet.c | 9 +++++++++ src/register/register-gnome/pricecell-gnome.c | 8 ++++++++ 4 files changed, 34 insertions(+) diff --git a/src/gnome-utils/gnc-amount-edit.c b/src/gnome-utils/gnc-amount-edit.c index 8d5c7e8a8d..fe4b78e7c4 100644 --- a/src/gnome-utils/gnc-amount-edit.c +++ b/src/gnome-utils/gnc-amount-edit.c @@ -43,6 +43,9 @@ #include "gnc-ui-util.h" #include "qof.h" +#ifdef G_OS_WIN32 +# include +#endif /* Signal codes */ enum @@ -154,6 +157,11 @@ gnc_amount_edit_key_press(GtkWidget *widget, GdkEventKey *event) GNCAmountEdit *gae = GNC_AMOUNT_EDIT(widget); gint result; +#ifdef G_OS_WIN32 + /* gdk never sends GDK_KP_Decimal on win32. See #486658 */ + if (event->hardware_keycode == VK_DECIMAL) + event->keyval = GDK_KP_Decimal; +#endif if (event->keyval == GDK_KP_Decimal) { if (gae->print_info.monetary) diff --git a/src/register/register-gnome/formulacell-gnome.c b/src/register/register-gnome/formulacell-gnome.c index 0df9a0e803..d1ac1809bd 100644 --- a/src/register/register-gnome/formulacell-gnome.c +++ b/src/register/register-gnome/formulacell-gnome.c @@ -41,6 +41,10 @@ #include "formulacell-gnome.h" #include "pricecell-gnome.h" +#ifdef G_OS_WIN32 +# include +#endif + //static QofLogModule log_module = GNC_MOD_REGISTER; static @@ -68,6 +72,11 @@ gnc_formula_cell_direct_update( BasicCell *bcell, * this after fixing a bug where one copy was kept up to date, and the * other not. So, fix this. */ +#ifdef G_OS_WIN32 + /* gdk never sends GDK_KP_Decimal on win32. See #486658 */ + if (event->hardware_keycode == VK_DECIMAL) + event->keyval = GDK_KP_Decimal; +#endif switch (event->keyval) { case GDK_Return: diff --git a/src/register/register-gnome/gnucash-sheet.c b/src/register/register-gnome/gnucash-sheet.c index ddf1175b65..ec9ce55b3a 100644 --- a/src/register/register-gnome/gnucash-sheet.c +++ b/src/register/register-gnome/gnucash-sheet.c @@ -45,6 +45,10 @@ #include "split-register.h" #include "gnc-engine.h" // For debugging, e.g. ENTER(), LEAVE() +#ifdef G_OS_WIN32 +# include +#endif + #define DEFAULT_REGISTER_HEIGHT 400 #define DEFAULT_REGISTER_WIDTH 400 /* Used to calculate the minimum preferred height of the register window: */ @@ -1885,6 +1889,11 @@ gnucash_sheet_key_press_event (GtkWidget *widget, GdkEventKey *event) bug#618434 save keyval to handle GDK_KP_Decimal event */ +#ifdef G_OS_WIN32 + /* gdk never sends GDK_KP_Decimal on win32. See #486658 */ + if (event->hardware_keycode == VK_DECIMAL) + event->keyval = GDK_KP_Decimal; +#endif if (sheet->preedit_length) { sheet->shift_state = 0; diff --git a/src/register/register-gnome/pricecell-gnome.c b/src/register/register-gnome/pricecell-gnome.c index 0007540171..ea17ceb5cf 100644 --- a/src/register/register-gnome/pricecell-gnome.c +++ b/src/register/register-gnome/pricecell-gnome.c @@ -37,6 +37,9 @@ #include "pricecell.h" #include "pricecell-gnome.h" +#ifdef G_OS_WIN32 +# include +#endif static gboolean gnc_price_cell_direct_update (BasicCell *bcell, @@ -57,6 +60,11 @@ gnc_price_cell_direct_update (BasicCell *bcell, is_return = FALSE; +#ifdef G_OS_WIN32 + /* gdk never sends GDK_KP_Decimal on win32. See #486658 */ + if (event->hardware_keycode == VK_DECIMAL) + event->keyval = GDK_KP_Decimal; +#endif switch (event->keyval) { case GDK_Return: