mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-11 03:56:16 +00:00
LibWeb+LibWebView+WebContent: Inform chromes when audio is played/paused
Most browsers have some indicator when audio is playing in a tab, which makes it easier to find that tab and mute unwanted audio. This adds an IPC to allow the Ladybird chromes to do something similar.
This commit is contained in:
parent
5424135d81
commit
40c0dd81d2
Notes:
sideshowbarker
2024-07-17 02:08:15 +09:00
Author: https://github.com/trflynn89
Commit: 40c0dd81d2
Pull-request: https://github.com/SerenityOS/serenity/pull/23739
11 changed files with 63 additions and 1 deletions
|
@ -315,6 +315,14 @@ void ViewImplementation::toggle_media_controls_state()
|
|||
client().async_toggle_media_controls_state(page_id());
|
||||
}
|
||||
|
||||
void ViewImplementation::did_change_audio_play_state(Badge<WebContentClient>, Web::HTML::AudioPlayState play_state)
|
||||
{
|
||||
m_audio_play_state = play_state;
|
||||
|
||||
if (on_audio_play_state_changed)
|
||||
on_audio_play_state_changed(m_audio_play_state);
|
||||
}
|
||||
|
||||
void ViewImplementation::handle_resize()
|
||||
{
|
||||
resize_backing_stores_if_needed(WindowResizeInProgress::Yes);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <LibGfx/StandardCursor.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWeb/HTML/AudioPlayState.h>
|
||||
#include <LibWeb/HTML/ColorPickerUpdateState.h>
|
||||
#include <LibWeb/HTML/FileFilter.h>
|
||||
#include <LibWeb/HTML/SelectItem.h>
|
||||
|
@ -101,6 +102,9 @@ public:
|
|||
void toggle_media_loop_state();
|
||||
void toggle_media_controls_state();
|
||||
|
||||
void did_change_audio_play_state(Badge<WebContentClient>, Web::HTML::AudioPlayState);
|
||||
Web::HTML::AudioPlayState audio_play_state() const { return m_audio_play_state; }
|
||||
|
||||
enum class ScreenshotType {
|
||||
Visible,
|
||||
Full,
|
||||
|
@ -178,6 +182,7 @@ public:
|
|||
Function<void()> on_text_test_finish;
|
||||
Function<void(Gfx::Color)> on_theme_color_change;
|
||||
Function<void(String const&, String const&, String const&)> on_insert_clipboard_entry;
|
||||
Function<void(Web::HTML::AudioPlayState)> on_audio_play_state_changed;
|
||||
Function<void()> on_inspector_loaded;
|
||||
Function<void(i32, Optional<Web::CSS::Selector::PseudoElement::Type> const&)> on_inspector_selected_dom_node;
|
||||
Function<void(i32, String const&)> on_inspector_set_dom_node_text;
|
||||
|
@ -252,6 +257,8 @@ protected:
|
|||
RefPtr<Core::Timer> m_repeated_crash_timer;
|
||||
|
||||
RefPtr<Core::Promise<LexicalPath>> m_pending_screenshot;
|
||||
|
||||
Web::HTML::AudioPlayState m_audio_play_state { Web::HTML::AudioPlayState::Paused };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -870,6 +870,18 @@ void WebContentClient::did_insert_clipboard_entry(u64 page_id, String const& dat
|
|||
view.on_insert_clipboard_entry(data, presentation_style, mime_type);
|
||||
}
|
||||
|
||||
void WebContentClient::did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState play_state)
|
||||
{
|
||||
auto maybe_view = m_views.get(page_id);
|
||||
if (!maybe_view.has_value()) {
|
||||
dbgln("Received insert clipboard entry for unknown page ID {}", page_id);
|
||||
return;
|
||||
}
|
||||
|
||||
auto& view = *maybe_view.value();
|
||||
view.did_change_audio_play_state({}, play_state);
|
||||
}
|
||||
|
||||
void WebContentClient::inspector_did_load(u64 page_id)
|
||||
{
|
||||
auto maybe_view = m_views.get(page_id);
|
||||
|
|
|
@ -96,6 +96,7 @@ private:
|
|||
virtual void did_finish_text_test(u64 page_id) override;
|
||||
virtual void did_change_theme_color(u64 page_id, Gfx::Color color) override;
|
||||
virtual void did_insert_clipboard_entry(u64 page_id, String const& data, String const& presentation_style, String const& mime_type) override;
|
||||
virtual void did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState) override;
|
||||
virtual void inspector_did_load(u64 page_id) override;
|
||||
virtual void inspector_did_select_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element) override;
|
||||
virtual void inspector_did_set_dom_node_text(u64 page_id, i32 node_id, String const& text) override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue