2025-07-19 21:42 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001199Spring engineGeneralpublic2010-07-14 14:27
Reportermomfreeek 
Assigned Tozerver 
PrioritynormalSeveritytweakReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version0.77b5+svn 
Target VersionFixed in Version0.82.0 
Summary0001199: [patch] mouse behaviour fix
Descriptiona few simple changes to GuiHandler.cpp. New behaviour:

Gui items (buildpics etc) register mouse clicks on MousePress rather than MouseRelease. Previous behaviour made it very easy to select the wrong buildpic if you moved the mouse fast.

Also when performing a drag operation with the mouse (such as area reclaim) releasing the mouse over the gui no longer cancels the drag. The drag command is performed and the gui element is ignored.

see issue here:
http://spring.clan-sy.com/phpbb/viewtopic.php?f=21&t=15867

I did a few tests. general mouse use & interactions with luaui, minimap, units etc all seem to work fine. I'm not very familiar with the code but the gui code seems fairly self contained and I couldn't see any potential issues.

Hope I might be able to use this with the new hardware cursor, how does it look?
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon GuiHandler.patch (1,746 bytes) 2008-11-08 14:49 -
    Index: GuiHandler.cpp
    ===================================================================
    --- GuiHandler.cpp	(revision 6992)
    +++ GuiHandler.cpp	(working copy)
    @@ -1052,7 +1052,16 @@
     		activeMousePress=true;
     	}
     	else if (AboveGui(x,y)) {
    -		activeMousePress = true;
    +		//handle click here
    +		//activeMousePress stays false so MouseRelease will be ignored
    +		const int iconPos = IconAtPos(x, y);
    +		if (iconPos >= 0) {
    +			const int iconCmd = icons[iconPos].commandsID;
    +			if ((iconCmd >= 0) && (iconCmd < commands.size())) {
    +				const bool rmb = (button == SDL_BUTTON_RIGHT);
    +				SetActiveCommand(iconCmd, rmb);
    +			}
    +		}
     		return true;
     	}
     	else if (minimap && minimap->IsAbove(x, y)) {
    @@ -1084,7 +1093,6 @@
     void CGuiHandler::MouseRelease(int x, int y, int button, float3& camerapos, float3& mousedir)
     {
     //	GML_RECMUTEX_LOCK(gui); // not needed, draw thread + read only
    -	int iconCmd = -1;
     
     	if (activeMousePress) {
     		activeMousePress = false;
    @@ -1100,28 +1108,14 @@
     
     	if (button < 0) {
     		button = -button; // proxied click from the minimap
    -	} else {
    -		// setup iconCmd
    -		if ((iconCmd < 0) && !game->hideInterface) {
    -			const int iconPos = IconAtPos(x, y);
    -			if (iconPos >= 0) {
    -				iconCmd = icons[iconPos].commandsID;
    -			}
    -		}
     	}
     
    -	if ((button == SDL_BUTTON_RIGHT) && (iconCmd == -1)) {
    +	if (button == SDL_BUTTON_RIGHT) {
     		// right click -> set the default cmd
     		inCommand = defaultCmdMemory;
     		defaultCmdMemory = -1;
     	}
     
    -	if ((iconCmd >= 0) && (iconCmd < commands.size())) {
    -		const bool rmb = (button == SDL_BUTTON_RIGHT);
    -		SetActiveCommand(iconCmd, rmb);
    -		return;
    -	}
    -
     	// not over a button, try to execute a command
     	Command c = GetCommand(x, y, button, false, camerapos, mousedir);
     
    
    patch file icon GuiHandler.patch (1,746 bytes) 2008-11-08 14:49 +

-Relationships
+Relationships

-Notes

~0003764

hoijui (reporter)

this is still not in master

in my eyes, this patch is 50/50 good/bad, because:
when pressing on button A and releasing on button B, the current system activates button B (bad). The new patch does not do this (good), but it activates button A instead (bad too in my eyes, good in momfreeek's eyes).

~0005098

jK (developer)

http://github.com/spring/spring/commit/d1a912e9c361857b41aab5c677e41be5ce381c2b
+Notes

-Issue History
Date Modified Username Field Change
2008-11-08 14:49 momfreeek New Issue
2008-11-08 14:49 momfreeek File Added: GuiHandler.patch
2009-05-20 12:48 tvo Summary mouse behaviour fix => [patch] mouse behaviour fix
2009-07-25 11:51 hoijui Note Added: 0003764
2010-07-14 14:27 jK Status new => assigned
2010-07-14 14:27 jK Assigned To => zerver
2010-07-14 14:27 jK Note Added: 0005098
2010-07-14 14:27 jK Status assigned => resolved
2010-07-14 14:27 jK Fixed in Version => 0.82
2010-07-14 14:27 jK Resolution open => fixed
+Issue History