forked from quickshell/quickshell
wayland/screencopy: add screencopy
This commit is contained in:
parent
918dd2392d
commit
cd429142a4
37 changed files with 3149 additions and 3 deletions
42
src/wayland/screencopy/CMakeLists.txt
Normal file
42
src/wayland/screencopy/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
qt_add_library(quickshell-wayland-screencopy STATIC
|
||||
manager.cpp
|
||||
view.cpp
|
||||
)
|
||||
|
||||
qt_add_qml_module(quickshell-wayland-screencopy
|
||||
URI Quickshell.Wayland._Screencopy
|
||||
VERSION 0.1
|
||||
DEPENDENCIES QtQuick
|
||||
)
|
||||
|
||||
install_qml_module(quickshell-wayland-screencopy)
|
||||
|
||||
set(SCREENCOPY_MODULES)
|
||||
|
||||
if (SCREENCOPY_ICC)
|
||||
add_subdirectory(image_copy_capture)
|
||||
list(APPEND SCREENCOPY_MODULES quickshell-wayland-screencopy-icc)
|
||||
endif()
|
||||
|
||||
if (SCREENCOPY_WLR)
|
||||
add_subdirectory(wlr_screencopy)
|
||||
list(APPEND SCREENCOPY_MODULES quickshell-wayland-screencopy-wlr)
|
||||
endif()
|
||||
|
||||
if (SCREENCOPY_HYPRLAND_TOPLEVEL)
|
||||
add_subdirectory(hyprland_screencopy)
|
||||
list(APPEND SCREENCOPY_MODULES quickshell-wayland-screencopy-hyprland)
|
||||
endif()
|
||||
|
||||
configure_file(build.hpp.in build.hpp @ONLY)
|
||||
target_include_directories(quickshell-wayland-screencopy PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy PRIVATE
|
||||
Qt::Quick Qt::WaylandClient Qt::WaylandClientPrivate wayland-client
|
||||
quickshell-wayland-buffer
|
||||
${SCREENCOPY_MODULES}
|
||||
)
|
||||
|
||||
qs_module_pch(quickshell-wayland-screencopy SET large)
|
||||
|
||||
target_link_libraries(quickshell PRIVATE quickshell-wayland-screencopyplugin)
|
||||
6
src/wayland/screencopy/build.hpp.in
Normal file
6
src/wayland/screencopy/build.hpp.in
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#pragma once
|
||||
// NOLINTBEGIN
|
||||
#cmakedefine01 SCREENCOPY_ICC
|
||||
#cmakedefine01 SCREENCOPY_WLR
|
||||
#cmakedefine01 SCREENCOPY_HYPRLAND_TOPLEVEL
|
||||
// NOLINTEND
|
||||
16
src/wayland/screencopy/hyprland_screencopy/CMakeLists.txt
Normal file
16
src/wayland/screencopy/hyprland_screencopy/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
qt_add_library(quickshell-wayland-screencopy-hyprland STATIC
|
||||
hyprland_screencopy.cpp
|
||||
)
|
||||
|
||||
wl_proto(wlp-hyprland-screencopy hyprland-toplevel-export-v1 "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-hyprland PRIVATE
|
||||
Qt::WaylandClient Qt::WaylandClientPrivate wayland-client
|
||||
Qt::Quick # for pch
|
||||
)
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-hyprland PUBLIC
|
||||
wlp-hyprland-screencopy wlp-foreign-toplevel
|
||||
)
|
||||
|
||||
qs_pch(quickshell-wayland-screencopy-hyprland SET large)
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="hyprland_toplevel_export_v1">
|
||||
<copyright>
|
||||
Copyright © 2022 Vaxry
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
</copyright>
|
||||
|
||||
<description summary="capturing the contents of toplevel windows">
|
||||
This protocol allows clients to ask for exporting another toplevel's
|
||||
surface(s) to a buffer.
|
||||
|
||||
Particularly useful for sharing a single window.
|
||||
</description>
|
||||
|
||||
<interface name="hyprland_toplevel_export_manager_v1" version="2">
|
||||
<description summary="manager to inform clients and begin capturing">
|
||||
This object is a manager which offers requests to start capturing from a
|
||||
source.
|
||||
</description>
|
||||
|
||||
<request name="capture_toplevel">
|
||||
<description summary="capture a toplevel">
|
||||
Capture the next frame of a toplevel. (window)
|
||||
|
||||
The captured frame will not contain any server-side decorations and will
|
||||
ignore the compositor-set geometry, like e.g. rounded corners.
|
||||
|
||||
It will contain all the subsurfaces and popups, however the latter will be clipped
|
||||
to the geometry of the base surface.
|
||||
|
||||
The handle parameter refers to the address of the window as seen in `hyprctl clients`.
|
||||
For example, for d161e7b0 it would be 3512854448.
|
||||
</description>
|
||||
<arg name="frame" type="new_id" interface="hyprland_toplevel_export_frame_v1"/>
|
||||
<arg name="overlay_cursor" type="int"
|
||||
summary="composite cursor onto the frame"/>
|
||||
<arg name="handle" type="uint" summary="the handle of the toplevel (window) to be captured"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the manager">
|
||||
All objects created by the manager will still remain valid, until their
|
||||
appropriate destroy request has been called.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<!-- Version 2 -->
|
||||
<request name="capture_toplevel_with_wlr_toplevel_handle" since="2">
|
||||
<description summary="capture a toplevel">
|
||||
Same as capture_toplevel, but with a zwlr_foreign_toplevel_handle_v1 handle.
|
||||
</description>
|
||||
<arg name="frame" type="new_id" interface="hyprland_toplevel_export_frame_v1"/>
|
||||
<arg name="overlay_cursor" type="int"
|
||||
summary="composite cursor onto the frame"/>
|
||||
<arg name="handle" type="object" interface="zwlr_foreign_toplevel_handle_v1" allow-null="false" summary="the zwlr_foreign_toplevel_handle_v1 handle of the toplevel to be captured"/>
|
||||
</request>
|
||||
<!-- End Version 2 -->
|
||||
</interface>
|
||||
|
||||
<interface name="hyprland_toplevel_export_frame_v1" version="2">
|
||||
<description summary="a frame ready for copy">
|
||||
This object represents a single frame.
|
||||
|
||||
When created, a series of buffer events will be sent, each representing a
|
||||
supported buffer type. The "buffer_done" event is sent afterwards to
|
||||
indicate that all supported buffer types have been enumerated. The client
|
||||
will then be able to send a "copy" request. If the capture is successful,
|
||||
the compositor will send a "flags" followed by a "ready" event.
|
||||
|
||||
wl_shm buffers are always supported, ie. the "buffer" event is guaranteed to be sent.
|
||||
|
||||
If the capture failed, the "failed" event is sent. This can happen anytime
|
||||
before the "ready" event.
|
||||
|
||||
Once either a "ready" or a "failed" event is received, the client should
|
||||
destroy the frame.
|
||||
</description>
|
||||
|
||||
<event name="buffer">
|
||||
<description summary="wl_shm buffer information">
|
||||
Provides information about wl_shm buffer parameters that need to be
|
||||
used for this frame. This event is sent once after the frame is created
|
||||
if wl_shm buffers are supported.
|
||||
</description>
|
||||
<arg name="format" type="uint" enum="wl_shm.format" summary="buffer format"/>
|
||||
<arg name="width" type="uint" summary="buffer width"/>
|
||||
<arg name="height" type="uint" summary="buffer height"/>
|
||||
<arg name="stride" type="uint" summary="buffer stride"/>
|
||||
</event>
|
||||
|
||||
<request name="copy">
|
||||
<description summary="copy the frame">
|
||||
Copy the frame to the supplied buffer. The buffer must have the
|
||||
correct size, see hyprland_toplevel_export_frame_v1.buffer and
|
||||
hyprland_toplevel_export_frame_v1.linux_dmabuf. The buffer needs to have a
|
||||
supported format.
|
||||
|
||||
If the frame is successfully copied, a "flags" and a "ready" event is
|
||||
sent. Otherwise, a "failed" event is sent.
|
||||
|
||||
This event will wait for appropriate damage to be copied, unless the ignore_damage
|
||||
arg is set to a non-zero value.
|
||||
</description>
|
||||
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||
<arg name="ignore_damage" type="int"/>
|
||||
</request>
|
||||
|
||||
<event name="damage">
|
||||
<description summary="carries the coordinates of the damaged region">
|
||||
This event is sent right before the ready event when ignore_damage was
|
||||
not set. It may be generated multiple times for each copy
|
||||
request.
|
||||
|
||||
The arguments describe a box around an area that has changed since the
|
||||
last copy request that was derived from the current screencopy manager
|
||||
instance.
|
||||
|
||||
The union of all regions received between the call to copy
|
||||
and a ready event is the total damage since the prior ready event.
|
||||
</description>
|
||||
<arg name="x" type="uint" summary="damaged x coordinates"/>
|
||||
<arg name="y" type="uint" summary="damaged y coordinates"/>
|
||||
<arg name="width" type="uint" summary="current width"/>
|
||||
<arg name="height" type="uint" summary="current height"/>
|
||||
</event>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="already_used" value="0"
|
||||
summary="the object has already been used to copy a wl_buffer"/>
|
||||
<entry name="invalid_buffer" value="1"
|
||||
summary="buffer attributes are invalid"/>
|
||||
</enum>
|
||||
|
||||
<enum name="flags" bitfield="true">
|
||||
<entry name="y_invert" value="1" summary="contents are y-inverted"/>
|
||||
</enum>
|
||||
|
||||
<event name="flags">
|
||||
<description summary="frame flags">
|
||||
Provides flags about the frame. This event is sent once before the
|
||||
"ready" event.
|
||||
</description>
|
||||
<arg name="flags" type="uint" enum="flags" summary="frame flags"/>
|
||||
</event>
|
||||
|
||||
<event name="ready">
|
||||
<description summary="indicates frame is available for reading">
|
||||
Called as soon as the frame is copied, indicating it is available
|
||||
for reading. This event includes the time at which presentation happened
|
||||
at.
|
||||
|
||||
The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
|
||||
each component being an unsigned 32-bit value. Whole seconds are in
|
||||
tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
|
||||
and the additional fractional part in tv_nsec as nanoseconds. Hence,
|
||||
for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part
|
||||
may have an arbitrary offset at start.
|
||||
|
||||
After receiving this event, the client should destroy the object.
|
||||
</description>
|
||||
<arg name="tv_sec_hi" type="uint"
|
||||
summary="high 32 bits of the seconds part of the timestamp"/>
|
||||
<arg name="tv_sec_lo" type="uint"
|
||||
summary="low 32 bits of the seconds part of the timestamp"/>
|
||||
<arg name="tv_nsec" type="uint"
|
||||
summary="nanoseconds part of the timestamp"/>
|
||||
</event>
|
||||
|
||||
<event name="failed">
|
||||
<description summary="frame copy failed">
|
||||
This event indicates that the attempted frame copy has failed.
|
||||
|
||||
After receiving this event, the client should destroy the object.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="delete this object, used or not">
|
||||
Destroys the frame. This request can be sent at any time by the client.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="linux_dmabuf">
|
||||
<description summary="linux-dmabuf buffer information">
|
||||
Provides information about linux-dmabuf buffer parameters that need to
|
||||
be used for this frame. This event is sent once after the frame is
|
||||
created if linux-dmabuf buffers are supported.
|
||||
</description>
|
||||
<arg name="format" type="uint" summary="fourcc pixel format"/>
|
||||
<arg name="width" type="uint" summary="buffer width"/>
|
||||
<arg name="height" type="uint" summary="buffer height"/>
|
||||
</event>
|
||||
|
||||
<event name="buffer_done">
|
||||
<description summary="all buffer types reported">
|
||||
This event is sent once after all buffer events have been sent.
|
||||
|
||||
The client should proceed to create a buffer of one of the supported
|
||||
types, and send a "copy" request.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
#include "hyprland_screencopy.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qobject.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
#include <wayland-hyprland-toplevel-export-v1-client-protocol.h>
|
||||
|
||||
#include "../../toplevel_management/handle.hpp"
|
||||
#include "../manager.hpp"
|
||||
#include "hyprland_screencopy_p.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::hyprland {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logScreencopy, "quickshell.wayland.screencopy.hyprland", QtWarningMsg);
|
||||
}
|
||||
|
||||
HyprlandScreencopyManager::HyprlandScreencopyManager(): QWaylandClientExtensionTemplate(2) {
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
HyprlandScreencopyManager* HyprlandScreencopyManager::instance() {
|
||||
static auto* instance = new HyprlandScreencopyManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
ScreencopyContext* HyprlandScreencopyManager::captureToplevel(
|
||||
toplevel_management::impl::ToplevelHandle* handle,
|
||||
bool paintCursors
|
||||
) {
|
||||
return new HyprlandScreencopyContext(this, handle, paintCursors);
|
||||
}
|
||||
|
||||
HyprlandScreencopyContext::HyprlandScreencopyContext(
|
||||
HyprlandScreencopyManager* manager,
|
||||
toplevel_management::impl::ToplevelHandle* handle,
|
||||
bool paintCursors
|
||||
)
|
||||
: manager(manager)
|
||||
, handle(handle)
|
||||
, paintCursors(paintCursors) {
|
||||
QObject::connect(
|
||||
handle,
|
||||
&QObject::destroyed,
|
||||
this,
|
||||
&HyprlandScreencopyContext::onToplevelDestroyed
|
||||
);
|
||||
}
|
||||
|
||||
HyprlandScreencopyContext::~HyprlandScreencopyContext() {
|
||||
if (this->object()) this->destroy();
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::onToplevelDestroyed() {
|
||||
qCWarning(logScreencopy) << "Toplevel destroyed while recording. Stopping" << this;
|
||||
if (this->object()) this->destroy();
|
||||
emit this->stopped();
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::captureFrame() {
|
||||
if (this->object()) return;
|
||||
|
||||
this->init(this->manager->capture_toplevel_with_wlr_toplevel_handle(
|
||||
this->paintCursors ? 1 : 0,
|
||||
this->handle->object()
|
||||
));
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer(
|
||||
uint32_t format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t /*stride*/
|
||||
) {
|
||||
// While different sizes can technically be requested, that would be insane.
|
||||
this->request.width = width;
|
||||
this->request.height = height;
|
||||
this->request.shm.formats.push(format);
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_linux_dmabuf(
|
||||
uint32_t format,
|
||||
uint32_t width,
|
||||
uint32_t height
|
||||
) {
|
||||
// While different sizes can technically be requested, that would be insane.
|
||||
this->request.width = width;
|
||||
this->request.height = height;
|
||||
this->request.dmabuf.formats.push(format);
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_flags(uint32_t flags) {
|
||||
if (flags & HYPRLAND_TOPLEVEL_EXPORT_FRAME_V1_FLAGS_Y_INVERT) {
|
||||
this->mSwapchain.backbuffer()->transform = buffer::WlBufferTransform::Flipped180;
|
||||
}
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_buffer_done() {
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
|
||||
this->copy(backbuffer->buffer(), this->copiedFirstFrame ? 0 : 1);
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_ready(
|
||||
uint32_t /*tvSecHi*/,
|
||||
uint32_t /*tvSecLo*/,
|
||||
uint32_t /*tvNsec*/
|
||||
) {
|
||||
this->destroy();
|
||||
this->copiedFirstFrame = true;
|
||||
this->mSwapchain.swapBuffers();
|
||||
emit this->frameCaptured();
|
||||
}
|
||||
|
||||
void HyprlandScreencopyContext::hyprland_toplevel_export_frame_v1_failed() {
|
||||
qCWarning(logScreencopy) << "Ending recording due to screencopy failure for" << this;
|
||||
emit this->stopped();
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy::hyprland
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include <qwayland-hyprland-toplevel-export-v1.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
|
||||
#include "../../toplevel_management/handle.hpp"
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::hyprland {
|
||||
|
||||
class HyprlandScreencopyManager
|
||||
: public QWaylandClientExtensionTemplate<HyprlandScreencopyManager>
|
||||
, public QtWayland::hyprland_toplevel_export_manager_v1 {
|
||||
public:
|
||||
ScreencopyContext*
|
||||
captureToplevel(toplevel_management::impl::ToplevelHandle* handle, bool paintCursors);
|
||||
|
||||
static HyprlandScreencopyManager* instance();
|
||||
|
||||
private:
|
||||
explicit HyprlandScreencopyManager();
|
||||
|
||||
friend class HyprlandScreencopyContext;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::hyprland
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <qwayland-hyprland-toplevel-export-v1.h>
|
||||
|
||||
#include "../../toplevel_management/handle.hpp"
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::hyprland {
|
||||
|
||||
class HyprlandScreencopyManager;
|
||||
|
||||
class HyprlandScreencopyContext
|
||||
: public ScreencopyContext
|
||||
, public QtWayland::hyprland_toplevel_export_frame_v1 {
|
||||
public:
|
||||
explicit HyprlandScreencopyContext(
|
||||
HyprlandScreencopyManager* manager,
|
||||
toplevel_management::impl::ToplevelHandle* handle,
|
||||
bool paintCursors
|
||||
);
|
||||
|
||||
~HyprlandScreencopyContext() override;
|
||||
Q_DISABLE_COPY_MOVE(HyprlandScreencopyContext);
|
||||
|
||||
void captureFrame() override;
|
||||
|
||||
protected:
|
||||
// clang-format off
|
||||
void hyprland_toplevel_export_frame_v1_buffer(uint32_t format, uint32_t width, uint32_t height, uint32_t stride) override;
|
||||
void hyprland_toplevel_export_frame_v1_linux_dmabuf(uint32_t format, uint32_t width, uint32_t height) override;
|
||||
void hyprland_toplevel_export_frame_v1_flags(uint32_t flags) override;
|
||||
void hyprland_toplevel_export_frame_v1_buffer_done() override;
|
||||
void hyprland_toplevel_export_frame_v1_ready(uint32_t tvSecHi, uint32_t tvSecLo, uint32_t tvNsec) override;
|
||||
void hyprland_toplevel_export_frame_v1_failed() override;
|
||||
// clang-format on
|
||||
|
||||
private slots:
|
||||
void onToplevelDestroyed();
|
||||
|
||||
private:
|
||||
HyprlandScreencopyManager* manager;
|
||||
buffer::WlBufferRequest request;
|
||||
bool copiedFirstFrame = false;
|
||||
|
||||
toplevel_management::impl::ToplevelHandle* handle;
|
||||
bool paintCursors;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::hyprland
|
||||
19
src/wayland/screencopy/image_copy_capture/CMakeLists.txt
Normal file
19
src/wayland/screencopy/image_copy_capture/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
qt_add_library(quickshell-wayland-screencopy-icc STATIC
|
||||
image_copy_capture.cpp
|
||||
)
|
||||
|
||||
wl_proto(wlp-ext-foreign-toplevel ext-foreign-toplevel-list-v1 "${WAYLAND_PROTOCOLS}/staging/ext-foreign-toplevel-list")
|
||||
wl_proto(wlp-image-copy-capture ext-image-copy-capture-v1 "${WAYLAND_PROTOCOLS}/staging/ext-image-copy-capture")
|
||||
wl_proto(wlp-image-capture-source ext-image-capture-source-v1 "${WAYLAND_PROTOCOLS}/staging/ext-image-capture-source")
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-icc PRIVATE
|
||||
Qt::WaylandClient Qt::WaylandClientPrivate wayland-client
|
||||
Qt::Quick # for pch
|
||||
)
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-icc PUBLIC
|
||||
wlp-image-copy-capture wlp-image-capture-source
|
||||
wlp-ext-foreign-toplevel # required for capture source to build
|
||||
)
|
||||
|
||||
qs_pch(quickshell-wayland-screencopy-icc SET large)
|
||||
225
src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp
Normal file
225
src/wayland/screencopy/image_copy_capture/image_copy_capture.cpp
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
#include "image_copy_capture.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
#include <private/qwaylandscreen_p.h>
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qrect.h>
|
||||
#include <qscreen.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qwayland-ext-image-copy-capture-v1.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
#include <sys/types.h>
|
||||
#include <wayland-ext-image-copy-capture-v1-client-protocol.h>
|
||||
#include <wayland-util.h>
|
||||
|
||||
#include "../manager.hpp"
|
||||
#include "image_copy_capture_p.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::icc {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logIcc, "quickshell.wayland.screencopy.icc", QtWarningMsg);
|
||||
}
|
||||
|
||||
using IccCaptureSession = QtWayland::ext_image_copy_capture_session_v1;
|
||||
using IccCaptureFrame = QtWayland::ext_image_copy_capture_frame_v1;
|
||||
|
||||
IccScreencopyContext::IccScreencopyContext(::ext_image_copy_capture_session_v1* session)
|
||||
: IccCaptureSession(session) {}
|
||||
|
||||
IccScreencopyContext::~IccScreencopyContext() {
|
||||
if (this->IccCaptureSession::object()) {
|
||||
this->IccCaptureSession::destroy();
|
||||
}
|
||||
|
||||
if (this->IccCaptureFrame::object()) {
|
||||
this->IccCaptureFrame::destroy();
|
||||
}
|
||||
}
|
||||
|
||||
void IccScreencopyContext::captureFrame() {
|
||||
if (this->IccCaptureFrame::object() || this->capturePending) return;
|
||||
|
||||
if (this->statePending) this->capturePending = true;
|
||||
else this->doCapture();
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_buffer_size(
|
||||
uint32_t width,
|
||||
uint32_t height
|
||||
) {
|
||||
this->clearOldState();
|
||||
|
||||
this->request.width = width;
|
||||
this->request.height = height;
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_shm_format(uint32_t format) {
|
||||
this->clearOldState();
|
||||
|
||||
this->request.shm.formats.push(format);
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_dmabuf_device(wl_array* device) {
|
||||
this->clearOldState();
|
||||
|
||||
if (device->size != sizeof(dev_t)) {
|
||||
qCFatal(logIcc) << "The size of dev_t used by the compositor and quickshell is mismatched. Try "
|
||||
"recompiling both.";
|
||||
}
|
||||
|
||||
this->request.dmabuf.device = *reinterpret_cast<dev_t*>(device->data);
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_dmabuf_format(
|
||||
uint32_t format,
|
||||
wl_array* modifiers
|
||||
) {
|
||||
this->clearOldState();
|
||||
|
||||
auto* modifierArray = reinterpret_cast<uint64_t*>(modifiers->data);
|
||||
auto modifierCount = modifiers->size / sizeof(uint64_t);
|
||||
|
||||
auto reqFormat = buffer::WlBufferRequest::DmaFormat(format);
|
||||
|
||||
for (uint16_t i = 0; i != modifierCount; i++) {
|
||||
reqFormat.modifiers.push(modifierArray[i]); // NOLINT
|
||||
}
|
||||
|
||||
this->request.dmabuf.formats.push(reqFormat);
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_done() {
|
||||
this->statePending = false;
|
||||
|
||||
if (this->capturePending) {
|
||||
this->doCapture();
|
||||
}
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_session_v1_stopped() {
|
||||
qCInfo(logIcc) << "Ending recording due to screencopy stop for" << this;
|
||||
emit this->stopped();
|
||||
}
|
||||
|
||||
void IccScreencopyContext::clearOldState() {
|
||||
if (!this->statePending) {
|
||||
this->request = buffer::WlBufferRequest();
|
||||
this->statePending = true;
|
||||
}
|
||||
}
|
||||
|
||||
void IccScreencopyContext::doCapture() {
|
||||
this->capturePending = false;
|
||||
|
||||
auto newBuffer = false;
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request, &newBuffer);
|
||||
|
||||
this->IccCaptureFrame::init(this->IccCaptureSession::create_frame());
|
||||
this->IccCaptureFrame::attach_buffer(backbuffer->buffer());
|
||||
|
||||
if (newBuffer) {
|
||||
// If the buffer was replaced, it will be blank and the compositor needs
|
||||
// to repaint the whole thing.
|
||||
this->IccCaptureFrame::damage_buffer(
|
||||
0,
|
||||
0,
|
||||
static_cast<int>(this->request.width),
|
||||
static_cast<int>(this->request.height)
|
||||
);
|
||||
|
||||
// We don't care about partial damage if the whole buffer was replaced.
|
||||
this->lastDamage = QRect();
|
||||
} else if (!this->lastDamage.isEmpty()) {
|
||||
// If buffers were swapped between the last frame and the current one, request a repaint
|
||||
// of the backbuffer in the same places that changes to the frontbuffer were recorded.
|
||||
this->IccCaptureFrame::damage_buffer(
|
||||
this->lastDamage.x(),
|
||||
this->lastDamage.y(),
|
||||
this->lastDamage.width(),
|
||||
this->lastDamage.height()
|
||||
);
|
||||
|
||||
// We don't need to do this more than once per buffer swap.
|
||||
this->lastDamage = QRect();
|
||||
}
|
||||
|
||||
this->IccCaptureFrame::capture();
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_frame_v1_transform(uint32_t transform) {
|
||||
this->mSwapchain.backbuffer()->transform = transform;
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_frame_v1_damage(
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
int32_t width,
|
||||
int32_t height
|
||||
) {
|
||||
this->damage = this->damage.united(QRect(x, y, width, height));
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_frame_v1_ready() {
|
||||
this->IccCaptureFrame::destroy();
|
||||
|
||||
this->mSwapchain.swapBuffers();
|
||||
this->lastDamage = this->damage;
|
||||
this->damage = QRect();
|
||||
|
||||
emit this->frameCaptured();
|
||||
}
|
||||
|
||||
void IccScreencopyContext::ext_image_copy_capture_frame_v1_failed(uint32_t reason) {
|
||||
switch (static_cast<IccCaptureFrame::failure_reason>(reason)) {
|
||||
case IccCaptureFrame::failure_reason_buffer_constraints:
|
||||
qFatal(logIcc) << "Got a buffer_constraints failure, however the buffer matches the last sent "
|
||||
"size. There is a bug in quickshell or your compositor.";
|
||||
break;
|
||||
case IccCaptureFrame::failure_reason_stopped:
|
||||
// Handled in the ExtCaptureSession handler.
|
||||
break;
|
||||
case IccCaptureFrame::failure_reason_unknown:
|
||||
qCWarning(logIcc) << "Ending recording due to screencopy failure for" << this;
|
||||
emit this->stopped();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IccManager::IccManager(): QWaylandClientExtensionTemplate(1) { this->initialize(); }
|
||||
|
||||
IccManager* IccManager::instance() {
|
||||
static auto* instance = new IccManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
ScreencopyContext*
|
||||
IccManager::createSession(::ext_image_capture_source_v1* source, bool paintCursors) {
|
||||
auto* session = this->create_session(
|
||||
source,
|
||||
paintCursors ? QtWayland::ext_image_copy_capture_manager_v1::options_paint_cursors : 0
|
||||
);
|
||||
return new IccScreencopyContext(session);
|
||||
}
|
||||
|
||||
IccOutputSourceManager::IccOutputSourceManager(): QWaylandClientExtensionTemplate(1) {
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
IccOutputSourceManager* IccOutputSourceManager::instance() {
|
||||
static auto* instance = new IccOutputSourceManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
ScreencopyContext* IccOutputSourceManager::captureOutput(QScreen* screen, bool paintCursors) {
|
||||
auto* waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen*>(screen->handle());
|
||||
if (!waylandScreen) return nullptr;
|
||||
|
||||
return IccManager::instance()->createSession(
|
||||
this->create_source(waylandScreen->output()),
|
||||
paintCursors
|
||||
);
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy::icc
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include <qscreen.h>
|
||||
#include <qwayland-ext-image-capture-source-v1.h>
|
||||
#include <qwayland-ext-image-copy-capture-v1.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::icc {
|
||||
|
||||
class IccManager
|
||||
: public QWaylandClientExtensionTemplate<IccManager>
|
||||
, public QtWayland::ext_image_copy_capture_manager_v1 {
|
||||
public:
|
||||
ScreencopyContext* createSession(::ext_image_capture_source_v1* source, bool paintCursors);
|
||||
|
||||
static IccManager* instance();
|
||||
|
||||
private:
|
||||
explicit IccManager();
|
||||
};
|
||||
|
||||
class IccOutputSourceManager
|
||||
: public QWaylandClientExtensionTemplate<IccOutputSourceManager>
|
||||
, public QtWayland::ext_output_image_capture_source_manager_v1 {
|
||||
public:
|
||||
ScreencopyContext* captureOutput(QScreen* screen, bool paintCursors);
|
||||
|
||||
static IccOutputSourceManager* instance();
|
||||
|
||||
private:
|
||||
explicit IccOutputSourceManager();
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::icc
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <qrect.h>
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <qwayland-ext-image-copy-capture-v1.h>
|
||||
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::icc {
|
||||
|
||||
class IccScreencopyContext
|
||||
: public ScreencopyContext
|
||||
, public QtWayland::ext_image_copy_capture_session_v1
|
||||
, public QtWayland::ext_image_copy_capture_frame_v1 {
|
||||
|
||||
public:
|
||||
IccScreencopyContext(::ext_image_copy_capture_session_v1* session);
|
||||
~IccScreencopyContext() override;
|
||||
Q_DISABLE_COPY_MOVE(IccScreencopyContext);
|
||||
|
||||
void captureFrame() override;
|
||||
|
||||
protected:
|
||||
// clang-formt off
|
||||
void ext_image_copy_capture_session_v1_buffer_size(uint32_t width, uint32_t height) override;
|
||||
void ext_image_copy_capture_session_v1_shm_format(uint32_t format) override;
|
||||
void ext_image_copy_capture_session_v1_dmabuf_device(wl_array* device) override;
|
||||
void
|
||||
ext_image_copy_capture_session_v1_dmabuf_format(uint32_t format, wl_array* modifiers) override;
|
||||
void ext_image_copy_capture_session_v1_done() override;
|
||||
void ext_image_copy_capture_session_v1_stopped() override;
|
||||
|
||||
void ext_image_copy_capture_frame_v1_transform(uint32_t transform) override;
|
||||
void ext_image_copy_capture_frame_v1_damage(int32_t x, int32_t y, int32_t width, int32_t height)
|
||||
override;
|
||||
void ext_image_copy_capture_frame_v1_ready() override;
|
||||
void ext_image_copy_capture_frame_v1_failed(uint32_t reason) override;
|
||||
// clang-formt on
|
||||
|
||||
private:
|
||||
void clearOldState();
|
||||
void doCapture();
|
||||
|
||||
buffer::WlBufferRequest request;
|
||||
bool statePending = true;
|
||||
bool capturePending = false;
|
||||
QRect damage;
|
||||
QRect lastDamage;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::icc
|
||||
56
src/wayland/screencopy/manager.cpp
Normal file
56
src/wayland/screencopy/manager.cpp
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
#include "manager.hpp"
|
||||
|
||||
#include <qobject.h>
|
||||
|
||||
#include "build.hpp"
|
||||
|
||||
#if SCREENCOPY_ICC || SCREENCOPY_WLR
|
||||
#include "../../core/qmlscreen.hpp"
|
||||
#endif
|
||||
|
||||
#if SCREENCOPY_ICC
|
||||
#include "image_copy_capture/image_copy_capture.hpp"
|
||||
#endif
|
||||
|
||||
#if SCREENCOPY_WLR
|
||||
#include "wlr_screencopy/wlr_screencopy.hpp"
|
||||
#endif
|
||||
|
||||
#if SCREENCOPY_HYPRLAND_TOPLEVEL
|
||||
#include "../toplevel_management/qml.hpp"
|
||||
#include "hyprland_screencopy/hyprland_screencopy.hpp"
|
||||
#endif
|
||||
|
||||
namespace qs::wayland::screencopy {
|
||||
|
||||
ScreencopyContext* ScreencopyManager::createContext(QObject* object, bool paintCursors) {
|
||||
if (auto* screen = qobject_cast<QuickshellScreenInfo*>(object)) {
|
||||
#if SCREENCOPY_ICC
|
||||
{
|
||||
auto* manager = icc::IccOutputSourceManager::instance();
|
||||
if (manager->isActive()) {
|
||||
return manager->captureOutput(screen->screen, paintCursors);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if SCREENCOPY_WLR
|
||||
{
|
||||
auto* manager = wlr::WlrScreencopyManager::instance();
|
||||
if (manager->isActive()) {
|
||||
return manager->captureOutput(screen->screen, paintCursors);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if SCREENCOPY_HYPRLAND_TOPLEVEL
|
||||
} else if (auto* toplevel = qobject_cast<toplevel_management::Toplevel*>(object)) {
|
||||
auto* manager = hyprland::HyprlandScreencopyManager::instance();
|
||||
if (manager->isActive()) {
|
||||
return manager->captureToplevel(toplevel->implHandle(), paintCursors);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy
|
||||
33
src/wayland/screencopy/manager.hpp
Normal file
33
src/wayland/screencopy/manager.hpp
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#pragma once
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "../buffer/manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy {
|
||||
|
||||
class ScreencopyContext: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
[[nodiscard]] buffer::WlBufferSwapchain& swapchain() { return this->mSwapchain; }
|
||||
virtual void captureFrame() = 0;
|
||||
|
||||
signals:
|
||||
void frameCaptured();
|
||||
void stopped();
|
||||
|
||||
protected:
|
||||
ScreencopyContext() = default;
|
||||
|
||||
buffer::WlBufferSwapchain mSwapchain;
|
||||
};
|
||||
|
||||
class ScreencopyManager {
|
||||
public:
|
||||
static ScreencopyContext* createContext(QObject* object, bool paintCursors);
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy
|
||||
149
src/wayland/screencopy/view.cpp
Normal file
149
src/wayland/screencopy/view.cpp
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
#include "view.hpp"
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qqmlinfo.h>
|
||||
#include <qquickitem.h>
|
||||
#include <qsize.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "../buffer/manager.hpp"
|
||||
#include "../buffer/qsg.hpp"
|
||||
#include "manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy {
|
||||
|
||||
void ScreencopyView::setCaptureSource(QObject* captureSource) {
|
||||
if (captureSource == this->mCaptureSource) return;
|
||||
auto hadContext = this->context != nullptr;
|
||||
this->destroyContext(false);
|
||||
|
||||
this->mCaptureSource = captureSource;
|
||||
|
||||
if (captureSource) {
|
||||
QObject::connect(
|
||||
captureSource,
|
||||
&QObject::destroyed,
|
||||
this,
|
||||
&ScreencopyView::onCaptureSourceDestroyed
|
||||
);
|
||||
|
||||
if (this->completed) this->createContext();
|
||||
}
|
||||
|
||||
if (!this->context && hadContext) this->update();
|
||||
emit this->captureSourceChanged();
|
||||
}
|
||||
|
||||
void ScreencopyView::onCaptureSourceDestroyed() {
|
||||
this->mCaptureSource = nullptr;
|
||||
this->destroyContext();
|
||||
}
|
||||
|
||||
void ScreencopyView::setPaintCursors(bool paintCursors) {
|
||||
if (paintCursors == this->mPaintCursors) return;
|
||||
this->mPaintCursors = paintCursors;
|
||||
if (this->completed && this->context) this->createContext();
|
||||
emit this->paintCursorsChanged();
|
||||
}
|
||||
|
||||
void ScreencopyView::setLive(bool live) {
|
||||
if (live == this->mLive) return;
|
||||
|
||||
if (live && !this->mLive && this->context) {
|
||||
this->context->captureFrame();
|
||||
}
|
||||
|
||||
this->mLive = live;
|
||||
emit this->liveChanged();
|
||||
}
|
||||
|
||||
void ScreencopyView::createContext() {
|
||||
this->destroyContext(false);
|
||||
this->context = ScreencopyManager::createContext(this->mCaptureSource, this->mPaintCursors);
|
||||
|
||||
if (!this->context) {
|
||||
qmlWarning(this) << "Capture source set to non captureable object.";
|
||||
return;
|
||||
}
|
||||
|
||||
QObject::connect(
|
||||
this->context,
|
||||
&ScreencopyContext::stopped,
|
||||
this,
|
||||
&ScreencopyView::destroyContextWithUpdate
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this->context,
|
||||
&ScreencopyContext::frameCaptured,
|
||||
this,
|
||||
&ScreencopyView::onFrameCaptured
|
||||
);
|
||||
|
||||
this->context->captureFrame();
|
||||
}
|
||||
|
||||
void ScreencopyView::destroyContext(bool update) {
|
||||
auto hadContext = this->context != nullptr;
|
||||
delete this->context;
|
||||
this->context = nullptr;
|
||||
this->bHasContent = false;
|
||||
this->bSourceSize = QSize();
|
||||
if (hadContext && update) this->update();
|
||||
}
|
||||
|
||||
void ScreencopyView::captureFrame() {
|
||||
if (this->context) this->context->captureFrame();
|
||||
else qmlWarning(this) << "Cannot capture frame, as no recording context is ready.";
|
||||
}
|
||||
|
||||
void ScreencopyView::onFrameCaptured() {
|
||||
this->setFlag(QQuickItem::ItemHasContents);
|
||||
this->update();
|
||||
this->bHasContent = true;
|
||||
this->bSourceSize = this->context->swapchain().frontbuffer()->size();
|
||||
}
|
||||
|
||||
void ScreencopyView::componentComplete() {
|
||||
this->QQuickItem::componentComplete();
|
||||
|
||||
auto* bufManager = buffer::WlBufferManager::instance();
|
||||
if (!bufManager->isReady()) {
|
||||
QObject::connect(
|
||||
bufManager,
|
||||
&buffer::WlBufferManager::ready,
|
||||
this,
|
||||
&ScreencopyView::onBuffersReady
|
||||
);
|
||||
} else {
|
||||
this->onBuffersReady();
|
||||
}
|
||||
}
|
||||
|
||||
void ScreencopyView::onBuffersReady() {
|
||||
this->completed = true;
|
||||
if (this->mCaptureSource) this->createContext();
|
||||
}
|
||||
|
||||
QSGNode* ScreencopyView::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* /*unused*/) {
|
||||
if (!this->context || !this->bHasContent) {
|
||||
delete oldNode;
|
||||
this->setFlag(QQuickItem::ItemHasContents, false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto* node = static_cast<buffer::WlBufferQSGDisplayNode*>(oldNode); // NOLINT
|
||||
|
||||
if (!node) {
|
||||
node = new buffer::WlBufferQSGDisplayNode(this->window());
|
||||
}
|
||||
|
||||
auto& swapchain = this->context->swapchain();
|
||||
node->syncSwapchain(swapchain);
|
||||
node->setRect(this->boundingRect());
|
||||
|
||||
if (this->mLive) this->context->captureFrame();
|
||||
return node;
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy
|
||||
96
src/wayland/screencopy/view.hpp
Normal file
96
src/wayland/screencopy/view.hpp
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
#pragma once
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qproperty.h>
|
||||
#include <qqmlintegration.h>
|
||||
#include <qquickitem.h>
|
||||
#include <qsgnode.h>
|
||||
#include <qtmetamacros.h>
|
||||
|
||||
#include "manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy {
|
||||
|
||||
///! Displays a video stream from other windows or a monitor.
|
||||
/// ScreencopyView displays live video streams or single captured frames from valid
|
||||
/// capture sources. See @@captureSource for details on which objects are accepted.
|
||||
class ScreencopyView: public QQuickItem {
|
||||
Q_OBJECT;
|
||||
QML_ELEMENT;
|
||||
// clang-format off
|
||||
/// The object to capture from. Accepts any of the following:
|
||||
/// - `null` - Clears the displayed image.
|
||||
/// - @@Quickshell.ShellScreen - A monitor.
|
||||
/// Requires a compositor that supports `wlr-screencopy-unstable`
|
||||
/// or both `ext-image-copy-capture-v1` and `ext-capture-source-v1`.
|
||||
/// - @@Quickshell.Wayland.Toplevel - A toplevel window.
|
||||
/// Requires a compositor that supports `hyprland-toplevel-export-v1`.
|
||||
Q_PROPERTY(QObject* captureSource READ captureSource WRITE setCaptureSource NOTIFY captureSourceChanged);
|
||||
/// If true, the system cursor will be painted on the image. Defaults to false.
|
||||
Q_PROPERTY(bool paintCursor READ paintCursors WRITE setPaintCursors NOTIFY paintCursorsChanged);
|
||||
/// If true, a live video feed from the capture source will be displayed instead of a still image.
|
||||
/// Defaults to false.
|
||||
Q_PROPERTY(bool live READ live WRITE setLive NOTIFY liveChanged);
|
||||
/// If true, the view has content ready to display. Content is not always immediately available,
|
||||
/// and this property can be used to avoid displaying it until ready.
|
||||
Q_PROPERTY(bool hasContent READ default NOTIFY hasContentChanged BINDABLE bindableHasContent);
|
||||
/// The size of the source image. Valid when @@hasContent is true.
|
||||
Q_PROPERTY(QSize sourceSize READ default NOTIFY sourceSizeChanged BINDABLE bindableSourceSize);
|
||||
// clang-format on
|
||||
|
||||
public:
|
||||
explicit ScreencopyView(QQuickItem* parent = nullptr): QQuickItem(parent) {}
|
||||
|
||||
void componentComplete() override;
|
||||
|
||||
/// Capture a single frame. Has no effect if @@live is true.
|
||||
Q_INVOKABLE void captureFrame();
|
||||
|
||||
[[nodiscard]] QObject* captureSource() const { return this->mCaptureSource; }
|
||||
void setCaptureSource(QObject* captureSource);
|
||||
|
||||
[[nodiscard]] bool paintCursors() const { return this->mPaintCursors; }
|
||||
void setPaintCursors(bool paintCursors);
|
||||
|
||||
[[nodiscard]] bool live() const { return this->mLive; }
|
||||
void setLive(bool live);
|
||||
|
||||
[[nodiscard]] QBindable<bool> bindableHasContent() { return &this->bHasContent; }
|
||||
[[nodiscard]] QBindable<QSize> bindableSourceSize() { return &this->bSourceSize; }
|
||||
|
||||
signals:
|
||||
/// The compositor has ended the video stream. Attempting to restart it may or may not work.
|
||||
void stopped();
|
||||
|
||||
void captureSourceChanged();
|
||||
void paintCursorsChanged();
|
||||
void liveChanged();
|
||||
void hasContentChanged();
|
||||
void sourceSizeChanged();
|
||||
|
||||
protected:
|
||||
QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData* data) override;
|
||||
|
||||
private slots:
|
||||
void onCaptureSourceDestroyed();
|
||||
void onFrameCaptured();
|
||||
void destroyContextWithUpdate() { this->destroyContext(); }
|
||||
void onBuffersReady();
|
||||
|
||||
private:
|
||||
void destroyContext(bool update = true);
|
||||
void createContext();
|
||||
|
||||
// clang-format off
|
||||
Q_OBJECT_BINDABLE_PROPERTY(ScreencopyView, bool, bHasContent, &ScreencopyView::hasContentChanged);
|
||||
Q_OBJECT_BINDABLE_PROPERTY(ScreencopyView, QSize, bSourceSize, &ScreencopyView::sourceSizeChanged);
|
||||
// clang-format on
|
||||
|
||||
QObject* mCaptureSource = nullptr;
|
||||
bool mPaintCursors = false;
|
||||
bool mLive = false;
|
||||
ScreencopyContext* context = nullptr;
|
||||
bool completed = false;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy
|
||||
14
src/wayland/screencopy/wlr_screencopy/CMakeLists.txt
Normal file
14
src/wayland/screencopy/wlr_screencopy/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
qt_add_library(quickshell-wayland-screencopy-wlr STATIC
|
||||
wlr_screencopy.cpp
|
||||
)
|
||||
|
||||
wl_proto(wlp-wlr-screencopy wlr-screencopy-unstable-v1 "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-wlr PRIVATE
|
||||
Qt::WaylandClient Qt::WaylandClientPrivate wayland-client
|
||||
Qt::Quick # for pch
|
||||
)
|
||||
|
||||
target_link_libraries(quickshell-wayland-screencopy-wlr PUBLIC wlp-wlr-screencopy)
|
||||
|
||||
qs_pch(quickshell-wayland-screencopy-wlr SET large)
|
||||
|
|
@ -0,0 +1,232 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="wlr_screencopy_unstable_v1">
|
||||
<copyright>
|
||||
Copyright © 2018 Simon Ser
|
||||
Copyright © 2019 Andri Yngvason
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice (including the next
|
||||
paragraph) shall be included in all copies or substantial portions of the
|
||||
Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
DEALINGS IN THE SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<description summary="screen content capturing on client buffers">
|
||||
This protocol allows clients to ask the compositor to copy part of the
|
||||
screen content to a client buffer.
|
||||
|
||||
Warning! The protocol described in this file is experimental and
|
||||
backward incompatible changes may be made. Backward compatible changes
|
||||
may be added together with the corresponding interface version bump.
|
||||
Backward incompatible changes are done by bumping the version number in
|
||||
the protocol and interface names and resetting the interface version.
|
||||
Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
version number in the protocol and interface names are removed and the
|
||||
interface version number is reset.
|
||||
</description>
|
||||
|
||||
<interface name="zwlr_screencopy_manager_v1" version="3">
|
||||
<description summary="manager to inform clients and begin capturing">
|
||||
This object is a manager which offers requests to start capturing from a
|
||||
source.
|
||||
</description>
|
||||
|
||||
<request name="capture_output">
|
||||
<description summary="capture an output">
|
||||
Capture the next frame of an entire output.
|
||||
</description>
|
||||
<arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/>
|
||||
<arg name="overlay_cursor" type="int"
|
||||
summary="composite cursor onto the frame"/>
|
||||
<arg name="output" type="object" interface="wl_output"/>
|
||||
</request>
|
||||
|
||||
<request name="capture_output_region">
|
||||
<description summary="capture an output's region">
|
||||
Capture the next frame of an output's region.
|
||||
|
||||
The region is given in output logical coordinates, see
|
||||
xdg_output.logical_size. The region will be clipped to the output's
|
||||
extents.
|
||||
</description>
|
||||
<arg name="frame" type="new_id" interface="zwlr_screencopy_frame_v1"/>
|
||||
<arg name="overlay_cursor" type="int"
|
||||
summary="composite cursor onto the frame"/>
|
||||
<arg name="output" type="object" interface="wl_output"/>
|
||||
<arg name="x" type="int"/>
|
||||
<arg name="y" type="int"/>
|
||||
<arg name="width" type="int"/>
|
||||
<arg name="height" type="int"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the manager">
|
||||
All objects created by the manager will still remain valid, until their
|
||||
appropriate destroy request has been called.
|
||||
</description>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_screencopy_frame_v1" version="3">
|
||||
<description summary="a frame ready for copy">
|
||||
This object represents a single frame.
|
||||
|
||||
When created, a series of buffer events will be sent, each representing a
|
||||
supported buffer type. The "buffer_done" event is sent afterwards to
|
||||
indicate that all supported buffer types have been enumerated. The client
|
||||
will then be able to send a "copy" request. If the capture is successful,
|
||||
the compositor will send a "flags" followed by a "ready" event.
|
||||
|
||||
For objects version 2 or lower, wl_shm buffers are always supported, ie.
|
||||
the "buffer" event is guaranteed to be sent.
|
||||
|
||||
If the capture failed, the "failed" event is sent. This can happen anytime
|
||||
before the "ready" event.
|
||||
|
||||
Once either a "ready" or a "failed" event is received, the client should
|
||||
destroy the frame.
|
||||
</description>
|
||||
|
||||
<event name="buffer">
|
||||
<description summary="wl_shm buffer information">
|
||||
Provides information about wl_shm buffer parameters that need to be
|
||||
used for this frame. This event is sent once after the frame is created
|
||||
if wl_shm buffers are supported.
|
||||
</description>
|
||||
<arg name="format" type="uint" enum="wl_shm.format" summary="buffer format"/>
|
||||
<arg name="width" type="uint" summary="buffer width"/>
|
||||
<arg name="height" type="uint" summary="buffer height"/>
|
||||
<arg name="stride" type="uint" summary="buffer stride"/>
|
||||
</event>
|
||||
|
||||
<request name="copy">
|
||||
<description summary="copy the frame">
|
||||
Copy the frame to the supplied buffer. The buffer must have a the
|
||||
correct size, see zwlr_screencopy_frame_v1.buffer and
|
||||
zwlr_screencopy_frame_v1.linux_dmabuf. The buffer needs to have a
|
||||
supported format.
|
||||
|
||||
If the frame is successfully copied, a "flags" and a "ready" events are
|
||||
sent. Otherwise, a "failed" event is sent.
|
||||
</description>
|
||||
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="already_used" value="0"
|
||||
summary="the object has already been used to copy a wl_buffer"/>
|
||||
<entry name="invalid_buffer" value="1"
|
||||
summary="buffer attributes are invalid"/>
|
||||
</enum>
|
||||
|
||||
<enum name="flags" bitfield="true">
|
||||
<entry name="y_invert" value="1" summary="contents are y-inverted"/>
|
||||
</enum>
|
||||
|
||||
<event name="flags">
|
||||
<description summary="frame flags">
|
||||
Provides flags about the frame. This event is sent once before the
|
||||
"ready" event.
|
||||
</description>
|
||||
<arg name="flags" type="uint" enum="flags" summary="frame flags"/>
|
||||
</event>
|
||||
|
||||
<event name="ready">
|
||||
<description summary="indicates frame is available for reading">
|
||||
Called as soon as the frame is copied, indicating it is available
|
||||
for reading. This event includes the time at which presentation happened
|
||||
at.
|
||||
|
||||
The timestamp is expressed as tv_sec_hi, tv_sec_lo, tv_nsec triples,
|
||||
each component being an unsigned 32-bit value. Whole seconds are in
|
||||
tv_sec which is a 64-bit value combined from tv_sec_hi and tv_sec_lo,
|
||||
and the additional fractional part in tv_nsec as nanoseconds. Hence,
|
||||
for valid timestamps tv_nsec must be in [0, 999999999]. The seconds part
|
||||
may have an arbitrary offset at start.
|
||||
|
||||
After receiving this event, the client should destroy the object.
|
||||
</description>
|
||||
<arg name="tv_sec_hi" type="uint"
|
||||
summary="high 32 bits of the seconds part of the timestamp"/>
|
||||
<arg name="tv_sec_lo" type="uint"
|
||||
summary="low 32 bits of the seconds part of the timestamp"/>
|
||||
<arg name="tv_nsec" type="uint"
|
||||
summary="nanoseconds part of the timestamp"/>
|
||||
</event>
|
||||
|
||||
<event name="failed">
|
||||
<description summary="frame copy failed">
|
||||
This event indicates that the attempted frame copy has failed.
|
||||
|
||||
After receiving this event, the client should destroy the object.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="delete this object, used or not">
|
||||
Destroys the frame. This request can be sent at any time by the client.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
<request name="copy_with_damage" since="2">
|
||||
<description summary="copy the frame when it's damaged">
|
||||
Same as copy, except it waits until there is damage to copy.
|
||||
</description>
|
||||
<arg name="buffer" type="object" interface="wl_buffer"/>
|
||||
</request>
|
||||
|
||||
<event name="damage" since="2">
|
||||
<description summary="carries the coordinates of the damaged region">
|
||||
This event is sent right before the ready event when copy_with_damage is
|
||||
requested. It may be generated multiple times for each copy_with_damage
|
||||
request.
|
||||
|
||||
The arguments describe a box around an area that has changed since the
|
||||
last copy request that was derived from the current screencopy manager
|
||||
instance.
|
||||
|
||||
The union of all regions received between the call to copy_with_damage
|
||||
and a ready event is the total damage since the prior ready event.
|
||||
</description>
|
||||
<arg name="x" type="uint" summary="damaged x coordinates"/>
|
||||
<arg name="y" type="uint" summary="damaged y coordinates"/>
|
||||
<arg name="width" type="uint" summary="current width"/>
|
||||
<arg name="height" type="uint" summary="current height"/>
|
||||
</event>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
<event name="linux_dmabuf" since="3">
|
||||
<description summary="linux-dmabuf buffer information">
|
||||
Provides information about linux-dmabuf buffer parameters that need to
|
||||
be used for this frame. This event is sent once after the frame is
|
||||
created if linux-dmabuf buffers are supported.
|
||||
</description>
|
||||
<arg name="format" type="uint" summary="fourcc pixel format"/>
|
||||
<arg name="width" type="uint" summary="buffer width"/>
|
||||
<arg name="height" type="uint" summary="buffer height"/>
|
||||
</event>
|
||||
|
||||
<event name="buffer_done" since="3">
|
||||
<description summary="all buffer types reported">
|
||||
This event is sent once after all buffer events have been sent.
|
||||
|
||||
The client should proceed to create a buffer of one of the supported
|
||||
types, and send a "copy" request.
|
||||
</description>
|
||||
</event>
|
||||
</interface>
|
||||
</protocol>
|
||||
133
src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp
Normal file
133
src/wayland/screencopy/wlr_screencopy/wlr_screencopy.cpp
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
#include "wlr_screencopy.hpp"
|
||||
#include <cstdint>
|
||||
|
||||
#include <private/qwaylandscreen_p.h>
|
||||
#include <qlogging.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qobject.h>
|
||||
#include <qscreen.h>
|
||||
#include <qtmetamacros.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
#include <wayland-wlr-screencopy-unstable-v1-client-protocol.h>
|
||||
|
||||
#include "../../buffer/manager.hpp"
|
||||
#include "../manager.hpp"
|
||||
#include "wlr_screencopy_p.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::wlr {
|
||||
|
||||
namespace {
|
||||
Q_LOGGING_CATEGORY(logScreencopy, "quickshell.wayland.screencopy.wlr", QtWarningMsg);
|
||||
}
|
||||
|
||||
WlrScreencopyManager::WlrScreencopyManager(): QWaylandClientExtensionTemplate(3) {
|
||||
this->initialize();
|
||||
}
|
||||
|
||||
WlrScreencopyManager* WlrScreencopyManager::instance() {
|
||||
static auto* instance = new WlrScreencopyManager();
|
||||
return instance;
|
||||
}
|
||||
|
||||
ScreencopyContext*
|
||||
WlrScreencopyManager::captureOutput(QScreen* screen, bool paintCursors, QRect region) {
|
||||
if (!dynamic_cast<QtWaylandClient::QWaylandScreen*>(screen->handle())) return nullptr;
|
||||
return new WlrScreencopyContext(this, screen, paintCursors, region);
|
||||
}
|
||||
|
||||
WlrScreencopyContext::WlrScreencopyContext(
|
||||
WlrScreencopyManager* manager,
|
||||
QScreen* screen,
|
||||
bool paintCursors,
|
||||
QRect region
|
||||
)
|
||||
: manager(manager)
|
||||
, screen(dynamic_cast<QtWaylandClient::QWaylandScreen*>(screen->handle()))
|
||||
, paintCursors(paintCursors)
|
||||
, region(region) {
|
||||
QObject::connect(screen, &QObject::destroyed, this, &WlrScreencopyContext::onScreenDestroyed);
|
||||
}
|
||||
|
||||
WlrScreencopyContext::~WlrScreencopyContext() {
|
||||
if (this->object()) this->destroy();
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::onScreenDestroyed() {
|
||||
qCWarning(logScreencopy) << "Screen destroyed while recording. Stopping" << this;
|
||||
if (this->object()) this->destroy();
|
||||
emit this->stopped();
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::captureFrame() {
|
||||
if (this->object()) return;
|
||||
|
||||
if (this->region.isEmpty()) {
|
||||
this->init(manager->capture_output(this->paintCursors ? 1 : 0, screen->output()));
|
||||
} else {
|
||||
this->init(manager->capture_output_region(
|
||||
this->paintCursors ? 1 : 0,
|
||||
screen->output(),
|
||||
this->region.x(),
|
||||
this->region.y(),
|
||||
this->region.width(),
|
||||
this->region.height()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer(
|
||||
uint32_t format,
|
||||
uint32_t width,
|
||||
uint32_t height,
|
||||
uint32_t /*stride*/
|
||||
) {
|
||||
// While different sizes can technically be requested, that would be insane.
|
||||
this->request.width = width;
|
||||
this->request.height = height;
|
||||
this->request.shm.formats.push(format);
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_linux_dmabuf(
|
||||
uint32_t format,
|
||||
uint32_t width,
|
||||
uint32_t height
|
||||
) {
|
||||
// While different sizes can technically be requested, that would be insane.
|
||||
this->request.width = width;
|
||||
this->request.height = height;
|
||||
this->request.dmabuf.formats.push(format);
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_flags(uint32_t flags) {
|
||||
if (flags & ZWLR_SCREENCOPY_FRAME_V1_FLAGS_Y_INVERT) {
|
||||
this->mSwapchain.backbuffer()->transform = buffer::WlBufferTransform::Flipped180;
|
||||
}
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_buffer_done() {
|
||||
auto* backbuffer = this->mSwapchain.createBackbuffer(this->request);
|
||||
|
||||
if (this->copiedFirstFrame) {
|
||||
this->copy_with_damage(backbuffer->buffer());
|
||||
} else {
|
||||
this->copy(backbuffer->buffer());
|
||||
}
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_ready(
|
||||
uint32_t /*tvSecHi*/,
|
||||
uint32_t /*tvSecLo*/,
|
||||
uint32_t /*tvNsec*/
|
||||
) {
|
||||
this->destroy();
|
||||
this->copiedFirstFrame = true;
|
||||
this->mSwapchain.swapBuffers();
|
||||
emit this->frameCaptured();
|
||||
}
|
||||
|
||||
void WlrScreencopyContext::zwlr_screencopy_frame_v1_failed() {
|
||||
qCWarning(logScreencopy) << "Ending recording due to screencopy failure for" << this;
|
||||
emit this->stopped();
|
||||
}
|
||||
|
||||
} // namespace qs::wayland::screencopy::wlr
|
||||
25
src/wayland/screencopy/wlr_screencopy/wlr_screencopy.hpp
Normal file
25
src/wayland/screencopy/wlr_screencopy/wlr_screencopy.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
|
||||
#include <qscreen.h>
|
||||
#include <qwayland-wlr-screencopy-unstable-v1.h>
|
||||
#include <qwaylandclientextension.h>
|
||||
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::wlr {
|
||||
|
||||
class WlrScreencopyManager
|
||||
: public QWaylandClientExtensionTemplate<WlrScreencopyManager>
|
||||
, public QtWayland::zwlr_screencopy_manager_v1 {
|
||||
public:
|
||||
ScreencopyContext* captureOutput(QScreen* screen, bool paintCursors, QRect region = QRect());
|
||||
|
||||
static WlrScreencopyManager* instance();
|
||||
|
||||
private:
|
||||
explicit WlrScreencopyManager();
|
||||
|
||||
friend class WlrScreencopyContext;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::wlr
|
||||
51
src/wayland/screencopy/wlr_screencopy/wlr_screencopy_p.hpp
Normal file
51
src/wayland/screencopy/wlr_screencopy/wlr_screencopy_p.hpp
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#pragma once
|
||||
|
||||
#include <private/qwaylandscreen_p.h>
|
||||
#include <qtclasshelpermacros.h>
|
||||
#include <qwayland-wlr-screencopy-unstable-v1.h>
|
||||
|
||||
#include "../manager.hpp"
|
||||
|
||||
namespace qs::wayland::screencopy::wlr {
|
||||
|
||||
class WlrScreencopyManager;
|
||||
|
||||
class WlrScreencopyContext
|
||||
: public ScreencopyContext
|
||||
, public QtWayland::zwlr_screencopy_frame_v1 {
|
||||
public:
|
||||
explicit WlrScreencopyContext(
|
||||
WlrScreencopyManager* manager,
|
||||
QScreen* screen,
|
||||
bool paintCursors,
|
||||
QRect region
|
||||
);
|
||||
~WlrScreencopyContext() override;
|
||||
Q_DISABLE_COPY_MOVE(WlrScreencopyContext);
|
||||
|
||||
void captureFrame() override;
|
||||
|
||||
protected:
|
||||
// clang-format off
|
||||
void zwlr_screencopy_frame_v1_buffer(uint32_t format, uint32_t width, uint32_t height, uint32_t stride) override;
|
||||
void zwlr_screencopy_frame_v1_linux_dmabuf(uint32_t format, uint32_t width, uint32_t height) override;
|
||||
void zwlr_screencopy_frame_v1_flags(uint32_t flags) override;
|
||||
void zwlr_screencopy_frame_v1_buffer_done() override;
|
||||
void zwlr_screencopy_frame_v1_ready(uint32_t tvSecHi, uint32_t tvSecLo, uint32_t tvNsec) override;
|
||||
void zwlr_screencopy_frame_v1_failed() override;
|
||||
// clang-format on
|
||||
|
||||
private slots:
|
||||
void onScreenDestroyed();
|
||||
|
||||
private:
|
||||
WlrScreencopyManager* manager;
|
||||
buffer::WlBufferRequest request;
|
||||
bool copiedFirstFrame = false;
|
||||
|
||||
QtWaylandClient::QWaylandScreen* screen;
|
||||
bool paintCursors;
|
||||
QRect region;
|
||||
};
|
||||
|
||||
} // namespace qs::wayland::screencopy::wlr
|
||||
Loading…
Add table
Add a link
Reference in a new issue