diff --git a/libvisual/po/de.po b/libvisual/po/de.po index b92cdd716..bdd7f0bdc 100644 --- a/libvisual/po/de.po +++ b/libvisual/po/de.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: libvisual 0.4.0-2.2\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-01 21:15+0100\n" +"POT-Creation-Date: 2023-02-04 23:12+0100\n" "PO-Revision-Date: 2017-08-10 18:46+GMT\n" "Last-Translator: Chris Leick \n" "Language-Team: German \n" @@ -900,7 +900,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Ungültige Tiefe an Scaler übergeben" -#: tools/lv-tool/lv-tool.cpp:837 tools/lv-tool/lv-tool.cpp:934 +#: tools/lv-tool/lv-tool.cpp:881 tools/lv-tool/lv-tool.cpp:1062 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/es_AR.po b/libvisual/po/es_AR.po index 0dd3b67be..3f4743833 100644 --- a/libvisual/po/es_AR.po +++ b/libvisual/po/es_AR.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Libvisual Library 0.4.0\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-01 21:15+0100\n" +"POT-Creation-Date: 2023-02-04 23:12+0100\n" "PO-Revision-Date: 2005-03-20 17:09-0300\n" "Last-Translator: \n" "Language-Team: Spanish\n" @@ -918,7 +918,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Profundidad pasada al escalador inválida" -#: tools/lv-tool/lv-tool.cpp:837 tools/lv-tool/lv-tool.cpp:934 +#: tools/lv-tool/lv-tool.cpp:881 tools/lv-tool/lv-tool.cpp:1062 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/es_ES.po b/libvisual/po/es_ES.po index 4ad84219e..621de51be 100644 --- a/libvisual/po/es_ES.po +++ b/libvisual/po/es_ES.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Libvisual Library 0.4.0\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-01 21:15+0100\n" +"POT-Creation-Date: 2023-02-04 23:12+0100\n" "PO-Revision-Date: 2005-03-20 17:09-0300\n" "Last-Translator: \n" "Language-Team: Spanish\n" @@ -918,7 +918,7 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "Profundidad pasada al escalador inválida" -#: tools/lv-tool/lv-tool.cpp:837 tools/lv-tool/lv-tool.cpp:934 +#: tools/lv-tool/lv-tool.cpp:881 tools/lv-tool/lv-tool.cpp:1062 msgid "lv-tool" msgstr "" diff --git a/libvisual/po/libvisual-0.4.pot b/libvisual/po/libvisual-0.4.pot index 534038748..cee0f6c10 100644 --- a/libvisual/po/libvisual-0.4.pot +++ b/libvisual/po/libvisual-0.4.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: libvisual 0.4.1\n" "Report-Msgid-Bugs-To: https://github.com/Libvisual/libvisual/issues/\n" -"POT-Creation-Date: 2023-02-01 21:15+0100\n" +"POT-Creation-Date: 2023-02-04 23:12+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -871,6 +871,6 @@ msgstr "" msgid "Invalid depth passed to the scaler" msgstr "" -#: tools/lv-tool/lv-tool.cpp:837 tools/lv-tool/lv-tool.cpp:934 +#: tools/lv-tool/lv-tool.cpp:881 tools/lv-tool/lv-tool.cpp:1062 msgid "lv-tool" msgstr "" diff --git a/libvisual/tools/lv-tool/lv-tool.cpp b/libvisual/tools/lv-tool/lv-tool.cpp index f0559ec4a..6876b43ff 100644 --- a/libvisual/tools/lv-tool/lv-tool.cpp +++ b/libvisual/tools/lv-tool/lv-tool.cpp @@ -128,10 +128,21 @@ namespace LV { return Time(SDL_GetTicks()); } - Time operator-(Time & other) const { - return Time(this->m_moment - other.m_moment); + friend Time operator-(Time const& lhs, Time const& rhs) { + return Time(lhs.m_moment - rhs.m_moment); } + friend bool operator>=(Time const& lhs, Time const& rhs) { + return lhs.m_moment >= rhs.m_moment; + } + + //! Converts the time to seconds + double to_secs() const + { + return this->m_moment / 1000.0; + } + + //! Converts the time to microseconds uint64_t to_usecs() const { return this->m_moment * 1000; }; @@ -455,6 +466,39 @@ namespace { } }; + class ResizeRequest + { + unsigned int m_width; + unsigned int m_height; + LV::Time m_received_at; + LV::Time m_applied_at; + + public: + ResizeRequest() : m_width(0), m_height(0) { + } + + unsigned int width() const { return m_width; } + unsigned int height() const { return m_height; } + + bool is_due() const { + if (m_applied_at >= m_received_at) { + return false; + } + const double seconds_passed = (LV::Time::now() - m_received_at).to_secs(); + return seconds_passed >= 0.2; // >=300ms is known to feel slow to humans + } + + void store(unsigned int width, unsigned int height) { + m_width = width; + m_height = height; + m_received_at = LV::Time::now(); + } + + void mark_as_applied() { + m_applied_at = LV::Time::now(); + } + }; + /** print info about libvisual plugin */ void print_plugin_info(VisPluginInfo const& info) { @@ -856,6 +900,7 @@ int main (int argc, char **argv) // main loop bool running = true; + ResizeRequest resize_request; //bool visible = true; while (running) @@ -925,17 +970,7 @@ int main (int argc, char **argv) case VISUAL_EVENT_RESIZE: { - DisplayLock lock {display}; - - width = ev.event.resize.width; - height = ev.event.resize.height; - - video = display.create(depth, vidoptions, width, height, true); - display.set_title(_("lv-tool")); - - bin.set_video (video); - bin.sync(false); - + resize_request.store(ev.event.resize.width, ev.event.resize.height); break; } @@ -1017,6 +1052,21 @@ int main (int argc, char **argv) } } + if (resize_request.is_due ()) { + DisplayLock lock {display}; + + width = resize_request.width(); + height = resize_request.height(); + + video = display.create(depth, vidoptions, width, height, true); + display.set_title(_("lv-tool")); + + bin.set_video (video); + bin.sync(false); + + resize_request.mark_as_applied(); + } + if (bin.depth_changed()) { DisplayLock lock {display};