Skip to content

Commit

Permalink
Cleanup build flags, global namespace and includes (#1841)
Browse files Browse the repository at this point in the history
- Separated displays so they don't have to all be included in build even when the features are disabled.
- Removed weird linker magic for display init and replaced it with straightforward (and faster) template functions that behave the same.
  - Replaced `disabled_display_output` classes with log messages.
- Add explicit compiler errors when feature dependent headers get included where they shouldn't (wl, x11).
- Switch BUILD_MOUSE_EVENTS dependency from OWN_WINDOW to BUILD_X11.
- Other minor improvements to some existing code which shouldn't affect behavior.
- Improve documentation.
- Remove X11 from unrelated headers.
  - This reaches 0% unneeded X11 polution in the sources.
  - Reenabled parts of window_type which would work in Wayland.
  - Remove unneeded guards.
- Display files are now no longer compiled if their features are disabled.

Signed-off-by: Tin Švagelj <[email protected]>
  • Loading branch information
Caellian authored Apr 23, 2024
1 parent c51fbe6 commit 6adf6b9
Show file tree
Hide file tree
Showing 46 changed files with 1,241 additions and 966 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@ doc/*.html
Makefile
CMakeCache.txt
CMakeFiles
cmake_install.cmake
cmake_uninstall.cmake
CPackConfig.cmake
CPackSourceConfig.cmake

data/convertconf.h
data/defconfig.h
*.so
*.a
/config.h
/build.h

# Compiler cache
.cache
Expand Down
3 changes: 3 additions & 0 deletions 3rdparty/toluapp/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
build/

# ignore generated Makefile; keep stub
Makefile
14 changes: 8 additions & 6 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ dependent_option(BUILD_XSHAPE "Enable Xshape support" true
"BUILD_X11" false
"Xshape support requires X11")
dependent_option(BUILD_XINPUT "Build Xinput 2 support" true
"BUILD_X11;BUILD_MOUSE_EVENTS" false
"Xinput 2 support requires X11 and BUILD_MOUSE_EVENTS enabled")
"BUILD_X11" false
"Xinput 2 support requires X11")

# if we build with any GUI support
if(BUILD_X11)
Expand All @@ -206,8 +206,8 @@ if(BUILD_WAYLAND)
endif(BUILD_WAYLAND)

dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
"BUILD_WAYLAND OR OWN_WINDOW" false
"Mouse event support requires Wayland or OWN_WINDOW enabled")
"BUILD_WAYLAND OR BUILD_X11" false
"Mouse event support requires Wayland or X11 enabled")

# Lua library options
dependent_option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false
Expand Down Expand Up @@ -247,9 +247,11 @@ option(BUILD_IRC "Enable if you want IRC support" false)

option(BUILD_HTTP "Enable if you want HTTP support" false)

if(BUILD_HTTP)
if(NOT BUILD_HTTP)
set(HTTPPORT "10080" CACHE STRING "Port to use for out_to_http")
endif(BUILD_HTTP)
else(NOT BUILD_HTTP)
set(HTTPPORT "10080")
endif(NOT BUILD_HTTP)

option(BUILD_ICONV "Enable iconv support" false)

Expand Down
7 changes: 6 additions & 1 deletion data/conky-dfly-smp.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
--
-- For more on Lua, see:
-- https://www.lua.org/pil/contents.html
--
-- Conky Lua API: https://conky.cc/lua

-- Configuration settings: https://conky.cc/config_settings
conky.config = {
alignment = 'bottom_left',
background = false,
Expand All @@ -36,7 +39,8 @@ conky.config = {
extra_newline = false,
own_window = false,
own_window_class = 'Conky',
own_window_type = 'desktop',
own_window_type = 'normal',
own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
stippled_borders = 0,
update_interval = 3.0,
uppercase = false,
Expand All @@ -45,6 +49,7 @@ conky.config = {
show_graph_range = false
}

-- Variables: https://conky.cc/variables
conky.text = [[
$sysname $version on $machine
$hr
Expand Down
7 changes: 6 additions & 1 deletion data/conky.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
--
-- For more on Lua, see:
-- https://www.lua.org/pil/contents.html
--
-- Conky Lua API: https://conky.cc/lua

-- Configuration settings: https://conky.cc/config_settings
conky.config = {
alignment = 'top_left',
background = false,
Expand Down Expand Up @@ -39,7 +42,8 @@ conky.config = {
out_to_x = true,
own_window = true,
own_window_class = 'Conky',
own_window_type = 'desktop',
own_window_type = 'normal',
own_window_hints = 'undecorated,sticky,below,skip_taskbar,skip_pager',
show_graph_range = false,
show_graph_scale = false,
stippled_borders = 0,
Expand All @@ -49,6 +53,7 @@ conky.config = {
use_xft = true,
}

-- Variables: https://conky.cc/variables
conky.text = [[
${color grey}Info:$color ${scroll 32 Conky $conky_version - $sysname $nodename $kernel $machine}
$hr
Expand Down
4 changes: 4 additions & 0 deletions data/conky_no_x11.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
--
-- For more on Lua, see:
-- https://www.lua.org/pil/contents.html
--
-- Conky Lua API: https://conky.cc/lua

-- Configuration settings: https://conky.cc/config_settings
conky.config = {
background = false,
cpu_avg_samples = 2,
Expand All @@ -22,6 +25,7 @@ conky.config = {
use_spacer = 'none',
};

-- Variables: https://conky.cc/variables
conky.text =
[[${scroll 16 $nodename - $sysname $kernel on $machine | }
Uptime: $uptime
Expand Down
39 changes: 34 additions & 5 deletions doc/config_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,38 @@ desc: |-
values:
- name: alignment
desc: |-
Aligned position on screen, may be top_left, top_right,
top_middle, bottom_left, bottom_right, bottom_middle, middle_left,
middle_middle, middle_right, or none (also can be abbreviated as tl,
tr, tm, bl, br, bm, ml, mm, mr). See also gap_x and gap_y.
Aligned position on screen, may be `none` or one of:
<table>
<tr>
<td><code>top_left</code> (<em>or</em> <code>tl</code>)</td>
<td><code>top_middle</code> (<em>or</em> <code>tm</code>)</td>
<td><code>top_right</code> (<em>or</em> <code>tr</code>)</td>
</tr>
<tr>
<td><code>middle_left</code> (<em>or</em> <code>ml</code>)</td>
<td><code>middle_middle</code> (<em>or</em> <code>mm</code>)</td>
<td><code>middle_right</code> (<em>or</em> <code>mr</code>)</td>
</tr>
<tr>
<td><code>bottom_left</code> (<em>or</em> <code>bl</code>)</td>
<td><code>bottom_middle</code> (<em>or</em> <code>bm</code>)</td>
<td><code>bottom_right</code> (<em>or</em> <code>br</code>)</td>
</tr>
</table>
In case of `panel` and `dock` windows, it might make more sense to use one
of the following aliases:
| Alias | Value |
|:------:|:-------------:|
| `top` | `top_middle` |
| `left` | `middle_left` |
|`right` |`middle_right` |
|`bottom`|`bottom_middle`|
|`center`|`middle_middle`|
See also `gap_x` and `gap_y` settings.
- name: append_file
desc: Append the file given as argument.
- name: background
Expand Down Expand Up @@ -437,7 +465,7 @@ values:
default: false
- name: own_window_type
desc: |-
If own_window is set, under X11 you can specify type of window conky
If `own_window` is set, under X11 you can specify type of window conky
displayed as:
- `normal` mode makes conky show as normal window. This mode can be
Expand All @@ -464,6 +492,7 @@ values:
panels/windows as those will cover conky.
`own_window_hints` are ignored for `override` windows.
To make conky mount on root window, set `own_window` to `false`.
default: normal
args:
- (normal|desktop|dock|panel|utility|override)
Expand Down
46 changes: 33 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,6 @@ set(conky_sources
display-console.hh
display-file.cc
display-file.hh
display-ncurses.cc
display-ncurses.hh
display-http.cc
display-http.hh
display-x11.cc
display-x11.hh
display-wayland.cc
display-wayland.hh
lua-config.cc
lua-config.hh
setting.cc
Expand Down Expand Up @@ -236,23 +228,46 @@ if(BUILD_PORT_MONITORS)
set(optional_sources ${optional_sources} ${port_monitors})
endif(BUILD_PORT_MONITORS)

if(BUILD_HTTP)
set(http
display-http.cc
display-http.hh
)
set(optional_sources ${optional_sources} ${http})
endif(BUILD_HTTP)

if(BUILD_X11)
set(x11 x11.cc x11.h)
set(x11
display-x11.cc
display-x11.hh
x11-settings.cc
x11-settings.h
x11.cc
x11.h
)
set(optional_sources ${optional_sources} ${x11})
endif(BUILD_X11)

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

if(BUILD_MOUSE_EVENTS)
if(BUILD_MOUSE_EVENTS OR BUILD_XINPUT)
set(mouse_events mouse-events.cc mouse-events.h)
set(optional_sources ${optional_sources} ${mouse_events})
endif(BUILD_MOUSE_EVENTS)
endif(BUILD_MOUSE_EVENTS OR BUILD_XINPUT)
endif(BUILD_GUI)


if(BUILD_WAYLAND)
set(wl_srcs wl.cc wl.h xdg-shell-protocol.c wlr-layer-shell-protocol.c)
set(wl_srcs
wl.cc
wl.h
display-wayland.cc
display-wayland.hh
xdg-shell-protocol.c
wlr-layer-shell-protocol.c
)
set(optional_sources ${optional_sources} ${wl_srcs})

# generate protocol implementations
Expand Down Expand Up @@ -324,7 +339,12 @@ if(BUILD_ICONV)
endif(BUILD_ICONV)

if(BUILD_NCURSES)
set(ncurses_srcs nc.cc nc.h)
set(ncurses_srcs
nc.cc
nc.h
display-ncurses.cc
display-ncurses.hh
)
set(optional_sources ${optional_sources} ${ncurses_srcs})
endif(BUILD_NCURSES)

Expand Down
Loading

0 comments on commit 6adf6b9

Please sign in to comment.