Skip to content

Commit

Permalink
WIP: SDL display support
Browse files Browse the repository at this point in the history
  • Loading branch information
mmuman committed Jan 22, 2023
1 parent d3e9bcb commit 20f8420
Show file tree
Hide file tree
Showing 8 changed files with 643 additions and 8 deletions.
7 changes: 7 additions & 0 deletions cmake/ConkyBuildOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,20 @@ else(BUILD_X11)
set(BUILD_NVIDIA false)
endif(BUILD_X11)

option(BUILD_SDL "Build SDL 1.2 support" false)
if(BUILD_SDL)
endif(BUILD_SDL)

# if we build with any GUI support
if(BUILD_X11)
set(BUILD_GUI true)
endif(BUILD_X11)
if(BUILD_WAYLAND)
set(BUILD_GUI true)
endif(BUILD_WAYLAND)
if(BUILD_SDL)
set(BUILD_GUI true)
endif(BUILD_SDL)

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

# check for SDL
if(BUILD_SDL)
include(FindSDL)
include(FindSDL_ttf)
find_package(SDL)
if(SDL_FOUND)
set(conky_includes ${conky_includes} ${SDL_INCLUDE_DIR})
set(conky_libs ${conky_libs} ${SDL_LIBRARIES})
find_package(SDL_ttf)
if(SDLTTF_FOUND)
set(conky_includes ${conky_includes} ${SDL_TTF_INCLUDE_DIR})
set(conky_libs ${conky_libs} ${SDL_TTF_LIBRARIES})
else(SDLTTL_FOUND)
message(FATAL_ERROR "Unable to find SDL_ttf library")
endif(SDLTTF_FOUND)
check_include_files(SDL_gfxPrimitives.h HAVE_SDL_GFXPRIMITIVES_H)
find_library(SDLGFX_LIBRARY SDL_gfx)
else(SDL_FOUND)
message(FATAL_ERROR "Unable to find SDL library")
endif(SDL_FOUND)
check_include_files(ftw.h HAVE_FTW_H)
endif(BUILD_SDL)

if(BUILD_AUDACIOUS)
set(WANT_GLIB true)
pkg_check_modules(NEW_AUDACIOUS audacious>=1.4.0)
Expand Down
4 changes: 4 additions & 0 deletions cmake/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#cmakedefine HAVE_SYS_INOTIFY_H 1
#cmakedefine HAVE_DIRENT_H 1

#cmakedefine HAVE_FTW_H 1

#cmakedefine HAVE_SOME_SOUNDCARD_H 1
#cmakedefine HAVE_LINUX_SOUNDCARD_H 1

Expand Down Expand Up @@ -115,6 +117,8 @@

#cmakedefine BUILD_HTTP 1

#cmakedefine BUILD_SDL 1

#cmakedefine BUILD_GUI 1

#cmakedefine BUILD_ICONV 1
Expand Down
7 changes: 7 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ set(conky_sources
display-ncurses.hh
display-http.cc
display-http.hh
display-sdl.cc
display-sdl.hh
display-x11.cc
display-x11.hh
display-wayland.cc
Expand Down Expand Up @@ -248,6 +250,11 @@ if(BUILD_GUI)
set(optional_sources ${optional_sources} ${gui})
endif(BUILD_GUI)

if(BUILD_SDL)
set(sdl_srcs x11-color.cc x11-color.h)
set(optional_sources ${optional_sources} ${sdl_srcs})
endif(BUILD_SDL)

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})
Expand Down
16 changes: 8 additions & 8 deletions src/colours.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
#ifdef BUILD_X11
#include "x11.h"
#endif /*BUILD_X11*/
#ifdef BUILD_WAYLAND
#if defined(BUILD_WAYLAND) || defined(BUILD_SDL)
#include "x11-color.h"
#endif /*BUILD_WAYLAND*/
#endif /* BUILD_WAYLAND || BUILD_SDL */

/* precalculated: 31/255, and 63/255 */
#define CONST_8_TO_5_BITS 0.12156862745098
Expand Down Expand Up @@ -88,7 +88,7 @@ unsigned int adjust_colours(unsigned int colour) {
}

#ifdef BUILD_GUI
#ifdef BUILD_WAYLAND
#if defined(BUILD_WAYLAND) || defined(BUILD_SDL)
static int hex_nibble_value(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
Expand Down Expand Up @@ -128,13 +128,13 @@ long manually_get_x11_color(const char *name) {
NORM_ERR("can't parse X color '%s' (%d)", name, len);
return 0xFF00FF;
}
#endif /* BUILD_WAYLAND */
#endif /* BUILD_WAYLAND || BUILD_SDL */

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

Expand All @@ -160,9 +160,9 @@ long get_x11_color(const char *name) {

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

long get_x11_color(const std::string &colour) {
Expand Down
2 changes: 2 additions & 0 deletions src/display-output.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ extern void init_file_output();
extern void init_http_output();
extern void init_x11_output();
extern void init_wayland_output();
extern void init_sdl_output();

/*
* The selected and active display output.
Expand Down Expand Up @@ -113,6 +114,7 @@ bool initialize_display_outputs() {
init_http_output();
init_x11_output();
init_wayland_output();
init_sdl_output();

std::vector<display_output_base *> outputs;
outputs.reserve(display_outputs->size());
Expand Down
Loading

0 comments on commit 20f8420

Please sign in to comment.