Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wayland GUI backend #1310

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
39253f8
build, colours, core, gui, wayland, wl, x11: implement wayland displa…
Nov 28, 2022
e157b85
wl: declare desktop/monitor info functions as weak symbols
Nov 28, 2022
0f15e68
wayland: implement buffer scaling
Nov 28, 2022
bb4ad8c
wayland: switch to zwlr_layer_shell_v1 and implement proper window pl…
Nov 28, 2022
f588b78
colours: parse X11 colors under Wayland
Nov 28, 2022
44c793a
colours: define manually_get_x11_color for usage outside X11
Nov 28, 2022
2259969
wayland: fix crash after 5 minutes
Nov 28, 2022
0fd47b7
wayland: respond to xdg_wm_base.ping
Nov 28, 2022
19cbc7c
wayland: rework window destruction/resizing
Nov 28, 2022
a62f969
config: add out_to_wayland to bool setting list for config converter
Nov 28, 2022
766b826
doc: document out_to_wayland setting
Nov 28, 2022
beb5883
core: fix right-alignment with wayland
Nov 28, 2022
c0cd25a
core: fix segfault when no display outputs are enabled
Nov 28, 2022
fbee173
core: fix misbehavior in specials handling that fails badly with Wayl…
Nov 28, 2022
14afe66
x11, gui: update display-x11.cc to account for some code moved into g…
Nov 28, 2022
689215f
gui: remove background_color from gui.cc and window_type/window_hints…
Nov 28, 2022
7ef0ae4
x11: update x11.cc for functionality moved into gui.cc
Nov 28, 2022
00adf3e
x11, imlib2: early-exit in some X functions if X is not available at …
Nov 28, 2022
4b512c5
x11: early-return from use_xdbe_setting::set_up if X11 not initialized
Nov 28, 2022
4585e50
x11: do not treat init failure as fatal with Wayland
Dec 12, 2022
baf3bd9
ci: update for Wayland build
Dec 9, 2022
252c1da
wayland: clamp text width
Dec 12, 2022
6e57f18
wayland: permit unused parameters
Dec 12, 2022
7f9bc31
build: add pangoft2 to Wayland deps
Dec 12, 2022
dd0b9b0
Bump web deps.
brndnmtthws Dec 14, 2022
c56000e
FreeBSD: Additional memory reporting variables.
pghvlaans Dec 24, 2022
9c7ed7f
src/common.cc: Fix accidental whitespace change
pghvlaans Dec 24, 2022
c30a1b4
docs/variables.yaml: A better description for memlaundry.
pghvlaans Dec 24, 2022
75066bd
Tidy a couple things.
brndnmtthws Dec 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build-and-test-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
- ubuntu-20.04
- ubuntu-22.04
x11: [ON, OFF]
wayland: [ON, OFF]
compiler:
- clang
- gcc
Expand Down Expand Up @@ -74,6 +75,8 @@ jobs:
libpulse-dev \
librsvg2-dev \
libsystemd-dev \
libwayland-bin \
libwayland-dev \
libx11-dev \
libxdamage-dev \
libxext-dev \
Expand All @@ -82,7 +85,8 @@ jobs:
libxml2-dev \
libxmmsclient-dev \
libxnvctrl-dev \
ncurses-dev
ncurses-dev \
wayland-protocols
- name: Install libc++
if: matrix.compiler == 'clang'
run: |
Expand Down Expand Up @@ -125,6 +129,7 @@ jobs:
-DBUILD_RSS=ON \
-DBUILD_TESTS=ON \
-DBUILD_WLAN=ON \
-DBUILD_WAYLAND=${{ matrix.wayland }}\
-DBUILD_X11=${{ matrix.x11 }} \
-DBUILD_XMMS2=ON \
-DCMAKE_C_COMPILER=$CC \
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-and-test-macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
cd build
cmake .. \
-DMAINTAINER_MODE=ON \
-DBUILD_WAYLAND=OFF \
-DBUILD_TESTS=ON
- name: Compile
working-directory: build
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
libpulse-dev \
librsvg2-dev \
libsystemd-dev \
libwayland-dev \
libx11-dev \
libxdamage-dev \
libxext-dev \
Expand Down
5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ J
Some cleaning and commenting apparently :)
SIGHUP config file reload

K. Eugene Carlson <kvngncrlsn at gmail dot com>
Additional Linux memory reporting variables
Linux CPU frequency governor reporting
Additional FreeBSD memory reporting variables

Kapil Hari Paranjape <[email protected]>
ibm_volume patch
kFreeBSD support patch
Expand Down
5 changes: 5 additions & 0 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ else(BUILD_NCURSES)
FORCE)
endif(BUILD_NCURSES)

option(BUILD_WAYLAND "Build Wayland support" true)

option(BUILD_X11 "Build X11 support" true)
if(BUILD_X11)
option(OWN_WINDOW "Enable own_window support" true)
Expand Down Expand Up @@ -208,6 +210,9 @@ endif(BUILD_X11)
if(BUILD_X11)
set(BUILD_GUI true)
endif(BUILD_X11)
if(BUILD_WAYLAND)
set(BUILD_GUI true)
endif(BUILD_WAYLAND)

if(OWN_WINDOW)
option(BUILD_ARGB "Build ARGB (real transparency) support" true)
Expand Down
37 changes: 37 additions & 0 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,37 @@ if(BUILD_X11)
endif(X11_FOUND)
endif(BUILD_X11)

if(BUILD_WAYLAND)
find_package(Wayland REQUIRED)
set(conky_libs ${conky_libs} ${WAYLAND_CLIENT_LIBRARY})
set(conky_includes ${conky_includes} ${WAYLAND_CLIENT_INCLUDE_DIR})

find_package(PkgConfig)

pkg_check_modules(wayland-protocols QUIET wayland-protocols>=1.13)
if(WAYLAND_CLIENT_FOUND AND wayland-protocols_FOUND)
# find Wayland protocols
pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir)

# find 'wayland-scanner' executable
pkg_get_variable(WAYLAND_SCANNER wayland-scanner wayland_scanner)
else(WAYLAND_CLIENT_FOUND AND wayland-protocols_FOUND)
message(FATAL_ERROR "Unable to find wayland-scanner and xdg-shell protocol")
endif(WAYLAND_CLIENT_FOUND AND wayland-protocols_FOUND)

pkg_check_modules(PANGOCAIRO pangocairo)
set(conky_libs ${conky_libs} ${PANGOCAIRO_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOCAIRO_INCLUDE_DIRS})

pkg_check_modules(PANGOFC pangofc)
set(conky_libs ${conky_libs} ${PANGOFC_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOFC_INCLUDE_DIRS})

pkg_check_modules(PANGOFT2 pangoft2)
set(conky_libs ${conky_libs} ${PANGOFT2_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOFT2_INCLUDE_DIRS})
endif(BUILD_WAYLAND)

# Otherwise, use the most recent Lua version
pkg_search_module(LUA
REQUIRED
Expand Down Expand Up @@ -454,6 +485,12 @@ if(BUILD_PULSEAUDIO)
set(conky_includes ${conky_includes} ${PULSEAUDIO_INCLUDE_DIRS})
endif(BUILD_PULSEAUDIO)

if(WANT_CURL)
pkg_check_modules(CURL REQUIRED libcurl)
set(conky_libs ${conky_libs} ${CURL_LIBRARIES})
set(conky_includes ${conky_includes} ${CURL_INCLUDE_DIRS})
endif(WANT_CURL)

# Common libraries
if(WANT_GLIB)
pkg_check_modules(GLIB REQUIRED glib-2.0>=2.36)
Expand Down
59 changes: 59 additions & 0 deletions cmake/FindWayland.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
find_path(
WAYLAND_CLIENT_INCLUDE_DIR
NAMES wayland-client.h
)

find_library(
WAYLAND_CLIENT_LIBRARY
NAMES wayland-client libwayland-client
)

if(WAYLAND_CLIENT_INCLUDE_DIR AND WAYLAND_CLIENT_LIBRARY)
add_library(wayland::client UNKNOWN IMPORTED)

set_target_properties(
wayland::client PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_CLIENT_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${WAYLAND_CLIENT_LIBRARY}"
)
endif()

find_path(
WAYLAND_SERVER_INCLUDE_DIR
NAMES wayland-server.h
)

find_library(
WAYLAND_SERVER_LIBRARY
NAMES wayland-server libwayland-server
)

if(WAYLAND_SERVER_INCLUDE_DIR AND WAYLAND_SERVER_LIBRARY)
add_library(wayland::server UNKNOWN IMPORTED)

set_target_properties(
wayland::server PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${WAYLAND_SERVER_INCLUDE_DIR}"
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
IMPORTED_LOCATION "${WAYLAND_SERVER_LIBRARY}"
)
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
WAYLAND_CLIENT
REQUIRED_VARS WAYLAND_CLIENT_LIBRARY WAYLAND_CLIENT_INCLUDE_DIR
)

find_package_handle_standard_args(
WAYLAND_SERVER
REQUIRED_VARS WAYLAND_SERVER_LIBRARY WAYLAND_SERVER_INCLUDE_DIR
)

mark_as_advanced(
WAYLAND_CLIENT_INCLUDE_DIR
WAYLAND_CLIENT_LIBRARY
WAYLAND_SERVER_INCLUDE_DIR
WAYLAND_SERVER_LIBRARY
)
2 changes: 2 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

#cmakedefine HAVE_CLOCK_GETTIME 1

#cmakedefine BUILD_WAYLAND 1

#cmakedefine BUILD_X11 1

#cmakedefine OWN_WINDOW 1
Expand Down
4 changes: 4 additions & 0 deletions doc/config_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ values:
will provide more useful things).
- name: out_to_stderr
desc: Print text to stderr.
- name: out_to_wayland
desc: |-
Open a Wayland window to display output.
default: no
- name: out_to_x
desc: |-
When set to no, there will be no output in X (useful when
Expand Down
8 changes: 8 additions & 0 deletions doc/variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,8 @@ values:
- mbox
- name: mem
desc: Amount of memory in use.
- name: memactive
desc: Amount of active memory. FreeBSD only.
- name: memavail
desc: Amount of available memory as recorded in /proc/meminfo. Linux 3.14+ only.
- name: membar
Expand Down Expand Up @@ -1226,10 +1228,16 @@ values:
- (scale)
- (-t)
- (-l)
- name: meminactive
desc: Amount of inactive memory. FreeBSD only.
- name: memlaundry
desc: Amount of memory in the laundry queue. FreeBSD only.
- name: memmax
desc: Total amount of memory.
- name: memperc
desc: Percentage of memory in use.
- name: memwired
desc: Amount of wired memory. FreeBSD only.
- name: memwithbuffers
desc: |-
Amount of memory in use, including that used by system
Expand Down
1 change: 1 addition & 0 deletions extras/convert.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ local bool_setting = {
background = true, disable_auto_reload = true, double_buffer = true, draw_borders = true,
draw_graph_borders = true, draw_outline = true, draw_shades = true, extra_newline = true,
format_human_readable = true, no_buffers = true, out_to_console = true,
out_to_wayland = true,
out_to_ncurses = true, out_to_stderr = true, out_to_x = true, override_utf8_locale = true,
own_window = true, own_window_argb_visual = true, own_window_transparent = true,
short_units = true, show_graph_range = true, show_graph_scale = true,
Expand Down
30 changes: 29 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ set(conky_sources
display-http.hh
display-x11.cc
display-x11.hh
display-wayland.cc
display-wayland.hh
lua-config.cc
lua-config.hh
setting.cc
Expand Down Expand Up @@ -227,7 +229,7 @@ if(BUILD_PORT_MONITORS)
endif(BUILD_PORT_MONITORS)

if(BUILD_GUI)
set(gui fonts.cc fonts.h)
set(gui fonts.cc fonts.h gui.cc gui.h)
set(optional_sources ${optional_sources} ${gui})
endif(BUILD_GUI)

Expand All @@ -241,6 +243,32 @@ if(BUILD_X11)
endif(BUILD_XINERAMA)
endif(BUILD_X11)

if(BUILD_WAYLAND)
set(wl_srcs wl.cc wl.h xdg-shell-protocol.c wlr-layer-shell-protocol.c x11-color.cc x11-color.h)
set(optional_sources ${optional_sources} ${wl_srcs})
# generate protocol implementations
set(XDG_PROT_DEF "${WAYLAND_PROTOCOLS_DIR}/stable/xdg-shell/xdg-shell.xml")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-protocol.h
COMMAND ${WAYLAND_SCANNER} client-header ${XDG_PROT_DEF} xdg-shell-client-protocol.h)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-protocol.c
COMMAND ${WAYLAND_SCANNER} private-code ${XDG_PROT_DEF} xdg-shell-protocol.c
DEPENDS xdg-shell-client-protocol.h)

set(WLR_LAYER_SHELL_PROT_DEF "${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wlr-layer-shell-client-protocol.h
COMMAND ${WAYLAND_SCANNER} client-header ${WLR_LAYER_SHELL_PROT_DEF} wlr-layer-shell-client-protocol.h)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/wlr-layer-shell-protocol.c
COMMAND ${WAYLAND_SCANNER} private-code ${WLR_LAYER_SHELL_PROT_DEF} wlr-layer-shell-protocol.c
DEPENDS wlr-layer-shell-client-protocol.h)

# include output dir in include path
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif(BUILD_WAYLAND)

if(BUILD_HDDTEMP)
set(hddtemp hddtemp.cc hddtemp.h)
set(optional_sources ${optional_sources} ${hddtemp})
Expand Down
67 changes: 64 additions & 3 deletions src/colours.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@
*/
#include "conky.h"
#include "logging.h"
#include "gui.h"
#ifdef BUILD_X11
#include "x11.h"
#endif
#endif /*BUILD_X11*/
#ifdef BUILD_WAYLAND
#include "x11-color.h"
#endif /*BUILD_WAYLAND*/

/* precalculated: 31/255, and 63/255 */
#define CONST_8_TO_5_BITS 0.12156862745098
Expand Down Expand Up @@ -83,8 +87,61 @@ unsigned int adjust_colours(unsigned int colour) {
return colour;
}

#ifdef BUILD_X11

#ifdef BUILD_GUI
#ifdef BUILD_WAYLAND
static int hex_nibble_value(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
} else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
return -1;
}

long manually_get_x11_color(const char *name) {
unsigned short r, g, b;
size_t len = strlen(name);
if (OsLookupColor(-1, name, len, &r, &g, &b)) {
return 0x000000ff | ((r & 0xff) << 24) | ((g & 0xff) << 16) | ((b & 0xff) << 8);
}
if (name[0] == '#') {
name++;
len--;
}
if (len == 6 || len == 8)
{
unsigned char argb[4] = {0xff, 0, 0, 0};
for (size_t i = 0; i + 1 < len; i += 2) {
int nib1 = hex_nibble_value(name[i]);
int nib2 = hex_nibble_value(name[i+1]);
if (nib1 < 0 || nib2 < 0) {
goto err;
}
int val = (nib1 << 4) + nib2;

argb[3 - i / 2] = val;
}
long out;
memcpy(static_cast<void*>(&out), argb, 4);
return out;
}
err:
NORM_ERR("can't parse X color '%s' (%d)", name, len);
return 0xFF00FF;
}
#endif /* BUILD_WAYLAND */

long get_x11_color(const char *name) {
#ifdef BUILD_X11
#ifdef BUILD_WAYLAND
if (!display) {
return manually_get_x11_color(name);
}
#endif /*BUILD_WAYLAND*/
assert(display != nullptr);
XColor color;

color.pixel = 0;
Expand All @@ -108,9 +165,13 @@ long get_x11_color(const char *name) {
}

return static_cast<long>(color.pixel);
#endif /*BUILD_X11*/
#ifdef BUILD_WAYLAND
return manually_get_x11_color(name);
#endif /*BUILD_WAYLAND*/
}

long get_x11_color(const std::string &colour) {
return get_x11_color(colour.c_str());
}
#endif
#endif /*BUILD_GUI*/
Loading