2025-07-02 00:07 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001737Spring engineGeneralpublic2010-07-14 14:16
Reporterstephenashelton 
Assigned TojK 
PrioritynormalSeveritytweakReproducibilityalways
StatusresolvedResolutionfixed 
Product Version0.80.5+git 
Target VersionFixed in Version 
Summary0001737: Mouse drag should not be detected solely by time
DescriptionThe middle mouse button click toggles camera mode (where the camera follows mouse movement), but click vs drag is determined solely by time. This patch also checks that the position hasn't substantially changed.
Additional InformationIn my current build, the entire block of code commented out (not a fan of this feature). Perhaps adding this to SpringSettings would be a good call?
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon draw_recognition.patch (1,485 bytes) 2009-11-22 07:52 -
    diff --git a/rts/Game/UI/MouseHandler.cpp b/rts/Game/UI/MouseHandler.cpp
    index 6084d54..0a0d478 100644
    --- a/rts/Game/UI/MouseHandler.cpp
    +++ b/rts/Game/UI/MouseHandler.cpp
    @@ -42,6 +42,7 @@
     #include "Sound/Sound.h"
     #include "Sound/AudioChannel.h"
     #include <boost/cstdint.hpp>
    +#include "math.h"
     
     // can't be up there since those contain conflicting definitions
     #include <SDL_mouse.h>
    @@ -324,11 +325,17 @@ void CMouseHandler::MouseRelease(int x, int y, int button)
            }
     
            // Switch camera mode on a middle click that wasn't a middle mouse drag scroll.
    -       // (the latter is determined by the time the mouse was held down:
    -       //  <= 0.3 s means a camera mode switch, > 0.3 s means a drag scroll)
    +       // (the latter is determined by the time the mouse was held down and current 
    +       // position being less than 3 pixels away from the click
    +       //  <= 0.3 s and < 3 px away (in x or y) means a camera mode switch, 
    +       //  > 0.3 s means a drag scroll)
            if (button == SDL_BUTTON_MIDDLE) {
    -               if (buttons[SDL_BUTTON_MIDDLE].time > (gu->gameTime - 0.3f))
    +               ButtonPressEvt lastEvent = buttons[SDL_BUTTON_MIDDLE];
    +               if ( lastEvent.time > (gu->gameTime - 0.3f)
    +                                       && abs(lastEvent.x - lastx) < 3
    +                                       && abs(lastEvent.y - lasty) < 3 ) {
                            ToggleState();
    +               }
                    return;
            }
    
    
    patch file icon draw_recognition.patch (1,485 bytes) 2009-11-22 07:52 +

-Relationships
+Relationships

-Notes

~0005094

jK (developer)

For ppl who dislike MiddleClickScrolling there is `MouseDragScrollThreshold` now,
making MiddleClickScrolling moved pixels dependend is unwanted for me, if it is that important make a patch with a user config to customize the maxMovedPixels.
+Notes

-Issue History
Date Modified Username Field Change
2009-11-22 07:52 stephenashelton New Issue
2009-11-22 07:52 stephenashelton File Added: draw_recognition.patch
2010-07-14 14:16 jK Note Added: 0005094
2010-07-14 14:16 jK Status new => resolved
2010-07-14 14:16 jK Resolution open => fixed
2010-07-14 14:16 jK Assigned To => jK
+Issue History