fix mouse chasing in 2x2 & floating layouts
QTimer was getting new connections added w/o removing existing ones; fix the same in FreezePointer zero check is seemingly not needed now; zeros spam was caused by this QTimer misuse
This commit is contained in:
parent
2d11fdee43
commit
27dff0c888
|
|
@ -159,6 +159,7 @@ protected:
|
||||||
// handle runaways with released buttons; FIXME: need more elegant way to persistently grab in this case
|
// handle runaways with released buttons; FIXME: need more elegant way to persistently grab in this case
|
||||||
if( !m_widget->rect().contains( mouseEvent->pos() ) ){ // bomb cursor via timer to get it back to the widget
|
if( !m_widget->rect().contains( mouseEvent->pos() ) ){ // bomb cursor via timer to get it back to the widget
|
||||||
if( !m_rescueTimer.isActive() ){
|
if( !m_rescueTimer.isActive() ){
|
||||||
|
m_rescueTimer.disconnect(); // disconnect everything
|
||||||
m_rescueTimer.callOnTimeout( [center = center](){ QCursor::setPos( center ); } );
|
m_rescueTimer.callOnTimeout( [center = center](){ QCursor::setPos( center ); } );
|
||||||
m_rescueTimer.start( 33 );
|
m_rescueTimer.start( 33 );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -295,13 +295,11 @@ static QTimer g_chasemouse_caller;
|
||||||
|
|
||||||
void XYWnd::ChaseMouse(){
|
void XYWnd::ChaseMouse(){
|
||||||
const float multiplier = g_chasemouse_timer.elapsed_msec() / 10.0f;
|
const float multiplier = g_chasemouse_timer.elapsed_msec() / 10.0f;
|
||||||
if( multiplier != 0 ){ // a lot of zeros happen = torn, slow, inconsistent motion 🤔
|
g_chasemouse_timer.start();
|
||||||
g_chasemouse_timer.start();
|
Scroll( float_to_integer( multiplier * m_chasemouse_delta_x ), float_to_integer( multiplier * -m_chasemouse_delta_y ) );
|
||||||
Scroll( float_to_integer( multiplier * m_chasemouse_delta_x ), float_to_integer( multiplier * -m_chasemouse_delta_y ) );
|
//globalOutputStream() << "chasemouse: multiplier=" << multiplier << " x=" << m_chasemouse_delta_x << " y=" << m_chasemouse_delta_y << '\n';
|
||||||
//globalOutputStream() << "chasemouse: multiplier=" << multiplier << " x=" << m_chasemouse_delta_x << " y=" << m_chasemouse_delta_y << '\n';
|
|
||||||
|
|
||||||
XY_MouseMoved( m_chasemouse_current_x, m_chasemouse_current_y, getButtonState() );
|
XY_MouseMoved( m_chasemouse_current_x, m_chasemouse_current_y, getButtonState() );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool XYWnd::chaseMouseMotion( const int x, const int y ){
|
bool XYWnd::chaseMouseMotion( const int x, const int y ){
|
||||||
|
|
@ -332,6 +330,7 @@ bool XYWnd::chaseMouseMotion( const int x, const int y ){
|
||||||
if ( !g_chasemouse_caller.isActive() ) {
|
if ( !g_chasemouse_caller.isActive() ) {
|
||||||
//globalOutputStream() << "chasemouse timer start... ";
|
//globalOutputStream() << "chasemouse timer start... ";
|
||||||
g_chasemouse_timer.start();
|
g_chasemouse_timer.start();
|
||||||
|
g_chasemouse_caller.disconnect(); // disconnect everything
|
||||||
g_chasemouse_caller.callOnTimeout( [this](){ ChaseMouse(); } );
|
g_chasemouse_caller.callOnTimeout( [this](){ ChaseMouse(); } );
|
||||||
g_chasemouse_caller.start( 4 ); // with 0 consumes entire thread by spamming calls 🤷♀️
|
g_chasemouse_caller.start( 4 ); // with 0 consumes entire thread by spamming calls 🤷♀️
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user