fix interpreting of gdk mouse button numbers

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9170 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Spray 2004-11-04 21:50:10 +00:00
parent 456e7098b5
commit 5b9330bb8e
2 changed files with 33 additions and 3 deletions

View File

@ -1,3 +1,9 @@
2004-11-04 John Spray <spray_john@users.sourceforge.net>
* GWorkArea.C: convert GdkEventButton->state from
gdk mouse button ids into mouse_button::state
using gButtonToLyx function
2004-10-23 John Spray <spray_john@users.sourceforge.net>
* ghelpers.[Ch]: Add buildLengthUnitList() to get vector of

View File

@ -26,8 +26,32 @@ using std::string;
namespace lyx {
namespace frontend {
ColorCache colorCache;
namespace {
mouse_button::state gButtonToLyx(guint gdkbutton)
{
// GDK uses int 1,2,3 but lyx uses enums (1,2,4)
switch (gdkbutton) {
case 1:
return mouse_button::button1;
case 2:
return mouse_button::button2;
case 3:
return mouse_button::button3;
case 4:
return mouse_button::button4;
case 5:
return mouse_button::button5;
}
// This shouldn't happen, according to gdk docs
lyxerr << "gButtonToLyx: unhandled button index\n";
return mouse_button::button1;
}
} // namespace anon
ColorCache colorCache;
Gdk::Color * ColorCache::getColor(LColor_color clr)
{
@ -377,7 +401,7 @@ bool GWorkArea::onButtonPress(GdkEventButton * event)
dispatch(FuncRequest(ka,
static_cast<int>(event->x),
static_cast<int>(event->y),
static_cast<mouse_button::state>(event->button)));
gButtonToLyx(event->button)));
workArea_.grab_focus();
return true;
}
@ -388,7 +412,7 @@ bool GWorkArea::onButtonRelease(GdkEventButton * event)
dispatch(FuncRequest(LFUN_MOUSE_RELEASE,
static_cast<int>(event->x),
static_cast<int>(event->y),
static_cast<mouse_button::state>(event->button)));
gButtonToLyx(event->button)));
return true;
}