static int modeswitchmask;
static int numlockmask;
static bool beep = false;
+static bool debug_mode = false;
+
+#define DEBUG(fmt, ...) do { \
+ if (debug_mode) \
+ printf("[i3lock-debug] " fmt, ##__VA_ARGS__); \
+} while (0)
#ifndef NOLIBCAIRO
static cairo_surface_t *img = NULL;
*
*/
static void handle_key_release(xcb_key_release_event_t *event) {
- //printf("releasing %d, state raw = %d\n", event->detail, event->state);
+ DEBUG("releasing key %d, state raw = %d, modeswitch_active = %d, iso_level3_shift_active = %d\n",
+ event->detail, event->state, modeswitch_active, iso_level3_shift_active);
/* fix state */
event->state &= ~numlockmask;
} else if (sym == XK_ISO_Level3_Shift) {
iso_level3_shift_active = false;
}
+ DEBUG("release done. modeswitch_active = %d, iso_level3_shift_active = %d\n",
+ modeswitch_active, iso_level3_shift_active);
}
/*
*
*/
static void handle_key_press(xcb_key_press_event_t *event) {
- //printf("keypress %d, state raw = %d\n", event->detail, event->state);
+ DEBUG("keypress %d, state raw = %d, modeswitch_active = %d, iso_level3_shift_active = %d\n",
+ event->detail, event->state, modeswitch_active, iso_level3_shift_active);
xcb_keysym_t sym0, sym1, sym;
/* For each keycode, there is a list of symbols. The list could look like this:
sym1 = xcb_key_press_lookup_keysym(symbols, event, base_column + 1);
switch (sym0) {
case XK_Mode_switch:
- //printf("Mode switch enabled\n");
+ DEBUG("Mode switch enabled\n");
modeswitch_active = true;
return;
case XK_ISO_Level3_Shift:
if (xcb_is_modifier_key(sym) || xcb_is_cursor_key(sym))
return;
- //printf("sym = %c (%d)\n", sym, sym);
+ DEBUG("resolved to keysym = %c (%d)\n", sym, sym);
/* convert the keysym to UCS */
uint16_t ucs = keysym2ucs(sym);
/* store the UCS in a string to convert it */
uint8_t inp[3] = {(ucs & 0xFF00) >> 8, (ucs & 0xFF), 0};
+ DEBUG("input part = %s\n", inp);
/* store it in the password array as UTF-8 */
input_position += convert_ucs_to_utf8((char*)inp, password + input_position);
password[input_position] = '\0';
- //printf("current password = %s\n", password);
+ DEBUG("current password = %s\n", password);
}
/*
{"dpms", no_argument, NULL, 'd'},
{"color", required_argument, NULL, 'c'},
{"pointer", required_argument, NULL , 'p'},
+ {"debug", no_argument, NULL, 0},
#ifndef NOLIBCAIRO
{"image", required_argument, NULL, 'i'},
{"tiling", no_argument, NULL, 't'},
errx(1, "i3lock: Invalid pointer type given. Expected one of \"win\" or \"default\".\n");
}
break;
+ case 0:
+ if (strcmp(longopts[optind].name, "debug") == 0)
+ debug_mode = true;
+ break;
default:
errx(1, "i3lock: Unknown option. Syntax: i3lock [-v] [-n] [-b] [-d] [-c color] [-p win|default]"
#ifndef NOLIBCAIRO