浏览代码

Merge pull request #335 from dydzio0614/bug2476_fix2

Fix #2 for bug #2476
ArseniyShestakov 8 年之前
父节点
当前提交
2cf7c7b234
共有 3 个文件被更改,包括 7 次插入1 次删除
  1. 1 1
      client/gui/CGuiHandler.cpp
  2. 5 0
      client/gui/SDL_Extensions.cpp
  3. 1 0
      client/gui/SDL_Extensions.h

+ 1 - 1
client/gui/CGuiHandler.cpp

@@ -402,7 +402,7 @@ void CGuiHandler::handleMoveInterested(const SDL_MouseMotionEvent & motion)
 	std::list<CIntObject*> miCopy = motioninterested;
 	for(auto & elem : miCopy)
 	{
-		if ((elem)->strongInterest || isItIn(&(elem)->pos, motion.x-1, motion.y-1)) //-1 offset to include lower bound, fixes bug #2476
+		if(elem->strongInterest || isItInOrLowerBounds(&elem->pos, motion.x, motion.y)) //checking lower bounds fixes bug #2476
 		{
 			(elem)->mouseMoved(motion);
 		}

+ 5 - 0
client/gui/SDL_Extensions.cpp

@@ -62,6 +62,11 @@ bool isItIn(const SDL_Rect * rect, int x, int y)
 	return (x>rect->x && x<rect->x+rect->w) && (y>rect->y && y<rect->y+rect->h);
 }
 
+bool isItInOrLowerBounds(const SDL_Rect * rect, int x, int y)
+{
+	return (x >= rect->x && x < rect->x + rect->w) && (y >= rect->y && y < rect->y + rect->h);
+}
+
 void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
 {
 	if(!dst) dst = screen;

+ 1 - 0
client/gui/SDL_Extensions.h

@@ -70,6 +70,7 @@ extern SDL_Surface * screen, *screen2, *screenBuf;
 void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst=screen);
 void blitAt(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst=screen);
 bool isItIn(const SDL_Rect * rect, int x, int y);
+bool isItInOrLowerBounds(const SDL_Rect * rect, int x, int y);
 
 /**
  * The colors class defines color constants of type SDL_Color.