Skip to content

Commit 55db943

Browse files
committed
new(src,cmake): add initial support for kwin output-management wayland protocol for gamma correction.
Also, fetch needed protocols at configure time instead of embedding them in the repository. Signed-off-by: Federico Di Pierro <[email protected]>
1 parent 7d447d0 commit 55db943

File tree

10 files changed

+227
-579
lines changed

10 files changed

+227
-579
lines changed

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
77
include(GNUInstallDirs)
88
find_package(PkgConfig)
99

10+
# Add path for custom CMake modules.
11+
list(APPEND CMAKE_MODULE_PATH
12+
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
13+
1014
execute_process(
1115
COMMAND git log -1 --format=%h
1216
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
@@ -50,7 +54,7 @@ list(APPEND COMBINED_LDFLAGS ${LOGIN_LIBS_LDFLAGS})
5054
# Optional dependencies
5155

5256
# Needed to eventually build wayland protocols
53-
add_subdirectory(protocol)
57+
include(WaylandProtocols)
5458

5559
# Helper macro for dealing correctly with optional pkg-config dependencies.
5660
# There are a number of issues when using pkg-config with cmake (as compared to
@@ -98,9 +102,9 @@ macro(optional_dep name modules description)
98102
endif()
99103
endmacro()
100104

101-
optional_dep(GAMMA "x11;xrandr;libdrm;wayland-client" "Gamma correction" src/modules/gamma_plugins protocol/wlr-gamma-control-unstable-v1.xml)
102-
optional_dep(DPMS "x11;xext;libdrm;wayland-client" "DPMS" src/modules/dpms_plugins protocol/org_kde_kwin_dpms.xml;protocol/wlr-output-power-management-unstable-v1.xml)
103-
optional_dep(SCREEN "x11" "screen emitted brightness" src/modules/screen_plugins protocol/wlr-screencopy-unstable-v1.xml)
105+
optional_dep(GAMMA "x11;xrandr;libdrm;wayland-client" "Gamma correction" src/modules/gamma_plugins https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/raw/master/unstable/wlr-gamma-control-unstable-v1.xml;https://raw.githubusercontent.com/KDE/plasma-wayland-protocols/master/src/protocols/outputdevice.xml;https://raw.githubusercontent.com/KDE/plasma-wayland-protocols/master/src/protocols/output-management.xml)
106+
optional_dep(DPMS "x11;xext;libdrm;wayland-client" "DPMS" src/modules/dpms_plugins https://raw.githubusercontent.com/KDE/plasma-wayland-protocols/master/src/protocols/dpms.xml;https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/raw/master/unstable/wlr-output-power-management-unstable-v1.xml)
107+
optional_dep(SCREEN "x11" "screen emitted brightness" src/modules/screen_plugins https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/raw/master/unstable/wlr-screencopy-unstable-v1.xml)
104108
optional_dep(DDC "ddcutil>=0.9.5" "external monitor backlight")
105109
optional_dep(YOCTOLIGHT "libusb-1.0" "Yoctolight usb als devices support")
106110
optional_dep(PIPEWIRE "libpipewire-0.3" "Enable pipewire camera sensor support")

TODO.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
### Generic
3636
- [ ] Drop is_smooth options for gamma
3737
- [ ] avoid returning boolean where it does not make sense
38+
- [ ] Rename Wl to Wlr (wlroots) in interfaces
3839

3940
## Ideas
4041
- [ ] follow ddcci kernel driver and in case, drop ddcutil and add the kernel driver as clightd opt-dep
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
# Stolen from: https://github.com/giucam/orbital/blob/512c1b3b20a32cf67ba326e8acce3c1c32e11fa2/cmake/Wayland.cmake, thanks!
1+
include(FetchContent)
2+
23
function(WAYLAND_ADD_PROTOCOL_CLIENT protocol)
34
find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner REQUIRED)
45

56
get_filename_component(proto_name ${protocol} NAME_WLE)
6-
get_filename_component(proto_fullpath ${protocol} ABSOLUTE)
7+
FetchContent_Declare(${proto_name} URL ${protocol} DOWNLOAD_NO_EXTRACT TRUE)
8+
FetchContent_Populate(${proto_name})
9+
710
message(STATUS "Enabled '${proto_name}' wayland client protocol")
811

9-
set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}-client-protocol.h")
10-
set(_code "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}-protocol.c")
12+
set(_client_header "${${proto_name}_BINARY_DIR}/${proto_name}-client-protocol.h")
13+
set(_code "${${proto_name}_BINARY_DIR}/${proto_name}-protocol.c")
14+
# set(_client_header "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}-client-protocol.h")
15+
# set(_code "${CMAKE_CURRENT_BINARY_DIR}/${proto_name}-protocol.c")
16+
set(proto_fullpath "${${proto_name}_SOURCE_DIR}/${proto_name}.xml")
1117

1218
add_custom_command(
1319
OUTPUT "${_client_header}" "${_code}"
@@ -17,5 +23,6 @@ function(WAYLAND_ADD_PROTOCOL_CLIENT protocol)
1723
)
1824

1925
target_sources(${PROJECT_NAME} PRIVATE ${_code})
20-
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
26+
target_include_directories(${PROJECT_NAME} PRIVATE ${${proto_name}_BINARY_DIR})
2127
endfunction()
28+

protocol/org_kde_kwin_dpms.xml

Lines changed: 0 additions & 81 deletions
This file was deleted.

protocol/wlr-gamma-control-unstable-v1.xml

Lines changed: 0 additions & 126 deletions
This file was deleted.

0 commit comments

Comments
 (0)