mirror of git://git.suckless.org/svkbd
add check for debug flag in printdbg() function itself
This commit is contained in:
parent
7980cb5f51
commit
4b5a61b275
65
svkbd.c
65
svkbd.c
|
@ -165,8 +165,7 @@ motionnotify(XEvent *e)
|
||||||
|
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (!IsModifierKey(keys[i].keysym) && keys[i].pressed == True && lostfocus != gainedfocus) {
|
if (!IsModifierKey(keys[i].keysym) && keys[i].pressed == True && lostfocus != gainedfocus) {
|
||||||
if (debug)
|
printdbg("Pressed key lost focus: %ld\n", keys[i].keysym);
|
||||||
printdbg("Pressed key lost focus: %ld\n", keys[i].keysym);
|
|
||||||
lostfocus = i;
|
lostfocus = i;
|
||||||
ispressingkeysym = 0;
|
ispressingkeysym = 0;
|
||||||
keys[i].pressed = 0;
|
keys[i].pressed = 0;
|
||||||
|
@ -175,8 +174,7 @@ motionnotify(XEvent *e)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((lostfocus != -1) && (gainedfocus != -1) && (lostfocus != gainedfocus)) {
|
if ((lostfocus != -1) && (gainedfocus != -1) && (lostfocus != gainedfocus)) {
|
||||||
if (debug)
|
printdbg("Clicking new key that gained focus\n");
|
||||||
printdbg("Clicking new key that gained focus\n");
|
|
||||||
press(&keys[gainedfocus], 0);
|
press(&keys[gainedfocus], 0);
|
||||||
keys[gainedfocus].pressed = True;
|
keys[gainedfocus].pressed = True;
|
||||||
keys[gainedfocus].highlighted = True;
|
keys[gainedfocus].highlighted = True;
|
||||||
|
@ -433,8 +431,7 @@ press(Key *k, KeySym buttonmod)
|
||||||
|
|
||||||
k->pressed = !k->pressed;
|
k->pressed = !k->pressed;
|
||||||
|
|
||||||
if (debug)
|
printdbg("Begin click: %ld\n", k->keysym);
|
||||||
printdbg("Begin click: %ld\n", k->keysym);
|
|
||||||
pressbegin.tv_sec = 0;
|
pressbegin.tv_sec = 0;
|
||||||
pressbegin.tv_usec = 0;
|
pressbegin.tv_usec = 0;
|
||||||
ispressingkeysym = 0;
|
ispressingkeysym = 0;
|
||||||
|
@ -446,8 +443,7 @@ press(Key *k, KeySym buttonmod)
|
||||||
/*record the begin of the press, don't simulate the actual keypress yet */
|
/*record the begin of the press, don't simulate the actual keypress yet */
|
||||||
record_press_begin(k->keysym);
|
record_press_begin(k->keysym);
|
||||||
} else {
|
} else {
|
||||||
if (debug)
|
printdbg("Simulating press: %ld (mod %ld)\n", k->keysym, buttonmod);
|
||||||
printdbg("Simulating press: %ld (mod %ld)\n", k->keysym, buttonmod);
|
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
|
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
|
||||||
simulate_keypress(keys[i].keysym);
|
simulate_keypress(keys[i].keysym);
|
||||||
|
@ -493,8 +489,7 @@ printkey(Key *k, KeySym mod)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (debug)
|
printdbg("Printing key %ld (shift=%d)\n", k->keysym, shift);
|
||||||
printdbg("Printing key %ld (shift=%d)\n", k->keysym, shift);
|
|
||||||
if (k->keysym == XK_Cancel)
|
if (k->keysym == XK_Cancel)
|
||||||
return;
|
return;
|
||||||
KeySym * keysym = &(k->keysym);
|
KeySym * keysym = &(k->keysym);
|
||||||
|
@ -514,8 +509,7 @@ printkey(Key *k, KeySym mod)
|
||||||
Status return_status;
|
Status return_status;
|
||||||
int l = Xutf8LookupString(xic, &event, buffer, 32, &ignore, &return_status);
|
int l = Xutf8LookupString(xic, &event, buffer, 32, &ignore, &return_status);
|
||||||
buffer[l] = '\0';
|
buffer[l] = '\0';
|
||||||
if (debug)
|
printdbg("Print buffer: [%s] (length=%d)\n", &buffer, l);
|
||||||
printdbg("Print buffer: [%s] (length=%d)\n", &buffer, l);
|
|
||||||
printf("%s", buffer);
|
printf("%s", buffer);
|
||||||
|
|
||||||
XDestroyIC(xic);
|
XDestroyIC(xic);
|
||||||
|
@ -579,8 +573,7 @@ unpress(Key *k, KeySym buttonmod)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pressbegin.tv_sec || pressbegin.tv_usec) && (enableoverlays || pressonrelease) && k && k->keysym == ispressingkeysym) {
|
if ((pressbegin.tv_sec || pressbegin.tv_usec) && (enableoverlays || pressonrelease) && k && k->keysym == ispressingkeysym) {
|
||||||
if (debug)
|
printdbg("Delayed simulation of press after release: %ld\n", k->keysym);
|
||||||
printdbg("Delayed simulation of press after release: %ld\n", k->keysym);
|
|
||||||
/* simulate the press event, as we postponed it earlier in press() */
|
/* simulate the press event, as we postponed it earlier in press() */
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
|
if (keys[i].pressed && IsModifierKey(keys[i].keysym)) {
|
||||||
|
@ -595,14 +588,10 @@ unpress(Key *k, KeySym buttonmod)
|
||||||
pressbegin.tv_usec = 0;
|
pressbegin.tv_usec = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug) {
|
if (k)
|
||||||
if (k) {
|
printdbg("Simulation of release: %ld\n", k->keysym);
|
||||||
printdbg("Simulation of release: %ld\n", k->keysym);
|
else
|
||||||
} else {
|
printdbg("Simulation of release (all keys)\n");
|
||||||
printdbg("Simulation of release (all keys)\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
if (keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
|
if (keys[i].pressed && !IsModifierKey(keys[i].keysym)) {
|
||||||
|
@ -670,20 +659,18 @@ run(void)
|
||||||
/* time-out expired without anything interesting happening, check for long-presses */
|
/* time-out expired without anything interesting happening, check for long-presses */
|
||||||
if (ispressing && ispressingkeysym) {
|
if (ispressing && ispressingkeysym) {
|
||||||
duration = get_press_duration();
|
duration = get_press_duration();
|
||||||
if (debug == 2)
|
if (debug >= 2)
|
||||||
printdbg("%f\n", duration);
|
printdbg("%f\n", duration);
|
||||||
overlayidx = hasoverlay(ispressingkeysym);
|
overlayidx = hasoverlay(ispressingkeysym);
|
||||||
duration = get_press_duration();
|
duration = get_press_duration();
|
||||||
if ((overlayidx != -1) && (duration >= overlay_delay)) {
|
if ((overlayidx != -1) && (duration >= overlay_delay)) {
|
||||||
if (debug)
|
printdbg("press duration %f, activating overlay\n", duration);
|
||||||
printdbg("press duration %f, activating overlay\n", duration);
|
|
||||||
showoverlay(overlayidx);
|
showoverlay(overlayidx);
|
||||||
pressbegin.tv_sec = 0;
|
pressbegin.tv_sec = 0;
|
||||||
pressbegin.tv_usec = 0;
|
pressbegin.tv_usec = 0;
|
||||||
ispressingkeysym = 0;
|
ispressingkeysym = 0;
|
||||||
} else if ((overlayidx == -1) && (duration >= repeat_delay)) {
|
} else if ((overlayidx == -1) && (duration >= repeat_delay)) {
|
||||||
if (debug)
|
printdbg("press duration %f, activating repeat\n", duration);
|
||||||
printdbg("press duration %f, activating repeat\n", duration);
|
|
||||||
simulate_keyrelease(ispressingkeysym);
|
simulate_keyrelease(ispressingkeysym);
|
||||||
simulate_keypress(ispressingkeysym);
|
simulate_keypress(ispressingkeysym);
|
||||||
XSync(dpy, False);
|
XSync(dpy, False);
|
||||||
|
@ -698,8 +685,7 @@ run(void)
|
||||||
since then X doesn't know the keyup is never coming.. (since
|
since then X doesn't know the keyup is never coming.. (since
|
||||||
process will be dead before finger lifts - in that case we
|
process will be dead before finger lifts - in that case we
|
||||||
just trigger out fake up presses for all keys */
|
just trigger out fake up presses for all keys */
|
||||||
if (debug)
|
printdbg("signal received, releasing all keys");
|
||||||
printdbg("signal received, releasing all keys");
|
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0);
|
XTestFakeKeyEvent(dpy, XKeysymToKeycode(dpy, keys[i].keysym), False, 0);
|
||||||
}
|
}
|
||||||
|
@ -990,8 +976,7 @@ cyclelayer(void)
|
||||||
currentlayer++;
|
currentlayer++;
|
||||||
if (currentlayer >= numlayers)
|
if (currentlayer >= numlayers)
|
||||||
currentlayer = 0;
|
currentlayer = 0;
|
||||||
if (debug)
|
printdbg("Cycling to layer %d\n", currentlayer);
|
||||||
printdbg("Cycling to layer %d\n", currentlayer);
|
|
||||||
setlayer();
|
setlayer();
|
||||||
updatekeys();
|
updatekeys();
|
||||||
drawkeyboard();
|
drawkeyboard();
|
||||||
|
@ -1005,8 +990,7 @@ togglelayer(void)
|
||||||
} else if (numlayers > 1) {
|
} else if (numlayers > 1) {
|
||||||
currentlayer = 1;
|
currentlayer = 1;
|
||||||
}
|
}
|
||||||
if (debug)
|
printdbg("Toggling layer %d\n", currentlayer);
|
||||||
printdbg("Toggling layer %d\n", currentlayer);
|
|
||||||
setlayer();
|
setlayer();
|
||||||
updatekeys();
|
updatekeys();
|
||||||
drawkeyboard();
|
drawkeyboard();
|
||||||
|
@ -1015,9 +999,9 @@ togglelayer(void)
|
||||||
void
|
void
|
||||||
showoverlay(int idx)
|
showoverlay(int idx)
|
||||||
{
|
{
|
||||||
if (debug)
|
int i, j;
|
||||||
printdbg("Showing overlay %d\n", idx);
|
|
||||||
int i,j;
|
printdbg("Showing overlay %d\n", idx);
|
||||||
|
|
||||||
/* unpress existing key (visually only) */
|
/* unpress existing key (visually only) */
|
||||||
for (i = 0; i < numkeys; i++) {
|
for (i = 0; i < numkeys; i++) {
|
||||||
|
@ -1053,8 +1037,7 @@ showoverlay(int idx)
|
||||||
void
|
void
|
||||||
hideoverlay(void)
|
hideoverlay(void)
|
||||||
{
|
{
|
||||||
if (debug)
|
printdbg("Hiding overlay, overlay was #%d\n", currentoverlay);
|
||||||
printdbg("Hiding overlay, overlay was #%d\n", currentoverlay);
|
|
||||||
currentoverlay = -1;
|
currentoverlay = -1;
|
||||||
overlaykeysym = 0;
|
overlaykeysym = 0;
|
||||||
currentlayer--;
|
currentlayer--;
|
||||||
|
@ -1066,8 +1049,7 @@ sigterm(int signo)
|
||||||
{
|
{
|
||||||
running = False;
|
running = False;
|
||||||
sigtermd = True;
|
sigtermd = True;
|
||||||
if (debug)
|
printdbg("SIGTERM received\n");
|
||||||
printdbg("SIGTERM received\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1118,6 +1100,9 @@ init_layers(char *layer_names_list, const char *initial_layer_name)
|
||||||
void
|
void
|
||||||
printdbg(const char *fmt, ...)
|
printdbg(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
if (!debug)
|
||||||
|
return;
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vfprintf(stderr, fmt, ap);
|
vfprintf(stderr, fmt, ap);
|
||||||
|
|
Loading…
Reference in New Issue