Compositor recovery recreated contexts and replayed viewport sizes, but it left the restarted helper with the default display metadata. A recovered context could fall back to a 60 Hz timer instead of the window's current display id and refresh rate until the frontend later observed a screen change. Store the display id in the shared view state, alongside the existing maximum frame rate, and replay both values while restoring view state after reconnect.
66 lines
2.1 KiB
C++
66 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) 2023-2024, Tim Flynn <trflynn89@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Optional.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibGfx/Point.h>
|
|
#include <LibGfx/Rect.h>
|
|
#include <LibGfx/Size.h>
|
|
#include <LibWeb/Page/InputEvent.h>
|
|
#include <LibWebView/ViewImplementation.h>
|
|
|
|
namespace Ladybird {
|
|
|
|
class WebViewBridge final : public WebView::ViewImplementation {
|
|
public:
|
|
static ErrorOr<NonnullOwnPtr<WebViewBridge>> create(Vector<Web::DevicePixelRect> screen_rects, double device_pixel_ratio, u64 maximum_frames_per_second, Optional<u64> display_id);
|
|
virtual ~WebViewBridge() override;
|
|
|
|
virtual void initialize_client(CreateNewClient = CreateNewClient::Yes) override;
|
|
void initialize_client_as_child(WebViewBridge& parent, u64 page_index);
|
|
|
|
void set_device_pixel_ratio(double device_pixel_ratio);
|
|
void set_zoom_level(double zoom_level);
|
|
double inverse_device_pixel_ratio() const { return 1.0 / device_pixel_ratio(); }
|
|
|
|
void set_viewport_rect(Gfx::IntRect);
|
|
|
|
void set_display_metadata(u64 maximum_frames_per_second, Optional<u64> display_id);
|
|
|
|
void exit_fullscreen();
|
|
|
|
void update_palette();
|
|
|
|
void enqueue_input_event(Web::MouseEvent);
|
|
void enqueue_input_event(Web::DragEvent);
|
|
void enqueue_input_event(Web::KeyEvent);
|
|
void enqueue_input_event(Web::PinchEvent);
|
|
|
|
struct Paintable {
|
|
Gfx::SharedImageBuffer const* shared_image_buffer { nullptr };
|
|
Gfx::IntSize bitmap_size;
|
|
};
|
|
Optional<Paintable> paintable();
|
|
|
|
Function<void()> on_zoom_level_changed;
|
|
|
|
private:
|
|
WebViewBridge(Vector<Web::DevicePixelRect> screen_rects, double device_pixel_ratio, u64 maximum_frames_per_second, Optional<u64> display_id);
|
|
|
|
void update_compositor_display_metadata();
|
|
|
|
virtual void update_zoom() override;
|
|
virtual Web::DevicePixelSize viewport_size() const override;
|
|
virtual Gfx::IntPoint to_content_position(Gfx::IntPoint widget_position) const override;
|
|
virtual Gfx::IntPoint to_widget_position(Gfx::IntPoint content_position) const override;
|
|
|
|
Vector<Web::DevicePixelRect> m_screen_rects;
|
|
Gfx::IntSize m_viewport_size;
|
|
};
|
|
|
|
}
|