gnome-settings-daemon r304 - in trunk: . plugins/keybindings plugins/media-keys
- From: jensg svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-settings-daemon r304 - in trunk: . plugins/keybindings plugins/media-keys
- Date: Sat, 12 Apr 2008 22:20:17 +0100 (BST)
Author: jensg
Date: Sat Apr 12 22:20:16 2008
New Revision: 304
URL: http://svn.gnome.org/viewvc/gnome-settings-daemon?rev=304&view=rev
Log:
2008-04-12 Jens Granseuer <jensgr gmx net>
* plugins/keybindings/gsd-keybindings-manager.c: (do_grab):
* plugins/media-keys/gsd-media-keys-manager.c: (grab_key): make some
tiny optimizations and add some more comments on what's happening
Modified:
trunk/ChangeLog
trunk/plugins/keybindings/gsd-keybindings-manager.c
trunk/plugins/media-keys/gsd-media-keys-manager.c
Modified: trunk/plugins/keybindings/gsd-keybindings-manager.c
==============================================================================
--- trunk/plugins/keybindings/gsd-keybindings-manager.c (original)
+++ trunk/plugins/keybindings/gsd-keybindings-manager.c Sat Apr 12 22:20:16 2008
@@ -316,28 +316,31 @@
gboolean grab,
Key *key)
{
- int indexes[N_BITS];/*indexes of bits we need to flip*/
+ int indexes[N_BITS]; /* indexes of bits we need to flip */
int i;
int bit;
int bits_set_cnt;
int uppervalue;
- guint mask_to_traverse = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
+ guint mask = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
bit = 0;
- for (i = 0; i < N_BITS; i++) {
- if (mask_to_traverse & (1<<i)) {
- indexes[bit++]=i;
+ /* store the indices of all set bits in mask in the array */
+ for (i = 0; mask; ++i, mask >>= 1) {
+ if (mask & 0x1) {
+ indexes[bit++] = i;
}
}
bits_set_cnt = bit;
uppervalue = 1 << bits_set_cnt;
- for (i = 0; i < uppervalue; i++) {
+ /* grab all possible modifier combinations for our mask */
+ for (i = 0; i < uppervalue; ++i) {
GSList *l;
int j, result = 0;
- for (j = 0; j < bits_set_cnt; j++) {
+ /* map bits in the counter to those in the mask */
+ for (j = 0; j < bits_set_cnt; ++j) {
if (i & (1<<j)) {
result |= (1<<indexes[j]);
}
Modified: trunk/plugins/media-keys/gsd-media-keys-manager.c
==============================================================================
--- trunk/plugins/media-keys/gsd-media-keys-manager.c (original)
+++ trunk/plugins/media-keys/gsd-media-keys-manager.c Sat Apr 12 22:20:16 2008
@@ -305,16 +305,17 @@
Key *key,
gboolean grab)
{
- int indexes[N_BITS];/*indexes of bits we need to flip*/
+ int indexes[N_BITS]; /* indexes of bits we need to flip */
int i;
int bit;
int bits_set_cnt;
int uppervalue;
- guint mask_to_traverse = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
+ guint mask = IGNORED_MODS & ~key->state & GDK_MODIFIER_MASK;
bit = 0;
- for (i = 0; i < N_BITS; i++) {
- if (mask_to_traverse & (1 << i)) {
+ /* store the indices of all set bits in mask in the array */
+ for (i = 0; mask; ++i, mask >>= 1) {
+ if (mask & 0x1) {
indexes[bit++] = i;
}
}
@@ -322,12 +323,14 @@
bits_set_cnt = bit;
uppervalue = 1 << bits_set_cnt;
- for (i = 0; i < uppervalue; i++) {
+ /* grab all possible modifier combinations for our mask */
+ for (i = 0; i < uppervalue; ++i) {
GSList *l;
int j;
int result = 0;
- for (j = 0; j < bits_set_cnt; j++) {
+ /* map bits in the counter to those in the mask */
+ for (j = 0; j < bits_set_cnt; ++j) {
if (i & (1 << j)) {
result |= (1 << indexes[j]);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]