Skip to content

Commit

Permalink
Merge pull request #372 from sbriseid/viewlib_touchpad_fix
Browse files Browse the repository at this point in the history
Fixed issue with trackpad rotation (now resetting last pos for each r…
  • Loading branch information
sbriseid authored Sep 27, 2024
2 parents 4cdff43 + 1f8fabb commit d50cb83
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions viewlib/src/gvView.C
Original file line number Diff line number Diff line change
Expand Up @@ -825,26 +825,30 @@ void gvView::mouseReleaseEvent(QMouseEvent* e)
void gvView::mouseMoveEvent(QMouseEvent* e)
//===========================================================================
{
bool alt_pressed = (QApplication::keyboardModifiers() & Qt::AltModifier);
bool ctrl_pressed = (QApplication::keyboardModifiers() & Qt::ControlModifier);
bool shift_pressed = (QApplication::keyboardModifiers() & Qt::ShiftModifier);

bool trackpad_rotate = (alt_pressed && !ctrl_pressed && !shift_pressed);
bool trackpad_zoom = (ctrl_pressed && shift_pressed && !alt_pressed);
bool trackpad_pan = (shift_pressed && !alt_pressed && !ctrl_pressed);
// We first check if any of the trackpad/touchpad keys/keycombos are active.
bool alt_down = (QApplication::keyboardModifiers() & Qt::AltModifier);
bool ctrl_down = (QApplication::keyboardModifiers() & Qt::ControlModifier);
bool shift_down = (QApplication::keyboardModifiers() & Qt::ShiftModifier);
bool trackpad_rotate = (alt_down && !ctrl_down && !shift_down);
bool trackpad_zoom = (ctrl_down && shift_down && !alt_down);
bool trackpad_pan = (shift_down && !alt_down && !ctrl_down);

bool trackpad_nav_enabled = (trackpad_rotate || trackpad_zoom || trackpad_pan);
if (!trackpad_nav_enabled_ && trackpad_nav_enabled)
{
trackpad_nav_enabled_ = true;
last_mouse_pos_ = e->pos();
starting_mouse_pos_ = e->pos();
mouse_is_active_ = true;
}

if (!mouse_is_active_ && !trackpad_nav_enabled_)
// If neither trackpad is enabled and no mouse button down we return, no transformation applied.
if (!trackpad_nav_enabled)
{
return;
trackpad_nav_enabled_ = false;
if (!mouse_is_active_)
{
return;
}
}

// Handling mouse movement while selecting first,
Expand Down

0 comments on commit d50cb83

Please sign in to comment.