From 20f9f60c6a6f758af4f24496c88e2c037d068dd6 Mon Sep 17 00:00:00 2001 From: Tin Date: Fri, 10 Nov 2023 23:07:02 +0100 Subject: [PATCH] Fix build & cleanup Signed-off-by: Tin --- README.md | 4 ++-- cmake/ConkyBuildOptions.cmake | 4 ++-- doc/config_settings.yaml | 27 +++++++++++++++------------ src/display-wayland.cc | 10 +++------- src/gui.cc | 25 +++++++++++++++---------- src/gui.h | 22 +++++++++++++--------- src/main.cc | 3 +++ src/x11.cc | 7 ------- 8 files changed, 53 insertions(+), 49 deletions(-) diff --git a/README.md b/README.md index 4d9d1cdb..03e1a479 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ Conky can display more than 300 built-in objects, including support for: usage**, disk usage, **"top"** like process stats, and **network monitoring**, just to name a few). - Built-in **IMAP** and **POP3** support. -- Built-in support for many popular music players ([MPD][https://www.musicpd.org/], - [XMMS2][https://github.com/XMMS2], [Audacious][https://audacious-media-player.org/]). +- Built-in support for many popular music players ([MPD][], + [XMMS2][], [Audacious][]). - Can be extended using built-in [**Lua**](lua) support, or any of your own scripts and programs ([more](https://github.com/brndnmtthws/conky/wiki#tutorial)). - Built-in [**Imlib2**][imlib2] and [**Cairo**][cairo] bindings for arbitrary drawing diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index d82db150..557649d6 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -167,8 +167,8 @@ else() endif(OS_DARWIN) dependent_option(BUILD_ARGB "Build ARGB (real transparency) support" true - "OWN_WINDOW" false - "ARGB support requires OWN_WINDOW enabled") + "BUILD_X11;OWN_WINDOW" false + "ARGB support requires X11 and OWN_WINDOW enabled, not needed on Wayland") dependent_option(BUILD_XINERAMA "Build Xinerama support" true "BUILD_X11" false "Xinerama support requires X11") diff --git a/doc/config_settings.yaml b/doc/config_settings.yaml index 24594b3c..3b29b56d 100644 --- a/doc/config_settings.yaml +++ b/doc/config_settings.yaml @@ -287,26 +287,26 @@ values: isn't reached, the next char will start on a new line. If you want to make sure that lines don't get broken, set 'width' to 0. args: - - seconds + - integer_number - name: max_user_text desc: |- Maximum size of user text buffer in bytes, i.e. text inside conky.text section in config file. default: 16384 args: - - seconds + - integer_number - name: maximum_width desc: Maximum width of window. args: - - seconds + - integer_number - name: minimum_height desc: Minimum height of the window. args: - - seconds + - integer_number - name: minimum_width desc: Minimum width of window. args: - - seconds + - integer_number - name: mpd_host desc: Host of MPD server. - name: mpd_password @@ -375,12 +375,15 @@ values: When ARGB visuals are enabled, this use this to modify the alpha value used. Valid range is 0-255, where 0 is 0% opacity, and 255 is 100% opacity. + default: 255 + args: + - integer_number - name: own_window_argb_visual desc: |- - Boolean, use ARGB visual? ARGB can be used for real - transparency, note that a composite manager is required for real - transparency. This option will not work as desired (in most cases) in - conjunction with 'own_window_type override'. + Boolean, use ARGB visual? ARGB can be used for real transparency, note + that a composite manager is required on X11. + This option will not work as desired (in most cases) in conjunction with + 'own_window_type override'. - name: own_window_class desc: Manually set the WM_CLASS name. default: Conky @@ -392,16 +395,16 @@ values: (see `/usr/lib/X11/rgb.txt`). default: black args: - - seconds + - color - name: own_window_hints desc: |- - If own_window is yes, you may use these window manager hints + If own_window is yes, you may specify comma separated window manager hints to affect the way Conky displays. Notes: Use own_window_type desktop as another way to implement many of these hints implicitly. If you use own_window_type override, window manager hints have no meaning and are ignored. args: - - seconds + - hint(,hint)* - name: own_window_title desc: |- Manually set the window name. diff --git a/src/display-wayland.cc b/src/display-wayland.cc index 4a0f8ec3..8e546add 100644 --- a/src/display-wayland.cc +++ b/src/display-wayland.cc @@ -946,19 +946,15 @@ void display_output_wayland::end_draw_stuff() { void display_output_wayland::clear_text(int exposures) { struct window *window = global_window; cairo_save(window->cr); + Colour color; -#ifdef OWN_WINDOW - color = background_colour.get(*state); if (set_transparent.get(*state)) { color.alpha = 0; } else { -#ifdef BUILD_ARGB + color = background_colour.get(*state); color.alpha = own_window_argb_value.get(*state); -#else - color.alpha = 0xff; -#endif } -#endif + cairo_set_source_rgba(window->cr, color.red / 255.0, color.green / 255.0, color.blue / 255.0, color.alpha / 255.0); cairo_set_operator(window->cr, CAIRO_OPERATOR_SOURCE); diff --git a/src/gui.cc b/src/gui.cc index 0b46d16e..71608d4a 100644 --- a/src/gui.cc +++ b/src/gui.cc @@ -59,8 +59,6 @@ void x11_init_window(lua::state &l, bool own); /********************* ************************/ -priv::colour_setting background_colour("own_window_colour", 0); - bool out_to_gui(lua::state &l) { bool to_gui = false; #ifdef BUILD_X11 @@ -203,24 +201,31 @@ conky::range_config_setting border_width("border_width", 0, 1, true); #ifdef OWN_WINDOW -conky::simple_config_setting set_transparent("own_window_transparent", - false, false); -conky::simple_config_setting own_window_class("own_window_class", - PACKAGE_NAME, false); - conky::simple_config_setting own_window_title( "own_window_title", PACKAGE_NAME " (" + gethostnamecxx() + ")", false); +#endif /* OWN_WINDOW */ +#if defined(OWN_WINDOW) && defined(BUILD_X11) +conky::simple_config_setting own_window_class("own_window_class", + PACKAGE_NAME, false); conky::simple_config_setting own_window_type("own_window_type", TYPE_NORMAL, false); conky::simple_config_setting own_window_hints( "own_window_hints", 0, false); +#endif /* OWN_WINDOW && BUILD_X11 */ -#ifdef BUILD_ARGB +#if defined(OWN_WINDOW) || defined(BUILD_WAYLAND) +priv::colour_setting background_colour("own_window_colour", 0); +conky::simple_config_setting set_transparent("own_window_transparent", + false, false); +#endif /* OWN_WINDOW || BUILD_WAYLAND */ + +#if defined(BUILD_ARGB) || defined(BUILD_WAYLAND) +conky::simple_config_setting use_argb_visual("own_window_argb_visual", + false, false); conky::range_config_setting own_window_argb_value("own_window_argb_value", 0, 255, 255, false); -#endif /* BUILD_ARGB */ -#endif /* OWN_WINDOW */ +#endif /* BUILD_ARGB || BUILD_WAYLAND */ priv::own_window_setting own_window; /******************** ************************/ diff --git a/src/gui.h b/src/gui.h index 91c2b47b..f4af0642 100644 --- a/src/gui.h +++ b/src/gui.h @@ -109,26 +109,30 @@ extern conky::range_config_setting border_width; extern conky::simple_config_setting forced_redraw; #ifdef OWN_WINDOW -extern conky::simple_config_setting set_transparent; -extern conky::simple_config_setting own_window_class; +extern priv::own_window_setting own_window; extern conky::simple_config_setting own_window_title; -extern conky::simple_config_setting own_window_type; +#endif /* OWN_WINDOW */ +#if defined(OWN_WINDOW) && defined(BUILD_X11) struct window_hints_traits { static const lua::Type type = lua::TSTRING; typedef uint16_t Type; static std::pair convert(lua::state &l, int index, const std::string &name); }; + +extern conky::simple_config_setting own_window_class; +extern conky::simple_config_setting own_window_type; extern conky::simple_config_setting own_window_hints; +#endif /* OWN_WINDOW && BUILD_X11 */ -#ifdef BUILD_ARGB +#if defined(OWN_WINDOW) || defined(BUILD_WAYLAND) extern priv::colour_setting background_colour; -extern conky::simple_config_setting use_argb_visual; +extern conky::simple_config_setting set_transparent; +#endif /* OWN_WINDOW || BUILD_WAYLAND */ -/* range of 0-255 for alpha */ +#if defined(BUILD_ARGB) || defined(BUILD_WAYLAND) +extern conky::simple_config_setting use_argb_visual; extern conky::range_config_setting own_window_argb_value; -#endif /*BUILD_ARGB*/ -#endif /*OWN_WINDOW*/ -extern priv::own_window_setting own_window; +#endif /* BUILD_ARGB || BUILD_WAYLAND */ diff --git a/src/main.cc b/src/main.cc index 9c67c94f..ef38fc71 100644 --- a/src/main.cc +++ b/src/main.cc @@ -187,6 +187,9 @@ static void print_version() { #endif /* BUILD_X11 */ #ifdef BUILD_WAYLAND << _(" Wayland:\n") +#ifdef BUILD_ARGB + << _(" * ARGB visual\n") +#endif /* BUILD_ARGB */ #ifdef BUILD_MOUSE_EVENTS << _(" * Mouse events\n") #endif /* BUILD_MOUSE_EVENTS */ diff --git a/src/x11.cc b/src/x11.cc index b2b913c5..5a1674dc 100644 --- a/src/x11.cc +++ b/src/x11.cc @@ -216,13 +216,6 @@ conky::simple_config_setting use_xft("use_xft", false, false); conky::simple_config_setting forced_redraw("forced_redraw", false, false); -#ifdef OWN_WINDOW -#ifdef BUILD_ARGB -conky::simple_config_setting use_argb_visual("own_window_argb_visual", - false, false); -#endif /* BUILD_ARGB */ -#endif /* OWN_WINDOW */ - #ifdef BUILD_XDBE priv::use_xdbe_setting use_xdbe; #else