Truly independent web browser
UI/Qt: Offset the Wayland page surface by Qt's window frame
Tim Ledbetter3b5a33b6cac9
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.hindex f8ad0fc6cbf..971db8a0c1d 100644--- a/UI/Qt/WebContentView.h+++ b/UI/Qt/WebContentView.h@@ -484,6 +484,7 @@ private:void release_retired_backing_stores_no_longer_painted();void release_all_retired_backing_stores();QRect rect_shown_in_window() const;+ QPoint position_in_surface_of(QWindow const& parent, QPoint) const;// Shows the page's frames on Wayland by handing their dma-bufs to the compositor of the desktop. Without it, the// page's window draws them in a swap chain of its own.@@ -491,7 +492,7 @@ private:bool m_page_surface_failed { false };// Where the page surface shows a frame, in device pixels of the view.QRect m_page_surface_rect;- // Where the page surface last showed a frame, in the logical coordinates of the browser window.+ // Where the page surface last showed a frame, in the logical coordinates of the browser window's surface.QPoint m_page_surface_position;// The backing stores the view is done with that the compositor of the desktop may still read. The page they belong// to can stop displaying the tab before the compositor is done.diff --git a/UI/Qt/WebContentViewLinux.cpp b/UI/Qt/WebContentViewLinux.cppindex 55f2cccdbc3..b40de9df7a3 100644--- a/UI/Qt/WebContentViewLinux.cpp+++ b/UI/Qt/WebContentViewLinux.cpp@@ -1359,7 +1359,7 @@ void WebContentView::update_page_surface(PageSurfaceContent content)}auto to_logical = [&](int device_pixels) { return max(1, qRound(device_pixels / device_pixel_ratio())); };- auto view_position = mapTo(window(), QPoint { 0, 0 });+ auto view_position = position_in_surface_of(*parent, QPoint { 0, 0 });WaylandPageSurface::Frame frame {.shared_image_buffer = *paintable->shared_image_buffer,.dmabuf = *dmabuf,@@ -1415,10 +1415,16 @@ QRect WebContentView::rect_shown_in_window() constreturn shown;}+QPoint WebContentView::position_in_surface_of(QWindow const& parent, QPoint position) const+{+ auto frame_margins = parent.frameMargins();+ return mapTo(window(), position) + QPoint { frame_margins.left(), frame_margins.top() };+}+bool WebContentView::show_image_over_page(QImage const& image, QPoint position){auto* parent = window()->windowHandle();- if (!m_page_surface || !parent || !m_page_surface->show_overlay(*parent, image, mapTo(window(), position)))+ if (!m_page_surface || !parent || !m_page_surface->show_overlay(*parent, image, position_in_surface_of(*parent, position)))return false;// NB: The overlay changes on screen when the browser window commits next, so have Qt repaint a pixel of it.update(0, 0, 1, 1);