summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Applications/HexEditor/HexEditor.cpp8
-rw-r--r--Userland/Applications/HexEditor/HexEditor.h2
-rw-r--r--Userland/Applications/Piano/main.cpp4
-rw-r--r--Userland/Applications/PixelPaint/Tools/SprayTool.cpp6
-rw-r--r--Userland/Applications/PixelPaint/Tools/TextTool.cpp6
-rw-r--r--Userland/Applications/SoundPlayer/PlaybackManager.cpp4
-rw-r--r--Userland/Demos/CatDog/main.cpp7
-rw-r--r--Userland/Demos/WidgetGallery/DemoWizardDialog.cpp28
-rw-r--r--Userland/DevTools/Profiler/main.cpp4
-rw-r--r--Userland/Libraries/LibVideo/PlaybackManager.cpp11
-rw-r--r--Userland/Libraries/LibVideo/PlaybackManager.h4
-rw-r--r--Userland/Services/WindowServer/WindowFrame.cpp4
12 files changed, 37 insertions, 51 deletions
diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp
index 03d762f603..206f2f1043 100644
--- a/Userland/Applications/HexEditor/HexEditor.cpp
+++ b/Userland/Applications/HexEditor/HexEditor.cpp
@@ -31,8 +31,7 @@
#include <unistd.h>
HexEditor::HexEditor()
- : m_blink_timer(Core::Timer::construct())
- , m_document(make<HexDocumentMemory>(ByteBuffer::create_zeroed(0).release_value_but_fixme_should_propagate_errors()))
+ : m_document(make<HexDocumentMemory>(ByteBuffer::create_zeroed(0).release_value_but_fixme_should_propagate_errors()))
{
set_should_hide_unnecessary_scrollbars(true);
set_focus_policy(GUI::FocusPolicy::StrongFocus);
@@ -42,11 +41,10 @@ HexEditor::HexEditor()
set_foreground_role(ColorRole::BaseText);
vertical_scrollbar().set_step(line_height());
- m_blink_timer->set_interval(500);
- m_blink_timer->on_timeout = [this]() {
+ m_blink_timer = Core::Timer::create_repeating(500, [this]() {
m_cursor_blink_active = !m_cursor_blink_active;
update();
- };
+ }).release_value_but_fixme_should_propagate_errors();
m_blink_timer->start();
}
diff --git a/Userland/Applications/HexEditor/HexEditor.h b/Userland/Applications/HexEditor/HexEditor.h
index 8bb6ada27c..d7e085b49c 100644
--- a/Userland/Applications/HexEditor/HexEditor.h
+++ b/Userland/Applications/HexEditor/HexEditor.h
@@ -85,7 +85,7 @@ private:
size_t m_position { 0 };
bool m_cursor_at_low_nibble { false };
EditMode m_edit_mode { Hex };
- NonnullRefPtr<Core::Timer> m_blink_timer;
+ RefPtr<Core::Timer> m_blink_timer;
bool m_cursor_blink_active { false };
NonnullOwnPtr<HexDocument> m_document;
GUI::UndoStack m_undo_stack;
diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp
index b8ad18c16c..1b72d7c78e 100644
--- a/Userland/Applications/Piano/main.cpp
+++ b/Userland/Applications/Piano/main.cpp
@@ -47,10 +47,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
window->resize(840, 600);
window->set_icon(app_icon.bitmap_for_size(16));
- auto main_widget_updater = Core::Timer::construct(static_cast<int>((1 / 30.0) * 1000), [&] {
+ auto main_widget_updater = TRY(Core::Timer::create_repeating(static_cast<int>((1 / 30.0) * 1000), [&] {
if (window->is_active())
Core::EventLoop::current().post_event(main_widget, make<Core::CustomEvent>(0));
- });
+ }));
main_widget_updater->start();
auto& file_menu = window->add_menu("&File");
diff --git a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp
index a28bc03137..c1cf9f661b 100644
--- a/Userland/Applications/PixelPaint/Tools/SprayTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/SprayTool.cpp
@@ -22,11 +22,9 @@ namespace PixelPaint {
SprayTool::SprayTool()
{
- m_timer = Core::Timer::construct();
- m_timer->on_timeout = [&]() {
+ m_timer = Core::Timer::create_repeating(200, [&]() {
paint_it();
- };
- m_timer->set_interval(200);
+ }).release_value_but_fixme_should_propagate_errors();
}
static double nrand()
diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.cpp b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
index b2d579bddd..f825ce224a 100644
--- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
@@ -36,11 +36,9 @@ TextTool::TextTool()
m_text_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap);
m_selected_font = Gfx::FontDatabase::default_font();
m_text_editor->set_font(m_selected_font);
- m_cursor_blink_timer = Core::Timer::construct();
- m_cursor_blink_timer->on_timeout = [&]() {
+ m_cursor_blink_timer = Core::Timer::create_repeating(500, [&]() {
m_cursor_blink_state = !m_cursor_blink_state;
- };
- m_cursor_blink_timer->set_interval(500);
+ }).release_value_but_fixme_should_propagate_errors();
}
void TextTool::on_tool_deactivation()
diff --git a/Userland/Applications/SoundPlayer/PlaybackManager.cpp b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
index e929cf144d..bf7a00c1a4 100644
--- a/Userland/Applications/SoundPlayer/PlaybackManager.cpp
+++ b/Userland/Applications/SoundPlayer/PlaybackManager.cpp
@@ -11,11 +11,11 @@ PlaybackManager::PlaybackManager(NonnullRefPtr<Audio::ConnectionToServer> connec
: m_connection(connection)
{
// FIXME: The buffer enqueuing should happen on a wholly independent second thread.
- m_timer = Core::Timer::construct(PlaybackManager::update_rate_ms, [&]() {
+ m_timer = Core::Timer::create_repeating(PlaybackManager::update_rate_ms, [&]() {
if (!m_loader)
return;
next_buffer();
- });
+ }).release_value_but_fixme_should_propagate_errors();
m_device_sample_rate = connection->get_sample_rate();
}
diff --git a/Userland/Demos/CatDog/main.cpp b/Userland/Demos/CatDog/main.cpp
index b57dcbd5a6..6075cac907 100644
--- a/Userland/Demos/CatDog/main.cpp
+++ b/Userland/Demos/CatDog/main.cpp
@@ -66,17 +66,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
(void)TRY(advice_widget->try_set_layout<GUI::VerticalBoxLayout>());
advice_widget->layout()->set_spacing(0);
- auto advice_timer = TRY(Core::Timer::try_create());
- advice_timer->set_interval(15'000);
- advice_timer->set_single_shot(true);
- advice_timer->on_timeout = [&] {
+ auto advice_timer = TRY(Core::Timer::create_single_shot(15'000, [&] {
window->move_to_front();
advice_window->move_to_front();
catdog_widget->set_roaming(false);
advice_window->move_to(window->x() - advice_window->width() / 2, window->y() - advice_window->height());
advice_window->show();
advice_window->set_always_on_top();
- };
+ }));
advice_timer->start();
advice_widget->on_dismiss = [&] {
diff --git a/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp b/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp
index a9156e8dbe..0cff4d365e 100644
--- a/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp
+++ b/Userland/Demos/WidgetGallery/DemoWizardDialog.cpp
@@ -41,26 +41,28 @@ DemoWizardDialog::DemoWizardDialog(GUI::Window* parent_window)
.release_value_but_fixme_should_propagate_errors();
m_page_2->body_widget().load_from_gml(demo_wizard_page_2_gml).release_value_but_fixme_should_propagate_errors();
m_page_2_progressbar = m_page_2->body_widget().find_descendant_of_type_named<GUI::Progressbar>("page_2_progressbar");
- m_page_2_timer = Core::Timer::try_create(this).release_value_but_fixme_should_propagate_errors();
+ m_page_2_timer = Core::Timer::create_repeating(
+ 100, [&]() {
+ if (m_page_2_progress_value < 100)
+ m_page_2_progress_value++;
+ m_page_2_progressbar->set_value(m_page_2_progress_value);
+
+ // Go to final page on progress completion
+ if (m_page_2_progress_value == 100) {
+ m_page_2_progress_value = 0;
+ replace_page(*m_back_page);
+ }
+ },
+ this)
+ .release_value_but_fixme_should_propagate_errors();
m_page_2->on_page_enter = [&]() {
m_page_2_progress_value = 0;
- m_page_2_timer->restart(100);
+ m_page_2_timer->restart();
};
m_page_2->on_page_leave = [&]() {
m_page_2_progress_value = 0;
m_page_2_timer->stop();
};
- m_page_2_timer->on_timeout = [&]() {
- if (m_page_2_progress_value < 100)
- m_page_2_progress_value++;
- m_page_2_progressbar->set_value(m_page_2_progress_value);
-
- // Go to final page on progress completion
- if (m_page_2_progress_value == 100) {
- m_page_2_progress_value = 0;
- replace_page(*m_back_page);
- }
- };
// Don't set a on_next_page handler for page 2 as we automatically navigate to the final page on progress completion
// Create the back cover
diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp
index 5660ed4a0d..3021605013 100644
--- a/Userland/DevTools/Profiler/main.cpp
+++ b/Userland/DevTools/Profiler/main.cpp
@@ -326,9 +326,9 @@ static bool prompt_to_stop_profiling(pid_t pid, DeprecatedString const& process_
auto& timer_label = widget->add<GUI::Label>("...");
Core::ElapsedTimer clock;
clock.start();
- auto update_timer = Core::Timer::construct(100, [&] {
+ auto update_timer = Core::Timer::create_repeating(100, [&] {
timer_label.set_text(DeprecatedString::formatted("{:.1} seconds", static_cast<float>(clock.elapsed()) / 1000.0f));
- });
+ }).release_value_but_fixme_should_propagate_errors();
update_timer->start();
auto& stop_button = widget->add<GUI::Button>("Stop");
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.cpp b/Userland/Libraries/LibVideo/PlaybackManager.cpp
index 725516dee4..77d881a8fb 100644
--- a/Userland/Libraries/LibVideo/PlaybackManager.cpp
+++ b/Userland/Libraries/LibVideo/PlaybackManager.cpp
@@ -33,16 +33,9 @@ PlaybackManager::PlaybackManager(Core::Object& event_handler, NonnullOwnPtr<Demu
, m_selected_video_track(video_track)
, m_decoder(move(decoder))
, m_frame_queue(make<VideoFrameQueue>())
- , m_present_timer(Core::Timer::construct())
- , m_decode_timer(Core::Timer::construct())
{
- m_present_timer->set_single_shot(true);
- m_present_timer->set_interval(0);
- m_present_timer->on_timeout = [&] { update_presented_frame(); };
-
- m_decode_timer->set_single_shot(true);
- m_decode_timer->set_interval(0);
- m_decode_timer->on_timeout = [&] { on_decode_timer(); };
+ m_present_timer = Core::Timer::create_single_shot(0, [&] { update_presented_frame(); }).release_value_but_fixme_should_propagate_errors();
+ m_decode_timer = Core::Timer::create_single_shot(0, [&] { on_decode_timer(); }).release_value_but_fixme_should_propagate_errors();
}
void PlaybackManager::set_playback_status(PlaybackStatus status)
diff --git a/Userland/Libraries/LibVideo/PlaybackManager.h b/Userland/Libraries/LibVideo/PlaybackManager.h
index 9fd77674b4..950c5be667 100644
--- a/Userland/Libraries/LibVideo/PlaybackManager.h
+++ b/Userland/Libraries/LibVideo/PlaybackManager.h
@@ -155,10 +155,10 @@ private:
NonnullOwnPtr<VideoFrameQueue> m_frame_queue;
Optional<FrameQueueItem> m_next_frame;
- NonnullRefPtr<Core::Timer> m_present_timer;
+ RefPtr<Core::Timer> m_present_timer;
unsigned m_decoding_buffer_time_ms = 16;
- NonnullRefPtr<Core::Timer> m_decode_timer;
+ RefPtr<Core::Timer> m_decode_timer;
u64 m_skipped_frames;
};
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp
index 4bea34055a..74777c1d58 100644
--- a/Userland/Services/WindowServer/WindowFrame.cpp
+++ b/Userland/Services/WindowServer/WindowFrame.cpp
@@ -948,12 +948,12 @@ void WindowFrame::handle_menu_mouse_event(Menu& menu, MouseEvent const& event)
void WindowFrame::start_flash_animation()
{
if (!m_flash_timer) {
- m_flash_timer = Core::Timer::construct(100, [this] {
+ m_flash_timer = Core::Timer::create_repeating(100, [this] {
VERIFY(m_flash_counter);
invalidate_titlebar();
if (!--m_flash_counter)
m_flash_timer->stop();
- });
+ }).release_value_but_fixme_should_propagate_errors();
}
m_flash_counter = 8;
m_flash_timer->start();