Author Topic: Shift doesn't work in keyboard shortcuts  (Read 17523 times)

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Shift doesn't work in keyboard shortcuts
« on: July 30, 2012, 05:38:17 pm »
Using Code::Blocks svn 8164 (from jenslody.de Debian repository) on Ubuntu (Fluxbox / Unity), amd64. Same problem happened with older codeblocks from ubuntu repository.

For some weird reason, the Shift key seems to be ignored in some (?) keyboard shortcuts. SHIFT+F2 beheaves like F2, CTRL+SHIFT+F9 like CTRL+F9, etc.

This only happens with keyboard shortcuts. I can type capital letters using SHIFT, I can cycle through tabs backwards with CTRL+SHIFT+Tab. SHIFT does work in some shortcuts. For example following work correctly:
CTRL+SHIFT+Z (Redo),
CTRL+SHIFT+C (comment selected)
CTRL+SHIFT+S (save all files)
CTRL+SHIFT+F4 (close all files)
CTRL+SHIFT+F (find in files)

But following shortcuts beheave as if SHIFT was not pressed:

SHIFT+F2 (toggle Manager window)
SHIFT+F3 (Find Previous)
CTRL+SHIFT+F9 (Compile current file)
SHIFT+F8 (Stop debugger)

Issuing corresponding command from menu does work.

I haven't noticed similar issue with Shift key in any other application, including wxwidgets based applications. This seems to be related to some custom shortcut handling in C::B.

I have tried running codeblocks with default settings (deleted ~/.codeblocks), but it didn't help.

If there's anything else I can try, please let me know.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Shift doesn't work in keyboard shortcuts
« Reply #1 on: July 30, 2012, 05:52:49 pm »
Not a C::B problem. It is a global gtk/xkeyboard-config problem. And it happens with xkeyboard-config 2.4+ if I remember correctly.
It is pretty annoying problem, but I have no time to dig it further.
Please report it to the Ubuntu maintainers, so they can report it upstream to xkeyboard-config maintainers.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Shift doesn't work in keyboard shortcuts
« Reply #2 on: July 30, 2012, 06:00:26 pm »
Is this a known problem? Have you looked into this in past? Do you have any additional information? Any other application where this problem manifests?

I strongly doubt Ubuntu maintainers would agree this is not a C::B problem without further info.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Shift doesn't work in keyboard shortcuts
« Reply #3 on: July 30, 2012, 06:11:47 pm »
I've compiled the one of the wx samples, defined a shortcut with a shift in it (shift+f3 I think) and it has not been triggered.
So the sample has the same problem. I've not tried to make a pure gtk application to see if the problem is there, but I think
it will because this problem is X/system wide.

I'm on gentoo and when I was able to downgrade to the last 2.3.x release of xkeyboard-config package it fixed the problem,
unfortunately I'm no longer able to downgrade, so I suffer a lot with this problem.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Shift doesn't work in keyboard shortcuts
« Reply #4 on: July 30, 2012, 07:11:58 pm »
Which sample specifically, and how did you modify it? I couldn't reproduce this problem. I tried to modify menu accelerator to Shift-F2 and Shift-F3 in "menu" sample, and checked events reported by "keyboard" sample in both wx-2.8 and wx-2.9.1, and they all worked correctly.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Shift doesn't work in keyboard shortcuts
« Reply #5 on: July 30, 2012, 07:45:57 pm »
Which sample specifically, and how did you modify it? I couldn't reproduce this problem. I tried to modify menu accelerator to Shift-F2 and Shift-F3 in "menu" sample, and checked events reported by "keyboard" sample in both wx-2.8 and wx-2.9.1, and they all worked correctly.

In your test, were F2 and F3 bound to something as well? Does the problem only occur for function keys where the key is bound with & without the shift?
« Last Edit: July 30, 2012, 08:41:20 pm by dmoore »

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Shift doesn't work in keyboard shortcuts
« Reply #6 on: July 30, 2012, 08:04:10 pm »
You are correct. After I added both shift and non-shift accelerators for same key, the shift version stopped working.

Here is pure GTK example demonstrating the problem (hacked from some tutorial I found online):

Code
/* build with: gcc file.c $(pkg-config gtk+-2.0 --cflags --libs) */
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>

int main( int argc, char *argv[])
{
  GtkWidget *window, *vbox, *menubar, *filemenu, *file, *nop, *quit;
  GtkAccelGroup *accel_group = NULL;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
  gtk_window_set_default_size(GTK_WINDOW(window), 250, 200);
  gtk_window_set_title(GTK_WINDOW(window), "menu");

  vbox = gtk_vbox_new(FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), vbox);

  menubar = gtk_menu_bar_new();
  filemenu = gtk_menu_new();

  accel_group = gtk_accel_group_new();
  gtk_window_add_accel_group(GTK_WINDOW(window), accel_group);

  file = gtk_menu_item_new_with_mnemonic("_File");
  nop = gtk_image_menu_item_new_from_stock(GTK_STOCK_NEW, NULL);
  quit = gtk_image_menu_item_new_from_stock(GTK_STOCK_QUIT, NULL);

  gtk_widget_add_accelerator(nop, "activate", accel_group,
      GDK_F3, 0, GTK_ACCEL_VISIBLE);
  gtk_widget_add_accelerator(quit, "activate", accel_group,
      GDK_F3, GDK_SHIFT_MASK, GTK_ACCEL_VISIBLE);

  gtk_menu_item_set_submenu(GTK_MENU_ITEM(file), filemenu);
  gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), nop);
  gtk_menu_shell_append(GTK_MENU_SHELL(filemenu), quit);
  gtk_menu_shell_append(GTK_MENU_SHELL(menubar), file);
  gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 3);

  g_signal_connect_swapped(G_OBJECT(window), "destroy",
      G_CALLBACK(gtk_main_quit), NULL);

  g_signal_connect(G_OBJECT(quit), "activate",
      G_CALLBACK(gtk_main_quit), NULL);

  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}

Shift-F3 should quit the application, but it doesn't because of existing F3 accelerator. If you change it to Shift-F4, or remove the F3 accelerator, it works.
« Last Edit: July 30, 2012, 08:20:19 pm by vid512 »

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Shift doesn't work in keyboard shortcuts
« Reply #7 on: July 30, 2012, 08:49:26 pm »
If you register Shift-F3, but not F3, then press F3 without Shift does the Shift-F3 handler register the keypress?

Offline vid512

  • Multiple posting newcomer
  • *
  • Posts: 36
Re: Shift doesn't work in keyboard shortcuts
« Reply #8 on: July 30, 2012, 08:59:22 pm »
Yes, it does.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Shift doesn't work in keyboard shortcuts
« Reply #9 on: July 30, 2012, 10:15:30 pm »
Looks like this problem was reported on Arch:

https://bugs.archlinux.org/task/26414

However, I suspect the proposed fix does not solve this problem as it appears these changes made it into ubuntu. This also affects gnome terminal. I reported a bug against xkeyboard-config in launchpad:

https://bugs.launchpad.net/ubuntu/+source/xkeyboard-config/+bug/1031062

and might send it upstream too depending on the response.

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Shift doesn't work in keyboard shortcuts
« Reply #10 on: July 30, 2012, 11:02:15 pm »
It looks like the bug is actually in GTK+

https://bugzilla.gnome.org/show_bug.cgi?id=661973