1
0
forked from 0ad/0ad

Fix atlas clicking following 8f36ca47a1 / D326 by adding the missing clicks property to the wxWidgets SDL event construction.

Differential Revision: https://code.wildfiregames.com/D452
Fixes #4557
Patch By: causative
This was SVN commit r19589.
This commit is contained in:
elexis 2017-05-16 00:09:16 +00:00
parent 2599d0374e
commit 90beda96f8
3 changed files with 13 additions and 3 deletions

View File

@ -51,6 +51,11 @@
static HighResTimer g_Timer; static HighResTimer g_Timer;
/**
* wxWidgets only registers the double click on mousedown.
*/
static int g_Clicks = 1;
using namespace AtlasMessage; using namespace AtlasMessage;
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -272,9 +277,12 @@ private:
// Button down and double click appear to be mutually exclusive events, // Button down and double click appear to be mutually exclusive events,
// meaning a second button down event is not sent before a double click // meaning a second button down event is not sent before a double click
if (evt.ButtonDown() || evt.ButtonDClick()) if (evt.ButtonDown() || evt.ButtonDClick())
POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), true, evt.GetPosition())); {
g_Clicks = evt.ButtonDClick() ? 2 : 1;
POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), true, evt.GetPosition(), g_Clicks));
}
else if (evt.ButtonUp()) else if (evt.ButtonUp())
POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), false, evt.GetPosition())); POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), false, evt.GetPosition(), g_Clicks));
else if (evt.GetEventType() == wxEVT_MOTION) else if (evt.GetEventType() == wxEVT_MOTION)
POST_MESSAGE(GuiMouseMotionEvent, (evt.GetPosition())); POST_MESSAGE(GuiMouseMotionEvent, (evt.GetPosition()));
} }

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2014 Wildfire Games. /* Copyright (C) 2017 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -170,6 +170,7 @@ MESSAGEHANDLER(GuiMouseButtonEvent)
ev.ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; ev.ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP;
ev.ev.button.button = msg->button; ev.ev.button.button = msg->button;
ev.ev.button.state = msg->pressed ? SDL_PRESSED : SDL_RELEASED; ev.ev.button.state = msg->pressed ? SDL_PRESSED : SDL_RELEASED;
ev.ev.button.clicks = msg->clicks;
float x, y; float x, y;
msg->pos->GetScreenSpace(x, y); msg->pos->GetScreenSpace(x, y);
ev.ev.button.x = (u16)clamp((int)x, 0, g_xres); ev.ev.button.x = (u16)clamp((int)x, 0, g_xres);

View File

@ -90,6 +90,7 @@ MESSAGE(GuiMouseButtonEvent,
((int, button)) ((int, button))
((bool, pressed)) ((bool, pressed))
((Position, pos)) ((Position, pos))
((int, clicks))
); );
MESSAGE(GuiMouseMotionEvent, MESSAGE(GuiMouseMotionEvent,