Limit hover-picks to once per frame.
Hopefully fixes the observed issues on Linux when spamming mouse-moves over a large pickable, but only testing will say for sure.
This commit is contained in:
parent
4d144dfbf2
commit
6bd8bbc25e
1 changed files with 20 additions and 10 deletions
|
@ -145,7 +145,8 @@ public:
|
||||||
mouseYNode(fgGetNode("/devices/status/mice/mouse/y", true))
|
mouseYNode(fgGetNode("/devices/status/mice/mouse/y", true))
|
||||||
{
|
{
|
||||||
tooltipTimeoutDone = false;
|
tooltipTimeoutDone = false;
|
||||||
|
hoverPickScheduled = false;
|
||||||
|
|
||||||
fgGetNode("/sim/mouse/hide-cursor", true )->addChangeListener(this, true);
|
fgGetNode("/sim/mouse/hide-cursor", true )->addChangeListener(this, true);
|
||||||
fgGetNode("/sim/mouse/cursor-timeout-sec", true )->addChangeListener(this, true);
|
fgGetNode("/sim/mouse/cursor-timeout-sec", true )->addChangeListener(this, true);
|
||||||
fgGetNode("/sim/mouse/right-button-mode-cycle-enabled", true)->addChangeListener(this, true);
|
fgGetNode("/sim/mouse/right-button-mode-cycle-enabled", true)->addChangeListener(this, true);
|
||||||
|
@ -188,6 +189,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void scheduleHoverPick(const osg::Vec2d& windowPos)
|
||||||
|
{
|
||||||
|
hoverPickScheduled = true;
|
||||||
|
hoverPos = windowPos;
|
||||||
|
}
|
||||||
|
|
||||||
void doHoverPick(const osg::Vec2d& windowPos)
|
void doHoverPick(const osg::Vec2d& windowPos)
|
||||||
{
|
{
|
||||||
std::vector<SGSceneryPick> pickList;
|
std::vector<SGSceneryPick> pickList;
|
||||||
|
@ -228,7 +235,9 @@ public:
|
||||||
|
|
||||||
FGMouseCursor::instance()->setCursor(cur);
|
FGMouseCursor::instance()->setCursor(cur);
|
||||||
if (!didPick) {
|
if (!didPick) {
|
||||||
updateHover();
|
SGPropertyNode_ptr args(new SGPropertyNode);
|
||||||
|
globals->get_commands()->execute("update-hover", args);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,14 +255,7 @@ public:
|
||||||
|
|
||||||
FGMouseCursor::instance()->setCursor(cur);
|
FGMouseCursor::instance()->setCursor(cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateHover()
|
|
||||||
{
|
|
||||||
SGPropertyNode_ptr args(new SGPropertyNode);
|
|
||||||
globals->get_commands()->execute("update-hover", args);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// implement the property-change-listener interfacee
|
// implement the property-change-listener interfacee
|
||||||
virtual void valueChanged( SGPropertyNode * node )
|
virtual void valueChanged( SGPropertyNode * node )
|
||||||
{
|
{
|
||||||
|
@ -290,6 +292,9 @@ public:
|
||||||
SGPropertyNode_ptr xAccelNode;
|
SGPropertyNode_ptr xAccelNode;
|
||||||
SGPropertyNode_ptr yAccelNode;
|
SGPropertyNode_ptr yAccelNode;
|
||||||
SGPropertyNode_ptr mouseXNode, mouseYNode;
|
SGPropertyNode_ptr mouseXNode, mouseYNode;
|
||||||
|
|
||||||
|
bool hoverPickScheduled;
|
||||||
|
osg::Vec2d hoverPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,6 +432,11 @@ void FGMouseInput::update ( double dt )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((mode == 0) && d->hoverPickScheduled) {
|
||||||
|
d->doHoverPick(d->hoverPos);
|
||||||
|
d->hoverPickScheduled = false;
|
||||||
|
}
|
||||||
|
|
||||||
// if delay is <= 0, disable tooltips
|
// if delay is <= 0, disable tooltips
|
||||||
if ( !d->tooltipTimeoutDone &&
|
if ( !d->tooltipTimeoutDone &&
|
||||||
(d->tooltipDelayMsec > 0) &&
|
(d->tooltipDelayMsec > 0) &&
|
||||||
|
@ -566,7 +576,7 @@ void FGMouseInput::processMotion(int x, int y, const osgGA::GUIEventAdapter* ea)
|
||||||
if (modeIndex == 0) {
|
if (modeIndex == 0) {
|
||||||
osg::Vec2d windowPos;
|
osg::Vec2d windowPos;
|
||||||
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
|
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
|
||||||
d->doHoverPick(windowPos);
|
d->scheduleHoverPick(windowPos);
|
||||||
// mouse has moved, so we may need to issue tooltip-timeout command again
|
// mouse has moved, so we may need to issue tooltip-timeout command again
|
||||||
d->tooltipTimeoutDone = false;
|
d->tooltipTimeoutDone = false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue