Login
Log in using an SSO provider:
Fedora Account System
Red Hat Associate
Red Hat Customer
Login using a Red Hat Bugzilla account
Forgot Password
Create an Account
Red Hat Bugzilla – Attachment 134941 Details for
Bug 201176
Key shortcuts set in capplet for next/prev song, start/stop playing don't work
Home
New
Search
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh92 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
[?]
This site requires JavaScript to be enabled to function correctly, please enable it.
testaccel.c
testaccel.c (text/x-csrc), 7.98 KB, created by
Matthias Clasen
on 2006-08-25 17:42:30 UTC
(
hide
)
Description:
testaccel.c
Filename:
MIME Type:
Creator:
Matthias Clasen
Created:
2006-08-25 17:42:30 UTC
Size:
7.98 KB
patch
obsolete
>#include <gtk/gtk.h> >#include <gdk/gdkx.h> >#include <X11/XKBlib.h> > >static void >dump_controls (void) >{ > Display *display; > XkbDescPtr xkb; > gint pcf; > > display = gdk_x11_get_default_xdisplay (); > xkb = XkbGetMap (display, XkbModifierMapMask | XkbVirtualModsMask, XkbUseCoreKbd); > XkbGetNames (display, XkbGroupNamesMask | XkbVirtualModNamesMask, xkb); > XkbGetControls (display, XkbAllControlsMask, xkb); > XkbGetPerClientControls (display, &pcf); > > g_print ("internal: effective %#x, real %#x, virtual %#x\n", > xkb->ctrls->internal.mask, > xkb->ctrls->internal.real_mods, > xkb->ctrls->internal.vmods); > g_print ("ignore_lock: effective %#x, real %#x, virtual %#x\n", > xkb->ctrls->ignore_lock.mask, > xkb->ctrls->ignore_lock.real_mods, > xkb->ctrls->ignore_lock.vmods); > g_print ("enabled_ctrls: %#x\n", xkb->ctrls->enabled_ctrls); > g_print ("ignore group lock: %d\n", (xkb->ctrls->enabled_ctrls & XkbIgnoreGroupLockMask) != 0); > g_print ("per-client controls: %#x\n", pcf); > g_print ("detectable autorepeat: %d\n", (pcf & XkbPCF_DetectableAutoRepeatMask) != 0); > g_print ("grabs use xkb state: %d\n", (pcf & XkbPCF_GrabsUseXKBStateMask) != 0); > g_print ("auto reset: %d\n", (pcf & XkbPCF_AutoResetControlsMask) != 0); > g_print ("lookup state when grabbed: %d\n", (pcf & XkbPCF_LookupStateWhenGrabbed) != 0); > g_print ("SendEvent uses XKB state: %d\n", (pcf & XkbPCF_SendEventUsesXKBState) != 0); > > XkbFreeKeyboard (xkb, XkbAllComponentsMask, True); >} > >/* Toggle some XKB controls that make the server ignore > * some locked modifiers and group switches when resolving > * key grabs. > */ >static void >ignore_lock_mods (void) >{ > Display *display; > XkbDescPtr xkb; > gint i, j; > gint ignored_vmods; > > static struct { > const gchar *name; > Atom atom; > } vmods[] = { > { "NumLock", 0 }, > { "LevelThree", 0 }, > { "ScrollLock", 0 }, > { "LevelFive", 0 }, > { NULL, 0 } > }; > > > g_print ("BEFORE\n"); > dump_controls (); > > display = gdk_x11_get_default_xdisplay (); > xkb = XkbGetMap (display, XkbModifierMapMask | XkbVirtualModsMask, XkbUseCoreKbd); > XkbGetNames (display, XkbGroupNamesMask | XkbVirtualModNamesMask, xkb); > XkbGetControls (display, XkbAllControlsMask, xkb); > > if (!vmods[0].atom) > for (j = 0; vmods[j].name; j++) > vmods[j].atom = XInternAtom (display, vmods[j].name, FALSE); > > ignored_vmods = 0; > for (i = 0; i < XkbNumVirtualMods; i++) > { > for (j = 0; vmods[j].name; j++) > { > if (xkb->names->vmods[i] == None) > continue; > > if (xkb->names->vmods[i] == vmods[j].atom) > { > gchar *name; > > name = XGetAtomName (display, xkb->names->vmods[i]); > g_print ("ignore vmod %d, %s\n", i, name); > > ignored_vmods |= 1 << i; > } > } > } > > XkbChangeEnabledControls (display, XkbUseCoreKbd, > XkbIgnoreGroupLockMask, > XkbIgnoreGroupLockMask); > > XkbSetIgnoreLockMods (display, XkbUseCoreKbd, > LockMask, LockMask, ignored_vmods, ignored_vmods); > > XkbFreeKeyboard (xkb, XkbAllComponentsMask, True); > > XFlush (display); > > > g_print ("AFTER\n"); > dump_controls (); >} > >/* Translate virtual modifiers in GdkModifierType to the > * real modifiers they are mapped to, so that the result > * can be used with XGrabKey. Returns FALSE if a virtual > * modifier can not be mapped because it is not bound. > * > * This is something that we would have to do in GDK if we > * added a grabkey function. > */ >static gboolean >translate_virtual_modifiers (gint *mods) >{ > Display *display; > XkbDescPtr xkb; > gint added; > gboolean result; > > static struct { > const gchar *name; > Atom atom; > GdkModifierType mask; > } vmods[] = { > { "Meta", 0, GDK_META_MASK }, > { "Super", 0, GDK_SUPER_MASK }, > { "Hyper", 0, GDK_HYPER_MASK }, > { NULL, 0, 0 } > }; > gint i, j; > > result = TRUE; > > display = gdk_x11_get_default_xdisplay (); > xkb = XkbGetMap (display, XkbModifierMapMask | XkbVirtualModsMask, XkbUseCoreKbd); > XkbGetNames (display, XkbGroupNamesMask | XkbVirtualModNamesMask, xkb); > > if (!vmods[0].atom) > for (j = 0; vmods[j].name; j++) > vmods[j].atom = XInternAtom (display, vmods[j].name, FALSE); > > added = 0; > > for (j = 0; vmods[j].atom; j++) > { > if (*mods & vmods[j].mask) > { > g_print ("looking for %d virtual modifiers\n", XkbNumVirtualMods); > for (i = 0; i < XkbNumVirtualMods; i++) > { > gchar *name; > > if (xkb->names->vmods[i] != None) > name = XGetAtomName (display, xkb->names->vmods[i]); > else > name = "(unbound)"; > g_print ("vmod %d: %s, mask %#x\n", > i, name, xkb->server->vmods[i]); > if (xkb->names->vmods[i] == vmods[j].atom) > { > added |= xkb->server->vmods[i]; > if (!xkb->server->vmods[i]) > { > g_warning ("virtual modifier %s not bound\n", > vmods[j].name); > result = FALSE; > } > } > } > } > } > > XkbFreeKeyboard (xkb, XkbAllComponentsMask, True); > > *mods |= added; > > return result; >} > >static void >grab_or_ungrab_key (gint keycode, gint mods, gboolean grab) >{ > Display *display; > Window root; > > if (keycode == 0) > return; > > display = gdk_x11_get_default_xdisplay (); > root = DefaultRootWindow (display); > > g_print ("%s %d, %#x on window %#x\n", grab ? "grab" : "ungrab", > keycode, mods, root); > > gdk_error_trap_push (); > > if (grab) > XGrabKey (display, keycode, mods, root, > True, GrabModeAsync, GrabModeAsync); > else > XUngrabKey (display, keycode, mods, root); > gdk_flush (); > > if (gdk_error_trap_pop ()) > g_warning ("Failed to grab keycode '%u'.", keycode); >} > > >static void >edited (GtkCellRendererText *cell, > gchar *path_string, > gint accel_key, > gint accel_mods, > gint keycode, > gpointer data) >{ > GtkTreeModel *model = GTK_TREE_MODEL (data); > GtkTreeIter iter; > GtkTreePath *path = gtk_tree_path_new_from_string (path_string); > gchar *text; > gint xmods, old_xmods, old_keycode; > > xmods = accel_mods; > if (!translate_virtual_modifiers (&xmods)) > return; > > text = gtk_accelerator_name (accel_key, accel_mods); > g_print ("keycode %d, xmods %#x (keyval %d, mods %#x) -> %s\n", > keycode, xmods, accel_key, accel_mods, text); > > gtk_tree_model_get_iter (model, &iter, path); > gtk_tree_model_get (model, &iter, 1, &old_keycode, 2, &old_xmods, -1); > gtk_list_store_set (GTK_LIST_STORE (model), &iter, > 0, text, > 1, keycode, > 2, xmods, > -1); > > grab_or_ungrab_key (old_keycode, old_xmods, FALSE); > grab_or_ungrab_key (keycode, xmods, TRUE); > > gtk_tree_path_free (path); > g_free (text); >} > >static GdkFilterReturn >key_filter (GdkXEvent *gdk_xevent, > GdkEvent *event, > gpointer data) >{ > XEvent *xevent = (XEvent*)gdk_xevent; > > if (xevent->type != KeyPress) > return GDK_FILTER_CONTINUE; > > g_print ("received %d %#x\n", > xevent->xkey.keycode, > xevent->xkey.state); > return GDK_FILTER_REMOVE; >} > >int >main (int argc, char *argv[]) >{ > GtkWidget *window, *tv; > GtkListStore *store; > GtkTreeIter iter; > GtkCellRenderer *cell; > gint mods; > > gtk_init (&argc, &argv); > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > > store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT); > > gtk_list_store_append (store, &iter); > gtk_list_store_set (store, &iter, 0, "", 1, 0, 2, 0, -1); > > tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); > cell = gtk_cell_renderer_accel_new (); > g_object_set (cell, "editable", TRUE, NULL); > g_signal_connect (cell, "accel-edited", G_CALLBACK (edited), store); > gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), 0, > "Accel", cell, > "text", 0, > NULL); > > gtk_container_add (GTK_CONTAINER (window), tv); > > gtk_widget_show_all (window); > > gdk_window_add_filter (gdk_get_default_root_window (), > key_filter, NULL); > > /* dump out the current mapping of Super, Hyper and Meta */ > mods = GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK; > translate_virtual_modifiers (&mods); > > /* Set up XKB controls to ignore locked modifiers */ > ignore_lock_mods (); > > gtk_main (); > > return 0; >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 201176
: 134941