+#if FL_REVISION < 89
+ case FL_KEYBOARD:
+#else
+ case FL_KEYPRESS:
+#endif
+ {
+ lyxerr[Debug::WORKAREA] << "Workarea event: KEYBOARD" << endl;
+
+ KeySym keysym = 0;
+ char dummy[1];
+ XKeyEvent * xke = reinterpret_cast<XKeyEvent *>(ev);
+#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5)
+ // XForms < 0.89.5 does not have compose support
+ // so we are using our own compose support
+ LyXLookupString(ev, dummy, 1, &keysym);
+#else
+ XLookupString(xke, dummy, 1, &keysym, 0);
+#endif
+ if (lyxerr.debugging(Debug::KEY)) {
+ char const * tmp = XKeysymToString(key);
+ char const * tmp2 = XKeysymToString(keysym);
+ string const stm = (tmp ? tmp : "");
+ string const stm2 = (tmp2 ? tmp2 : "");
+
+ lyxerr[Debug::KEY] << "WorkArea: Key is `" << stm << "' ["
+ << key << "]" << endl;
+ lyxerr[Debug::KEY] << "WorkArea: Keysym is `" << stm2 << "' ["
+ << keysym << "]" << endl;
+ }
+
+#if FL_REVISION < 89 || (FL_REVISION == 89 && FL_FIXLEVEL < 5)
+ if (keysym == NoSymbol) {
+ lyxerr[Debug::KEY]
+ << "Empty kdb action (probably composing)"
+ << endl;
+ break;
+ }
+ KeySym ret_key = keysym;
+#else
+ // Note that we need this handling because of a bug
+ // in XForms 0.89, if this bug is resolved in the way I hope
+ // we can just use the keysym directly with out looking
+ // at key at all. (Lgb)
+ KeySym ret_key = 0;
+ if (!key) {
+ // We migth have to add more keysyms here also,
+ // we will do that as the issues arise. (Lgb)
+ if (keysym == XK_space) {
+ ret_key = keysym;
+ lyxerr[Debug::KEY] << "Using keysym [A]"
+ << endl;
+ } else
+ break;
+ } else {
+ // It seems that this was a bit optimistic...
+ // With this hacking things seems to be better (Lgb)
+ //if (!iscntrl(key)) {
+ // ret_key = key;
+ // lyxerr[Debug::KEY]
+ // << "Using key [B]\n"
+ // << "Uchar["
+ // << static_cast<unsigned char>(key)
+ // << endl;
+ //} else {
+ ret_key = (keysym ? keysym : key);
+ lyxerr[Debug::KEY] << "Using keysym [B]"
+ << endl;
+ //}
+ }
+
+#endif
+ unsigned int const ret_state = xke->state;
+
+ // If you have a better way to handle "wild-output" of
+ // characters after the key has been released than the one
+ // below, please contact me. (Lgb)
+ static Time last_time_pressed;
+ static unsigned int last_key_pressed;
+ static unsigned int last_state_pressed;
+ lyxerr[Debug::KEY] << "Workarea Diff: "
+ << xke->time - last_time_pressed
+ << endl;
+ if (xke->time - last_time_pressed < 25 // should perhaps be tunable
+ && ret_state == last_state_pressed
+ && xke->keycode == last_key_pressed) {
+ lyxerr[Debug::KEY]
+ << "Workarea: Purging X events." << endl;
+ //lyxerr << "Workarea Events: "
+ // << XEventsQueued(fl_get_display(), QueuedAlready)
+ // << endl;
+ if (XEventsQueued(fl_get_display(), QueuedAlready) > 0)
+ XSync(fl_get_display(), 1);
+ // This purge make f.ex. scrolling stop immidiatly when
+ // releasing the PageDown button. The question is if
+ // this purging of XEvents can cause any harm...
+ // after some testing I can see no problems, but
+ // I'd like other reports too.
+ break;
+ }
+ last_time_pressed = xke->time;
+ last_key_pressed = xke->keycode;
+ last_state_pressed = ret_state;
+
+ area->workAreaKeyPress(ret_key, ret_state);
+ }
+ break;
+
+#if FL_REVISION >= 89
+ case FL_KEYRELEASE:
+ lyxerr[Debug::WORKAREA] << "Workarea event: KEYRELEASE" << endl;
+ break;
+#endif
+