Skip to content

Commit

Permalink
Work around a wxGTK bug causing duplicate wheel events (fixes #1216)
Browse files Browse the repository at this point in the history
  • Loading branch information
eevee committed Sep 24, 2024
1 parent 205e897 commit 3188c78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/MapEditor/UI/MapCanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,13 @@ void MapCanvas::onMouseMotion(wxMouseEvent& e)
// -----------------------------------------------------------------------------
void MapCanvas::onMouseWheel(wxMouseEvent& e)
{
// wxGTK has a bug causing duplicate wheel events, but the duplicates have
// exactly the same timestamp, which makes them easy to detect
if (e.GetTimestamp() == last_wheel_timestamp_)
return;
else
last_wheel_timestamp_ = e.GetTimestamp();

#ifdef __WXOSX__
double mwheel_rotation = (double)e.GetWheelRotation() / (double)e.GetWheelDelta();
if (mwheel_rotation < 0)
Expand Down
1 change: 1 addition & 0 deletions src/MapEditor/UI/MapCanvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class MapCanvas : public OGLCanvas, public KeyBindHandler
bool mouse_warp_ = false;
vector<int> fps_avg_;
sf::Clock sf_clock_;
long last_wheel_timestamp_ = -1;

// Events
void onSize(wxSizeEvent& e);
Expand Down

0 comments on commit 3188c78

Please sign in to comment.