mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 10:45:58 +01:00
core: Move tearing to hyprwayland-scanner (#5657)
Adds a new dependency: hyprwayland-scanner https://github.com/hyprwm/hyprwayland-scanner --------- Co-authored-by: Mihai Fufezan <mihai@fufexan.net>
This commit is contained in:
parent
5c97b96278
commit
ea95449402
11 changed files with 108 additions and 78 deletions
8
.github/actions/setup_base/action.yml
vendored
8
.github/actions/setup_base/action.yml
vendored
|
@ -25,6 +25,7 @@ runs:
|
||||||
glslang \
|
glslang \
|
||||||
go \
|
go \
|
||||||
hyprlang \
|
hyprlang \
|
||||||
|
hyprcursor \
|
||||||
jq \
|
jq \
|
||||||
libc++ \
|
libc++ \
|
||||||
libdisplay-info \
|
libdisplay-info \
|
||||||
|
@ -44,6 +45,7 @@ runs:
|
||||||
pango \
|
pango \
|
||||||
pixman \
|
pixman \
|
||||||
pkgconf \
|
pkgconf \
|
||||||
|
pugixml \
|
||||||
scdoc \
|
scdoc \
|
||||||
seatd \
|
seatd \
|
||||||
systemd \
|
systemd \
|
||||||
|
@ -58,11 +60,11 @@ runs:
|
||||||
libzip \
|
libzip \
|
||||||
librsvg
|
librsvg
|
||||||
|
|
||||||
- name: Get hyprcursor-git
|
- name: Get hyprwayland-scanner-git
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/hyprwm/hyprcursor --recursive
|
git clone https://github.com/hyprwm/hyprwayland-scanner --recursive
|
||||||
cd hyprcursor
|
cd hyprwayland-scanner
|
||||||
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
|
cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr -S . -B ./build
|
||||||
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
cmake --build ./build --config Release --target all -j`nproc 2>/dev/null || getconf NPROCESSORS_CONF`
|
||||||
cmake --install build
|
cmake --install build
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -17,8 +17,8 @@ result*
|
||||||
.cache
|
.cache
|
||||||
|
|
||||||
*.o
|
*.o
|
||||||
*-protocol.c
|
protocols/*.c*
|
||||||
*-protocol.h
|
protocols/*.h*
|
||||||
.ccls-cache
|
.ccls-cache
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,7 @@ pkg_get_variable(WaylandScanner wayland-scanner wayland_scanner)
|
||||||
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
|
||||||
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
|
||||||
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
|
||||||
|
find_program(HYPRWAYLAND_SCANNER NAMES hyprwayland-scanner REQUIRED)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
if(CMAKE_BUILD_TYPE MATCHES Debug OR CMAKE_BUILD_TYPE MATCHES DEBUG)
|
||||||
message(STATUS "Configuring Hyprland in Debug with CMake")
|
message(STATUS "Configuring Hyprland in Debug with CMake")
|
||||||
|
@ -238,6 +239,19 @@ function(protocol protoPath protoName external)
|
||||||
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c)
|
target_sources(Hyprland PRIVATE protocols/${protoName}-protocol.c)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
function(protocolNew protoPath protoName external)
|
||||||
|
if (external)
|
||||||
|
execute_process(
|
||||||
|
COMMAND hyprwayland-scanner ${protoPath} ${CMAKE_SOURCE_DIR}/protocols/
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp)
|
||||||
|
else()
|
||||||
|
execute_process(
|
||||||
|
COMMAND hyprwayland-scanner ${WAYLAND_PROTOCOLS_DIR}/${protoPath} ${CMAKE_SOURCE_DIR}/protocols/
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
|
||||||
|
target_sources(Hyprland PRIVATE protocols/${protoName}.cpp)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
target_link_libraries(Hyprland
|
target_link_libraries(Hyprland
|
||||||
${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
|
${CMAKE_SOURCE_DIR}/subprojects/wlroots-hyprland/build/libwlroots.a
|
||||||
|
@ -260,10 +274,9 @@ protocol("stable/xdg-shell/xdg-shell.xml" "xdg-shell" false)
|
||||||
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
|
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml" "linux-dmabuf-unstable-v1" false)
|
||||||
protocol("unstable/xdg-output/xdg-output-unstable-v1.xml" "xdg-output-unstable-v1" false)
|
protocol("unstable/xdg-output/xdg-output-unstable-v1.xml" "xdg-output-unstable-v1" false)
|
||||||
protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false)
|
protocol("staging/fractional-scale/fractional-scale-v1.xml" "fractional-scale-v1" false)
|
||||||
protocol("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false)
|
|
||||||
protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false)
|
protocol("unstable/text-input/text-input-unstable-v1.xml" "text-input-unstable-v1" false)
|
||||||
protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)
|
protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)
|
||||||
protocol("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false)
|
protocolNew("staging/tearing-control/tearing-control-v1.xml" "tearing-control-v1" false)
|
||||||
|
|
||||||
# tools
|
# tools
|
||||||
add_subdirectory(hyprctl)
|
add_subdirectory(hyprctl)
|
||||||
|
|
24
flake.lock
24
flake.lock
|
@ -72,6 +72,29 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"hyprwayland-scanner": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
],
|
||||||
|
"systems": [
|
||||||
|
"systems"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1713612394,
|
||||||
|
"narHash": "sha256-uWA8iPYzrdpCT9d8I9YHrxkjBdooqOZIH6ZOHoQiOUc=",
|
||||||
|
"owner": "hyprwm",
|
||||||
|
"repo": "hyprwayland-scanner",
|
||||||
|
"rev": "f58a3f56e89857dc7ab7166cff2f971345026634",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "hyprwm",
|
||||||
|
"repo": "hyprwayland-scanner",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1712963716,
|
"lastModified": 1712963716,
|
||||||
|
@ -93,6 +116,7 @@
|
||||||
"hyprcursor": "hyprcursor",
|
"hyprcursor": "hyprcursor",
|
||||||
"hyprland-protocols": "hyprland-protocols",
|
"hyprland-protocols": "hyprland-protocols",
|
||||||
"hyprlang": "hyprlang",
|
"hyprlang": "hyprlang",
|
||||||
|
"hyprwayland-scanner": "hyprwayland-scanner",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"systems": "systems",
|
"systems": "systems",
|
||||||
"wlroots": "wlroots",
|
"wlroots": "wlroots",
|
||||||
|
|
|
@ -34,6 +34,12 @@
|
||||||
inputs.systems.follows = "systems";
|
inputs.systems.follows = "systems";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
hyprwayland-scanner = {
|
||||||
|
url = "github:hyprwm/hyprwayland-scanner";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
inputs.systems.follows = "systems";
|
||||||
|
};
|
||||||
|
|
||||||
xdph = {
|
xdph = {
|
||||||
url = "github:hyprwm/xdg-desktop-portal-hyprland";
|
url = "github:hyprwm/xdg-desktop-portal-hyprland";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
hyprcursor,
|
hyprcursor,
|
||||||
hyprland-protocols,
|
hyprland-protocols,
|
||||||
hyprlang,
|
hyprlang,
|
||||||
|
hyprwayland-scanner,
|
||||||
jq,
|
jq,
|
||||||
libGL,
|
libGL,
|
||||||
libdrm,
|
libdrm,
|
||||||
|
@ -86,6 +87,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
|
hyprwayland-scanner
|
||||||
jq
|
jq
|
||||||
makeWrapper
|
makeWrapper
|
||||||
meson
|
meson
|
||||||
|
|
|
@ -24,6 +24,7 @@ in {
|
||||||
inputs.hyprcursor.overlays.default
|
inputs.hyprcursor.overlays.default
|
||||||
inputs.hyprland-protocols.overlays.default
|
inputs.hyprland-protocols.overlays.default
|
||||||
inputs.hyprlang.overlays.default
|
inputs.hyprlang.overlays.default
|
||||||
|
inputs.hyprwayland-scanner.overlays.default
|
||||||
self.overlays.wlroots-hyprland
|
self.overlays.wlroots-hyprland
|
||||||
self.overlays.udis86
|
self.overlays.udis86
|
||||||
# Hyprland packages themselves
|
# Hyprland packages themselves
|
||||||
|
|
|
@ -17,6 +17,11 @@ wayland_scanner = find_program(
|
||||||
wayland_scanner_dep.get_variable('wayland_scanner'),
|
wayland_scanner_dep.get_variable('wayland_scanner'),
|
||||||
native: true,
|
native: true,
|
||||||
)
|
)
|
||||||
|
hyprwayland_scanner_dep = dependency('hyprwayland-scanner', native: true)
|
||||||
|
hyprwayland_scanner = find_program(
|
||||||
|
hyprwayland_scanner_dep.get_variable('hyprwayland_scanner'),
|
||||||
|
native: true,
|
||||||
|
)
|
||||||
|
|
||||||
protocols = [
|
protocols = [
|
||||||
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
|
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
|
||||||
|
@ -25,7 +30,6 @@ protocols = [
|
||||||
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
|
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
|
||||||
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
|
[wl_protocol_dir, 'staging/fractional-scale/fractional-scale-v1.xml'],
|
||||||
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
|
[wl_protocol_dir, 'staging/cursor-shape/cursor-shape-v1.xml'],
|
||||||
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
|
|
||||||
['wlr-foreign-toplevel-management-unstable-v1.xml'],
|
['wlr-foreign-toplevel-management-unstable-v1.xml'],
|
||||||
['wlr-layer-shell-unstable-v1.xml'],
|
['wlr-layer-shell-unstable-v1.xml'],
|
||||||
['wlr-output-power-management-unstable-v1.xml'],
|
['wlr-output-power-management-unstable-v1.xml'],
|
||||||
|
@ -36,8 +40,14 @@ protocols = [
|
||||||
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
|
[hl_protocol_dir, 'protocols/hyprland-toplevel-export-v1.xml'],
|
||||||
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
|
[hl_protocol_dir, 'protocols/hyprland-global-shortcuts-v1.xml']
|
||||||
]
|
]
|
||||||
|
|
||||||
|
new_protocols = [
|
||||||
|
[wl_protocol_dir, 'staging/tearing-control/tearing-control-v1.xml'],
|
||||||
|
]
|
||||||
|
|
||||||
wl_protos_src = []
|
wl_protos_src = []
|
||||||
wl_protos_headers = []
|
wl_protos_headers = []
|
||||||
|
|
||||||
foreach p : protocols
|
foreach p : protocols
|
||||||
xml = join_paths(p)
|
xml = join_paths(p)
|
||||||
wl_protos_src += custom_target(
|
wl_protos_src += custom_target(
|
||||||
|
@ -56,15 +66,28 @@ foreach p : protocols
|
||||||
)
|
)
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
new_wl_protos = []
|
||||||
|
foreach p : new_protocols
|
||||||
|
xml = join_paths(p)
|
||||||
|
new_wl_protos += custom_target(
|
||||||
|
xml.underscorify(),
|
||||||
|
input: xml,
|
||||||
|
install: true,
|
||||||
|
install_dir: [false, join_paths(get_option('includedir'), 'hyprland/protocols')],
|
||||||
|
output: ['@BASENAME@.cpp', '@BASENAME@.hpp'],
|
||||||
|
command: [hyprwayland_scanner, '@INPUT@', '@OUTDIR@'],
|
||||||
|
)
|
||||||
|
endforeach
|
||||||
|
|
||||||
wayland_server = dependency('wayland-server', version: '>=1.20.0')
|
wayland_server = dependency('wayland-server', version: '>=1.20.0')
|
||||||
|
|
||||||
lib_server_protos = static_library(
|
lib_server_protos = static_library(
|
||||||
'server_protos',
|
'server_protos',
|
||||||
wl_protos_src + wl_protos_headers,
|
wl_protos_src + wl_protos_headers + new_wl_protos,
|
||||||
dependencies: wayland_server.partial_dependency(compile_args: true),
|
dependencies: wayland_server.partial_dependency(compile_args: true),
|
||||||
)
|
)
|
||||||
|
|
||||||
server_protos = declare_dependency(
|
server_protos = declare_dependency(
|
||||||
link_with: lib_server_protos,
|
link_with: lib_server_protos,
|
||||||
sources: wl_protos_headers,
|
sources: wl_protos_headers + new_wl_protos,
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include "../protocols/TearingControl.hpp"
|
#include "../protocols/TearingControl.hpp"
|
||||||
|
|
||||||
#include "xdg-output-unstable-v1-protocol.h"
|
#include "xdg-output-unstable-v1-protocol.h"
|
||||||
#include "tearing-control-v1-protocol.h"
|
#include "tearing-control-v1.hpp"
|
||||||
|
|
||||||
CProtocolManager::CProtocolManager() {
|
CProtocolManager::CProtocolManager() {
|
||||||
m_pToplevelExportProtocolManager = std::make_unique<CToplevelExportProtocolManager>();
|
m_pToplevelExportProtocolManager = std::make_unique<CToplevelExportProtocolManager>();
|
||||||
|
|
|
@ -1,40 +1,20 @@
|
||||||
#include "TearingControl.hpp"
|
#include "TearingControl.hpp"
|
||||||
#include "tearing-control-v1-protocol.h"
|
|
||||||
#include "../managers/ProtocolManager.hpp"
|
#include "../managers/ProtocolManager.hpp"
|
||||||
#include "../desktop/Window.hpp"
|
#include "../desktop/Window.hpp"
|
||||||
#include "../Compositor.hpp"
|
#include "../Compositor.hpp"
|
||||||
|
|
||||||
static void destroyManager(wl_client* client, wl_resource* resource) {
|
|
||||||
RESOURCE_OR_BAIL(PRESOURCE);
|
|
||||||
reinterpret_cast<CTearingControlProtocol*>(PRESOURCE->data())->onManagerResourceDestroy(resource);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getTearingControl(wl_client* client, wl_resource* resource, uint32_t id, wl_resource* surface) {
|
|
||||||
RESOURCE_OR_BAIL(PRESOURCE);
|
|
||||||
reinterpret_cast<CTearingControlProtocol*>(PRESOURCE->data())->onGetController(client, resource, id, wlr_surface_from_resource(surface));
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
CTearingControlProtocol::CTearingControlProtocol(const wl_interface* iface, const int& ver, const std::string& name) : IWaylandProtocol(iface, ver, name) {
|
||||||
g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<CWindow*>(param)); });
|
g_pHookSystem->hookDynamic("destroyWindow", [this](void* self, SCallbackInfo& info, std::any param) { this->onWindowDestroy(std::any_cast<CWindow*>(param)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wp_tearing_control_manager_v1_interface MANAGER_IMPL = {
|
|
||||||
.destroy = ::destroyManager,
|
|
||||||
.get_tearing_control = ::getTearingControl,
|
|
||||||
};
|
|
||||||
|
|
||||||
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
void CTearingControlProtocol::bindManager(wl_client* client, void* data, uint32_t ver, uint32_t id) {
|
||||||
const auto RESOURCE = m_vManagers.emplace_back(std::make_unique<CWaylandResource>(client, &wp_tearing_control_manager_v1_interface, ver, id)).get();
|
const auto RESOURCE = m_vManagers.emplace_back(std::make_unique<CWpTearingControlManagerV1>(client, ver, id)).get();
|
||||||
|
RESOURCE->setOnDestroy([this](CWpTearingControlManagerV1* p) { this->onManagerResourceDestroy(p->resource()); });
|
||||||
|
|
||||||
if (!RESOURCE->good()) {
|
RESOURCE->setDestroy([this](CWpTearingControlManagerV1* pMgr) { this->onManagerResourceDestroy(pMgr->resource()); });
|
||||||
Debug::log(LOG, "Couldn't bind TearingControlMgr");
|
RESOURCE->setGetTearingControl([this](CWpTearingControlManagerV1* pMgr, uint32_t id, wl_resource* surface) {
|
||||||
return;
|
this->onGetController(wl_resource_get_client(pMgr->resource()), pMgr->resource(), id, wlr_surface_from_resource(surface));
|
||||||
}
|
});
|
||||||
|
|
||||||
RESOURCE->setImplementation(&MANAGER_IMPL, nullptr);
|
|
||||||
RESOURCE->setData(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTearingControlProtocol::onManagerResourceDestroy(wl_resource* res) {
|
void CTearingControlProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||||
|
@ -42,10 +22,8 @@ void CTearingControlProtocol::onManagerResourceDestroy(wl_resource* res) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTearingControlProtocol::onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf) {
|
void CTearingControlProtocol::onGetController(wl_client* client, wl_resource* resource, uint32_t id, wlr_surface* surf) {
|
||||||
const auto CONTROLLER = m_vTearingControllers
|
const auto CONTROLLER =
|
||||||
.emplace_back(std::make_unique<CTearingControl>(
|
m_vTearingControllers.emplace_back(std::make_unique<CTearingControl>(std::make_shared<CWpTearingControlV1>(client, wl_resource_get_version(resource), id), surf)).get();
|
||||||
std::make_shared<CWaylandResource>(client, &wp_tearing_control_v1_interface, wl_resource_get_version(resource), id), surf))
|
|
||||||
.get();
|
|
||||||
|
|
||||||
if (!CONTROLLER->good()) {
|
if (!CONTROLLER->good()) {
|
||||||
m_vTearingControllers.pop_back();
|
m_vTearingControllers.pop_back();
|
||||||
|
@ -66,25 +44,11 @@ void CTearingControlProtocol::onWindowDestroy(CWindow* pWindow) {
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
static void destroyController(wl_client* client, wl_resource* resource) {
|
CTearingControl::CTearingControl(SP<CWpTearingControlV1> resource_, wlr_surface* surf_) : resource(resource_) {
|
||||||
RESOURCE_OR_BAIL(PRESOURCE);
|
|
||||||
PROTO::tearing->onControllerDestroy(reinterpret_cast<CTearingControl*>(PRESOURCE->data()));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setPresentationHint(wl_client* client, wl_resource* resource, uint32_t hint) {
|
|
||||||
RESOURCE_OR_BAIL(PRESOURCE);
|
|
||||||
reinterpret_cast<CTearingControl*>(PRESOURCE->data())->onHint(hint);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct wp_tearing_control_v1_interface CONTROLLER_IMPL = {
|
|
||||||
.set_presentation_hint = ::setPresentationHint,
|
|
||||||
.destroy = ::destroyController,
|
|
||||||
};
|
|
||||||
|
|
||||||
CTearingControl::CTearingControl(SP<CWaylandResource> resource_, wlr_surface* surf_) : resource(resource_) {
|
|
||||||
resource->setImplementation(&CONTROLLER_IMPL, nullptr);
|
|
||||||
resource->setData(this);
|
resource->setData(this);
|
||||||
resource->setOnDestroyHandler([](CWaylandResource* res) { PROTO::tearing->onControllerDestroy(reinterpret_cast<CTearingControl*>(res->data())); });
|
resource->setOnDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||||
|
resource->setDestroy([this](CWpTearingControlV1* res) { PROTO::tearing->onControllerDestroy(this); });
|
||||||
|
resource->setSetPresentationHint([this](CWpTearingControlV1* res, wpTearingControlV1PresentationHint hint) { this->onHint(hint); });
|
||||||
|
|
||||||
for (auto& w : g_pCompositor->m_vWindows) {
|
for (auto& w : g_pCompositor->m_vWindows) {
|
||||||
if (w->m_pWLSurface.wlr() == surf_) {
|
if (w->m_pWLSurface.wlr() == surf_) {
|
||||||
|
@ -94,8 +58,8 @@ CTearingControl::CTearingControl(SP<CWaylandResource> resource_, wlr_surface* su
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CTearingControl::onHint(uint32_t hint_) {
|
void CTearingControl::onHint(wpTearingControlV1PresentationHint hint_) {
|
||||||
hint = hint_ == WP_TEARING_CONTROL_V1_PRESENTATION_HINT_VSYNC ? TEARING_VSYNC : TEARING_ASYNC;
|
hint = hint_;
|
||||||
updateWindow();
|
updateWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,9 +67,9 @@ void CTearingControl::updateWindow() {
|
||||||
if (!pWindow)
|
if (!pWindow)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pWindow->m_bTearingHint = hint == TEARING_ASYNC;
|
pWindow->m_bTearingHint = hint == PRESENTATION_HINT_ASYNC;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CTearingControl::good() {
|
bool CTearingControl::good() {
|
||||||
return resource->good();
|
return resource->resource();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,16 @@
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "WaylandProtocol.hpp"
|
#include "WaylandProtocol.hpp"
|
||||||
|
#include "tearing-control-v1.hpp"
|
||||||
|
|
||||||
class CWindow;
|
class CWindow;
|
||||||
|
|
||||||
enum eTearingPresentationHint {
|
|
||||||
TEARING_VSYNC = 0,
|
|
||||||
TEARING_ASYNC,
|
|
||||||
};
|
|
||||||
|
|
||||||
class CTearingControlProtocol;
|
class CTearingControlProtocol;
|
||||||
|
|
||||||
class CTearingControl {
|
class CTearingControl {
|
||||||
public:
|
public:
|
||||||
CTearingControl(SP<CWaylandResource> resource_, wlr_surface* surf_);
|
CTearingControl(SP<CWpTearingControlV1> resource_, wlr_surface* surf_);
|
||||||
|
|
||||||
void onHint(uint32_t hint_);
|
void onHint(wpTearingControlV1PresentationHint hint_);
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
|
|
||||||
|
@ -31,9 +26,9 @@ class CTearingControl {
|
||||||
private:
|
private:
|
||||||
void updateWindow();
|
void updateWindow();
|
||||||
|
|
||||||
SP<CWaylandResource> resource;
|
SP<CWpTearingControlV1> resource;
|
||||||
CWindow* pWindow = nullptr;
|
CWindow* pWindow = nullptr;
|
||||||
eTearingPresentationHint hint = TEARING_VSYNC;
|
wpTearingControlV1PresentationHint hint = PRESENTATION_HINT_VSYNC;
|
||||||
|
|
||||||
friend class CTearingControlProtocol;
|
friend class CTearingControlProtocol;
|
||||||
};
|
};
|
||||||
|
@ -51,7 +46,7 @@ class CTearingControlProtocol : public IWaylandProtocol {
|
||||||
private:
|
private:
|
||||||
void onWindowDestroy(CWindow* pWindow);
|
void onWindowDestroy(CWindow* pWindow);
|
||||||
|
|
||||||
std::vector<UP<CWaylandResource>> m_vManagers;
|
std::vector<UP<CWpTearingControlManagerV1>> m_vManagers;
|
||||||
std::vector<UP<CTearingControl>> m_vTearingControllers;
|
std::vector<UP<CTearingControl>> m_vTearingControllers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue