Skip to content

Commit

Permalink
Core: move to hyprwayland-scanner (#624)
Browse files Browse the repository at this point in the history
nix: add hyprwayland-scanner dep

flake.lock: update

---------

Co-authored-by: Mihai Fufezan <[email protected]>
  • Loading branch information
vaxerski and fufexan authored Dec 29, 2024
1 parent 77d194c commit 753c538
Show file tree
Hide file tree
Showing 21 changed files with 709 additions and 867 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Makefile
cmake_install.cmake
build/
compile_commands.json
protocols/*.c
protocols/*.h
protocols/*.cpp
protocols/*.hpp
*.kdev4
74 changes: 35 additions & 39 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ message(STATUS "Checking deps...")
find_package(Threads REQUIRED)
find_package(PkgConfig REQUIRED)
find_package(OpenGL REQUIRED)
find_package(hyprwayland-scanner 0.4.4 REQUIRED)
pkg_check_modules(
deps
REQUIRED
Expand Down Expand Up @@ -85,54 +86,49 @@ target_link_libraries(hyprlock PRIVATE pam rt Threads::Threads PkgConfig::deps
OpenGL::EGL OpenGL::GL)

# protocols
find_program(WaylandScanner NAMES wayland-scanner)
message(STATUS "Found WaylandScanner at ${WaylandScanner}")
execute_process(
COMMAND pkg-config --variable=pkgdatadir wayland-protocols
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE WAYLAND_PROTOCOLS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)
message(STATUS "Found wayland-protocols at ${WAYLAND_PROTOCOLS_DIR}")
pkg_get_variable(WAYLAND_SCANNER_PKGDATA_DIR wayland-scanner pkgdatadir)
message(
STATUS "Found wayland-scanner pkgdatadir at ${WAYLAND_SCANNER_PKGDATA_DIR}")

function(protocol protoPath protoName external)
function(protocolnew protoPath protoName external)
if(external)
execute_process(
COMMAND ${WaylandScanner} client-header ${protoPath}
protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND ${WaylandScanner} private-code ${protoPath}
protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(hyprlock PRIVATE protocols/${protoName}-protocol.c)
set(path ${CMAKE_SOURCE_DIR}/${protoPath})
else()
execute_process(
COMMAND
${WaylandScanner} client-header ${WAYLAND_PROTOCOLS_DIR}/${protoPath}
protocols/${protoName}-protocol.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(
COMMAND
${WaylandScanner} private-code ${WAYLAND_PROTOCOLS_DIR}/${protoPath}
protocols/${protoName}-protocol.c
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(hyprlock PRIVATE protocols/${protoName}-protocol.c)
set(path ${WAYLAND_PROTOCOLS_DIR}/${protoPath})
endif()
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/${protoName}.cpp
${CMAKE_SOURCE_DIR}/protocols/${protoName}.hpp
COMMAND hyprwayland-scanner --client ${path}/${protoName}.xml
${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(hyprlock PRIVATE protocols/${protoName}.cpp
protocols/${protoName}.hpp)
endfunction()
function(protocolWayland)
add_custom_command(
OUTPUT ${CMAKE_SOURCE_DIR}/protocols/wayland.cpp
${CMAKE_SOURCE_DIR}/protocols/wayland.hpp
COMMAND hyprwayland-scanner --wayland-enums --client
${WAYLAND_SCANNER_PKGDATA_DIR}/wayland.xml ${CMAKE_SOURCE_DIR}/protocols/
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
target_sources(hyprlock PRIVATE protocols/wayland.cpp protocols/wayland.hpp)
endfunction()

make_directory(${CMAKE_SOURCE_DIR}/protocols) # we don't ship any custom ones so
# the dir won't be there
protocol("staging/ext-session-lock/ext-session-lock-v1.xml"
"ext-session-lock-v1" false)
protocol("staging/cursor-shape/cursor-shape-v1.xml" "cursor-shape-v1" false)
protocol("unstable/tablet/tablet-unstable-v2.xml" "tablet-unstable-v2" false)
protocol("staging/fractional-scale/fractional-scale-v1.xml"
"fractional-scale-v1" false)
protocol("stable/viewporter/viewporter.xml" "viewporter" false)
protocol("protocols/wlr-screencopy-unstable-v1.xml"
"wlr-screencopy-unstable-v1" true)
protocol("unstable/linux-dmabuf/linux-dmabuf-unstable-v1.xml"
"linux-dmabuf-unstable-v1" false)

protocolwayland()

protocolnew("protocols" "wlr-screencopy-unstable-v1" true)
protocolnew("staging/ext-session-lock" "ext-session-lock-v1" false)
protocolnew("stable/linux-dmabuf" "linux-dmabuf-v1" false)
protocolnew("staging/fractional-scale" "fractional-scale-v1" false)
protocolnew("stable/viewporter" "viewporter" false)
protocolnew("staging/cursor-shape" "cursor-shape-v1" false)
protocolnew("stable/tablet" "tablet-v2" false)

# Installation
install(TARGETS hyprlock)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ You need the following dependencies
- wayland-client
- wayland-protocols
- mesa
- hyprwayland-scanner

And the development libraries for the following
- cairo
Expand Down
48 changes: 36 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
inputs.systems.follows = "systems";
inputs.hyprutils.follows = "hyprutils";
};

hyprwayland-scanner = {
url = "github:hyprwm/hyprwayland-scanner";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
};
};

outputs = {
Expand Down
2 changes: 2 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
hyprgraphics,
hyprlang,
hyprutils,
hyprwayland-scanner,
pam,
pango,
sdbus-cpp,
Expand All @@ -33,6 +34,7 @@ stdenv.mkDerivation {
nativeBuildInputs = [
cmake
pkg-config
hyprwayland-scanner
wayland-scanner
];

Expand Down
1 change: 1 addition & 0 deletions nix/overlays.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ in {
inputs.hyprgraphics.overlays.default
inputs.hyprlang.overlays.default
inputs.hyprutils.overlays.default
inputs.hyprwayland-scanner.overlays.default
inputs.self.overlays.sdbuscpp
(final: prev: {
hyprlock = prev.callPackage ./default.nix {
Expand Down
14 changes: 7 additions & 7 deletions src/core/CursorShape.cpp
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
#include "CursorShape.hpp"
#include "hyprlock.hpp"
#include "Seat.hpp"

CCursorShape::CCursorShape(wp_cursor_shape_manager_v1* mgr) : mgr(mgr) {
if (!g_pHyprlock->m_pPointer)
CCursorShape::CCursorShape(SP<CCWpCursorShapeManagerV1> mgr) : mgr(mgr) {
if (!g_pSeatManager->m_pPointer)
return;

dev = wp_cursor_shape_manager_v1_get_pointer(mgr, g_pHyprlock->m_pPointer);
dev = makeShared<CCWpCursorShapeDeviceV1>(mgr->sendGetPointer(g_pSeatManager->m_pPointer->resource()));
}

void CCursorShape::setShape(const wp_cursor_shape_device_v1_shape shape) {
void CCursorShape::setShape(const wpCursorShapeDeviceV1Shape shape) {
if (!dev)
return;

wp_cursor_shape_device_v1_set_shape(dev, lastCursorSerial, shape);
dev->sendSetShape(lastCursorSerial, shape);
}

void CCursorShape::hideCursor() {
wl_pointer_set_cursor(g_pHyprlock->m_pPointer, lastCursorSerial, nullptr, 0, 0);
g_pSeatManager->m_pPointer->sendSetCursor(lastCursorSerial, nullptr, 0, 0);
}
12 changes: 6 additions & 6 deletions src/core/CursorShape.hpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#pragma once

#include <wayland-client.h>
#include "cursor-shape-v1-protocol.h"
#include "../defines.hpp"
#include "cursor-shape-v1.hpp"

class CCursorShape {
public:
CCursorShape(wp_cursor_shape_manager_v1* mgr);
CCursorShape(SP<CCWpCursorShapeManagerV1> mgr);

void setShape(const wp_cursor_shape_device_v1_shape shape);
void setShape(const wpCursorShapeDeviceV1Shape shape);
void hideCursor();

uint32_t lastCursorSerial = 0;

private:
wp_cursor_shape_manager_v1* mgr = nullptr;
wp_cursor_shape_device_v1* dev = nullptr;
SP<CCWpCursorShapeManagerV1> mgr = nullptr;
SP<CCWpCursorShapeDeviceV1> dev = nullptr;
};
1 change: 0 additions & 1 deletion src/core/Egl.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <wayland-client.h>
#include <memory>

#include <EGL/egl.h>
Expand Down
Loading

0 comments on commit 753c538

Please sign in to comment.