Tell dispatch which mouse button is being dragged.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5415 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2002-10-15 16:12:27 +00:00
parent be90eb4453
commit fe2ea80ac9
2 changed files with 46 additions and 49 deletions

View File

@ -1,3 +1,12 @@
2002-10-15 Angus Leeming <leeming@lyx.org>
* XWorkArea.C (work_area_handler): it transpires that
ev->xbutton.button == 0 when the mouse is dragged,
so it cannot be used to initialise x_button_state and
hence FuncRequest.
This patch uses the 'key' that is passed into the function
by xforms to extract this info and so resolve the problem.
2002-10-15 Angus Leeming <leeming@lyx.org> 2002-10-15 Angus Leeming <leeming@lyx.org>
* FormCitation.C (updateBrowser): deselect the highlighted item when * FormCitation.C (updateBrowser): deselect the highlighted item when

View File

@ -69,45 +69,28 @@ mouse_button::state x_button_state(unsigned int button)
{ {
mouse_button::state b = mouse_button::none; mouse_button::state b = mouse_button::none;
switch (button) { switch (button) {
case Button1: case FL_MBUTTON1:
b = mouse_button::button1; b = mouse_button::button1;
break; break;
case Button2: case FL_MBUTTON2:
b = mouse_button::button2; b = mouse_button::button2;
break; break;
case Button3: case FL_MBUTTON3:
b = mouse_button::button3; b = mouse_button::button3;
break; break;
case Button4: case FL_MBUTTON4:
b = mouse_button::button4; b = mouse_button::button4;
break; break;
case Button5: case FL_MBUTTON5:
b = mouse_button::button5; b = mouse_button::button5;
break; break;
default: // FIXME default: // FIXME
break; break;
} }
return b; return b;
} }
mouse_button::state x_motion_state(unsigned int state)
{
mouse_button::state b = mouse_button::none;
if (state & Button1MotionMask)
b |= mouse_button::button1;
if (state & Button2MotionMask)
b |= mouse_button::button2;
if (state & Button3MotionMask)
b |= mouse_button::button3;
if (state & Button4MotionMask)
b |= mouse_button::button4;
if (state & Button5MotionMask)
b |= mouse_button::button5;
return b;
}
key_modifier::state x_key_state(unsigned int state) key_modifier::state x_key_state(unsigned int state)
{ {
key_modifier::state k = key_modifier::none; key_modifier::state k = key_modifier::none;
@ -355,18 +338,20 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
// Should really have used xbutton.state // Should really have used xbutton.state
lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: PUSH" << endl;
area->dispatch( area->dispatch(
FuncRequest(LFUN_MOUSE_PRESS, ev->xbutton.x - ob->x, FuncRequest(LFUN_MOUSE_PRESS,
ev->xbutton.y - ob->y, ev->xbutton.x - ob->x,
x_button_state(ev->xbutton.button))); ev->xbutton.y - ob->y,
x_button_state(key)));
break; break;
case FL_RELEASE: case FL_RELEASE:
if (!ev || ev->xbutton.button == 0) break; if (!ev || ev->xbutton.button == 0) break;
// Should really have used xbutton.state // Should really have used xbutton.state
lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: RELEASE" << endl;
area->dispatch( area->dispatch(
FuncRequest(LFUN_MOUSE_RELEASE, ev->xbutton.x - ob->x, FuncRequest(LFUN_MOUSE_RELEASE,
ev->xbutton.y - ob->y, ev->xbutton.x - ob->x,
x_button_state(ev->xbutton.button))); ev->xbutton.y - ob->y,
x_button_state(key)));
break; break;
#if FL_VERSION < 1 && FL_REVISION < 89 #if FL_VERSION < 1 && FL_REVISION < 89
case FL_MOUSE: case FL_MOUSE:
@ -384,9 +369,10 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
scrollbar_value_old = fl_get_scrollbar_value(area->scrollbar); scrollbar_value_old = fl_get_scrollbar_value(area->scrollbar);
lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: MOUSE" << endl;
area->dispatch( area->dispatch(
FuncRequest(LFUN_MOUSE_MOTION, ev->xbutton.x - ob->x, FuncRequest(LFUN_MOUSE_MOTION,
ev->xbutton.y - ob->y, ev->xbutton.x - ob->x,
x_button_state(ev->xbutton.button))); ev->xbutton.y - ob->y,
x_button_state(key)));
} }
break; break;
#if FL_VERSION < 1 && FL_REVISION < 89 #if FL_VERSION < 1 && FL_REVISION < 89
@ -519,18 +505,20 @@ int XWorkArea::work_area_handler(FL_OBJECT * ob, int event,
case FL_DBLCLICK: case FL_DBLCLICK:
if (ev) { if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: DBLCLICK" << endl;
FuncRequest cmd(LFUN_MOUSE_DOUBLE, ev->xbutton.x - ob->x, FuncRequest cmd(LFUN_MOUSE_DOUBLE,
ev->xbutton.y - ob->y, ev->xbutton.x - ob->x,
x_button_state(ev->xbutton.button)); ev->xbutton.y - ob->y,
x_button_state(key));
area->dispatch(cmd); area->dispatch(cmd);
} }
break; break;
case FL_TRPLCLICK: case FL_TRPLCLICK:
if (ev) { if (ev) {
lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl; lyxerr[Debug::WORKAREA] << "Workarea event: TRPLCLICK" << endl;
FuncRequest cmd(LFUN_MOUSE_TRIPLE, ev->xbutton.x - ob->x, FuncRequest cmd(LFUN_MOUSE_TRIPLE,
ev->xbutton.y - ob->y, ev->xbutton.x - ob->x,
x_button_state(ev->xbutton.button)); ev->xbutton.y - ob->y,
x_button_state(key));
area->dispatch(cmd); area->dispatch(cmd);
} }
break; break;