Here is a possible fix for the repeating macro issue. The problem occurs when HAVE_X11_EXTENSIONS_XTEST_H is true and is caused because the last character that is pressed never sends the release to X11.
I modified my g15macro.c to always record a key release (but only display it for the special keys). Your mileage might vary and I have only tested this for a short while, but it seems stable enough...
I followed the directions in http://ubuntuforums.org/showthread.php?p=2461304
to get the g15daemon running using the 1.9.0 pre 2.0 version of g15daemon.
Code:
void xkey_handler(XEvent *event) {
static unsigned long lasttime;
unsigned char keytext[256];
unsigned int keycode = event->xkey.keycode;
int press = True;
int display = True;
if(event->type==KeyRelease){ // we only do keyreleases for some keys
pthread_mutex_lock(&x11mutex);
KeySym key = XKeycodeToKeysym(dpy, keycode, 0);
pthread_mutex_unlock(&x11mutex);
switch (key) {
case XK_Shift_L:
case XK_Shift_R:
case XK_Control_L:
case XK_Control_R:
case XK_Caps_Lock:
case XK_Shift_Lock:
case XK_Meta_L:
case XK_Meta_R:
case XK_Alt_L:
case XK_Alt_R:
case XK_Super_L:
case XK_Super_R:
case XK_Hyper_L:
case XK_Hyper_R:
break;
default:
display = False;
break;
}
press = False;
}
if(recording){
current_recording.recorded_keypress[rec_index].keycode = keycode;
current_recording.recorded_keypress[rec_index].pressed = press;
current_recording.recorded_keypress[rec_index].modifiers = event->xkey.state;
if(rec_index==0)
current_recording.recorded_keypress[rec_index].time_ms=0;
else
current_recording.recorded_keypress[rec_index].time_ms=g15daemon_gettime_ms() - lasttime;
rec_index++;
/* now the default stuff */
pthread_mutex_lock(&x11mutex);
XUngrabKeyboard(dpy,CurrentTime);
pthread_mutex_unlock(&x11mutex);
if(display == True) {
fake_keyevent(keycode,press,event->xkey.state);
}
pthread_mutex_lock(&x11mutex);
XGrabKeyboard(dpy, root_win, True, GrabModeAsync, GrabModeAsync, CurrentTime);
XFlush(dpy);
strcpy((char*)keytext,XKeysymToString(XKeycodeToKeysym(dpy, keycode, 0)));
pthread_mutex_unlock(&x11mutex);
if(display == True) {
if(0==strcmp((char*)keytext,"space"))
strcpy((char*)keytext," ");
strcat((char*)recstring,(char*)keytext);
g15r_renderString (canvas, (unsigned char *)recstring, 0, G15_TEXT_MED, 80-((strlen((char*)recstring)/2)*5), 22);
g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN);
}
}else
rec_index=0;
lasttime = g15daemon_gettime_ms();
}
Also, I moved the save routine to write out the configuration every time a new macro is recorded.
Code:
void *Lkeys_thread() {
...
default:
if(keystate >=G15_KEY_G1 && keystate <=G15_KEY_G18){
if(recording==1){
record_complete(keystate);
recording = 0;
pthread_mutex_lock(&x11mutex);
XUngrabKeyboard(dpy,CurrentTime);
XFlush(dpy);
/* Write configuration every time a macro is recorded*/
config_fd = open(configpath,O_CREAT|O_WRONLY|O_SYNC,0600);
write(config_fd,mstates[0],sizeof(mstates_t));
write(config_fd,mstates[1],sizeof(mstates_t));
write(config_fd,mstates[2],sizeof(mstates_t));
close(config_fd);
pthread_mutex_unlock(&x11mutex);
} else {
macro_playback(keystate);
}
}
break;
}
keystate = 0;
}
}
return NULL;
}
The diff is as follows: (diff -w)
Code:
72d71
< char configpath[1024];
442,446d440
< config_fd = open(configpath,O_CREAT|O_WRONLY|O_SYNC,0600);
< write(config_fd,mstates[0],sizeof(mstates_t));
< write(config_fd,mstates[1],sizeof(mstates_t));
< write(config_fd,mstates[2],sizeof(mstates_t));
< close(config_fd);
472d465
< int display = True;
495,496c488
< display = False;
< break;
---
> return;
497a490
>
515d507
< if(display == True) {
517d508
< }
522d512
<
525,526d514
<
< if(display == True) {
532d519
< }
611a599
> char configpath[1024];
Bookmarks