Converted the internal timer from timeval to std::chrono::time_point<system_clock>

This commit is contained in:
Markus Gans 2021-06-16 15:42:46 +02:00
parent de4ac269e4
commit 85ae1612fd
19 changed files with 333 additions and 437 deletions

View File

@ -1,3 +1,7 @@
2021-06-16 Markus Gans <guru.mail@muenster.de>
* Converted the internal timer from timeval
to std::chrono::time_point<system_clock>
2021-06-06 Markus Gans <guru.mail@muenster.de> 2021-06-06 Markus Gans <guru.mail@muenster.de>
* Bug fixing in FString and FTermDetection * Bug fixing in FString and FTermDetection
* FTermDetection now has clean code by using FString instead of char* * FTermDetection now has clean code by using FString instead of char*

View File

@ -43,7 +43,7 @@ fi
# Build commands # Build commands
case "$1" in case "$1" in
"--release"|"release") "--release"|"release")
if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-fno-rtti" if ! ./configure --prefix="$PREFIX" CXXFLAGS="-O3" # "-flto -fno-rtti"
then then
echo "${RED}Configure failed!${NORMAL}" 1>&2 echo "${RED}Configure failed!${NORMAL}" 1>&2
exit 255 exit 255

View File

@ -110,15 +110,14 @@ Watch::Watch (FWidget* parent)
void Watch::printTime() void Watch::printTime()
{ {
finalcut::FString str{}; finalcut::FString str{};
std::tm now{}; using namespace std::chrono;
auto now = system_clock::to_time_t(system_clock::now());
const std::time_t t = std::time(nullptr); // get current time auto lt = *localtime(&now);
localtime_r(&t, &now);
if ( sec ) if ( sec )
str.sprintf("%02d:%02d:%02d", now.tm_hour, now.tm_min, now.tm_sec); str.sprintf("%02d:%02d:%02d", lt.tm_hour, lt.tm_min, lt.tm_sec);
else else
str.sprintf("%02d:%02d ", now.tm_hour, now.tm_min); str.sprintf("%02d:%02d ", lt.tm_hour, lt.tm_min);
time_str = str; time_str = str;
time_str.redraw(); time_str.redraw();

View File

@ -103,7 +103,7 @@ Special X11 bitmap font used by FINAL CUT to display graphic objects.
%build %build
autoreconf -vif autoreconf -vif
export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic" export CPPFLAGS="%{optflags} -Wall -Wextra -Wpedantic -flto"
%ifnarch %ix86 x86_64 %ifnarch %ix86 x86_64
export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter" export CPPFLAGS="$CPPFLAGS -Wno-error=unused-parameter"
%endif %endif

View File

@ -72,7 +72,7 @@ int FApplication::loop_level {0}; // event loop level
int FApplication::quit_code {EXIT_SUCCESS}; int FApplication::quit_code {EXIT_SUCCESS};
bool FApplication::quit_now {false}; bool FApplication::quit_now {false};
uInt64 FApplication::next_event_wait {5000}; // 5 ms (200 Hz) uInt64 FApplication::next_event_wait {5000}; // 5 ms (200 Hz)
struct timeval FApplication::time_last_event {}; TimeValue FApplication::time_last_event {};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -392,8 +392,7 @@ void FApplication::init()
setMaxChildren(1); setMaxChildren(1);
// Initialize the last event time // Initialize the last event time
time_last_event.tv_sec = 0; time_last_event = TimeValue{};
time_last_event.tv_usec = 0;
// Initialize keyboard // Initialize keyboard
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FTerm::getFKeyboard();
@ -858,7 +857,7 @@ void FApplication::queuingMouseInput() const
return; return;
auto& keyboard = FTerm::getFKeyboard(); auto& keyboard = FTerm::getFKeyboard();
struct timeval* time_keypressed = keyboard.getKeyPressedTime(); auto time_keypressed = keyboard.getKeyPressedTime();
mouse.processEvent (time_keypressed); mouse.processEvent (time_keypressed);
keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput(); keyboard.hasUnprocessedInput() = mouse.hasUnprocessedInput();
mouse.clearEvent(); mouse.clearEvent();
@ -1308,7 +1307,7 @@ bool FApplication::processNextEvent()
if ( is_timeout || hasDataInQueue() ) if ( is_timeout || hasDataInQueue() )
{ {
FObject::getCurrentTime (&time_last_event); time_last_event = FObject::getCurrentTime();
queuingKeyboardInput(); queuingKeyboardInput();
queuingMouseInput(); queuingMouseInput();
processKeyboardEvent(); processKeyboardEvent();
@ -1401,7 +1400,7 @@ bool FApplication::isEventProcessable ( FObject* receiver
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FApplication::isNextEventTimeout() bool FApplication::isNextEventTimeout()
{ {
return FObject::isTimeout (&time_last_event, next_event_wait); return FObject::isTimeout (time_last_event, next_event_wait);
} }

View File

@ -51,7 +51,7 @@ uInt64 FKeyboard::key_timeout{100000}; // 100 ms (10 Hz)
uInt64 FKeyboard::read_blocking_time{100000}; // 100 ms (10 Hz) uInt64 FKeyboard::read_blocking_time{100000}; // 100 ms (10 Hz)
uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz) uInt64 FKeyboard::read_blocking_time_short{5000}; // 5 ms (200 Hz)
bool FKeyboard::non_blocking_input_support{true}; bool FKeyboard::non_blocking_input_support{true};
struct timeval FKeyboard::time_keypressed{}; TimeValue FKeyboard::time_keypressed{};
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -63,8 +63,7 @@ struct timeval FKeyboard::time_keypressed{};
FKeyboard::FKeyboard() FKeyboard::FKeyboard()
{ {
// Initialize keyboard values // Initialize keyboard values
time_keypressed.tv_sec = 0; time_keypressed = TimeValue{}; // Set to epoch time
time_keypressed.tv_usec = 0;
// Get the stdin file status flags // Get the stdin file status flags
stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL); stdin_status_flags = fcntl(FTermios::getStdIn(), F_GETFL);
@ -392,7 +391,7 @@ inline FKey FKeyboard::getSingleKey()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FKeyboard::isKeypressTimeout() inline bool FKeyboard::isKeypressTimeout()
{ {
return FObject::isTimeout (&time_keypressed, key_timeout); return FObject::isTimeout (time_keypressed, key_timeout);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -457,7 +456,7 @@ inline ssize_t FKeyboard::readKey()
void FKeyboard::parseKeyBuffer() void FKeyboard::parseKeyBuffer()
{ {
ssize_t bytesread{}; ssize_t bytesread{};
FObject::getCurrentTime (&time_keypressed); time_keypressed = FObject::getCurrentTime();
while ( (bytesread = readKey()) > 0 ) while ( (bytesread = readKey()) > 0 )
{ {

View File

@ -196,37 +196,37 @@ FString FMouse::getClassName() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMouse::clearEvent() void FMouse::clearEvent()
{ {
mouse_event_occurred = false; mouse_event_occurred = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMouse::setMaxWidth (uInt16 x_max) void FMouse::setMaxWidth (uInt16 x_max)
{ {
max_width = x_max; max_width = x_max;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMouse::setMaxHeight (uInt16 y_max) void FMouse::setMaxHeight (uInt16 y_max)
{ {
max_height = y_max; max_height = y_max;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FMouse::setDblclickInterval (const uInt64 timeout) void FMouse::setDblclickInterval (const uInt64 timeout)
{ {
dblclick_interval = timeout; dblclick_interval = timeout;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMouse::hasEvent() const bool FMouse::hasEvent() const
{ {
return mouse_event_occurred; return mouse_event_occurred;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FMouse::hasUnprocessedInput() const bool FMouse::hasUnprocessedInput() const
{ {
return unprocessed_buffer_data; return unprocessed_buffer_data;
} }
@ -234,7 +234,7 @@ inline bool FMouse::hasUnprocessedInput() const
// protected methods of FMouse // protected methods of FMouse
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline const FPoint& FMouse::getNewPos() const const FPoint& FMouse::getNewPos() const
{ {
return new_mouse_position; return new_mouse_position;
} }
@ -258,9 +258,9 @@ uInt64 FMouse::getDblclickInterval() const
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
timeval* FMouse::getMousePressedTime() TimeValue FMouse::getMousePressedTime()
{ {
return &time_mousepressed; return time_mousepressed;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -276,16 +276,15 @@ void FMouse::setPending (bool is_pending)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::setMousePressedTime (const timeval* time) void FMouse::setMousePressedTime (const TimeValue& time)
{ {
time_mousepressed = *time; time_mousepressed = time;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouse::resetMousePressedTime() void FMouse::resetMousePressedTime()
{ {
time_mousepressed.tv_sec = 0; time_mousepressed = TimeValue{}; // Set to epoch time
time_mousepressed.tv_usec = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -295,7 +294,7 @@ void FMouse::setEvent()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMouse::isDblclickTimeout (const timeval* time) const bool FMouse::isDblclickTimeout (const TimeValue& time) const
{ {
return FObject::isTimeout (time, dblclick_interval); return FObject::isTimeout (time, dblclick_interval);
} }
@ -341,7 +340,7 @@ void FMouseGPM::setRawData (FKeyboard::keybuffer&)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseGPM::processEvent (struct timeval*) void FMouseGPM::processEvent (const TimeValue&)
{ {
clearButtonState(); clearButtonState();
@ -582,7 +581,7 @@ void FMouseX11::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseX11::processEvent (struct timeval* time) void FMouseX11::processEvent (const TimeValue& time)
{ {
// Parse and interpret the X11 xterm mouse string // Parse and interpret the X11 xterm mouse string
@ -641,7 +640,7 @@ void FMouseX11::setMoveState (const FPoint& mouse_position, int btn)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseX11::setButtonState (const int btn, const struct timeval* time) void FMouseX11::setButtonState (const int btn, const TimeValue& time)
{ {
// Get the x11 mouse button state // Get the x11 mouse button state
@ -765,7 +764,7 @@ void FMouseSGR::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseSGR::processEvent (struct timeval* time) void FMouseSGR::processEvent (const TimeValue& time)
{ {
const auto& mouse_position = getPos(); const auto& mouse_position = getPos();
uInt16 x{0}; uInt16 x{0};
@ -867,7 +866,7 @@ void FMouseSGR::setMoveState (const FPoint& mouse_position, int btn)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseSGR::setPressedButtonState ( const int btn void FMouseSGR::setPressedButtonState ( const int btn
, const struct timeval* time ) , const TimeValue& time )
{ {
// Gets the extended x11 mouse mode (SGR) status for pressed buttons // Gets the extended x11 mouse mode (SGR) status for pressed buttons
@ -995,7 +994,7 @@ void FMouseUrxvt::setRawData (FKeyboard::keybuffer& fifo_buf)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseUrxvt::processEvent (struct timeval* time) void FMouseUrxvt::processEvent (const TimeValue& time)
{ {
// Parse and interpret the X11 xterm mouse string (Urxvt-Mode) // Parse and interpret the X11 xterm mouse string (Urxvt-Mode)
@ -1122,7 +1121,7 @@ void FMouseUrxvt::setMoveState (const FPoint& mouse_position, int btn)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseUrxvt::setButtonState (const int btn, const struct timeval* time) void FMouseUrxvt::setButtonState (const int btn, const TimeValue& time)
{ {
// Get the urxvt mouse button state // Get the urxvt mouse button state
@ -1561,7 +1560,7 @@ void FMouseControl::processQueuedInput()
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMouseControl::processEvent (struct timeval* time) void FMouseControl::processEvent (const TimeValue& time)
{ {
auto mtype = getMouseWithData(); auto mtype = getMouseWithData();
auto mouse_object = mouse_protocol[mtype].get(); auto mouse_object = mouse_protocol[mtype].get();

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2015-2020 Markus Gans * * Copyright 2015-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -21,6 +21,7 @@
***********************************************************************/ ***********************************************************************/
#include <memory> #include <memory>
#include <mutex>
#include "final/fevent.h" #include "final/fevent.h"
#include "final/fc.h" #include "final/fc.h"
@ -29,8 +30,17 @@
namespace finalcut namespace finalcut
{ {
// static class attributes namespace internal
bool FObject::timer_modify_lock; {
struct var
{
static std::mutex timer_mutex;
};
std::mutex var::timer_mutex{};
} // namespace internal
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -44,8 +54,6 @@ FObject::FObject (FObject* parent)
{ {
if ( parent ) // add object to parent if ( parent ) // add object to parent
parent->addChild(this); parent->addChild(this);
else
timer_modify_lock = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -179,54 +187,24 @@ bool FObject::event (FEvent* ev)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObject::getCurrentTime (timeval* time) TimeValue FObject::getCurrentTime()
{ {
// Get the current time as timeval struct return system_clock::now(); // Get the current time
gettimeofday(time, nullptr);
// NTP fix
while ( time->tv_usec >= 1000000 )
{
time->tv_usec -= 1000000;
time->tv_sec++;
}
while ( time->tv_usec < 0 )
{
if ( time->tv_sec > 0 )
{
time->tv_usec += 1000000;
time->tv_sec--;
}
else
{
time->tv_usec = 0;
break;
}
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FObject::isTimeout (const timeval* time, uInt64 timeout) bool FObject::isTimeout (const TimeValue& time, uInt64 timeout)
{ {
// Checks whether the specified time span (timeout in µs) has elapse // Checks whether the specified time span (timeout in µs) has elapsed
struct timeval now{}; const auto now = getCurrentTime();
struct timeval diff{};
FObject::getCurrentTime(&now); if ( now < time )
diff.tv_sec = now.tv_sec - time->tv_sec; return false;
diff.tv_usec = now.tv_usec - time->tv_usec;
if ( diff.tv_usec < 0 ) const auto diff = now - time;
{ const auto diff_usec = uInt64(duration_cast<microseconds>(diff).count());
diff.tv_sec--; return diff_usec > timeout;
diff.tv_usec += 1000000;
}
const auto diff_usec = uInt64((diff.tv_sec * 1000000) + diff.tv_usec);
return ( diff_usec > timeout );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -235,10 +213,8 @@ int FObject::addTimer (int interval)
// Create a timer and returns the timer identifier number // Create a timer and returns the timer identifier number
// (interval in ms) // (interval in ms)
timeval time_interval{};
timeval currentTime{};
int id{1}; int id{1};
timer_modify_lock = true; std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
// find an unused timer id // find an unused timer id
@ -262,10 +238,8 @@ int FObject::addTimer (int interval)
if ( id <= 0 || id > int(timer_list->size() + 1) ) if ( id <= 0 || id > int(timer_list->size() + 1) )
return 0; return 0;
time_interval.tv_sec = interval / 1000; const auto time_interval = milliseconds(interval);
time_interval.tv_usec = (interval % 1000) * 1000; const auto timeout = getCurrentTime() + time_interval;
getCurrentTime (&currentTime);
timeval timeout = currentTime + time_interval;
FTimerData t{ id, time_interval, timeout, this }; FTimerData t{ id, time_interval, timeout, this };
// insert in list sorted by timeout // insert in list sorted by timeout
@ -276,7 +250,6 @@ int FObject::addTimer (int interval)
++iter; ++iter;
timer_list->insert (iter, t); timer_list->insert (iter, t);
timer_modify_lock = false;
return id; return id;
} }
@ -288,7 +261,7 @@ bool FObject::delTimer (int id) const
if ( id <= 0 ) if ( id <= 0 )
return false; return false;
timer_modify_lock = true; std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
auto iter = timer_list->begin(); auto iter = timer_list->begin();
const auto& last = timer_list->end(); const auto& last = timer_list->end();
@ -299,11 +272,9 @@ bool FObject::delTimer (int id) const
if ( iter != last ) if ( iter != last )
{ {
timer_list->erase(iter); timer_list->erase(iter);
timer_modify_lock = false;
return true; return true;
} }
timer_modify_lock = false;
return false; return false;
} }
@ -312,6 +283,7 @@ bool FObject::delOwnTimers() const
{ {
// Deletes all timers of this object // Deletes all timers of this object
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
if ( ! timer_list ) if ( ! timer_list )
@ -320,7 +292,6 @@ bool FObject::delOwnTimers() const
if ( timer_list->empty() ) if ( timer_list->empty() )
return false; return false;
timer_modify_lock = true;
auto iter = timer_list->begin(); auto iter = timer_list->begin();
while ( iter != timer_list->end() ) while ( iter != timer_list->end() )
@ -331,7 +302,6 @@ bool FObject::delOwnTimers() const
++iter; ++iter;
} }
timer_modify_lock = false;
return true; return true;
} }
@ -340,6 +310,7 @@ bool FObject::delAllTimers() const
{ {
// Deletes all timers of all objects // Deletes all timers of all objects
std::lock_guard<std::mutex> lock_guard(internal::var::timer_mutex);
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
if ( ! timer_list ) if ( ! timer_list )
@ -348,10 +319,8 @@ bool FObject::delAllTimers() const
if ( timer_list->empty() ) if ( timer_list->empty() )
return false; return false;
timer_modify_lock = true;
timer_list->clear(); timer_list->clear();
timer_list->shrink_to_fit(); timer_list->shrink_to_fit();
timer_modify_lock = false;
return true; return true;
} }
@ -374,21 +343,19 @@ void FObject::onUserEvent (FUserEvent*)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
uInt FObject::processTimerEvent() uInt FObject::processTimerEvent()
{ {
timeval currentTime{};
uInt activated{0}; uInt activated{0};
auto currentTime = getCurrentTime();
getCurrentTime (&currentTime); if ( ! internal::var::timer_mutex.try_lock() )
if ( isTimerInUpdating() )
return 0; return 0;
auto& timer_list = globalTimerList(); auto& timer_list = globalTimerList();
if ( ! timer_list ) if ( ! timer_list || timer_list->empty() )
return 0; {
internal::var::timer_mutex.unlock();
if ( timer_list->empty() )
return 0; return 0;
}
for (auto&& timer : *timer_list) for (auto&& timer : *timer_list)
{ {
@ -402,13 +369,14 @@ uInt FObject::processTimerEvent()
if ( timer.timeout < currentTime ) if ( timer.timeout < currentTime )
timer.timeout = currentTime + timer.interval; timer.timeout = currentTime + timer.interval;
if ( timer.interval.tv_usec > 0 || timer.interval.tv_sec > 0 ) if ( timer.interval > microseconds(0) )
activated++; activated++;
FTimerEvent t_ev(Event::Timer, timer.id); FTimerEvent t_ev(Event::Timer, timer.id);
performTimerAction (timer.object, &t_ev); performTimerAction (timer.object, &t_ev);
} }
internal::var::timer_mutex.unlock();
return activated; return activated;
} }

View File

@ -61,14 +61,12 @@ bool FVTerm::force_terminal_update{false};
uInt64 FVTerm::flush_wait{MIN_FLUSH_WAIT}; uInt64 FVTerm::flush_wait{MIN_FLUSH_WAIT};
uInt64 FVTerm::flush_average{MIN_FLUSH_WAIT}; uInt64 FVTerm::flush_average{MIN_FLUSH_WAIT};
uInt64 FVTerm::flush_median{MIN_FLUSH_WAIT}; uInt64 FVTerm::flush_median{MIN_FLUSH_WAIT};
uInt64 FVTerm::term_size_check_timeout{500000}; // 500 ms
uInt FVTerm::erase_char_length{}; uInt FVTerm::erase_char_length{};
uInt FVTerm::repeat_char_length{}; uInt FVTerm::repeat_char_length{};
uInt FVTerm::clr_bol_length{}; uInt FVTerm::clr_bol_length{};
uInt FVTerm::clr_eol_length{}; uInt FVTerm::clr_eol_length{};
uInt FVTerm::cursor_address_length{}; uInt FVTerm::cursor_address_length{};
struct timeval FVTerm::time_last_flush{}; TimeValue FVTerm::time_last_flush{};
struct timeval FVTerm::last_term_size_check{};
const FVTerm* FVTerm::init_object{nullptr}; const FVTerm* FVTerm::init_object{nullptr};
FVTerm::FTermArea* FVTerm::vterm{nullptr}; FVTerm::FTermArea* FVTerm::vterm{nullptr};
FVTerm::FTermArea* FVTerm::vdesktop{nullptr}; FVTerm::FTermArea* FVTerm::vdesktop{nullptr};
@ -603,7 +601,7 @@ void FVTerm::flush() const
std::fflush(stdout); std::fflush(stdout);
auto& mouse = FTerm::getFMouseControl(); auto& mouse = FTerm::getFMouseControl();
mouse.drawPointer(); mouse.drawPointer();
FObject::getCurrentTime (&time_last_flush); time_last_flush = FObject::getCurrentTime();
} }
@ -1876,11 +1874,8 @@ void FVTerm::init()
vdesktop->visible = true; vdesktop->visible = true;
active_area = vdesktop; active_area = vdesktop;
// Initialize the flush and last terminal size check time // Initialize the last flush time
time_last_flush.tv_sec = 0; time_last_flush = TimeValue{};
time_last_flush.tv_usec = 0;
last_term_size_check.tv_sec = 0;
last_term_size_check.tv_usec = 0;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -2879,33 +2874,13 @@ bool FVTerm::isInsideTerminal (const FPoint& pos) const
return false; return false;
} }
//----------------------------------------------------------------------
inline bool FVTerm::isTermSizeChanged() const
{
if ( ! isTermSizeCheckTimeout() )
return false;
FObject::getCurrentTime (&last_term_size_check);
auto& fterm_data = FTerm::getFTermData();
const auto& old_term_geometry = fterm_data.getTermGeometry();
FTerm::detectTermSize();
auto term_geometry = fterm_data.getTermGeometry();
term_geometry.move (-1, -1);
if ( old_term_geometry.getSize() != term_geometry.getSize() )
return true;
return false;
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::flushTimeAdjustment() const inline void FVTerm::flushTimeAdjustment() const
{ {
timeval now; const auto now = FObject::getCurrentTime();
FObject::getCurrentTime(&now); const auto diff = now - time_last_flush;
timeval diff = now - time_last_flush;
if ( diff.tv_sec > 0 || diff.tv_usec > 400000 ) if ( diff > milliseconds(400) )
{ {
flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms flush_wait = MIN_FLUSH_WAIT; // Reset to minimum values after 400 ms
flush_average = MIN_FLUSH_WAIT; flush_average = MIN_FLUSH_WAIT;
@ -2913,7 +2888,7 @@ inline void FVTerm::flushTimeAdjustment() const
} }
else else
{ {
auto usec = uInt64(diff.tv_usec); auto usec = uInt64(duration_cast<microseconds>(diff).count());
if ( usec < MIN_FLUSH_WAIT ) if ( usec < MIN_FLUSH_WAIT )
usec = MIN_FLUSH_WAIT; usec = MIN_FLUSH_WAIT;
@ -2947,13 +2922,7 @@ inline void FVTerm::flushTimeAdjustment() const
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline bool FVTerm::isFlushTimeout() inline bool FVTerm::isFlushTimeout()
{ {
return FObject::isTimeout (&time_last_flush, flush_wait); return FObject::isTimeout (time_last_flush, flush_wait);
}
//----------------------------------------------------------------------
inline bool FVTerm::isTermSizeCheckTimeout()
{
return FObject::isTimeout (&last_term_size_check, term_size_check_timeout);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2013-2020 Markus Gans * * Copyright 2013-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -238,7 +238,7 @@ class FApplication : public FWidget
FWidget* clicked_widget{}; FWidget* clicked_widget{};
FEventQueue event_queue{}; FEventQueue event_queue{};
static uInt64 next_event_wait; static uInt64 next_event_wait;
static timeval time_last_event; static TimeValue time_last_event;
static int loop_level; static int loop_level;
static int quit_code; static int quit_code;
static bool quit_now; static bool quit_now;

View File

@ -108,7 +108,7 @@ class FKeyboard final
FKey getKey() const; FKey getKey() const;
FString getKeyName (const FKey) const; FString getKeyName (const FKey) const;
keybuffer& getKeyBuffer(); keybuffer& getKeyBuffer();
timeval* getKeyPressedTime(); TimeValue getKeyPressedTime();
static uInt64 getKeypressTimeout(); static uInt64 getKeypressTimeout();
static uInt64 getReadBlockingTime(); static uInt64 getReadBlockingTime();
@ -179,7 +179,7 @@ class FKeyboard final
FKeyboardCommand escape_key_cmd{}; FKeyboardCommand escape_key_cmd{};
FKeyboardCommand mouse_tracking_cmd{}; FKeyboardCommand mouse_tracking_cmd{};
static timeval time_keypressed; static TimeValue time_keypressed;
static uInt64 read_blocking_time; static uInt64 read_blocking_time;
static uInt64 read_blocking_time_short; static uInt64 read_blocking_time_short;
static uInt64 key_timeout; static uInt64 key_timeout;
@ -214,8 +214,8 @@ inline FKeyboard::keybuffer& FKeyboard::getKeyBuffer()
{ return fifo_buf; } { return fifo_buf; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline timeval* FKeyboard::getKeyPressedTime() inline TimeValue FKeyboard::getKeyPressedTime()
{ return &time_keypressed; } { return time_keypressed; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline uInt64 FKeyboard::getKeypressTimeout() inline uInt64 FKeyboard::getKeypressTimeout()

View File

@ -72,23 +72,23 @@ class FLogger : public FLog
~FLogger() noexcept override; ~FLogger() noexcept override;
// Methods // Methods
FString getClassName() const override; FString getClassName() const override;
void info (const std::string&) override; void info (const std::string&) override;
void warn (const std::string&) override; void warn (const std::string&) override;
void error (const std::string&) override; void error (const std::string&) override;
void debug (const std::string&) override; void debug (const std::string&) override;
void flush() override; void flush() override;
void setOutputStream (const std::ostream&) override; void setOutputStream (const std::ostream&) override;
void setLineEnding (LineEnding) override; void setLineEnding (LineEnding) override;
void enableTimestamp() override; void enableTimestamp() override;
void disableTimestamp() override; void disableTimestamp() override;
private: private:
// Methods // Methods
void newlineReplace (std::string&, const std::string&) const; void newlineReplace (std::string&, const std::string&) const;
std::string getTimeString() const; std::string getTimeString() const;
std::string getEOL() const; std::string getEOL() const;
void printLogLine (const std::string&); void printLogLine (const std::string&);
// Data member // Data member
bool timestamp{false}; bool timestamp{false};

View File

@ -201,7 +201,7 @@ class FMouse : public FMouseData
template <typename ClassT> template <typename ClassT>
static FMouse* createMouseObject (); static FMouse* createMouseObject ();
virtual void setRawData (FKeyboard::keybuffer&) = 0; virtual void setRawData (FKeyboard::keybuffer&) = 0;
virtual void processEvent (struct timeval*) = 0; virtual void processEvent (const TimeValue&) = 0;
protected: protected:
// Accessors // Accessors
@ -209,17 +209,17 @@ class FMouse : public FMouseData
uInt16 getMaxWidth() const; uInt16 getMaxWidth() const;
uInt16 getMaxHeight() const; uInt16 getMaxHeight() const;
uInt64 getDblclickInterval() const; uInt64 getDblclickInterval() const;
timeval* getMousePressedTime(); TimeValue getMousePressedTime();
// Mutator // Mutator
void setNewPos (int, int); void setNewPos (int, int);
void setPending (bool = true); void setPending (bool = true);
void setEvent(); void setEvent();
void setMousePressedTime (const timeval*); void setMousePressedTime (const TimeValue&);
void resetMousePressedTime(); void resetMousePressedTime();
// Inquiry // Inquiry
bool isDblclickTimeout (const timeval*) const; bool isDblclickTimeout (const TimeValue&) const;
private: private:
// Data members // Data members
@ -228,7 +228,7 @@ class FMouse : public FMouseData
uInt16 max_width{80}; uInt16 max_width{80};
uInt16 max_height{25}; uInt16 max_height{25};
uInt64 dblclick_interval{500000}; // 500 ms uInt64 dblclick_interval{500000}; // 500 ms
struct timeval time_mousepressed{}; TimeValue time_mousepressed{};
FPoint new_mouse_position{}; FPoint new_mouse_position{};
}; };
@ -263,7 +263,7 @@ class FMouseGPM final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (const TimeValue&) override;
bool gpmMouse (bool = true); bool gpmMouse (bool = true);
bool enableGpmMouse(); bool enableGpmMouse();
bool disableGpmMouse(); bool disableGpmMouse();
@ -321,7 +321,7 @@ class FMouseX11 final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (const TimeValue&) override;
private: private:
// Enumeration // Enumeration
@ -351,7 +351,7 @@ class FMouseX11 final : public FMouse
// Methods // Methods
void setKeyState (int); void setKeyState (int);
void setMoveState (const FPoint&, int); void setMoveState (const FPoint&, int);
void setButtonState (const int, const struct timeval*); void setButtonState (const int, const TimeValue&);
// Data member // Data member
char x11_mouse[MOUSE_BUF_SIZE]{'\0'}; char x11_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -374,7 +374,7 @@ class FMouseSGR final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (const TimeValue&) override;
private: private:
// Enumeration // Enumeration
@ -403,7 +403,7 @@ class FMouseSGR final : public FMouse
// Methods // Methods
void setKeyState (int); void setKeyState (int);
void setMoveState (const FPoint&, int); void setMoveState (const FPoint&, int);
void setPressedButtonState (const int, const struct timeval*); void setPressedButtonState (const int, const TimeValue&);
void setReleasedButtonState (const int); void setReleasedButtonState (const int);
// Data members // Data members
@ -427,7 +427,7 @@ class FMouseUrxvt final : public FMouse
// Methods // Methods
void setRawData (FKeyboard::keybuffer&) override; void setRawData (FKeyboard::keybuffer&) override;
void processEvent (struct timeval*) override; void processEvent (const TimeValue&) override;
private: private:
// Enumeration // Enumeration
@ -457,7 +457,7 @@ class FMouseUrxvt final : public FMouse
// Methods // Methods
void setKeyState (int); void setKeyState (int);
void setMoveState (const FPoint&, int); void setMoveState (const FPoint&, int);
void setButtonState (const int, const struct timeval*); void setButtonState (const int, const TimeValue&);
// Data members // Data members
char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'}; char urxvt_mouse[MOUSE_BUF_SIZE]{'\0'};
@ -543,7 +543,7 @@ class FMouseControl
void disable(); void disable();
virtual void setRawData ( FMouse::MouseType virtual void setRawData ( FMouse::MouseType
, FKeyboard::keybuffer& ); , FKeyboard::keybuffer& );
virtual void processEvent (struct timeval* time); virtual void processEvent (const TimeValue&);
void processQueuedInput(); void processQueuedInput();
bool getGpmKeyPressed (bool = true); bool getGpmKeyPressed (bool = true);
void drawPointer(); void drawPointer();

View File

@ -44,15 +44,24 @@
#include <sys/time.h> // need for gettimeofday #include <sys/time.h> // need for gettimeofday
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <chrono>
#include <list> #include <list>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "final/fstring.h" #include "final/fstring.h"
#include "final/ftypes.h"
namespace finalcut namespace finalcut
{ {
using std::chrono::duration_cast;
using std::chrono::seconds;
using std::chrono::milliseconds;
using std::chrono::microseconds;
using std::chrono::system_clock;
using std::chrono::time_point;
// class forward declaration // class forward declaration
class FEvent; class FEvent;
class FKeyEvent; class FKeyEvent;
@ -122,7 +131,6 @@ class FObject
bool isDirectChild (const FObject*) const; bool isDirectChild (const FObject*) const;
bool isWidget() const; bool isWidget() const;
bool isInstanceOf (const FString&) const; bool isInstanceOf (const FString&) const;
bool isTimerInUpdating() const;
// Methods // Methods
void removeParent(); void removeParent();
@ -134,8 +142,8 @@ class FObject
virtual bool event (FEvent*); virtual bool event (FEvent*);
// Timer methods // Timer methods
static void getCurrentTime (timeval*); static TimeValue getCurrentTime();
static bool isTimeout (const timeval*, uInt64); static bool isTimeout (const TimeValue&, uInt64);
int addTimer (int); int addTimer (int);
bool delTimer (int) const; bool delTimer (int) const;
bool delOwnTimers() const; bool delOwnTimers() const;
@ -144,10 +152,10 @@ class FObject
protected: protected:
struct FTimerData struct FTimerData
{ {
int id; int id;
timeval interval; milliseconds interval;
timeval timeout; TimeValue timeout;
FObject* object; FObject* object;
}; };
// Using-declaration // Using-declaration
@ -178,7 +186,6 @@ class FObject
std::size_t max_children{UNLIMITED}; std::size_t max_children{UNLIMITED};
bool has_parent{false}; bool has_parent{false};
bool widget_object{false}; bool widget_object{false};
static bool timer_modify_lock;
}; };
@ -262,10 +269,6 @@ inline bool FObject::isWidget() const
inline bool FObject::isInstanceOf (const FString& classname) const inline bool FObject::isInstanceOf (const FString& classname) const
{ return classname == getClassName(); } { return classname == getClassName(); }
//----------------------------------------------------------------------
inline bool FObject::isTimerInUpdating() const
{ return timer_modify_lock; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FObject::FTimerList* FObject::getTimerList() const inline FObject::FTimerList* FObject::getTimerList() const
{ return globalTimerList().get(); } { return globalTimerList().get(); }
@ -274,61 +277,6 @@ inline FObject::FTimerList* FObject::getTimerList() const
inline void FObject::setWidgetProperty (bool property) inline void FObject::setWidgetProperty (bool property)
{ widget_object = property; } { widget_object = property; }
//----------------------------------------------------------------------
// Operator functions for timeval
//----------------------------------------------------------------------
static inline timeval operator + (const timeval& t1, const timeval& t2)
{
timeval tmp{};
tmp.tv_sec = t1.tv_sec + t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec + t2.tv_usec) >= 1000000 )
{
tmp.tv_sec++;
tmp.tv_usec -= 1000000;
}
return tmp;
}
//----------------------------------------------------------------------
static inline timeval operator - (const timeval& t1, const timeval& t2)
{
timeval tmp{};
tmp.tv_sec = t1.tv_sec - t2.tv_sec;
if ( (tmp.tv_usec = t1.tv_usec - t2.tv_usec) < 0 )
{
tmp.tv_sec--;
tmp.tv_usec += 1000000;
}
return tmp;
}
//----------------------------------------------------------------------
static inline timeval& operator += (timeval& t1, const timeval& t2)
{
t1.tv_sec += t2.tv_sec;
if ( (t1.tv_usec += t2.tv_usec) >= 1000000 )
{
t1.tv_sec++;
t1.tv_usec -= 1000000;
}
return t1;
}
//----------------------------------------------------------------------
static inline bool operator < (const timeval& t1, const timeval& t2)
{
return (t1.tv_sec < t2.tv_sec)
|| (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec);
}
} // namespace finalcut } // namespace finalcut
#endif // FOBJECT_H #endif // FOBJECT_H

View File

@ -34,6 +34,7 @@
#include <cstring> #include <cstring>
#include <array> #include <array>
#include <chrono>
#include <functional> #include <functional>
#include <limits> #include <limits>
#include <memory> #include <memory>
@ -51,25 +52,25 @@
<< " in " \ << " in " \
<< __func__ << std::endl // ; << __func__ << std::endl // ;
using uChar = unsigned char; using uChar = unsigned char;
using uShort = unsigned short; using uShort = unsigned short;
using uInt = unsigned int; using uInt = unsigned int;
using uLong = unsigned long; using uLong = unsigned long;
using uInt8 = std::uint8_t; using uInt8 = std::uint8_t;
using uInt16 = std::uint16_t; using uInt16 = std::uint16_t;
using uInt32 = std::uint32_t; using uInt32 = std::uint32_t;
using uInt64 = std::uint64_t; using uInt64 = std::uint64_t;
using sInt = signed int; using sInt = signed int;
using sLong = signed long; using sLong = signed long;
using sInt8 = std::int8_t; using sInt8 = std::int8_t;
using sInt16 = std::int16_t; using sInt16 = std::int16_t;
using sInt32 = std::int32_t; using sInt32 = std::int32_t;
using sInt64 = std::int64_t; using sInt64 = std::int64_t;
using lDouble = long double; using lDouble = long double;
using TimeValue = std::chrono::time_point<std::chrono::system_clock>;
using FCall = std::function<void()>; using FCall = std::function<void()>;
namespace finalcut namespace finalcut
{ {
@ -125,10 +126,10 @@ constexpr std::reverse_iterator<Iter> make_reverse_iterator (Iter iter)
return std::reverse_iterator<Iter>(iter); return std::reverse_iterator<Iter>(iter);
} }
template <typename T> template <typename CharT>
constexpr std::size_t stringLength (T&& array) constexpr std::size_t stringLength (const CharT* s)
{ {
return std::string(std::forward<T>(array)).length(); return std::char_traits<CharT>::length(s);
} }
using charSubstitution = std::unordered_map<wchar_t, wchar_t>; using charSubstitution = std::unordered_map<wchar_t, wchar_t>;

View File

@ -418,10 +418,8 @@ class FVTerm
bool updateTerminalLine (uInt) const; bool updateTerminalLine (uInt) const;
bool updateTerminalCursor() const; bool updateTerminalCursor() const;
bool isInsideTerminal (const FPoint&) const; bool isInsideTerminal (const FPoint&) const;
bool isTermSizeChanged() const;
void flushTimeAdjustment() const; void flushTimeAdjustment() const;
static bool isFlushTimeout(); static bool isFlushTimeout();
static bool isTermSizeCheckTimeout();
static bool hasPendingUpdates (const FTermArea*); static bool hasPendingUpdates (const FTermArea*);
static void markAsPrinted (uInt, uInt); static void markAsPrinted (uInt, uInt);
static void markAsPrinted (uInt, uInt, uInt); static void markAsPrinted (uInt, uInt, uInt);
@ -453,8 +451,7 @@ class FVTerm
static FChar next_attribute; static FChar next_attribute;
static FChar s_ch; // shadow character static FChar s_ch; // shadow character
static FChar i_ch; // inherit background character static FChar i_ch; // inherit background character
static timeval time_last_flush; static TimeValue time_last_flush;
static timeval last_term_size_check;
static bool draw_completed; static bool draw_completed;
static bool combined_char_support; static bool combined_char_support;
static bool no_terminal_updates; static bool no_terminal_updates;
@ -462,7 +459,6 @@ class FVTerm
static uInt64 flush_wait; static uInt64 flush_wait;
static uInt64 flush_average; static uInt64 flush_average;
static uInt64 flush_median; static uInt64 flush_median;
static uInt64 term_size_check_timeout;
static uInt erase_char_length; static uInt erase_char_length;
static uInt repeat_char_length; static uInt repeat_char_length;
static uInt clr_bol_length; static uInt clr_bol_length;

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -373,9 +373,11 @@ void FKeyboardTest::noArgumentTest()
CPPUNIT_ASSERT ( sum == 0 ); CPPUNIT_ASSERT ( sum == 0 );
timeval* time = keyboard->getKeyPressedTime(); auto time = keyboard->getKeyPressedTime();
CPPUNIT_ASSERT ( time->tv_sec == 0); auto duration_s = std::chrono::duration_cast<std::chrono::seconds>(time.time_since_epoch());
CPPUNIT_ASSERT ( time->tv_usec == 0); auto duration_us = std::chrono::duration_cast<std::chrono::microseconds>(time.time_since_epoch());
CPPUNIT_ASSERT ( duration_s.count() == 0);
CPPUNIT_ASSERT ( duration_us.count() == 0);
CPPUNIT_ASSERT ( ! keyboard->hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! keyboard->hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! keyboard->isKeyPressed() ); CPPUNIT_ASSERT ( ! keyboard->isKeyPressed() );

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -40,13 +40,13 @@ namespace test
class FMouse_protected : public finalcut::FMouse class FMouse_protected : public finalcut::FMouse
{ {
public: public:
virtual bool hasData() bool hasData() override
{ return true; } { return true; }
virtual void setRawData (finalcut::FKeyboard::keybuffer&) void setRawData (finalcut::FKeyboard::keybuffer&) override
{ } { }
virtual void processEvent (struct timeval*) void processEvent (const TimeValue&) override
{ } { }
uInt16 getMaxWidth() uInt16 getMaxWidth()
@ -59,7 +59,7 @@ class FMouse_protected : public finalcut::FMouse
return finalcut::FMouse::getMaxHeight(); return finalcut::FMouse::getMaxHeight();
} }
const finalcut::FPoint& getNewMousePosition() const finalcut::FPoint& getNewMousePosition() const
{ {
return finalcut::FMouse::getNewPos(); return finalcut::FMouse::getNewPos();
} }
@ -69,7 +69,7 @@ class FMouse_protected : public finalcut::FMouse
return finalcut::FMouse::getDblclickInterval(); return finalcut::FMouse::getDblclickInterval();
} }
bool isDblclickTimeout (timeval* t) bool isDblclickTimeout (const TimeValue& t)
{ {
return finalcut::FMouse::isDblclickTimeout(t); return finalcut::FMouse::isDblclickTimeout(t);
} }
@ -199,24 +199,24 @@ void FMouseTest::doubleClickTest()
test::FMouse_protected mouse; test::FMouse_protected mouse;
CPPUNIT_ASSERT ( mouse.getDblclickInterval() == 500000 ); // 500 ms CPPUNIT_ASSERT ( mouse.getDblclickInterval() == 500000 ); // 500 ms
timeval tv = { 0, 0 }; TimeValue tv = {};
CPPUNIT_ASSERT ( mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( mouse.isDblclickTimeout(tv) );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(tv) );
tv.tv_sec--; // Minus one second tv -= std::chrono::seconds(1); // Minus one second
CPPUNIT_ASSERT ( mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( mouse.isDblclickTimeout(tv) );
mouse.setDblclickInterval(1000000); mouse.setDblclickInterval(1000000);
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(tv) );
timeval tv_delta = { 0, 500000 }; auto tv_delta = std::chrono::microseconds(500000);
tv = tv - tv_delta; tv -= tv_delta;
CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( ! mouse.isDblclickTimeout(tv) );
tv = tv - tv_delta; tv -= tv_delta;
CPPUNIT_ASSERT ( mouse.isDblclickTimeout(&tv) ); CPPUNIT_ASSERT ( mouse.isDblclickTimeout(tv) );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -266,9 +266,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
timeval tv; auto tv = finalcut::FObject::getCurrentTime();
finalcut::FObject::getCurrentTime(&tv); x11_mouse.processEvent (tv);
x11_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(48, 18) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(48, 18) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -290,7 +289,7 @@ void FMouseTest::x11MouseTest()
finalcut::FKeyboard::keybuffer raw = \ finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', 'M', 0x23, 0x50, 0x32 }; { 0x1b, '[', 'M', 0x23, 0x50, 0x32 };
x11_mouse.setRawData (raw); x11_mouse.setRawData (raw);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() );
// Left mouse button pressed // Left mouse button pressed
@ -299,7 +298,7 @@ void FMouseTest::x11MouseTest()
x11_mouse.setRawData (rawdata2); x11_mouse.setRawData (rawdata2);
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -324,7 +323,7 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -349,8 +348,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -377,8 +376,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -397,7 +396,7 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata5); x11_mouse.setRawData (rawdata5);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! x11_mouse.isMiddleButtonPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMiddleButtonReleased() ); CPPUNIT_ASSERT ( x11_mouse.isMiddleButtonReleased() );
@ -410,8 +409,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -430,7 +429,7 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata6); x11_mouse.setRawData (rawdata6);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! x11_mouse.isRightButtonPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isRightButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isRightButtonReleased() ); CPPUNIT_ASSERT ( x11_mouse.isRightButtonReleased() );
@ -443,8 +442,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(80, 25) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(80, 25) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -463,7 +462,7 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata7); x11_mouse.setRawData (rawdata7);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! x11_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( x11_mouse.isWheelDown() ); CPPUNIT_ASSERT ( x11_mouse.isWheelDown() );
@ -476,8 +475,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -496,12 +495,12 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8); x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( x11_mouse.isMoved() ); CPPUNIT_ASSERT ( x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata8); x11_mouse.setRawData (rawdata8);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(3, 5) );
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
@ -515,8 +514,8 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( x11_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! x11_mouse.hasData() ); CPPUNIT_ASSERT ( ! x11_mouse.hasData() );
CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(16, 32) ); CPPUNIT_ASSERT ( x11_mouse.getPos() == finalcut::FPoint(16, 32) );
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
@ -535,21 +534,21 @@ void FMouseTest::x11MouseTest()
CPPUNIT_ASSERT ( ! x11_mouse.isMoved() ); CPPUNIT_ASSERT ( ! x11_mouse.isMoved() );
x11_mouse.setRawData (rawdata9); x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9); x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! x11_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( ! x11_mouse.isMetaKeyPressed() );
x11_mouse.setRawData (rawdata9); x11_mouse.setRawData (rawdata9);
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( x11_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( x11_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( x11_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( x11_mouse.isControlKeyPressed() );
@ -560,7 +559,7 @@ void FMouseTest::x11MouseTest()
{ 0x1b, '[', 'M', 0x20, 0x7f, 0x3f }; { 0x1b, '[', 'M', 0x20, 0x7f, 0x3f };
x11_mouse.setRawData (rawdata10); x11_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( x11_mouse.hasData() ); CPPUNIT_ASSERT ( x11_mouse.hasData() );
x11_mouse.processEvent (&tv); x11_mouse.processEvent (tv);
CPPUNIT_ASSERT ( x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( x11_mouse.hasEvent() );
x11_mouse.clearEvent(); x11_mouse.clearEvent();
CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! x11_mouse.hasEvent() );
@ -581,9 +580,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
timeval tv; auto tv = finalcut::FObject::getCurrentTime();
finalcut::FObject::getCurrentTime(&tv); sgr_mouse.processEvent (tv);
sgr_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -605,7 +603,7 @@ void FMouseTest::sgrMouseTest()
finalcut::FKeyboard::keybuffer raw = \ finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' }; { 0x1b, '[', '<', '0', ';', '7', '3', ';', '4', 'M' };
sgr_mouse.setRawData (raw); sgr_mouse.setRawData (raw);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
// Left mouse button released // Left mouse button released
@ -615,7 +613,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() );
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -640,8 +638,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(73, 4) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -667,8 +665,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -687,7 +685,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata5); sgr_mouse.setRawData (rawdata5);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMiddleButtonPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMiddleButtonReleased() ); CPPUNIT_ASSERT ( sgr_mouse.isMiddleButtonReleased() );
@ -700,8 +698,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 3) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 3) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -720,7 +718,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata6); sgr_mouse.setRawData (rawdata6);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! sgr_mouse.isRightButtonPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isRightButtonPressed() );
@ -734,8 +732,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(4, 9) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(4, 9) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -754,7 +752,7 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata7); sgr_mouse.setRawData (rawdata7);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( sgr_mouse.isWheelDown() ); CPPUNIT_ASSERT ( sgr_mouse.isWheelDown() );
@ -767,8 +765,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(1, 2) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(1, 2) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -787,12 +785,12 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8); sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(2, 3) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata8); sgr_mouse.setRawData (rawdata8);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
@ -806,8 +804,8 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasData() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasData() );
CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(5, 5) ); CPPUNIT_ASSERT ( sgr_mouse.getPos() == finalcut::FPoint(5, 5) );
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
@ -826,21 +824,21 @@ void FMouseTest::sgrMouseTest()
CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMoved() );
sgr_mouse.setRawData (rawdata9); sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9); sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! sgr_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( ! sgr_mouse.isMetaKeyPressed() );
sgr_mouse.setRawData (rawdata9); sgr_mouse.setRawData (rawdata9);
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( sgr_mouse.isControlKeyPressed() );
@ -851,7 +849,7 @@ void FMouseTest::sgrMouseTest()
{ 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' }; { 0x1b, '[', '<', '2', ';', '1', ';', '1', 'M' };
sgr_mouse.setRawData (rawdata10); sgr_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( sgr_mouse.hasEvent() );
sgr_mouse.clearEvent(); sgr_mouse.clearEvent();
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
@ -863,17 +861,17 @@ void FMouseTest::sgrMouseTest()
, 0x1b, '[', '<', '6', ';', '5', ';', '@', 'M', '@' }; , 0x1b, '[', '<', '6', ';', '5', ';', '@', 'M', '@' };
sgr_mouse.setRawData (rawdata11); sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11); sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
sgr_mouse.setRawData (rawdata11); sgr_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( sgr_mouse.hasData() ); CPPUNIT_ASSERT ( sgr_mouse.hasData() );
sgr_mouse.processEvent (&tv); sgr_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! sgr_mouse.hasEvent() );
CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( sgr_mouse.hasUnprocessedInput() );
@ -895,9 +893,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 ); CPPUNIT_ASSERT ( std::strcmp(rawdata1, "@@") == 0 );
timeval tv; auto tv = finalcut::FObject::getCurrentTime();
finalcut::FObject::getCurrentTime(&tv); urxvt_mouse.processEvent (tv);
urxvt_mouse.processEvent (&tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
@ -918,7 +915,7 @@ void FMouseTest::urxvtMouseTest()
finalcut::FKeyboard::keybuffer raw = \ finalcut::FKeyboard::keybuffer raw = \
{ 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' }; { 0x1b, '[', '3', '2', ';', '4', '9', ';', '6', 'M' };
urxvt_mouse.setRawData (raw); urxvt_mouse.setRawData (raw);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
// Left mouse button released // Left mouse button released
@ -928,7 +925,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -953,8 +950,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(49, 6) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -980,8 +977,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1000,7 +997,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata5); urxvt_mouse.setRawData (rawdata5);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMiddleButtonPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMiddleButtonReleased() ); CPPUNIT_ASSERT ( urxvt_mouse.isMiddleButtonReleased() );
@ -1013,8 +1010,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 3) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 3) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1033,7 +1030,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata6); urxvt_mouse.setRawData (rawdata6);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isRightButtonPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isRightButtonPressed() );
@ -1047,8 +1044,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(4, 9) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(4, 9) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1067,7 +1064,7 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata7); urxvt_mouse.setRawData (rawdata7);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasUnprocessedInput() );
CPPUNIT_ASSERT ( urxvt_mouse.isWheelDown() ); CPPUNIT_ASSERT ( urxvt_mouse.isWheelDown() );
@ -1080,8 +1077,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 2) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 2) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1100,12 +1097,12 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8); urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(2, 3) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata8); urxvt_mouse.setRawData (rawdata8);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
@ -1119,8 +1116,8 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(5, 5) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(5, 5) );
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
@ -1139,21 +1136,21 @@ void FMouseTest::urxvtMouseTest()
CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMoved() );
urxvt_mouse.setRawData (rawdata9); urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9); urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() );
CPPUNIT_ASSERT ( ! urxvt_mouse.isMetaKeyPressed() ); CPPUNIT_ASSERT ( ! urxvt_mouse.isMetaKeyPressed() );
urxvt_mouse.setRawData (rawdata9); urxvt_mouse.setRawData (rawdata9);
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isLeftButtonPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isShiftKeyPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isShiftKeyPressed() );
CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() ); CPPUNIT_ASSERT ( urxvt_mouse.isControlKeyPressed() );
@ -1164,7 +1161,7 @@ void FMouseTest::urxvtMouseTest()
{ 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' }; { 0x1b, '[', '3', '2', ';', '1', ';', '1', 'M' };
urxvt_mouse.setRawData (rawdata10); urxvt_mouse.setRawData (rawdata10);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( urxvt_mouse.hasEvent() );
urxvt_mouse.clearEvent(); urxvt_mouse.clearEvent();
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
@ -1176,17 +1173,17 @@ void FMouseTest::urxvtMouseTest()
, 0x1b, '[', '3', '4', ';', '5', ';', '@', 'M', '@' }; , 0x1b, '[', '3', '4', ';', '5', ';', '@', 'M', '@' };
urxvt_mouse.setRawData (rawdata11); urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11); urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
urxvt_mouse.setRawData (rawdata11); urxvt_mouse.setRawData (rawdata11);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasEvent() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
@ -1199,7 +1196,7 @@ void FMouseTest::urxvtMouseTest()
urxvt_mouse.setRawData (rawdata12); urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() ); CPPUNIT_ASSERT ( urxvt_mouse.hasUnprocessedInput() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(-5, 5) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(-5, 5) );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 5) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(1, 5) );
@ -1207,7 +1204,7 @@ void FMouseTest::urxvtMouseTest()
urxvt_mouse.setRawData (rawdata12); urxvt_mouse.setRawData (rawdata12);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(3, -3) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(3, -3) );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 1) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(3, 1) );
@ -1220,7 +1217,7 @@ void FMouseTest::urxvtMouseTest()
{ 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' }; { 0x1b, '[', '3', '2', ';', '7', '0', ';', '2', '5', 'M' };
urxvt_mouse.setRawData (rawdata13); urxvt_mouse.setRawData (rawdata13);
CPPUNIT_ASSERT ( urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( urxvt_mouse.hasData() );
urxvt_mouse.processEvent (&tv); urxvt_mouse.processEvent (tv);
CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() ); CPPUNIT_ASSERT ( ! urxvt_mouse.hasData() );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(70, 25) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() != finalcut::FPoint(70, 25) );
CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(40, 20) ); CPPUNIT_ASSERT ( urxvt_mouse.getPos() == finalcut::FPoint(40, 20) );
@ -1271,9 +1268,8 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
timeval tv; auto tv = finalcut::FObject::getCurrentTime();
finalcut::FObject::getCurrentTime(&tv); mouse_control.processEvent (tv);
mouse_control.processEvent (&tv);
CPPUNIT_ASSERT ( ! mouse_control.hasData() ); CPPUNIT_ASSERT ( ! mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(5, 8) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(5, 8) );
CPPUNIT_ASSERT ( mouse_control.hasEvent() ); CPPUNIT_ASSERT ( mouse_control.hasEvent() );
@ -1293,7 +1289,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata1); mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata1);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() ); CPPUNIT_ASSERT ( ! mouse_control.isLeftButtonPressed() );
CPPUNIT_ASSERT ( mouse_control.isLeftButtonReleased() ); CPPUNIT_ASSERT ( mouse_control.isLeftButtonReleased() );
@ -1306,8 +1302,8 @@ void FMouseTest::mouseControlTest()
mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata2); mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata2);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasData() ); CPPUNIT_ASSERT ( ! mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(1, 1) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(1, 1) );
CPPUNIT_ASSERT ( mouse_control.hasEvent() ); CPPUNIT_ASSERT ( mouse_control.hasEvent() );
@ -1326,7 +1322,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata2); mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata2);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() ); CPPUNIT_ASSERT ( ! mouse_control.isMiddleButtonPressed() );
CPPUNIT_ASSERT ( mouse_control.isMiddleButtonReleased() ); CPPUNIT_ASSERT ( mouse_control.isMiddleButtonReleased() );
@ -1337,8 +1333,8 @@ void FMouseTest::mouseControlTest()
mouse_control.setRawData (finalcut::FMouse::MouseType::Urxvt, rawdata3); mouse_control.setRawData (finalcut::FMouse::MouseType::Urxvt, rawdata3);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasData() ); CPPUNIT_ASSERT ( ! mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 3) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 3) );
CPPUNIT_ASSERT ( mouse_control.hasEvent() ); CPPUNIT_ASSERT ( mouse_control.hasEvent() );
@ -1357,7 +1353,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::MouseType::Urxvt, rawdata3); mouse_control.setRawData (finalcut::FMouse::MouseType::Urxvt, rawdata3);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( ! mouse_control.isRightButtonPressed() ); CPPUNIT_ASSERT ( ! mouse_control.isRightButtonPressed() );
@ -1370,8 +1366,8 @@ void FMouseTest::mouseControlTest()
mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata4); mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata4);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasData() ); CPPUNIT_ASSERT ( ! mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(80, 25) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(80, 25) );
CPPUNIT_ASSERT ( mouse_control.hasEvent() ); CPPUNIT_ASSERT ( mouse_control.hasEvent() );
@ -1390,7 +1386,7 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata4); mouse_control.setRawData (finalcut::FMouse::MouseType::X11, rawdata4);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( ! mouse_control.hasUnprocessedInput() );
CPPUNIT_ASSERT ( mouse_control.isWheelDown() ); CPPUNIT_ASSERT ( mouse_control.isWheelDown() );
@ -1402,8 +1398,8 @@ void FMouseTest::mouseControlTest()
mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5);
CPPUNIT_ASSERT ( mouse_control.hasData() ); CPPUNIT_ASSERT ( mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() ); CPPUNIT_ASSERT ( mouse_control.hasUnprocessedInput() );
finalcut::FObject::getCurrentTime(&tv); tv = finalcut::FObject::getCurrentTime();
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( ! mouse_control.hasData() ); CPPUNIT_ASSERT ( ! mouse_control.hasData() );
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(1, 2) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(1, 2) );
CPPUNIT_ASSERT ( mouse_control.hasEvent() ); CPPUNIT_ASSERT ( mouse_control.hasEvent() );
@ -1422,12 +1418,12 @@ void FMouseTest::mouseControlTest()
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(2, 3) );
CPPUNIT_ASSERT ( mouse_control.isMoved() ); CPPUNIT_ASSERT ( mouse_control.isMoved() );
mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5); mouse_control.setRawData (finalcut::FMouse::MouseType::Sgr, rawdata5);
mouse_control.processEvent (&tv); mouse_control.processEvent (tv);
CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) ); CPPUNIT_ASSERT ( mouse_control.getPos() == finalcut::FPoint(3, 4) );
CPPUNIT_ASSERT ( ! mouse_control.isMoved() ); CPPUNIT_ASSERT ( ! mouse_control.isMoved() );

View File

@ -3,7 +3,7 @@
* * * *
* This file is part of the FINAL CUT widget toolkit * * This file is part of the FINAL CUT widget toolkit *
* * * *
* Copyright 2018-2020 Markus Gans * * Copyright 2018-2021 Markus Gans *
* * * *
* FINAL CUT is free software; you can redistribute it and/or modify * * FINAL CUT is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as * * it under the terms of the GNU Lesser General Public License as *
@ -216,7 +216,6 @@ void FObjectTest::noArgumentTest()
CPPUNIT_ASSERT ( ! o1.isDirectChild(&o2) ); CPPUNIT_ASSERT ( ! o1.isDirectChild(&o2) );
CPPUNIT_ASSERT ( ! o1.isWidget() ); CPPUNIT_ASSERT ( ! o1.isWidget() );
CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") ); CPPUNIT_ASSERT ( o1.isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! o1.isTimerInUpdating() );
test::FObject_protected t; test::FObject_protected t;
auto ev = new finalcut::FEvent(finalcut::Event::None); auto ev = new finalcut::FEvent(finalcut::Event::None);
@ -287,7 +286,6 @@ void FObjectTest::childObjectTest()
CPPUNIT_ASSERT ( ! c1->isDirectChild(c7) ); CPPUNIT_ASSERT ( ! c1->isDirectChild(c7) );
CPPUNIT_ASSERT ( ! c1->isWidget() ); CPPUNIT_ASSERT ( ! c1->isWidget() );
CPPUNIT_ASSERT ( c1->isInstanceOf("FObject") ); CPPUNIT_ASSERT ( c1->isInstanceOf("FObject") );
CPPUNIT_ASSERT ( ! c1->isTimerInUpdating() );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -553,15 +551,16 @@ void FObjectTest::iteratorTest()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FObjectTest::timeTest() void FObjectTest::timeTest()
{ {
struct timeval time1; TimeValue time1{};
uInt64 timeout = 750000; // 750 ms uInt64 timeout = 750000; // 750 ms
finalcut::FObject::getCurrentTime(&time1); time1 = finalcut::FObject::getCurrentTime();
CPPUNIT_ASSERT ( ! finalcut::FObject::isTimeout (&time1, timeout) ); CPPUNIT_ASSERT ( ! finalcut::FObject::isTimeout (time1, timeout) );
sleep(1); sleep(1);
CPPUNIT_ASSERT ( finalcut::FObject::isTimeout (&time1, timeout) ); CPPUNIT_ASSERT ( finalcut::FObject::isTimeout (time1, timeout) );
time1.tv_sec = 300; time1 = TimeValue{}
time1.tv_usec = 2000000; // > 1000000 µs to test diff underflow + std::chrono::seconds(300)
CPPUNIT_ASSERT ( finalcut::FObject::isTimeout (&time1, timeout) ); + std::chrono::microseconds(2000000);
CPPUNIT_ASSERT ( finalcut::FObject::isTimeout (time1, timeout) );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -622,19 +621,20 @@ void FObjectTest::timerTest()
CPPUNIT_ASSERT ( t1.getTimerList()->size() == 0 ); CPPUNIT_ASSERT ( t1.getTimerList()->size() == 0 );
CPPUNIT_ASSERT ( t2.getTimerList()->size() == 0 ); CPPUNIT_ASSERT ( t2.getTimerList()->size() == 0 );
timeval tv1 = { 1321006271, 0 }; auto tv1 = TimeValue{} + std::chrono::seconds(1321006271);
timeval tv2 = { 27166271, 0 }; auto tv2 = TimeValue{} + std::chrono::seconds(27166271);
timeval tv_sum = tv1 + tv2; auto tv2_duration = std::chrono::duration_cast<std::chrono::seconds>(tv2.time_since_epoch());
CPPUNIT_ASSERT ( tv_sum.tv_sec == 1348172542 ); auto tv_sum = tv1 + tv2_duration;
CPPUNIT_ASSERT ( tv_sum.tv_usec == 0 ); auto sec_sum = std::chrono::duration_cast<std::chrono::seconds>(tv_sum.time_since_epoch()).count();
CPPUNIT_ASSERT ( sec_sum == 1348172542 );
timeval tv_difference = tv1 - tv2; auto tv_difference = tv1 - tv2_duration;
CPPUNIT_ASSERT ( tv_difference.tv_sec == 1293840000 ); auto sec_difference = std::chrono::duration_cast<std::chrono::seconds>(tv_difference.time_since_epoch()).count();
CPPUNIT_ASSERT ( tv_difference.tv_usec == 0 ); CPPUNIT_ASSERT ( sec_difference == 1293840000 );
tv_sum += tv2; tv_sum += tv2_duration;
CPPUNIT_ASSERT ( tv_sum.tv_sec == 1375338813 ); sec_sum = std::chrono::duration_cast<std::chrono::seconds>(tv_sum.time_since_epoch()).count();
CPPUNIT_ASSERT ( tv_sum.tv_usec == 0 ); CPPUNIT_ASSERT ( sec_sum == 1375338813 );
CPPUNIT_ASSERT ( tv2 < tv1 ); CPPUNIT_ASSERT ( tv2 < tv1 );
CPPUNIT_ASSERT ( ! (tv1 < tv2) ); CPPUNIT_ASSERT ( ! (tv1 < tv2) );
@ -645,21 +645,37 @@ void FObjectTest::timerTest()
CPPUNIT_ASSERT ( tv_difference < tv_sum ); CPPUNIT_ASSERT ( tv_difference < tv_sum );
CPPUNIT_ASSERT ( ! (tv_sum < tv_difference) ); CPPUNIT_ASSERT ( ! (tv_sum < tv_difference) );
tv1.tv_usec = tv2.tv_usec = 600000; tv1 += std::chrono::microseconds(600000);
tv_sum = tv1 + tv2; tv2 += std::chrono::microseconds(600000);
CPPUNIT_ASSERT ( tv_sum.tv_sec == 1348172543 ); tv2_duration = std::chrono::duration_cast<std::chrono::seconds>(tv2.time_since_epoch());
CPPUNIT_ASSERT ( tv_sum.tv_usec == 200000 ); tv_sum = tv1 + tv2_duration;
auto s_sum = std::chrono::duration_cast<std::chrono::seconds>(tv_sum.time_since_epoch()).count();
CPPUNIT_ASSERT ( s_sum == 1348172542 );
auto us_sum = ( std::chrono::duration_cast<std::chrono::microseconds>(tv_sum.time_since_epoch())
- std::chrono::seconds(1348172542) ).count();
CPPUNIT_ASSERT ( us_sum == 600000 );
tv1.tv_usec = 654321; auto tv1_sec = std::chrono::duration_cast<std::chrono::seconds>(tv1.time_since_epoch());
tv2.tv_usec = 123456; auto tv2_sec = std::chrono::duration_cast<std::chrono::seconds>(tv2.time_since_epoch());
tv_difference = tv1 - tv2; tv1 = TimeValue{} + tv1_sec + std::chrono::microseconds(654321);
CPPUNIT_ASSERT ( tv_difference.tv_sec == 1293840000 ); tv2 = TimeValue{} + tv2_sec + std::chrono::microseconds(123456);
CPPUNIT_ASSERT ( tv_difference.tv_usec == 530865 ); auto tv2_duration_ms = std::chrono::duration_cast<std::chrono::microseconds>(tv2.time_since_epoch());
tv_difference = tv1 - tv2_duration_ms;
sec_difference = std::chrono::duration_cast<std::chrono::seconds>(tv_difference.time_since_epoch()).count();
CPPUNIT_ASSERT ( sec_difference == 1293840000 );
auto usec_difference = ( std::chrono::duration_cast<std::chrono::microseconds>(tv_difference.time_since_epoch())
- std::chrono::seconds(1293840000) ).count();
CPPUNIT_ASSERT ( usec_difference == 530865 );
tv2.tv_usec = 999888; tv2_sec = std::chrono::duration_cast<std::chrono::seconds>(tv2.time_since_epoch());
tv_sum += tv2; tv2 = TimeValue{} + tv2_sec + std::chrono::microseconds(999888);
CPPUNIT_ASSERT ( tv_sum.tv_sec == 1375338815 ); auto tv2_duration2 = std::chrono::duration_cast<std::chrono::microseconds>(tv2.time_since_epoch());
CPPUNIT_ASSERT ( tv_sum.tv_usec == 199888 ); tv_sum += tv2_duration2;
s_sum = std::chrono::duration_cast<std::chrono::seconds>(tv_sum.time_since_epoch()).count();
CPPUNIT_ASSERT ( s_sum == 1375338814 );
us_sum = ( std::chrono::duration_cast<std::chrono::microseconds>(tv_sum.time_since_epoch())
- std::chrono::seconds(1375338814) ).count();
CPPUNIT_ASSERT ( us_sum == 599888 );
CPPUNIT_ASSERT ( tv2 < tv1 ); CPPUNIT_ASSERT ( tv2 < tv1 );
CPPUNIT_ASSERT ( ! (tv1 < tv2) ); CPPUNIT_ASSERT ( ! (tv1 < tv2) );