]> git.lyx.org Git - features.git/commitdiff
Added -wait_idle option to wait for the target process to idle at each key press.
authorTommaso Cucinotta <tommaso@lyx.org>
Sun, 6 Feb 2011 22:47:33 +0000 (22:47 +0000)
committerTommaso Cucinotta <tommaso@lyx.org>
Sun, 6 Feb 2011 22:47:33 +0000 (22:47 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37519 a592a061-630c-0410-9148-cb99ea01b6c8

development/autotests/xvkbd/resources.h
development/autotests/xvkbd/xvkbd.c

index efbc8697433e7393767c7d286d221b640af5601d..863c00b50409bed65a25d2b5f6aab6540203a764 100644 (file)
@@ -59,6 +59,7 @@ struct appres_struct {
   String window;
   String instance;
   String widget;
+  String wait_idle;
   XFontStruct *general_font;
   XFontStruct *letter_font;
   XFontStruct *special_font;
index b27a091b4643512a26ca0a33cb4b45bf471f06a4..9b69a0e42f6c056df4d05119aaa2824a45fb4849 100644 (file)
@@ -270,6 +270,8 @@ static XtResource application_resources[] = {
      Offset(secure), XtRImmediate, (XtPointer)FALSE },
   { "no_root", "NoRoot", XtRBoolean, sizeof(Boolean),
      Offset(no_root), XtRImmediate, (XtPointer)FALSE },
+  { "wait_idle", "Text", XtRString, sizeof(char *),
+    Offset(wait_idle), XtRImmediate, "" },
   { "nonexitable", "Secure", XtRBoolean, sizeof(Boolean),
      Offset(nonexitable), XtRImmediate, (XtPointer)FALSE },
   { "modalKeytop", "ModalKeytop", XtRBoolean, sizeof(Boolean),
@@ -429,6 +431,7 @@ static XrmOptionDescRec options[] = {
   { "-minimizable", ".minimizable", XrmoptionNoArg, "True" },
   { "-secure", ".secure", XrmoptionNoArg, "True" },
   { "-no_root", ".no_root", XrmoptionNoArg, "True" },
+  { "-wait_idle", ".wait_idle", XrmoptionSepArg, NULL },
   { "-nonexitable", ".nonexitable", XrmoptionNoArg, "True" },
   { "-xdm", ".Secure", XrmoptionNoArg, "True" },
   { "-dict", ".dictFile", XrmoptionSepArg, NULL },
@@ -1399,7 +1402,26 @@ static void SendString(const unsigned char *str)
 
   shift_state = 0;
   for (cp = str; *cp != '\0'; cp++) {
-    if (0 < appres.text_delay) usleep(appres.text_delay * 1000);
+    if (0 < appres.text_delay)
+      usleep(appres.text_delay * 1000);
+    if (appres.wait_idle && strlen(appres.wait_idle) > 0) {
+      int pid = atoi(appres.wait_idle);
+      int ret;
+      do {
+       char cmd[80];
+       snprintf(cmd, sizeof(cmd), "/proc/%d/status", pid);
+       FILE *f = fopen(cmd, "r");
+       if (f == NULL) {
+         fprintf(stderr, "Process not found: %d\n", pid);
+         exit(-1);
+       }
+       fclose(f);
+       snprintf(cmd, sizeof(cmd), "grep 'State.*running' /proc/%d/status", pid);
+       ret = system(cmd);
+       if (ret == 0)
+         usleep(50);
+      } while (ret == 0);
+    }
     if (*cp == '\\') {
       cp++;
       switch (*cp) {