fix dragging

This commit is contained in:
Chris Forbes
2010-02-18 00:26:11 +13:00
parent 262bf55219
commit ecb92c45b6

View File

@@ -57,6 +57,9 @@ namespace OpenRa.GlRenderer
Glfw.glfwInit(); Glfw.glfwInit();
Glfw.glfwOpenWindow(width, height, 0, 0, 0, 0, 0, 0, fullscreen ? Glfw.GLFW_FULLSCREEN : Glfw.GLFW_WINDOW); Glfw.glfwOpenWindow(width, height, 0, 0, 0, 0, 0, 0, fullscreen ? Glfw.GLFW_FULLSCREEN : Glfw.GLFW_WINDOW);
bool initDone = false; bool initDone = false;
var lastButtonBits = (MouseButtons)0;
Glfw.glfwSetMouseButtonCallback( mouseButtonCallback = ( button, action ) => Glfw.glfwSetMouseButtonCallback( mouseButtonCallback = ( button, action ) =>
{ {
var b = button == Glfw.GLFW_MOUSE_BUTTON_1 ? MouseButtons.Left var b = button == Glfw.GLFW_MOUSE_BUTTON_1 ? MouseButtons.Left
@@ -65,13 +68,15 @@ namespace OpenRa.GlRenderer
: 0; : 0;
Game.DispatchMouseInput( action == Glfw.GLFW_PRESS ? MouseInputEvent.Down : MouseInputEvent.Up, Game.DispatchMouseInput( action == Glfw.GLFW_PRESS ? MouseInputEvent.Down : MouseInputEvent.Up,
new MouseEventArgs( b, action == Glfw.GLFW_PRESS ? 1 : 0, mouseX, mouseY, 0 ), 0 ); new MouseEventArgs( b, action == Glfw.GLFW_PRESS ? 1 : 0, mouseX, mouseY, 0 ), 0 );
lastButtonBits = action == Glfw.GLFW_PRESS ? b : 0;
} ); } );
Glfw.glfwSetMousePosCallback(mousePositionCallback = (x, y) => Glfw.glfwSetMousePosCallback(mousePositionCallback = (x, y) =>
{ {
mouseX = x; mouseX = x;
mouseY = y; mouseY = y;
if (initDone) if (initDone)
Game.DispatchMouseInput(MouseInputEvent.Move, new MouseEventArgs(0, 0, x, y, 0), 0); Game.DispatchMouseInput(MouseInputEvent.Move, new MouseEventArgs(lastButtonBits, 0, x, y, 0), 0);
}); });
Glfw.glfwSetWindowCloseCallback( windowCloseCallback = () => Glfw.glfwSetWindowCloseCallback( windowCloseCallback = () =>
{ {