Author: ilor
Date: Wed Jul 9 21:34:36 2008
New Revision: 27879
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27879&view=rev
Log:
Fix dragging out of window issue in editor by a patch in game mouse handling.
This may have some side effects that I have not thought of.
Modified:
trunk/src/controller_base.cpp
trunk/src/mouse_handler_base.hpp
Modified: trunk/src/controller_base.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/controller_base.cpp?rev=27879&r1=27878&r2=27879&view=diff
==============================================================================
--- trunk/src/controller_base.cpp (original)
+++ trunk/src/controller_base.cpp Wed Jul 9 21:34:36 2008
@@ -72,6 +72,25 @@
case SDL_MOUSEBUTTONUP:
get_mouse_handler_base().mouse_press(event.button, browse_);
post_mouse_press(event);
+ break;
+ case SDL_ACTIVEEVENT:
+ if (event.active.type == SDL_APPMOUSEFOCUS && event.active.gain
== 0) {
+ if (get_mouse_handler_base().is_dragging()) {
+ //simulate mouse button up when the app has
lost mouse focus
+ //this should be a general fix for the issue
when the mouse
+ //is dragged out of the game window and then
the button is released
+ SDL_Event e;
+ e.type = SDL_MOUSEBUTTONUP;
+ e.button.state = SDL_RELEASED;
+ e.button.button = SDL_BUTTON_LEFT;
+ int x, y;
+ SDL_GetMouseState(&x, &y);
+ e.button.x = x;
+ e.button.y = y;
+
get_mouse_handler_base().mouse_press(event.button, browse_);
+ post_mouse_press(event);
+ }
+ }
break;
default:
break;
Modified: trunk/src/mouse_handler_base.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/mouse_handler_base.hpp?rev=27879&r1=27878&r2=27879&view=diff
==============================================================================
--- trunk/src/mouse_handler_base.hpp (original)
+++ trunk/src/mouse_handler_base.hpp Wed Jul 9 21:34:36 2008
@@ -48,6 +48,8 @@
void mouse_motion_event(const SDL_MouseMotionEvent& event, const bool
browse);
/** update the mouse with a fake mouse motion */
void mouse_update(const bool browse);
+
+ bool is_dragging() { return dragging_; }
/**
* This handles minimap scrolling and click-drag.
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits