* \author unknown
* \author John Levon
*
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
*/
#include <config.h>
-
#include "XWorkArea.h"
+
#include "debug.h"
#include "XLyXKeySym.h"
#include "funcrequest.h"
#include "Timeout.h"
-using std::endl;
using std::abs;
-using std::hex;
using std::dec;
+using std::endl;
+using std::hex;
+using std::string;
+
namespace {
-inline
-void waitForX(bool discard)
+inline void waitForX(bool discard)
{
XSync(fl_get_display(), discard);
}
XEvent * ev = static_cast<XEvent*>(xev);
XWorkArea * area = static_cast<XWorkArea*>(ob->u_vdata);
- if (!area) return 1;
+ if (!area)
+ return 1;
switch (event) {
+
case FL_DRAW:
if (!area->work_area || !area->work_area->form->visible)
return 1;
lyxerr[Debug::WORKAREA] << "Workarea event: DRAW" << endl;
area->redraw(area->workWidth(), area->workHeight());
break;
+
case FL_PUSH:
if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state
ev->xbutton.y - ob->y,
x_button_state(key)));
break;
+
case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state
ev->xbutton.y - ob->y,
x_button_state(key)));
break;
- case FL_DRAG:
- {
+
+ case FL_DRAG: {
if (!ev || !area->scrollbar)
break;
break;
}
- case FL_KEYPRESS:
- {
+ case FL_KEYPRESS: {
lyxerr[Debug::WORKAREA] << "Workarea event: KEYPRESS" << endl;
+
+ KeySym keysym = 0;
+ char dummy[1];
XKeyEvent * xke = reinterpret_cast<XKeyEvent *>(ev);
+ XLookupString(xke, dummy, 1, &keysym, 0);
if (lyxerr.debugging(Debug::KEY)) {
char const * const tmp = XKeysymToString(key);
- lyxerr << "XWorkArea: Key is `" << tmp
- << "' [" << key << "]" << endl;
+ char const * const tmp2 = XKeysymToString(keysym);
+ string const stm = (tmp ? tmp : string());
+ string const stm2 = (tmp2 ? tmp2 : string());
+
+ lyxerr << "XWorkArea: Key is `" << stm
+ << "' [" << key << "]\n"
+ << "XWorkArea: Keysym is `" << stm2
+ << "' [" << keysym << ']' << endl;
}
+ // 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 without looking
+ // at key at all. (Lgb)
+ KeySym ret_key = 0;
if (!key) {
- lyxerr << "Probably composing" << endl;
- break;
+ // We might 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;
+ //}
}
- KeySym ret_key = key;
unsigned int const ret_state = xke->state;
// If you have a better way to handle "wild-output" of
area->workAreaKeyPress(LyXKeySymPtr(xlk),
x_key_state(ret_state));
+ break;
}
- break;
case FL_KEYRELEASE:
lyxerr[Debug::WORKAREA] << "Workarea event: KEYRELEASE" << endl;
lyxerr[Debug::WORKAREA] << "Workarea event: ENTER" << endl;
fl_set_cursor(FL_ObjWin(area->work_area), XC_xterm);
break;
+
case FL_LEAVE:
lyxerr[Debug::WORKAREA] << "Workarea event: LEAVE" << endl;
// There should be no need for this. But there is.
fl_set_cursor(FL_ObjWin(area->work_area), FL_DEFAULT_CURSOR);
break;
+
case FL_DBLCLICK:
if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
area->dispatch(cmd);
}
break;
+
case FL_TRPLCLICK:
if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
area->dispatch(cmd);
}
break;
+
case FL_OTHER:
if (ev)
lyxerr[Debug::WORKAREA] << "Workarea event: OTHER" << endl;