mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-25 12:10:03 +00:00
Merge branch 'bi4k8-wayland-gui-backend'
This commit is contained in:
commit
cf16110c7a
7
.github/workflows/build-and-test-linux.yaml
vendored
7
.github/workflows/build-and-test-linux.yaml
vendored
@ -11,6 +11,7 @@ jobs:
|
||||
- ubuntu-20.04
|
||||
- ubuntu-22.04
|
||||
x11: [ON, OFF]
|
||||
wayland: [ON, OFF]
|
||||
compiler:
|
||||
- clang
|
||||
- gcc
|
||||
@ -74,6 +75,8 @@ jobs:
|
||||
libpulse-dev \
|
||||
librsvg2-dev \
|
||||
libsystemd-dev \
|
||||
libwayland-bin \
|
||||
libwayland-dev \
|
||||
libx11-dev \
|
||||
libxdamage-dev \
|
||||
libxext-dev \
|
||||
@ -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: |
|
||||
@ -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 \
|
||||
|
1
.github/workflows/build-and-test-macos.yaml
vendored
1
.github/workflows/build-and-test-macos.yaml
vendored
@ -32,6 +32,7 @@ jobs:
|
||||
cd build
|
||||
cmake .. \
|
||||
-DMAINTAINER_MODE=ON \
|
||||
-DBUILD_WAYLAND=OFF \
|
||||
-DBUILD_TESTS=ON
|
||||
- name: Compile
|
||||
working-directory: build
|
||||
|
1
.github/workflows/publish-appimage.yml
vendored
1
.github/workflows/publish-appimage.yml
vendored
@ -41,6 +41,7 @@ jobs:
|
||||
libpulse-dev \
|
||||
librsvg2-dev \
|
||||
libsystemd-dev \
|
||||
libwayland-dev \
|
||||
libx11-dev \
|
||||
libxdamage-dev \
|
||||
libxext-dev \
|
||||
|
@ -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)
|
||||
@ -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)
|
||||
|
@ -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
|
||||
@ -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)
|
||||
|
59
cmake/FindWayland.cmake
Normal file
59
cmake/FindWayland.cmake
Normal file
@ -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
|
||||
)
|
@ -42,6 +42,8 @@
|
||||
|
||||
#cmakedefine HAVE_CLOCK_GETTIME 1
|
||||
|
||||
#cmakedefine BUILD_WAYLAND 1
|
||||
|
||||
#cmakedefine BUILD_X11 1
|
||||
|
||||
#cmakedefine OWN_WINDOW 1
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
@ -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)
|
||||
|
||||
@ -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})
|
||||
|
@ -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
|
||||
@ -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;
|
||||
@ -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*/
|
||||
|
61
src/conky.cc
61
src/conky.cc
@ -54,6 +54,9 @@
|
||||
#include <sys/inotify.h>
|
||||
#pragma clang diagnostic pop
|
||||
#endif /* HAVE_SYS_INOTIFY_H */
|
||||
#ifdef BUILD_WAYLAND
|
||||
#include "wl.h"
|
||||
#endif /* BUILD_WAYLAND */
|
||||
#ifdef BUILD_X11
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wvariadic-macros"
|
||||
@ -90,6 +93,7 @@
|
||||
#include "exec.h"
|
||||
#ifdef BUILD_GUI
|
||||
#include "fonts.h"
|
||||
#include "gui.h"
|
||||
#endif
|
||||
#include "fs.h"
|
||||
#ifdef BUILD_ICONV
|
||||
@ -760,10 +764,13 @@ int get_border_total() {
|
||||
dpi_scale(border_width.get(*state));
|
||||
}
|
||||
|
||||
void remove_first_char(char* s) {
|
||||
memmove(s, s + 1, strlen(s));
|
||||
}
|
||||
|
||||
static int get_string_width_special(char *s, int special_index) {
|
||||
char *p, *final;
|
||||
special_t *current = specials;
|
||||
int idx = 1;
|
||||
int width = 0;
|
||||
long i;
|
||||
|
||||
@ -776,16 +783,16 @@ static int get_string_width_special(char *s, int special_index) {
|
||||
p = strndup(s, text_buffer_size.get(*state));
|
||||
final = p;
|
||||
|
||||
for (i = 0; i < special_index; i++) { current = current->next; }
|
||||
for (i = 0; i < idx; i++) { current = current->next; }
|
||||
for (i = 0; i <= special_index; i++) { current = current->next; }
|
||||
|
||||
while (*p != 0) {
|
||||
if (*p == SPECIAL_CHAR) {
|
||||
/* shift everything over by 1 so that the special char
|
||||
* doesn't mess up the size calculation */
|
||||
for (i = 0; i < static_cast<long>(strlen(p)); i++) {
|
||||
remove_first_char(p);
|
||||
/*for (i = 0; i < static_cast<long>(strlen(p)); i++) {
|
||||
*(p + i) = *(p + i + 1);
|
||||
}
|
||||
}*/
|
||||
if (current->type == GRAPH || current->type == GAUGE ||
|
||||
current->type == BAR) {
|
||||
width += current->width;
|
||||
@ -795,6 +802,8 @@ static int get_string_width_special(char *s, int special_index) {
|
||||
// influenced_by_font but do not include specials
|
||||
char *influenced_by_font = strdup(p);
|
||||
special_t *current_after_font = current;
|
||||
// influenced_by_font gets special chars removed, so after this loop i
|
||||
// counts the number of letters (not special chars) influenced by font
|
||||
for (i = 0; influenced_by_font[i] != 0; i++) {
|
||||
if (influenced_by_font[i] == SPECIAL_CHAR) {
|
||||
// remove specials and stop at fontchange
|
||||
@ -803,10 +812,7 @@ static int get_string_width_special(char *s, int special_index) {
|
||||
influenced_by_font[i] = 0;
|
||||
break;
|
||||
}
|
||||
{
|
||||
memmove(&influenced_by_font[i], &influenced_by_font[i + 1],
|
||||
strlen(&influenced_by_font[i + 1]) + 1);
|
||||
}
|
||||
remove_first_char(&influenced_by_font[i]);
|
||||
}
|
||||
}
|
||||
// add the length of influenced_by_font in the new font to width
|
||||
@ -815,20 +821,19 @@ static int get_string_width_special(char *s, int special_index) {
|
||||
width += calc_text_width(influenced_by_font);
|
||||
selected_font = orig_font;
|
||||
free(influenced_by_font);
|
||||
// make sure there chars counted in the new font are not again counted
|
||||
// make sure the chars counted in the new font are not again counted
|
||||
// in the old font
|
||||
int specials_skipped = 0;
|
||||
while (i > 0) {
|
||||
if (p[specials_skipped] != 1) {
|
||||
memmove(&p[specials_skipped], &p[specials_skipped + 1],
|
||||
strlen(&p[specials_skipped + 1]) + 1);
|
||||
if (p[specials_skipped] != SPECIAL_CHAR) {
|
||||
remove_first_char(&p[specials_skipped]);
|
||||
// i only counts non-special chars, so only decrement it for those
|
||||
i--;
|
||||
} else {
|
||||
specials_skipped++;
|
||||
}
|
||||
i--;
|
||||
}
|
||||
}
|
||||
idx++;
|
||||
current = current->next;
|
||||
} else {
|
||||
p++;
|
||||
@ -1480,9 +1485,7 @@ int draw_each_line_inner(char *s, int special_index, int last_special_applied) {
|
||||
cur_x, get_string_width_special(s), gap_x,
|
||||
current->arg, window.border_inner_margin,
|
||||
window.border_width); */
|
||||
if (pos_x > current->arg && pos_x > cur_x) {
|
||||
cur_x = pos_x - current->arg;
|
||||
}
|
||||
cur_x = pos_x - current->arg;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1555,7 +1558,8 @@ static void draw_text() {
|
||||
for (auto output : display_outputs()) output->begin_draw_text();
|
||||
#ifdef BUILD_GUI
|
||||
// XXX:only works if inside set_display_output()
|
||||
if (display_output() && display_output()->graphical()) {
|
||||
for (auto output : display_outputs()) {
|
||||
if (output && output->graphical()) {
|
||||
cur_y = text_start_y;
|
||||
int bw = dpi_scale(border_width.get(*state));
|
||||
|
||||
@ -1564,14 +1568,14 @@ static void draw_text() {
|
||||
if (stippled_borders.get(*state) != 0) {
|
||||
char ss[2] = {(char)dpi_scale(stippled_borders.get(*state)),
|
||||
(char)dpi_scale(stippled_borders.get(*state))};
|
||||
display_output()->set_line_style(bw, false);
|
||||
display_output()->set_dashes(ss);
|
||||
output->set_line_style(bw, false);
|
||||
output->set_dashes(ss);
|
||||
} else {
|
||||
display_output()->set_line_style(bw, true);
|
||||
output->set_line_style(bw, true);
|
||||
}
|
||||
|
||||
int offset = dpi_scale(border_inner_margin.get(*state)) + bw;
|
||||
display_output()->draw_rect(text_offset_x + text_start_x - offset,
|
||||
output->draw_rect(text_offset_x + text_start_x - offset,
|
||||
text_offset_y + text_start_y - offset,
|
||||
text_width + 2 * offset,
|
||||
text_height + 2 * offset);
|
||||
@ -1579,6 +1583,7 @@ static void draw_text() {
|
||||
|
||||
/* draw text */
|
||||
}
|
||||
}
|
||||
setup_fonts();
|
||||
#endif /* BUILD_GUI */
|
||||
for_each_line(text_buffer, draw_line);
|
||||
@ -1930,11 +1935,19 @@ static void set_default_configurations() {
|
||||
info.xmms2.status = nullptr;
|
||||
info.xmms2.playlist = nullptr;
|
||||
#endif /* BUILD_XMMS2 */
|
||||
|
||||
/* Enable a single output by default based on what was enabled at build-time */
|
||||
#ifdef BUILD_WAYLAND
|
||||
state->pushboolean(true);
|
||||
out_to_wayland.lua_set(*state);
|
||||
#else
|
||||
#ifdef BUILD_X11
|
||||
state->pushboolean(true);
|
||||
#ifdef BUILD_GUI
|
||||
out_to_x.lua_set(*state);
|
||||
#else
|
||||
state->pushboolean(true);
|
||||
out_to_stdout.lua_set(*state);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
info.users.number = 1;
|
||||
|
@ -54,6 +54,7 @@
|
||||
#include "irc.h"
|
||||
#endif /* BUILD_IRC */
|
||||
#ifdef BUILD_GUI
|
||||
#include "gui.h"
|
||||
#include "fonts.h"
|
||||
#endif /* BUILD_GUI */
|
||||
#include "fs.h"
|
||||
@ -749,7 +750,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
#endif /* BUILD_GUI */
|
||||
END OBJ(color, nullptr)
|
||||
#ifdef BUILD_GUI
|
||||
if (out_to_x.get(*state)) {
|
||||
if (out_to_gui(*state)) {
|
||||
obj->data.l =
|
||||
arg != nullptr ? get_x11_color(arg) : default_color.get(*state);
|
||||
set_current_text_color(obj->data.l);
|
||||
@ -883,7 +884,7 @@ struct text_object *construct_text_object(char *s, const char *arg, long line,
|
||||
obj->callbacks.print = &print_cat;
|
||||
obj->callbacks.free = &gen_free_opaque;
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
#ifdef BUILD_X11
|
||||
END OBJ(key_num_lock, 0) obj->callbacks.print = &print_key_num_lock;
|
||||
END OBJ(key_caps_lock, 0) obj->callbacks.print = &print_key_caps_lock;
|
||||
END OBJ(key_scroll_lock, 0) obj->callbacks.print = &print_key_scroll_lock;
|
||||
|
@ -56,6 +56,7 @@ extern void init_ncurses_output();
|
||||
extern void init_file_output();
|
||||
extern void init_http_output();
|
||||
extern void init_x11_output();
|
||||
extern void init_wayland_output();
|
||||
|
||||
/*
|
||||
* The selected and active display output.
|
||||
@ -111,6 +112,7 @@ bool initialize_display_outputs() {
|
||||
init_file_output();
|
||||
init_http_output();
|
||||
init_x11_output();
|
||||
init_wayland_output();
|
||||
|
||||
std::vector<display_output_base *> outputs;
|
||||
outputs.reserve(display_outputs->size());
|
||||
|
1197
src/display-wayland.cc
Normal file
1197
src/display-wayland.cc
Normal file
File diff suppressed because it is too large
Load Diff
89
src/display-wayland.hh
Normal file
89
src/display-wayland.hh
Normal file
@ -0,0 +1,89 @@
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (C) 2018-2021 François Revol et al.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_WAYLAND_HH
|
||||
#define DISPLAY_WAYLAND_HH
|
||||
|
||||
#include <limits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#include "display-output.hh"
|
||||
#include "luamm.hh"
|
||||
#include "wl.h"
|
||||
|
||||
namespace conky {
|
||||
|
||||
/*
|
||||
* A base class for Wayland display output.
|
||||
*/
|
||||
class display_output_wayland : public display_output_base {
|
||||
public:
|
||||
explicit display_output_wayland();
|
||||
|
||||
virtual ~display_output_wayland() {}
|
||||
|
||||
// check if available and enabled in settings
|
||||
virtual bool detect();
|
||||
// connect to DISPLAY and other stuff
|
||||
virtual bool initialize();
|
||||
virtual bool shutdown();
|
||||
|
||||
virtual bool main_loop_wait(double);
|
||||
|
||||
virtual void sigterm_cleanup();
|
||||
virtual void cleanup();
|
||||
|
||||
// drawing primitives
|
||||
virtual void set_foreground_color(long);
|
||||
|
||||
virtual int calc_text_width(const char *);
|
||||
|
||||
// GUI interface
|
||||
virtual void draw_string_at(int, int, const char *, int );
|
||||
// X11 lookalikes
|
||||
virtual void set_line_style(int, bool);
|
||||
virtual void set_dashes(char *);
|
||||
virtual void draw_line(int, int, int, int);
|
||||
virtual void draw_rect(int, int, int, int);
|
||||
virtual void fill_rect(int, int, int, int);
|
||||
virtual void draw_arc(int, int, int, int, int, int);
|
||||
virtual void move_win(int, int);
|
||||
virtual int dpi_scale(int);
|
||||
|
||||
virtual void end_draw_stuff();
|
||||
virtual void clear_text(int);
|
||||
|
||||
virtual int font_height(unsigned int);
|
||||
virtual int font_ascent(unsigned int);
|
||||
virtual int font_descent(unsigned int);
|
||||
virtual void setup_fonts(void);
|
||||
virtual void set_font(unsigned int);
|
||||
virtual void free_fonts(bool);
|
||||
virtual void load_fonts(bool);
|
||||
|
||||
// Wayland-specific
|
||||
};
|
||||
|
||||
} // namespace conky
|
||||
|
||||
#endif /* DISPLAY_WAYLAND_HH */
|
@ -51,6 +51,7 @@
|
||||
#include "display-x11.hh"
|
||||
#include "llua.h"
|
||||
#include "x11.h"
|
||||
#include "gui.h"
|
||||
#ifdef BUILD_X11
|
||||
#include "fonts.h"
|
||||
#endif
|
||||
@ -139,6 +140,9 @@ struct _x11_stuff_s {
|
||||
} x11_stuff;
|
||||
|
||||
static void X11_create_window() {
|
||||
if (!window.window) {
|
||||
return;
|
||||
}
|
||||
setup_fonts();
|
||||
load_fonts(utf8_mode.get(*state));
|
||||
#ifdef BUILD_XFT
|
||||
@ -221,6 +225,8 @@ bool display_output_x11::shutdown() { return false; }
|
||||
|
||||
bool display_output_x11::main_loop_wait(double t) {
|
||||
/* wait for X event or timeout */
|
||||
if(!display || !window.gc)
|
||||
return true;
|
||||
|
||||
if (XPending(display) == 0) {
|
||||
fd_set fdsr;
|
||||
|
11
src/fonts.cc
11
src/fonts.cc
@ -28,6 +28,7 @@
|
||||
*/
|
||||
|
||||
#include "fonts.h"
|
||||
#include "gui.h"
|
||||
#include "display-output.hh"
|
||||
#include "logging.h"
|
||||
|
||||
@ -40,7 +41,7 @@ void font_setting::lua_setter(lua::state &l, bool init) {
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (init && out_to_x.get(*state)) {
|
||||
if (init) {
|
||||
if (fonts.empty()) { fonts.resize(1); }
|
||||
fonts[0].name = do_convert(l, -1).first;
|
||||
}
|
||||
@ -66,7 +67,7 @@ void setup_fonts() {
|
||||
}
|
||||
|
||||
int add_font(const char *data_in) {
|
||||
if (!out_to_x.get(*state)) { return 0; }
|
||||
if (!out_to_gui(*state)) { return 0; }
|
||||
fonts.emplace_back();
|
||||
fonts.rbegin()->name = data_in;
|
||||
|
||||
@ -85,16 +86,16 @@ void load_fonts(bool utf8) {
|
||||
}
|
||||
|
||||
int font_height() {
|
||||
assert(selected_font < fonts.size());
|
||||
//assert(selected_font < fonts.size());
|
||||
return display_output()->font_height(selected_font);
|
||||
}
|
||||
|
||||
int font_ascent() {
|
||||
assert(selected_font < fonts.size());
|
||||
//assert(selected_font < fonts.size());
|
||||
return display_output()->font_ascent(selected_font);
|
||||
}
|
||||
|
||||
int font_descent() {
|
||||
assert(selected_font < fonts.size());
|
||||
//assert(selected_font < fonts.size());
|
||||
return display_output()->font_descent(selected_font);
|
||||
}
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "conky.h"
|
||||
#include "x11.h"
|
||||
|
||||
/* for fonts */
|
||||
struct font_list {
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#include "gui.h"
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
namespace conky {
|
||||
|
245
src/gui.cc
Normal file
245
src/gui.cc
Normal file
@ -0,0 +1,245 @@
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Any original torsmo code is licensed under the BSD license
|
||||
*
|
||||
* All code written since the fork of torsmo is licensed under the GPL
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||
* Copyright (c) 2005-2021 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "config.h"
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
#include "gui.h"
|
||||
#include "wl.h"
|
||||
|
||||
#ifdef BUILD_IMLIB2
|
||||
#include "imlib2.h"
|
||||
#endif /* BUILD_IMLIB2 */
|
||||
#ifndef OWN_WINDOW
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
bool have_argb_visual;
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
/* basic display attributes */
|
||||
int display_width;
|
||||
int display_height;
|
||||
int screen;
|
||||
|
||||
/* workarea where window / text is aligned (from _NET_WORKAREA on X11) */
|
||||
int workarea[4];
|
||||
|
||||
/* Window stuff */
|
||||
char window_created = 0;
|
||||
|
||||
/* local prototypes */
|
||||
#ifdef BUILD_X11
|
||||
void x11_init_window(lua::state &l, bool own);
|
||||
#endif /*BUILD_X11*/
|
||||
|
||||
/********************* <SETTINGS> ************************/
|
||||
|
||||
|
||||
priv::colour_setting background_colour("own_window_colour", 0);
|
||||
|
||||
bool out_to_gui(lua::state &l) {
|
||||
bool to_gui = false;
|
||||
#ifdef BUILD_X11
|
||||
to_gui |= out_to_x.get(l);
|
||||
#endif /* BUILD_X11 */
|
||||
#ifdef BUILD_WAYLAND
|
||||
to_gui |= out_to_wayland.get(l);
|
||||
#endif /* BUILD_WAYLAND */
|
||||
return to_gui;
|
||||
}
|
||||
|
||||
namespace priv {
|
||||
void own_window_setting::lua_setter(lua::state &l, bool init) {
|
||||
lua::stack_sentry s(l, -2);
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (init) {
|
||||
if (do_convert(l, -1).first) {
|
||||
#ifndef OWN_WINDOW
|
||||
std::cerr << "Support for the own_window setting has been "
|
||||
"disabled during compilation\n";
|
||||
l.pop();
|
||||
l.pushboolean(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (out_to_gui(l)) {
|
||||
#ifdef BUILD_X11
|
||||
x11_init_window(l, do_convert(l, -1).first);
|
||||
#endif /*BUILD_X11*/
|
||||
} else {
|
||||
// own_window makes no sense when not drawing to X
|
||||
l.pop();
|
||||
l.pushboolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
void colour_setting::lua_setter(lua::state &l, bool init) {
|
||||
lua::stack_sentry s(l, -2);
|
||||
Base::lua_setter(l, init);
|
||||
++s;
|
||||
}
|
||||
} // namespace priv
|
||||
|
||||
template <>
|
||||
conky::lua_traits<alignment>::Map conky::lua_traits<alignment>::map = {
|
||||
{"top_left", TOP_LEFT},
|
||||
{"top_right", TOP_RIGHT},
|
||||
{"top_middle", TOP_MIDDLE},
|
||||
{"bottom_left", BOTTOM_LEFT},
|
||||
{"bottom_right", BOTTOM_RIGHT},
|
||||
{"bottom_middle", BOTTOM_MIDDLE},
|
||||
{"middle_left", MIDDLE_LEFT},
|
||||
{"middle_middle", MIDDLE_MIDDLE},
|
||||
{"middle_right", MIDDLE_RIGHT},
|
||||
{"tl", TOP_LEFT},
|
||||
{"tr", TOP_RIGHT},
|
||||
{"tm", TOP_MIDDLE},
|
||||
{"bl", BOTTOM_LEFT},
|
||||
{"br", BOTTOM_RIGHT},
|
||||
{"bm", BOTTOM_MIDDLE},
|
||||
{"ml", MIDDLE_LEFT},
|
||||
{"mm", MIDDLE_MIDDLE},
|
||||
{"mr", MIDDLE_RIGHT},
|
||||
{"none", NONE}};
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
template <>
|
||||
conky::lua_traits<window_type>::Map conky::lua_traits<window_type>::map = {
|
||||
{"normal", TYPE_NORMAL},
|
||||
{"dock", TYPE_DOCK},
|
||||
{"panel", TYPE_PANEL},
|
||||
{"desktop", TYPE_DESKTOP},
|
||||
{"override", TYPE_OVERRIDE}};
|
||||
|
||||
template <>
|
||||
conky::lua_traits<window_hints>::Map conky::lua_traits<window_hints>::map = {
|
||||
{"undecorated", HINT_UNDECORATED},
|
||||
{"below", HINT_BELOW},
|
||||
{"above", HINT_ABOVE},
|
||||
{"sticky", HINT_STICKY},
|
||||
{"skip_taskbar", HINT_SKIP_TASKBAR},
|
||||
{"skip_pager", HINT_SKIP_PAGER}};
|
||||
|
||||
std::pair<uint16_t, bool> window_hints_traits::convert(
|
||||
lua::state &l, int index, const std::string &name) {
|
||||
lua::stack_sentry s(l);
|
||||
l.checkstack(1);
|
||||
|
||||
std::string hints = l.tostring(index);
|
||||
// add a sentinel to simplify the following loop
|
||||
hints += ',';
|
||||
size_t pos = 0;
|
||||
size_t newpos;
|
||||
uint16_t ret = 0;
|
||||
while ((newpos = hints.find_first_of(", ", pos)) != std::string::npos) {
|
||||
if (newpos > pos) {
|
||||
l.pushstring(hints.substr(pos, newpos - pos));
|
||||
auto t = conky::lua_traits<window_hints>::convert(l, -1, name);
|
||||
if (!t.second) { return {0, false}; }
|
||||
SET_HINT(ret, t.first);
|
||||
l.pop();
|
||||
}
|
||||
pos = newpos + 1;
|
||||
}
|
||||
return {ret, true};
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
namespace {
|
||||
// used to set the default value for own_window_title
|
||||
std::string gethostnamecxx() {
|
||||
update_uname();
|
||||
return info.uname_s.nodename;
|
||||
}
|
||||
} // namespace
|
||||
#endif /* OWN_WINDOW */
|
||||
|
||||
/*
|
||||
* The order of these settings cannot be completely arbitrary. Some of them
|
||||
* depend on others, and the setters are called in the order in which they are
|
||||
* defined. The order should be: x11_display_name -> out_to_x -> everything colour
|
||||
* related
|
||||
* -> border_*, own_window_*, etc -> own_window ->
|
||||
* double_buffer -> imlib_cache_size
|
||||
*/
|
||||
|
||||
conky::simple_config_setting<alignment> text_alignment("alignment", BOTTOM_LEFT,
|
||||
false);
|
||||
|
||||
conky::simple_config_setting<std::string> display_name("display", std::string(),
|
||||
false);
|
||||
|
||||
priv::colour_setting color[10] = {{"color0", 0xffffff}, {"color1", 0xffffff},
|
||||
{"color2", 0xffffff}, {"color3", 0xffffff},
|
||||
{"color4", 0xffffff}, {"color5", 0xffffff},
|
||||
{"color6", 0xffffff}, {"color7", 0xffffff},
|
||||
{"color8", 0xffffff}, {"color9", 0xffffff}};
|
||||
priv::colour_setting default_color("default_color", 0xffffff);
|
||||
priv::colour_setting default_shade_color("default_shade_color", 0x000000);
|
||||
priv::colour_setting default_outline_color("default_outline_color", 0x000000);
|
||||
|
||||
conky::range_config_setting<int> border_inner_margin(
|
||||
"border_inner_margin", 0, std::numeric_limits<int>::max(), 3, true);
|
||||
conky::range_config_setting<int> border_outer_margin(
|
||||
"border_outer_margin", 0, std::numeric_limits<int>::max(), 1, true);
|
||||
conky::range_config_setting<int> border_width("border_width", 0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1, true);
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
conky::simple_config_setting<bool> set_transparent("own_window_transparent",
|
||||
false, false);
|
||||
conky::simple_config_setting<std::string> own_window_class("own_window_class",
|
||||
PACKAGE_NAME, false);
|
||||
|
||||
conky::simple_config_setting<std::string> own_window_title(
|
||||
"own_window_title", PACKAGE_NAME " (" + gethostnamecxx() + ")", false);
|
||||
|
||||
conky::simple_config_setting<window_type> own_window_type("own_window_type",
|
||||
TYPE_NORMAL, false);
|
||||
conky::simple_config_setting<uint16_t, window_hints_traits> own_window_hints(
|
||||
"own_window_hints", 0, false);
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
conky::range_config_setting<int> own_window_argb_value("own_window_argb_value",
|
||||
0, 255, 255, false);
|
||||
#endif /* BUILD_ARGB */
|
||||
#endif /* OWN_WINDOW */
|
||||
priv::own_window_setting own_window;
|
||||
|
||||
/******************** </SETTINGS> ************************/
|
167
src/gui.h
Normal file
167
src/gui.h
Normal file
@ -0,0 +1,167 @@
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2005-2021 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
#ifndef GUI_H_
|
||||
#define GUI_H_
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#endif /*BUILD_X11*/
|
||||
|
||||
#include "colours.h"
|
||||
#include "setting.hh"
|
||||
|
||||
#if defined(BUILD_ARGB) && defined(OWN_WINDOW)
|
||||
/* true if use_argb_visual=true and argb visual was found*/
|
||||
extern bool have_argb_visual;
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_X11
|
||||
extern Display *display;
|
||||
#endif
|
||||
extern int display_width;
|
||||
extern int display_height;
|
||||
extern int screen;
|
||||
extern int workarea[4];
|
||||
|
||||
extern char window_created;
|
||||
|
||||
void destroy_window(void);
|
||||
void create_gc(void);
|
||||
void set_struts(int);
|
||||
|
||||
bool out_to_gui(lua::state &l);
|
||||
|
||||
void print_monitor(struct text_object *, char *, unsigned int);
|
||||
void print_monitor_number(struct text_object *, char *, unsigned int);
|
||||
void print_desktop(struct text_object *, char *, unsigned int);
|
||||
void print_desktop_number(struct text_object *, char *, unsigned int);
|
||||
void print_desktop_name(struct text_object *, char *, unsigned int);
|
||||
|
||||
/* Num lock, Scroll lock, Caps Lock */
|
||||
void print_key_num_lock(struct text_object *, char *, unsigned int);
|
||||
void print_key_caps_lock(struct text_object *, char *, unsigned int);
|
||||
void print_key_scroll_lock(struct text_object *, char *, unsigned int);
|
||||
|
||||
/* Keyboard layout and mouse speed in percentage */
|
||||
void print_keyboard_layout(struct text_object *, char *, unsigned int);
|
||||
void print_mouse_speed(struct text_object *, char *, unsigned int);
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
void xdbe_swap_buffers(void);
|
||||
#else
|
||||
void xpmdb_swap_buffers(void);
|
||||
#endif /* BUILD_XDBE */
|
||||
|
||||
/* alignments */
|
||||
enum alignment {
|
||||
TOP_LEFT,
|
||||
TOP_RIGHT,
|
||||
TOP_MIDDLE,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM_MIDDLE,
|
||||
MIDDLE_LEFT,
|
||||
MIDDLE_MIDDLE,
|
||||
MIDDLE_RIGHT,
|
||||
NONE
|
||||
};
|
||||
|
||||
extern conky::simple_config_setting<alignment> text_alignment;
|
||||
|
||||
namespace priv {
|
||||
class own_window_setting : public conky::simple_config_setting<bool> {
|
||||
typedef conky::simple_config_setting<bool> Base;
|
||||
|
||||
protected:
|
||||
virtual void lua_setter(lua::state &l, bool init);
|
||||
|
||||
public:
|
||||
own_window_setting() : Base("own_window", false, false) {}
|
||||
};
|
||||
|
||||
struct colour_traits {
|
||||
static const lua::Type type = lua::TSTRING;
|
||||
typedef unsigned long Type;
|
||||
|
||||
static inline std::pair<Type, bool> convert(lua::state &l, int index,
|
||||
const std::string &) {
|
||||
return {get_x11_color(l.tostring(index)), true};
|
||||
}
|
||||
};
|
||||
|
||||
class colour_setting
|
||||
: public conky::simple_config_setting<unsigned long, colour_traits> {
|
||||
typedef conky::simple_config_setting<unsigned long, colour_traits> Base;
|
||||
|
||||
protected:
|
||||
virtual void lua_setter(lua::state &l, bool init);
|
||||
|
||||
public:
|
||||
colour_setting(const std::string &name_, unsigned long default_value_ = 0)
|
||||
: Base(name_, default_value_, true) {}
|
||||
};
|
||||
} // namespace priv
|
||||
|
||||
extern conky::simple_config_setting<std::string> display_name;
|
||||
extern conky::simple_config_setting<int> head_index;
|
||||
extern priv::colour_setting color[10];
|
||||
extern priv::colour_setting default_color;
|
||||
extern priv::colour_setting default_shade_color;
|
||||
extern priv::colour_setting default_outline_color;
|
||||
|
||||
extern conky::range_config_setting<int> border_inner_margin;
|
||||
extern conky::range_config_setting<int> border_outer_margin;
|
||||
extern conky::range_config_setting<int> border_width;
|
||||
|
||||
extern conky::simple_config_setting<bool> forced_redraw;
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
extern conky::simple_config_setting<bool> set_transparent;
|
||||
extern conky::simple_config_setting<std::string> own_window_class;
|
||||
extern conky::simple_config_setting<std::string> own_window_title;
|
||||
extern conky::simple_config_setting<window_type> own_window_type;
|
||||
|
||||
struct window_hints_traits {
|
||||
static const lua::Type type = lua::TSTRING;
|
||||
typedef uint16_t Type;
|
||||
static std::pair<Type, bool> convert(lua::state &l, int index,
|
||||
const std::string &name);
|
||||
};
|
||||
extern conky::simple_config_setting<uint16_t, window_hints_traits>
|
||||
own_window_hints;
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
extern priv::colour_setting background_colour;
|
||||
extern conky::simple_config_setting<bool> use_argb_visual;
|
||||
|
||||
/* range of 0-255 for alpha */
|
||||
extern conky::range_config_setting<int> own_window_argb_value;
|
||||
#endif /*BUILD_ARGB*/
|
||||
#endif /*OWN_WINDOW*/
|
||||
extern priv::own_window_setting own_window;
|
||||
|
||||
#endif /*GUI_H_*/
|
||||
#endif /* BUILD_GUI */
|
@ -70,6 +70,9 @@ void imlib_cache_size_setting::lua_setter(lua::state &l, bool init) {
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (display == nullptr || window.visual == nullptr)
|
||||
return;
|
||||
|
||||
if (init && out_to_x.get(l)) {
|
||||
image_list_start = image_list_end = nullptr;
|
||||
context = imlib_context_new();
|
||||
|
18
src/llua.cc
18
src/llua.cc
@ -27,6 +27,14 @@
|
||||
#include "conky.h"
|
||||
#include "logging.h"
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
#include "gui.h"
|
||||
#endif /* BUILD_GUI */
|
||||
|
||||
extern "C" {
|
||||
#include <tolua++.h>
|
||||
}
|
||||
@ -485,13 +493,20 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
|
||||
if (lua_L == nullptr) { return; }
|
||||
lua_newtable(lua_L);
|
||||
|
||||
#ifdef BUILD_X11
|
||||
if (out_to_x.get(*state)) {
|
||||
llua_set_userdata("drawable", "Drawable", (void *)&window.drawable);
|
||||
llua_set_userdata("visual", "Visual", window.visual);
|
||||
llua_set_userdata("display", "Display", display);
|
||||
}
|
||||
#endif /*BUILD_X11*/
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
if (out_to_gui(*state)) {
|
||||
#ifdef BUILD_X11
|
||||
llua_set_number("width", window.width);
|
||||
llua_set_number("height", window.height);
|
||||
#endif /*BUILD_X11*/
|
||||
llua_set_number("border_inner_margin", border_inner_margin.get(*state));
|
||||
llua_set_number("border_outer_margin", border_outer_margin.get(*state));
|
||||
llua_set_number("border_width", border_width.get(*state));
|
||||
@ -503,6 +518,7 @@ void llua_setup_window_table(int text_start_x, int text_start_y, int text_width,
|
||||
|
||||
lua_setglobal(lua_L, "conky_window");
|
||||
}
|
||||
#endif /*BUILD_GUI*/
|
||||
}
|
||||
|
||||
void llua_update_window_table(int text_start_x, int text_start_y,
|
||||
@ -516,8 +532,10 @@ void llua_update_window_table(int text_start_x, int text_start_y,
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef BUILD_X11
|
||||
llua_set_number("width", window.width);
|
||||
llua_set_number("height", window.height);
|
||||
#endif /*BUILD_X11*/
|
||||
|
||||
llua_set_number("text_start_x", text_start_x);
|
||||
llua_set_number("text_start_y", text_start_y);
|
||||
|
@ -32,10 +32,6 @@ extern "C" {
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef BUILD_X11
|
||||
#include "x11.h"
|
||||
#endif /* BUILD_X11 */
|
||||
|
||||
#define LUAPREFIX "conky_"
|
||||
|
||||
#ifdef HAVE_SYS_INOTIFY_H
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "logging.h"
|
||||
#include "specials.h"
|
||||
#include "text_object.h"
|
||||
#include "x11.h"
|
||||
|
||||
/**
|
||||
* Length of a character in bytes.
|
||||
|
@ -28,6 +28,7 @@
|
||||
*/
|
||||
#include "conky.h"
|
||||
#ifdef BUILD_GUI
|
||||
#include "gui.h"
|
||||
#include "fonts.h"
|
||||
#endif /* BUILD_GUI */
|
||||
#include <cmath>
|
||||
@ -389,7 +390,7 @@ void new_gauge_in_shell(struct text_object *obj, char *p,
|
||||
}
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
void new_gauge_in_x11(struct text_object *obj, char *buf, double usage) {
|
||||
void new_gauge_in_gui(struct text_object *obj, char *buf, double usage) {
|
||||
struct special_t *s = nullptr;
|
||||
auto *g = static_cast<struct gauge *>(obj->special_data);
|
||||
|
||||
@ -420,7 +421,7 @@ void new_gauge(struct text_object *obj, char *p, unsigned int p_max_size,
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
if (display_output() && display_output()->graphical()) {
|
||||
new_gauge_in_x11(obj, p, usage);
|
||||
new_gauge_in_gui(obj, p, usage);
|
||||
}
|
||||
if (out_to_stdout.get(*state)) {
|
||||
new_gauge_in_shell(obj, p, p_max_size, usage);
|
||||
@ -705,7 +706,7 @@ static void new_bar_in_shell(struct text_object *obj, char *buffer,
|
||||
}
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
static void new_bar_in_x11(struct text_object *obj, char *buf, double usage) {
|
||||
static void new_bar_in_gui(struct text_object *obj, char *buf, double usage) {
|
||||
struct special_t *s = nullptr;
|
||||
auto *b = static_cast<struct bar *>(obj->special_data);
|
||||
|
||||
@ -737,7 +738,7 @@ void new_bar(struct text_object *obj, char *p, unsigned int p_max_size,
|
||||
|
||||
#ifdef BUILD_GUI
|
||||
if (display_output() && display_output()->graphical()) {
|
||||
new_bar_in_x11(obj, p, usage);
|
||||
new_bar_in_gui(obj, p, usage);
|
||||
}
|
||||
if (out_to_stdout.get(*state)) {
|
||||
new_bar_in_shell(obj, p, p_max_size, usage);
|
||||
|
118
src/wl.cc
Normal file
118
src/wl.cc
Normal file
@ -0,0 +1,118 @@
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Any original torsmo code is licensed under the BSD license
|
||||
*
|
||||
* All code written since the fork of torsmo is licensed under the GPL
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||
* Copyright (c) 2005-2021 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <cstring>
|
||||
|
||||
#include "conky.h"
|
||||
#include "wl.h"
|
||||
|
||||
#ifdef BUILD_WAYLAND
|
||||
|
||||
namespace priv {
|
||||
void out_to_wayland_setting::lua_setter(lua::state &l, bool init) {
|
||||
lua::stack_sentry s(l, -2);
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (init && do_convert(l, -1).first) {
|
||||
//init
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
void out_to_wayland_setting::cleanup(lua::state &l) {
|
||||
lua::stack_sentry s(l, -1);
|
||||
|
||||
if (do_convert(l, -1).first) {
|
||||
//deinit
|
||||
}
|
||||
|
||||
l.pop();
|
||||
}
|
||||
} // namespace priv
|
||||
|
||||
priv::out_to_wayland_setting out_to_wayland;
|
||||
|
||||
static const char NOT_IN_WAYLAND[] = "Not running in Wayland";
|
||||
|
||||
__attribute__((weak)) void print_monitor(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
strncpy(p, NOT_IN_WAYLAND, p_max_size);
|
||||
return;
|
||||
}
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_monitor_number(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
strncpy(p, NOT_IN_WAYLAND, p_max_size);
|
||||
return;
|
||||
}
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop(struct text_object *obj, char *p, unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
strncpy(p, NOT_IN_WAYLAND, p_max_size);
|
||||
return;
|
||||
}
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop_number(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
strncpy(p, NOT_IN_WAYLAND, p_max_size);
|
||||
return;
|
||||
}
|
||||
snprintf(p, p_max_size, "%d", -1);
|
||||
}
|
||||
|
||||
__attribute__((weak)) void print_desktop_name(struct text_object *obj, char *p,
|
||||
unsigned int p_max_size) {
|
||||
(void)obj;
|
||||
|
||||
if (!out_to_wayland.get(*state)) {
|
||||
strncpy(p, NOT_IN_WAYLAND, p_max_size);
|
||||
} else {
|
||||
strncpy(p, "NYI", p_max_size);
|
||||
}
|
||||
}
|
||||
#endif
|
52
src/wl.h
Normal file
52
src/wl.h
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
*
|
||||
* Conky, a system monitor, based on torsmo
|
||||
*
|
||||
* Any original torsmo code is licensed under the BSD license
|
||||
*
|
||||
* All code written since the fork of torsmo is licensed under the GPL
|
||||
*
|
||||
* Please see COPYING for details
|
||||
*
|
||||
* Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
|
||||
* Copyright (c) 2005-2021 Brenden Matthews, Philip Kovacs, et. al.
|
||||
* (see AUTHORS)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(BUILD_WAYLAND) && !defined(CONKY_WL_H)
|
||||
#define CONKY_WL_H
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "setting.hh"
|
||||
|
||||
namespace priv {
|
||||
class out_to_wayland_setting : public conky::simple_config_setting<bool> {
|
||||
typedef conky::simple_config_setting<bool> Base;
|
||||
|
||||
protected:
|
||||
virtual void lua_setter(lua::state &l, bool init);
|
||||
virtual void cleanup(lua::state &l);
|
||||
|
||||
public:
|
||||
out_to_wayland_setting() : Base("out_to_wayland", false, false) {}
|
||||
};
|
||||
} // namespace priv
|
||||
|
||||
extern priv::out_to_wayland_setting out_to_wayland;
|
||||
|
||||
#endif /* CONKY_WL_H */
|
390
src/wlr-layer-shell-unstable-v1.xml
Normal file
390
src/wlr-layer-shell-unstable-v1.xml
Normal file
@ -0,0 +1,390 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<protocol name="wlr_layer_shell_unstable_v1">
|
||||
<copyright>
|
||||
Copyright © 2017 Drew DeVault
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that copyright notice and this permission
|
||||
notice appear in supporting documentation, and that the name of
|
||||
the copyright holders not be used in advertising or publicity
|
||||
pertaining to distribution of the software without specific,
|
||||
written prior permission. The copyright holders make no
|
||||
representations about the suitability of this software for any
|
||||
purpose. It is provided "as is" without express or implied
|
||||
warranty.
|
||||
|
||||
THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|
||||
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
|
||||
AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
||||
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwlr_layer_shell_v1" version="4">
|
||||
<description summary="create surfaces that are layers of the desktop">
|
||||
Clients can use this interface to assign the surface_layer role to
|
||||
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||
rendered with a defined z-depth respective to each other. They may also be
|
||||
anchored to the edges and corners of a screen and specify input handling
|
||||
semantics. This interface should be suitable for the implementation of
|
||||
many desktop shell components, and a broad number of other applications
|
||||
that interact with the desktop.
|
||||
</description>
|
||||
|
||||
<request name="get_layer_surface">
|
||||
<description summary="create a layer_surface from a surface">
|
||||
Create a layer surface for an existing surface. This assigns the role of
|
||||
layer_surface, or raises a protocol error if another role is already
|
||||
assigned.
|
||||
|
||||
Creating a layer surface from a wl_surface which has a buffer attached
|
||||
or committed is a client error, and any attempts by a client to attach
|
||||
or manipulate a buffer prior to the first layer_surface.configure call
|
||||
must also be treated as errors.
|
||||
|
||||
After creating a layer_surface object and setting it up, the client
|
||||
must perform an initial commit without any buffer attached.
|
||||
The compositor will reply with a layer_surface.configure event.
|
||||
The client must acknowledge it and is then allowed to attach a buffer
|
||||
to map the surface.
|
||||
|
||||
You may pass NULL for output to allow the compositor to decide which
|
||||
output to use. Generally this will be the one that the user most
|
||||
recently interacted with.
|
||||
|
||||
Clients can specify a namespace that defines the purpose of the layer
|
||||
surface.
|
||||
</description>
|
||||
<arg name="id" type="new_id" interface="zwlr_layer_surface_v1"/>
|
||||
<arg name="surface" type="object" interface="wl_surface"/>
|
||||
<arg name="output" type="object" interface="wl_output" allow-null="true"/>
|
||||
<arg name="layer" type="uint" enum="layer" summary="layer to add this surface to"/>
|
||||
<arg name="namespace_" type="string" summary="namespace for the layer surface"/>
|
||||
</request>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="role" value="0" summary="wl_surface has another role"/>
|
||||
<entry name="invalid_layer" value="1" summary="layer value is invalid"/>
|
||||
<entry name="already_constructed" value="2" summary="wl_surface has a buffer attached or committed"/>
|
||||
</enum>
|
||||
|
||||
<enum name="layer">
|
||||
<description summary="available layers for surfaces">
|
||||
These values indicate which layers a surface can be rendered in. They
|
||||
are ordered by z depth, bottom-most first. Traditional shell surfaces
|
||||
will typically be rendered between the bottom and top layers.
|
||||
Fullscreen shell surfaces are typically rendered at the top layer.
|
||||
Multiple surfaces can share a single layer, and ordering within a
|
||||
single layer is undefined.
|
||||
</description>
|
||||
|
||||
<entry name="background" value="0"/>
|
||||
<entry name="bottom" value="1"/>
|
||||
<entry name="top" value="2"/>
|
||||
<entry name="overlay" value="3"/>
|
||||
</enum>
|
||||
|
||||
<!-- Version 3 additions -->
|
||||
|
||||
<request name="destroy" type="destructor" since="3">
|
||||
<description summary="destroy the layer_shell object">
|
||||
This request indicates that the client will not use the layer_shell
|
||||
object any more. Objects that have been created through this instance
|
||||
are not affected.
|
||||
</description>
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_layer_surface_v1" version="4">
|
||||
<description summary="layer metadata interface">
|
||||
An interface that may be implemented by a wl_surface, for surfaces that
|
||||
are designed to be rendered as a layer of a stacked desktop-like
|
||||
environment.
|
||||
|
||||
Layer surface state (layer, size, anchor, exclusive zone,
|
||||
margin, interactivity) is double-buffered, and will be applied at the
|
||||
time wl_surface.commit of the corresponding wl_surface is called.
|
||||
|
||||
Attaching a null buffer to a layer surface unmaps it.
|
||||
|
||||
Unmapping a layer_surface means that the surface cannot be shown by the
|
||||
compositor until it is explicitly mapped again. The layer_surface
|
||||
returns to the state it had right after layer_shell.get_layer_surface.
|
||||
The client can re-map the surface by performing a commit without any
|
||||
buffer attached, waiting for a configure event and handling it as usual.
|
||||
</description>
|
||||
|
||||
<request name="set_size">
|
||||
<description summary="sets the size of the surface">
|
||||
Sets the size of the surface in surface-local coordinates. The
|
||||
compositor will display the surface centered with respect to its
|
||||
anchors.
|
||||
|
||||
If you pass 0 for either value, the compositor will assign it and
|
||||
inform you of the assignment in the configure event. You must set your
|
||||
anchor to opposite edges in the dimensions you omit; not doing so is a
|
||||
protocol error. Both values are 0 by default.
|
||||
|
||||
Size is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="width" type="uint"/>
|
||||
<arg name="height" type="uint"/>
|
||||
</request>
|
||||
|
||||
<request name="set_anchor">
|
||||
<description summary="configures the anchor point of the surface">
|
||||
Requests that the compositor anchor the surface to the specified edges
|
||||
and corners. If two orthogonal edges are specified (e.g. 'top' and
|
||||
'left'), then the anchor point will be the intersection of the edges
|
||||
(e.g. the top left corner of the output); otherwise the anchor point
|
||||
will be centered on that edge, or in the center if none is specified.
|
||||
|
||||
Anchor is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="anchor" type="uint" enum="anchor"/>
|
||||
</request>
|
||||
|
||||
<request name="set_exclusive_zone">
|
||||
<description summary="configures the exclusive geometry of this surface">
|
||||
Requests that the compositor avoids occluding an area with other
|
||||
surfaces. The compositor's use of this information is
|
||||
implementation-dependent - do not assume that this region will not
|
||||
actually be occluded.
|
||||
|
||||
A positive value is only meaningful if the surface is anchored to one
|
||||
edge or an edge and both perpendicular edges. If the surface is not
|
||||
anchored, anchored to only two perpendicular edges (a corner), anchored
|
||||
to only two parallel edges or anchored to all edges, a positive value
|
||||
will be treated the same as zero.
|
||||
|
||||
A positive zone is the distance from the edge in surface-local
|
||||
coordinates to consider exclusive.
|
||||
|
||||
Surfaces that do not wish to have an exclusive zone may instead specify
|
||||
how they should interact with surfaces that do. If set to zero, the
|
||||
surface indicates that it would like to be moved to avoid occluding
|
||||
surfaces with a positive exclusive zone. If set to -1, the surface
|
||||
indicates that it would not like to be moved to accommodate for other
|
||||
surfaces, and the compositor should extend it all the way to the edges
|
||||
it is anchored to.
|
||||
|
||||
For example, a panel might set its exclusive zone to 10, so that
|
||||
maximized shell surfaces are not shown on top of it. A notification
|
||||
might set its exclusive zone to 0, so that it is moved to avoid
|
||||
occluding the panel, but shell surfaces are shown underneath it. A
|
||||
wallpaper or lock screen might set their exclusive zone to -1, so that
|
||||
they stretch below or over the panel.
|
||||
|
||||
The default value is 0.
|
||||
|
||||
Exclusive zone is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="zone" type="int"/>
|
||||
</request>
|
||||
|
||||
<request name="set_margin">
|
||||
<description summary="sets a margin from the anchor point">
|
||||
Requests that the surface be placed some distance away from the anchor
|
||||
point on the output, in surface-local coordinates. Setting this value
|
||||
for edges you are not anchored to has no effect.
|
||||
|
||||
The exclusive zone includes the margin.
|
||||
|
||||
Margin is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="top" type="int"/>
|
||||
<arg name="right" type="int"/>
|
||||
<arg name="bottom" type="int"/>
|
||||
<arg name="left" type="int"/>
|
||||
</request>
|
||||
|
||||
<enum name="keyboard_interactivity">
|
||||
<description summary="types of keyboard interaction possible for a layer shell surface">
|
||||
Types of keyboard interaction possible for layer shell surfaces. The
|
||||
rationale for this is twofold: (1) some applications are not interested
|
||||
in keyboard events and not allowing them to be focused can improve the
|
||||
desktop experience; (2) some applications will want to take exclusive
|
||||
keyboard focus.
|
||||
</description>
|
||||
|
||||
<entry name="none" value="0">
|
||||
<description summary="no keyboard focus is possible">
|
||||
This value indicates that this surface is not interested in keyboard
|
||||
events and the compositor should never assign it the keyboard focus.
|
||||
|
||||
This is the default value, set for newly created layer shell surfaces.
|
||||
|
||||
This is useful for e.g. desktop widgets that display information or
|
||||
only have interaction with non-keyboard input devices.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="exclusive" value="1">
|
||||
<description summary="request exclusive keyboard focus">
|
||||
Request exclusive keyboard focus if this surface is above the shell surface layer.
|
||||
|
||||
For the top and overlay layers, the seat will always give
|
||||
exclusive keyboard focus to the top-most layer which has keyboard
|
||||
interactivity set to exclusive. If this layer contains multiple
|
||||
surfaces with keyboard interactivity set to exclusive, the compositor
|
||||
determines the one receiving keyboard events in an implementation-
|
||||
defined manner. In this case, no guarantee is made when this surface
|
||||
will receive keyboard focus (if ever).
|
||||
|
||||
For the bottom and background layers, the compositor is allowed to use
|
||||
normal focus semantics.
|
||||
|
||||
This setting is mainly intended for applications that need to ensure
|
||||
they receive all keyboard events, such as a lock screen or a password
|
||||
prompt.
|
||||
</description>
|
||||
</entry>
|
||||
<entry name="on_demand" value="2" since="4">
|
||||
<description summary="request regular keyboard focus semantics">
|
||||
This requests the compositor to allow this surface to be focused and
|
||||
unfocused by the user in an implementation-defined manner. The user
|
||||
should be able to unfocus this surface even regardless of the layer
|
||||
it is on.
|
||||
|
||||
Typically, the compositor will want to use its normal mechanism to
|
||||
manage keyboard focus between layer shell surfaces with this setting
|
||||
and regular toplevels on the desktop layer (e.g. click to focus).
|
||||
Nevertheless, it is possible for a compositor to require a special
|
||||
interaction to focus or unfocus layer shell surfaces (e.g. requiring
|
||||
a click even if focus follows the mouse normally, or providing a
|
||||
keybinding to switch focus between layers).
|
||||
|
||||
This setting is mainly intended for desktop shell components (e.g.
|
||||
panels) that allow keyboard interaction. Using this option can allow
|
||||
implementing a desktop shell that can be fully usable without the
|
||||
mouse.
|
||||
</description>
|
||||
</entry>
|
||||
</enum>
|
||||
|
||||
<request name="set_keyboard_interactivity">
|
||||
<description summary="requests keyboard events">
|
||||
Set how keyboard events are delivered to this surface. By default,
|
||||
layer shell surfaces do not receive keyboard events; this request can
|
||||
be used to change this.
|
||||
|
||||
This setting is inherited by child surfaces set by the get_popup
|
||||
request.
|
||||
|
||||
Layer surfaces receive pointer, touch, and tablet events normally. If
|
||||
you do not want to receive them, set the input region on your surface
|
||||
to an empty region.
|
||||
|
||||
Keyboard interactivity is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="keyboard_interactivity" type="uint" enum="keyboard_interactivity"/>
|
||||
</request>
|
||||
|
||||
<request name="get_popup">
|
||||
<description summary="assign this layer_surface as an xdg_popup parent">
|
||||
This assigns an xdg_popup's parent to this layer_surface. This popup
|
||||
should have been created via xdg_surface::get_popup with the parent set
|
||||
to NULL, and this request must be invoked before committing the popup's
|
||||
initial state.
|
||||
|
||||
See the documentation of xdg_popup for more details about what an
|
||||
xdg_popup is and how it is used.
|
||||
</description>
|
||||
<arg name="popup" type="object" interface="xdg_popup"/>
|
||||
</request>
|
||||
|
||||
<request name="ack_configure">
|
||||
<description summary="ack a configure event">
|
||||
When a configure event is received, if a client commits the
|
||||
surface in response to the configure event, then the client
|
||||
must make an ack_configure request sometime before the commit
|
||||
request, passing along the serial of the configure event.
|
||||
|
||||
If the client receives multiple configure events before it
|
||||
can respond to one, it only has to ack the last configure event.
|
||||
|
||||
A client is not required to commit immediately after sending
|
||||
an ack_configure request - it may even ack_configure several times
|
||||
before its next surface commit.
|
||||
|
||||
A client may send multiple ack_configure requests before committing, but
|
||||
only the last request sent before a commit indicates which configure
|
||||
event the client really is responding to.
|
||||
</description>
|
||||
<arg name="serial" type="uint" summary="the serial from the configure event"/>
|
||||
</request>
|
||||
|
||||
<request name="destroy" type="destructor">
|
||||
<description summary="destroy the layer_surface">
|
||||
This request destroys the layer surface.
|
||||
</description>
|
||||
</request>
|
||||
|
||||
<event name="configure">
|
||||
<description summary="suggest a surface change">
|
||||
The configure event asks the client to resize its surface.
|
||||
|
||||
Clients should arrange their surface for the new states, and then send
|
||||
an ack_configure request with the serial sent in this configure event at
|
||||
some point before committing the new surface.
|
||||
|
||||
The client is free to dismiss all but the last configure event it
|
||||
received.
|
||||
|
||||
The width and height arguments specify the size of the window in
|
||||
surface-local coordinates.
|
||||
|
||||
The size is a hint, in the sense that the client is free to ignore it if
|
||||
it doesn't resize, pick a smaller size (to satisfy aspect ratio or
|
||||
resize in steps of NxM pixels). If the client picks a smaller size and
|
||||
is anchored to two opposite anchors (e.g. 'top' and 'bottom'), the
|
||||
surface will be centered on this axis.
|
||||
|
||||
If the width or height arguments are zero, it means the client should
|
||||
decide its own window dimension.
|
||||
</description>
|
||||
<arg name="serial" type="uint"/>
|
||||
<arg name="width" type="uint"/>
|
||||
<arg name="height" type="uint"/>
|
||||
</event>
|
||||
|
||||
<event name="closed">
|
||||
<description summary="surface should be closed">
|
||||
The closed event is sent by the compositor when the surface will no
|
||||
longer be shown. The output may have been destroyed or the user may
|
||||
have asked for it to be removed. Further changes to the surface will be
|
||||
ignored. The client should destroy the resource after receiving this
|
||||
event, and create a new surface if they so choose.
|
||||
</description>
|
||||
</event>
|
||||
|
||||
<enum name="error">
|
||||
<entry name="invalid_surface_state" value="0" summary="provided surface state is invalid"/>
|
||||
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
||||
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
||||
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
||||
</enum>
|
||||
|
||||
<enum name="anchor" bitfield="true">
|
||||
<entry name="top" value="1" summary="the top edge of the anchor rectangle"/>
|
||||
<entry name="bottom" value="2" summary="the bottom edge of the anchor rectangle"/>
|
||||
<entry name="left" value="4" summary="the left edge of the anchor rectangle"/>
|
||||
<entry name="right" value="8" summary="the right edge of the anchor rectangle"/>
|
||||
</enum>
|
||||
|
||||
<!-- Version 2 additions -->
|
||||
|
||||
<request name="set_layer" since="2">
|
||||
<description summary="change the layer of the surface">
|
||||
Change the layer that the surface is rendered on.
|
||||
|
||||
Layer is double-buffered, see wl_surface.commit.
|
||||
</description>
|
||||
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
1604
src/x11-color.cc
Normal file
1604
src/x11-color.cc
Normal file
File diff suppressed because it is too large
Load Diff
5
src/x11-color.h
Normal file
5
src/x11-color.h
Normal file
@ -0,0 +1,5 @@
|
||||
/* from xorg-server's oscolor.c */
|
||||
int OsLookupColor(int screen, const char *name, unsigned int len,
|
||||
unsigned short *pred,
|
||||
unsigned short *pgreen,
|
||||
unsigned short *pblue);
|
200
src/x11.cc
200
src/x11.cc
@ -41,7 +41,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xmd.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include "x11.h"
|
||||
#include "gui.h"
|
||||
#ifdef BUILD_IMLIB2
|
||||
#include "imlib2.h"
|
||||
#endif /* BUILD_IMLIB2 */
|
||||
@ -58,22 +58,11 @@
|
||||
#include <X11/extensions/shape.h>
|
||||
#endif /* BUILD_XSHAPE */
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
bool have_argb_visual;
|
||||
#endif /* BUILD_ARGB */
|
||||
|
||||
/* some basic X11 stuff */
|
||||
Display *display = nullptr;
|
||||
int display_width;
|
||||
int display_height;
|
||||
int screen;
|
||||
|
||||
/* workarea from _NET_WORKAREA, this is where window / text is aligned */
|
||||
int workarea[4];
|
||||
|
||||
/* Window stuff */
|
||||
struct conky_window window;
|
||||
char window_created = 0;
|
||||
struct conky_x11_window window;
|
||||
|
||||
/* local prototypes */
|
||||
static void update_workarea();
|
||||
@ -81,7 +70,6 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop);
|
||||
static Window find_subwindow(Window win, int w, int h);
|
||||
static void init_X11();
|
||||
static void deinit_X11();
|
||||
static void init_window(lua::state &l, bool own);
|
||||
|
||||
/********************* <SETTINGS> ************************/
|
||||
namespace priv {
|
||||
@ -103,37 +91,10 @@ void out_to_x_setting::cleanup(lua::state &l) {
|
||||
l.pop();
|
||||
}
|
||||
|
||||
void own_window_setting::lua_setter(lua::state &l, bool init) {
|
||||
lua::stack_sentry s(l, -2);
|
||||
|
||||
Base::lua_setter(l, init);
|
||||
|
||||
if (init) {
|
||||
if (do_convert(l, -1).first) {
|
||||
#ifndef OWN_WINDOW
|
||||
std::cerr << "Support for the own_window setting has been "
|
||||
"disabled during compilation\n";
|
||||
l.pop();
|
||||
l.pushboolean(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (out_to_x.get(l)) {
|
||||
init_window(l, do_convert(l, -1).first);
|
||||
} else {
|
||||
// own_window makes no sense when not drawing to X
|
||||
l.pop();
|
||||
l.pushboolean(false);
|
||||
}
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
bool use_xdbe_setting::set_up(lua::state &l) {
|
||||
// double_buffer makes no sense when not drawing to X
|
||||
if (!out_to_x.get(l)) { return false; }
|
||||
if (!out_to_x.get(l) || !display || !window.window) { return false; }
|
||||
|
||||
int major, minor;
|
||||
|
||||
@ -210,128 +171,11 @@ void use_xpmdb_setting::lua_setter(lua::state &l, bool init) {
|
||||
++s;
|
||||
}
|
||||
#endif
|
||||
|
||||
void colour_setting::lua_setter(lua::state &l, bool init) {
|
||||
lua::stack_sentry s(l, -2);
|
||||
|
||||
if (!out_to_x.get(l)) {
|
||||
// ignore if we're not using X
|
||||
l.replace(-2);
|
||||
} else {
|
||||
Base::lua_setter(l, init);
|
||||
}
|
||||
|
||||
++s;
|
||||
}
|
||||
} // namespace priv
|
||||
|
||||
template <>
|
||||
conky::lua_traits<alignment>::Map conky::lua_traits<alignment>::map = {
|
||||
{"top_left", TOP_LEFT},
|
||||
{"top_right", TOP_RIGHT},
|
||||
{"top_middle", TOP_MIDDLE},
|
||||
{"bottom_left", BOTTOM_LEFT},
|
||||
{"bottom_right", BOTTOM_RIGHT},
|
||||
{"bottom_middle", BOTTOM_MIDDLE},
|
||||
{"middle_left", MIDDLE_LEFT},
|
||||
{"middle_middle", MIDDLE_MIDDLE},
|
||||
{"middle_right", MIDDLE_RIGHT},
|
||||
{"tl", TOP_LEFT},
|
||||
{"tr", TOP_RIGHT},
|
||||
{"tm", TOP_MIDDLE},
|
||||
{"bl", BOTTOM_LEFT},
|
||||
{"br", BOTTOM_RIGHT},
|
||||
{"bm", BOTTOM_MIDDLE},
|
||||
{"ml", MIDDLE_LEFT},
|
||||
{"mm", MIDDLE_MIDDLE},
|
||||
{"mr", MIDDLE_RIGHT},
|
||||
{"none", NONE}};
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
template <>
|
||||
conky::lua_traits<window_type>::Map conky::lua_traits<window_type>::map = {
|
||||
{"normal", TYPE_NORMAL},
|
||||
{"dock", TYPE_DOCK},
|
||||
{"panel", TYPE_PANEL},
|
||||
{"desktop", TYPE_DESKTOP},
|
||||
{"override", TYPE_OVERRIDE}};
|
||||
|
||||
template <>
|
||||
conky::lua_traits<window_hints>::Map conky::lua_traits<window_hints>::map = {
|
||||
{"undecorated", HINT_UNDECORATED},
|
||||
{"below", HINT_BELOW},
|
||||
{"above", HINT_ABOVE},
|
||||
{"sticky", HINT_STICKY},
|
||||
{"skip_taskbar", HINT_SKIP_TASKBAR},
|
||||
{"skip_pager", HINT_SKIP_PAGER}};
|
||||
|
||||
std::pair<uint16_t, bool> window_hints_traits::convert(
|
||||
lua::state &l, int index, const std::string &name) {
|
||||
lua::stack_sentry s(l);
|
||||
l.checkstack(1);
|
||||
|
||||
std::string hints = l.tostring(index);
|
||||
// add a sentinel to simplify the following loop
|
||||
hints += ',';
|
||||
size_t pos = 0;
|
||||
size_t newpos;
|
||||
uint16_t ret = 0;
|
||||
while ((newpos = hints.find_first_of(", ", pos)) != std::string::npos) {
|
||||
if (newpos > pos) {
|
||||
l.pushstring(hints.substr(pos, newpos - pos));
|
||||
auto t = conky::lua_traits<window_hints>::convert(l, -1, name);
|
||||
if (!t.second) { return {0, false}; }
|
||||
SET_HINT(ret, t.first);
|
||||
l.pop();
|
||||
}
|
||||
pos = newpos + 1;
|
||||
}
|
||||
return {ret, true};
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
namespace {
|
||||
// used to set the default value for own_window_title
|
||||
std::string gethostnamecxx() {
|
||||
update_uname();
|
||||
return info.uname_s.nodename;
|
||||
}
|
||||
} // namespace
|
||||
#endif /* OWN_WINDOW */
|
||||
|
||||
/*
|
||||
* The order of these settings cannot be completely arbitrary. Some of them
|
||||
* depend on others, and the setters are called in the order in which they are
|
||||
* defined. The order should be: display_name -> out_to_x -> everything colour
|
||||
* related
|
||||
* -> border_*, own_window_*, etc -> own_window ->
|
||||
* double_buffer -> imlib_cache_size
|
||||
*/
|
||||
|
||||
conky::simple_config_setting<alignment> text_alignment("alignment", BOTTOM_LEFT,
|
||||
false);
|
||||
conky::simple_config_setting<std::string> display_name("display", std::string(),
|
||||
false);
|
||||
conky::simple_config_setting<int> head_index("xinerama_head", 0, true);
|
||||
priv::out_to_x_setting out_to_x;
|
||||
|
||||
priv::colour_setting color[10] = {{"color0", 0xffffff}, {"color1", 0xffffff},
|
||||
{"color2", 0xffffff}, {"color3", 0xffffff},
|
||||
{"color4", 0xffffff}, {"color5", 0xffffff},
|
||||
{"color6", 0xffffff}, {"color7", 0xffffff},
|
||||
{"color8", 0xffffff}, {"color9", 0xffffff}};
|
||||
priv::colour_setting default_color("default_color", 0xffffff);
|
||||
priv::colour_setting default_shade_color("default_shade_color", 0x000000);
|
||||
priv::colour_setting default_outline_color("default_outline_color", 0x000000);
|
||||
|
||||
conky::range_config_setting<int> border_inner_margin(
|
||||
"border_inner_margin", 0, std::numeric_limits<int>::max(), 3, true);
|
||||
conky::range_config_setting<int> border_outer_margin(
|
||||
"border_outer_margin", 0, std::numeric_limits<int>::max(), 1, true);
|
||||
conky::range_config_setting<int> border_width("border_width", 0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1, true);
|
||||
#ifdef BUILD_XFT
|
||||
conky::simple_config_setting<bool> use_xft("use_xft", false, false);
|
||||
#endif
|
||||
@ -339,29 +183,11 @@ conky::simple_config_setting<bool> use_xft("use_xft", false, false);
|
||||
conky::simple_config_setting<bool> forced_redraw("forced_redraw", false, false);
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
conky::simple_config_setting<bool> set_transparent("own_window_transparent",
|
||||
false, false);
|
||||
conky::simple_config_setting<std::string> own_window_class("own_window_class",
|
||||
PACKAGE_NAME, false);
|
||||
|
||||
conky::simple_config_setting<std::string> own_window_title(
|
||||
"own_window_title", PACKAGE_NAME " (" + gethostnamecxx() + ")", false);
|
||||
|
||||
conky::simple_config_setting<window_type> own_window_type("own_window_type",
|
||||
TYPE_NORMAL, false);
|
||||
conky::simple_config_setting<uint16_t, window_hints_traits> own_window_hints(
|
||||
"own_window_hints", 0, false);
|
||||
|
||||
priv::colour_setting background_colour("own_window_colour", 0);
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
conky::simple_config_setting<bool> use_argb_visual("own_window_argb_visual",
|
||||
false, false);
|
||||
conky::range_config_setting<int> own_window_argb_value("own_window_argb_value",
|
||||
0, 255, 255, false);
|
||||
#endif /* BUILD_ARGB */
|
||||
#endif /* OWN_WINDOW */
|
||||
priv::own_window_setting own_window;
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
priv::use_xdbe_setting use_xdbe;
|
||||
@ -405,8 +231,14 @@ static void init_X11() {
|
||||
? dispstr.c_str()
|
||||
: nullptr;
|
||||
if ((display = XOpenDisplay(disp)) == nullptr) {
|
||||
throw std::runtime_error(std::string("can't open display: ") +
|
||||
XDisplayName(disp));
|
||||
std::string err = std::string("can't open display: ") +
|
||||
XDisplayName(disp);
|
||||
#ifdef BUILD_WAYLAND
|
||||
fprintf(stderr, "%s\n", err.c_str());
|
||||
return;
|
||||
#else
|
||||
throw std::runtime_error(err);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -494,6 +326,8 @@ static Window find_desktop_window(Window *p_root, Window *p_desktop) {
|
||||
int format, i;
|
||||
unsigned long nitems, bytes;
|
||||
unsigned int n;
|
||||
if (!display)
|
||||
return 0;
|
||||
Window root = RootWindow(display, screen);
|
||||
Window win;
|
||||
Window troot, parent, *children;
|
||||
@ -636,10 +470,10 @@ void destroy_window() {
|
||||
if (window.xftdraw != nullptr) { XftDrawDestroy(window.xftdraw); }
|
||||
#endif /* BUILD_XFT */
|
||||
if (window.gc != nullptr) { XFreeGC(display, window.gc); }
|
||||
memset(&window, 0, sizeof(struct conky_window));
|
||||
memset(&window, 0, sizeof(struct conky_x11_window));
|
||||
}
|
||||
|
||||
static void init_window(lua::state &l __attribute__((unused)), bool own) {
|
||||
void x11_init_window(lua::state &l __attribute__((unused)), bool own) {
|
||||
DBGP("enter init_window()");
|
||||
// own is unused if OWN_WINDOW is not defined
|
||||
(void)own;
|
||||
@ -969,6 +803,10 @@ static void init_window(lua::state &l __attribute__((unused)), bool own) {
|
||||
if (window.window == 0u) {
|
||||
window.window = find_desktop_window(&window.root, &window.desktop);
|
||||
}
|
||||
if (window.window == 0u) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.visual = DefaultVisual(display, screen);
|
||||
window.colourmap = DefaultColormap(display, screen);
|
||||
|
||||
|
127
src/x11.h
127
src/x11.h
@ -66,7 +66,9 @@ enum window_hints {
|
||||
#define TEST_HINT(mask, hint) (mask & (1 << (hint)))
|
||||
#endif
|
||||
|
||||
struct conky_window {
|
||||
extern Display *display;
|
||||
|
||||
struct conky_x11_window {
|
||||
Window root, window, desktop;
|
||||
Drawable drawable;
|
||||
Visual *visual;
|
||||
@ -75,12 +77,12 @@ struct conky_window {
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
XdbeBackBuffer back_buffer;
|
||||
#else
|
||||
#else /*BUILD_XDBE*/
|
||||
Pixmap back_buffer;
|
||||
#endif
|
||||
#endif /*BUILD_XDBE*/
|
||||
#ifdef BUILD_XFT
|
||||
XftDraw *xftdraw;
|
||||
#endif
|
||||
#endif /*BUILD_XFT*/
|
||||
|
||||
int width;
|
||||
int height;
|
||||
@ -90,41 +92,14 @@ struct conky_window {
|
||||
#endif
|
||||
};
|
||||
|
||||
#if defined(BUILD_ARGB) && defined(OWN_WINDOW)
|
||||
/* true if use_argb_visual=true and argb visual was found*/
|
||||
extern bool have_argb_visual;
|
||||
#endif
|
||||
|
||||
extern Display *display;
|
||||
extern int display_width;
|
||||
extern int display_height;
|
||||
extern int screen;
|
||||
|
||||
extern int workarea[4];
|
||||
|
||||
extern struct conky_window window;
|
||||
extern char window_created;
|
||||
extern struct conky_x11_window window;
|
||||
|
||||
void destroy_window(void);
|
||||
void create_gc(void);
|
||||
void set_transparent_background(Window win);
|
||||
void get_x11_desktop_info(Display *current_display, Atom atom);
|
||||
void set_struts(int);
|
||||
|
||||
void print_monitor(struct text_object *, char *, unsigned int);
|
||||
void print_monitor_number(struct text_object *, char *, unsigned int);
|
||||
void print_desktop(struct text_object *, char *, unsigned int);
|
||||
void print_desktop_number(struct text_object *, char *, unsigned int);
|
||||
void print_desktop_name(struct text_object *, char *, unsigned int);
|
||||
|
||||
/* Num lock, Scroll lock, Caps Lock */
|
||||
void print_key_num_lock(struct text_object *, char *, unsigned int);
|
||||
void print_key_caps_lock(struct text_object *, char *, unsigned int);
|
||||
void print_key_scroll_lock(struct text_object *, char *, unsigned int);
|
||||
|
||||
/* Keyboard layout and mouse speed in percentage */
|
||||
void print_keyboard_layout(struct text_object *, char *, unsigned int);
|
||||
void print_mouse_speed(struct text_object *, char *, unsigned int);
|
||||
void x11_init_window(lua::state &l, bool own);
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
void xdbe_swap_buffers(void);
|
||||
@ -132,22 +107,6 @@ void xdbe_swap_buffers(void);
|
||||
void xpmdb_swap_buffers(void);
|
||||
#endif /* BUILD_XDBE */
|
||||
|
||||
/* alignments */
|
||||
enum alignment {
|
||||
TOP_LEFT,
|
||||
TOP_RIGHT,
|
||||
TOP_MIDDLE,
|
||||
BOTTOM_LEFT,
|
||||
BOTTOM_RIGHT,
|
||||
BOTTOM_MIDDLE,
|
||||
MIDDLE_LEFT,
|
||||
MIDDLE_MIDDLE,
|
||||
MIDDLE_RIGHT,
|
||||
NONE
|
||||
};
|
||||
|
||||
extern conky::simple_config_setting<alignment> text_alignment;
|
||||
|
||||
namespace priv {
|
||||
class out_to_x_setting : public conky::simple_config_setting<bool> {
|
||||
typedef conky::simple_config_setting<bool> Base;
|
||||
@ -160,16 +119,6 @@ class out_to_x_setting : public conky::simple_config_setting<bool> {
|
||||
out_to_x_setting() : Base("out_to_x", true, false) {}
|
||||
};
|
||||
|
||||
class own_window_setting : public conky::simple_config_setting<bool> {
|
||||
typedef conky::simple_config_setting<bool> Base;
|
||||
|
||||
protected:
|
||||
virtual void lua_setter(lua::state &l, bool init);
|
||||
|
||||
public:
|
||||
own_window_setting() : Base("own_window", false, false) {}
|
||||
};
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
class use_xdbe_setting : public conky::simple_config_setting<bool> {
|
||||
typedef conky::simple_config_setting<bool> Base;
|
||||
@ -196,72 +145,14 @@ class use_xpmdb_setting : public conky::simple_config_setting<bool> {
|
||||
use_xpmdb_setting() : Base("double_buffer", false, false) {}
|
||||
};
|
||||
#endif
|
||||
|
||||
struct colour_traits {
|
||||
static const lua::Type type = lua::TSTRING;
|
||||
typedef unsigned long Type;
|
||||
|
||||
static inline std::pair<Type, bool> convert(lua::state &l, int index,
|
||||
const std::string &) {
|
||||
return {get_x11_color(l.tostring(index)), true};
|
||||
}
|
||||
};
|
||||
|
||||
class colour_setting
|
||||
: public conky::simple_config_setting<unsigned long, colour_traits> {
|
||||
typedef conky::simple_config_setting<unsigned long, colour_traits> Base;
|
||||
|
||||
protected:
|
||||
virtual void lua_setter(lua::state &l, bool init);
|
||||
|
||||
public:
|
||||
colour_setting(const std::string &name_, unsigned long default_value_ = 0)
|
||||
: Base(name_, default_value_, true) {}
|
||||
};
|
||||
} // namespace priv
|
||||
} /* namespace priv */
|
||||
|
||||
extern priv::out_to_x_setting out_to_x;
|
||||
extern conky::simple_config_setting<std::string> display_name;
|
||||
extern conky::simple_config_setting<int> head_index;
|
||||
extern priv::colour_setting color[10];
|
||||
extern priv::colour_setting default_color;
|
||||
extern priv::colour_setting default_shade_color;
|
||||
extern priv::colour_setting default_outline_color;
|
||||
|
||||
extern conky::range_config_setting<int> border_inner_margin;
|
||||
extern conky::range_config_setting<int> border_outer_margin;
|
||||
extern conky::range_config_setting<int> border_width;
|
||||
|
||||
extern conky::simple_config_setting<bool> forced_redraw;
|
||||
|
||||
#ifdef BUILD_XFT
|
||||
extern conky::simple_config_setting<bool> use_xft;
|
||||
#endif
|
||||
|
||||
#ifdef OWN_WINDOW
|
||||
extern conky::simple_config_setting<bool> set_transparent;
|
||||
extern conky::simple_config_setting<std::string> own_window_class;
|
||||
extern conky::simple_config_setting<std::string> own_window_title;
|
||||
extern conky::simple_config_setting<window_type> own_window_type;
|
||||
|
||||
struct window_hints_traits {
|
||||
static const lua::Type type = lua::TSTRING;
|
||||
typedef uint16_t Type;
|
||||
static std::pair<Type, bool> convert(lua::state &l, int index,
|
||||
const std::string &name);
|
||||
};
|
||||
extern conky::simple_config_setting<uint16_t, window_hints_traits>
|
||||
own_window_hints;
|
||||
|
||||
#ifdef BUILD_ARGB
|
||||
extern conky::simple_config_setting<bool> use_argb_visual;
|
||||
|
||||
/* range of 0-255 for alpha */
|
||||
extern conky::range_config_setting<int> own_window_argb_value;
|
||||
#endif
|
||||
#endif /*OWN_WINDOW*/
|
||||
extern priv::own_window_setting own_window;
|
||||
|
||||
#ifdef BUILD_XDBE
|
||||
extern priv::use_xdbe_setting use_xdbe;
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user