Minor improvements.

This commit is contained in:
Martín Lucas Golini
2022-12-04 04:18:31 -03:00
parent 4ec5958638
commit 14324818ca
13 changed files with 46 additions and 8 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class EE_API Sys {
/** @return The number of milliseconds since the first call. Note that this value wraps if the
* program runs for more than ~49 days. */
static Uint32 getTicks();
static Uint64 getTicks();
/** Wait a specified number of milliseconds before returning. */
static void sleep( const Uint32& ms );
+1
View File
@@ -640,6 +640,7 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client {
};
std::vector<PluginGutterSpace> mPluginGutterSpaces;
Float mPluginsGutterSpace{ 0 };
Uint64 mLastExecuteEventId{ 0 };
UICodeEditor( const std::string& elementTag, const bool& autoRegisterBaseCommands = true,
const bool& autoRegisterBaseKeybindings = true );
+1
View File
@@ -166,6 +166,7 @@ class EE_API UIConsole : public UIWidget,
#else
Float mQuakeModeHeightPercent{ 0.6f };
#endif
Uint64 mLastExecuteEventId{ 0 };
UIConsole( Font* Font, const bool& makeDefaultCommands = true, const bool& attachToLog = true,
const unsigned int& maxLogLines = 1024 );
+1
View File
@@ -130,6 +130,7 @@ class EE_API UITextInput : public UITextView, public TextDocument::Client {
Clock mLastDoubleClick;
size_t mMenuIconSize{ 16 };
UIPopUpMenu* mCurrentMenu{ nullptr };
Uint64 mLastExecuteEventId{ 0 };
void resetWaitCursor();
+4
View File
@@ -232,6 +232,9 @@ class EE_API Input {
/** Process an input event. Called by the input update. */
void processEvent( InputEvent* Event );
/** @return An id of the current event update processed ( */
const Uint64& getEventsSentId() const;
protected:
friend class Window;
@@ -263,6 +266,7 @@ class EE_API Input {
Float mMouseSpeed;
bool mInputGrabed;
InputFinger mFingers[EE_MAX_FINGERS];
Uint64 mEventsSentId{ 0 };
std::map<Uint32, InputCallback> mCallbacks;
+2 -1
View File
@@ -817,6 +817,7 @@ end
function eepp_module_maps_add()
links { "eepp-maps-static" }
defines { "EE_MAPS_STATIC" }
includedirs { "src/modules/maps/include/","src/modules/maps/src/" }
end
@@ -904,7 +905,7 @@ end
solution "eepp"
targetdir("./bin/")
configurations { "debug", "release" }
configurations { "debug", "release" }
if os.is_real("ios") then
location("./make/" .. _OPTIONS.platform .. "/" )
+1
View File
@@ -546,6 +546,7 @@ end
function eepp_module_maps_add()
links { "eepp-maps-static" }
defines { "EE_MAPS_STATIC" }
incdirs { "src/modules/maps/include/","src/modules/maps/src/" }
end
+4 -4
View File
@@ -402,7 +402,7 @@ static void eeStartTicks() {
}
}
Uint32 Sys::getTicks() {
Uint64 Sys::getTicks() {
eeStartTicks();
#if EE_PLATFORM == EE_PLATFORM_WIN
@@ -414,16 +414,16 @@ Uint32 Sys::getTicks() {
hires_now.QuadPart *= 1000;
hires_now.QuadPart /= hires_ticks_per_second.QuadPart;
return (DWORD)hires_now.QuadPart;
return (Uint64)hires_now.QuadPart;
#elif defined( EE_PLATFORM_POSIX )
#ifdef EE_HAVE_CLOCK_GETTIME
Uint32 ticks;
Uint64 ticks;
struct timespec now;
clock_gettime( CLOCK_MONOTONIC, &now );
ticks = ( now.tv_sec - start.tv_sec ) * 1000 + ( now.tv_nsec - start.tv_nsec ) / 1000000;
return ( ticks );
#else
Uint32 ticks;
Uint64 ticks;
struct timeval now;
gettimeofday( &now, NULL );
ticks = ( now.tv_sec - start.tv_sec ) * 1000 + ( now.tv_usec - start.tv_usec ) / 1000;
+5
View File
@@ -792,6 +792,7 @@ void UICodeEditor::invalidateLongestLineWidth() {
Uint32 UICodeEditor::onFocus() {
if ( !mLocked ) {
getUISceneNode()->getWindow()->startTextInput();
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
resetCursor();
mDoc->setActiveClient( this );
}
@@ -820,6 +821,9 @@ Uint32 UICodeEditor::onTextInput( const TextInputEvent& event ) {
if ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' )
return 0;
if ( mLastExecuteEventId == getUISceneNode()->getWindow()->getInput()->getEventsSentId() )
return 0;
mDoc->textInput( event.getText() );
checkAutoCloseXMLTag( event.getText() );
@@ -844,6 +848,7 @@ Uint32 UICodeEditor::onKeyDown( const KeyEvent& event ) {
// Allow copy selection on locked mode
if ( !mLocked || mUnlockedCmd.find( cmd ) != mUnlockedCmd.end() ) {
mDoc->execute( cmd );
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
return 1;
}
}
+6
View File
@@ -754,6 +754,7 @@ Uint32 UIConsole::onKeyDown( const KeyEvent& event ) {
std::string cmd = mKeyBindings.getCommandFromKeyBind( { event.getKeyCode(), event.getMod() } );
if ( !cmd.empty() ) {
mDoc.execute( cmd );
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
return 1;
}
return UIWidget::onKeyDown( event );
@@ -765,6 +766,9 @@ Uint32 UIConsole::onTextInput( const TextInputEvent& event ) {
if ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' )
return 0;
if ( mLastExecuteEventId == getUISceneNode()->getWindow()->getInput()->getEventsSentId() )
return 0;
const String& text = event.getText();
for ( size_t i = 0; i < text.size(); i++ ) {
@@ -836,6 +840,8 @@ Uint32 UIConsole::onFocus() {
getSceneNode()->getWindow()->startTextInput();
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
return 1;
}
+6
View File
@@ -155,6 +155,8 @@ Uint32 UITextInput::onFocus() {
resetWaitCursor();
getSceneNode()->getWindow()->startTextInput();
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
}
return 1;
@@ -727,6 +729,7 @@ Uint32 UITextInput::onKeyDown( const KeyEvent& event ) {
// Allow copy selection on locked mode
if ( mAllowEditing ) {
mDoc.execute( cmd );
mLastExecuteEventId = getUISceneNode()->getWindow()->getInput()->getEventsSentId();
return 1;
}
}
@@ -741,6 +744,9 @@ Uint32 UITextInput::onTextInput( const TextInputEvent& event ) {
if ( input->isLeftAltPressed() && !event.getText().empty() && event.getText()[0] == '\t' )
return 0;
if ( mLastExecuteEventId == getUISceneNode()->getWindow()->getInput()->getEventsSentId() )
return 0;
const String& text = event.getText();
for ( size_t i = 0; i < text.size(); i++ ) {
+10 -2
View File
@@ -7,6 +7,7 @@
#include <eepp/window/backend/SDL2/joystickmanagersdl2.hpp>
#include <eepp/window/backend/SDL2/windowsdl2.hpp>
#include <eepp/window/engine.hpp>
#include <limits>
namespace EE { namespace Window { namespace Backend { namespace SDL2 {
@@ -22,6 +23,11 @@ InputSDL::~InputSDL() {}
void InputSDL::update() {
SDL_Event SDLEvent;
cleanStates();
++mEventsSentId;
if ( mEventsSentId == std::numeric_limits<Uint64>::max() )
mEventsSentId = 0;
if ( !mQueuedEvents.empty() ) {
for ( auto prevEvent : mQueuedEvents )
sendEvent( prevEvent );
@@ -39,8 +45,10 @@ void InputSDL::waitEvent( const Time& timeout ) {
if ( timeout == Time::Zero ) {
if ( SDL_WaitEvent( &SDLEvent ) )
mQueuedEvents.emplace_back( SDLEvent );
} else if ( SDL_WaitEventTimeout( &SDLEvent, (int)timeout.asMilliseconds() ) )
mQueuedEvents.emplace_back( SDLEvent );
} else if ( SDL_WaitEventTimeout( &SDLEvent, (int)timeout.asMilliseconds() ) ) {
if ( SDLEvent.type != SDL_FIRSTEVENT )
mQueuedEvents.emplace_back( SDLEvent );
}
}
bool InputSDL::grabInput() {
+4
View File
@@ -27,6 +27,10 @@ Input::Input( EE::Window::Window* window, JoystickManager* joystickmanager ) :
memset( mScancodeUp, 0, EE_KEYS_SPACE );
}
const Uint64& Input::getEventsSentId() const {
return mEventsSentId;
}
Input::~Input() {
eeSAFE_DELETE( mJoystickManager );
}