1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-18 02:55:12 +00:00

Separate cairo-xlib.h Lua bindings from cairo.h (#1844)

- Separate cairo-xlib.h Lua bindings from cairo.h
  - This allows cairo.h to be used from Lua on Wayland without X11 as requirement.
- Add pango dependency for Wayland (adds pangocairo).
- Make graphics related bindings depend on BUILD_GUI.
- Remove BUILD_GUI guard around options in platform checks.
  - Keeping only checks that **directly contain module requirements**

A way of creating surfaces in Lua that uses Shm allocated buffers should
be added in future. This commit only cleans up build options to avoid weird
errors.

Signed-off-by: Tin Švagelj <tin.svagelj@live.com>
This commit is contained in:
Tin Švagelj 2024-04-19 15:31:23 +00:00 committed by GitHub
parent c7df9c092e
commit 45500b1439
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 192 additions and 113 deletions

View File

@ -87,7 +87,7 @@ jobs:
lcov \ lcov \
libaudclient-dev \ libaudclient-dev \
libcairo2-dev \ libcairo2-dev \
libcurl4-gnutls-dev \ libpango1.0-dev \
libcurl4-gnutls-dev \ libcurl4-gnutls-dev \
libdbus-glib-1-dev \ libdbus-glib-1-dev \
libglib2.0-dev \ libglib2.0-dev \
@ -148,6 +148,7 @@ jobs:
-DBUILD_IRC=ON \ -DBUILD_IRC=ON \
-DBUILD_JOURNAL=ON \ -DBUILD_JOURNAL=ON \
-DBUILD_LUA_CAIRO=ON \ -DBUILD_LUA_CAIRO=ON \
-DBUILD_LUA_CAIRO_XLIB=ON \
-DBUILD_LUA_IMLIB2=ON \ -DBUILD_LUA_IMLIB2=ON \
-DBUILD_LUA_RSVG=${RSVG_ENABLED} \ -DBUILD_LUA_RSVG=${RSVG_ENABLED} \
-DBUILD_MYSQL=ON \ -DBUILD_MYSQL=ON \

3
.gitignore vendored
View File

@ -13,9 +13,6 @@ CMakeCache.txt
CMakeFiles CMakeFiles
data/convertconf.h data/convertconf.h
data/defconfig.h data/defconfig.h
lua/libcairo-orig.c
lua/libcairo.c
lua/libimlib2.c
*.so *.so
*.a *.a
/config.h /config.h

View File

@ -210,11 +210,18 @@ dependent_option(BUILD_MOUSE_EVENTS "Enable mouse event support" true
"Mouse event support requires Wayland or OWN_WINDOW enabled") "Mouse event support requires Wayland or OWN_WINDOW enabled")
# Lua library options # Lua library options
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false) dependent_option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false
"BUILD_GUI" false
"Cairo Lua bindings depend on BUILD_GUI")
dependent_option(BUILD_LUA_CAIRO_XLIB "Build Imlib2 bindings for Lua" true
"BUILD_X11;BUILD_LUA_CAIRO" false
"Cairo Xlib Lua bindings require Cairo and X11")
dependent_option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false dependent_option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false
"BUILD_X11;BUILD_IMLIB2" false "BUILD_X11;BUILD_IMLIB2" false
"Imlib2 Lua bindings require X11 and Imlib2") "Imlib2 Lua bindings require X11 and Imlib2")
option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false) dependent_option(BUILD_LUA_RSVG "Build rsvg bindings for Lua" false
"BUILD_GUI" false
"RSVG Lua bindings depend on BUILD_GUI")
option(BUILD_AUDACIOUS "Build audacious (music player) support" false) option(BUILD_AUDACIOUS "Build audacious (music player) support" false)

View File

@ -472,6 +472,14 @@ if(BUILD_WAYLAND)
set(conky_includes ${conky_includes} ${EPOLL_INCLUDE_DIRS}) set(conky_includes ${conky_includes} ${EPOLL_INCLUDE_DIRS})
endif(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD) endif(OS_DARWIN OR OS_DRAGONFLY OR OS_FREEBSD OR OS_NETBSD OR OS_OPENBSD)
pkg_check_modules(CAIRO REQUIRED cairo)
set(conky_libs ${conky_libs} ${CAIRO_LIBRARIES})
set(conky_includes ${conky_includes} ${CAIRO_INCLUDE_DIR})
pkg_check_modules(PANGO REQUIRED pango)
set(conky_libs ${conky_libs} ${PANGO_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGO_INCLUDE_DIRS})
pkg_check_modules(PANGOCAIRO pangocairo) pkg_check_modules(PANGOCAIRO pangocairo)
set(conky_libs ${conky_libs} ${PANGOCAIRO_LIBRARIES}) set(conky_libs ${conky_libs} ${PANGOCAIRO_LIBRARIES})
set(conky_includes ${conky_includes} ${PANGOCAIRO_INCLUDE_DIRS}) set(conky_includes ${conky_includes} ${PANGOCAIRO_INCLUDE_DIRS})
@ -491,34 +499,39 @@ set(conky_libs ${conky_libs} ${LUA_LIBRARIES})
set(conky_includes ${conky_includes} ${LUA_INCLUDE_DIR}) set(conky_includes ${conky_includes} ${LUA_INCLUDE_DIR})
include_directories(3rdparty/toluapp/include) include_directories(3rdparty/toluapp/include)
if(BUILD_GUI) # Check for libraries used by Lua bindings
# Check for libraries used by Lua bindings if(BUILD_LUA_CAIRO)
if(BUILD_LUA_CAIRO) pkg_check_modules(CAIRO REQUIRED cairo>=1.14)
pkg_check_modules(CAIRO REQUIRED cairo>=1.14 cairo-xlib)
set(luacairo_libs ${CAIRO_LIBRARIES} ${LUA_LIBRARIES}) set(luacairo_libs ${CAIRO_LIBRARIES} ${LUA_LIBRARIES})
set(luacairo_includes ${CAIRO_INCLUDE_DIRS} ${LUA_INCLUDE_DIR}) set(luacairo_includes ${CAIRO_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
if(BUILD_LUA_CAIRO_XLIB)
pkg_check_modules(CAIROXLIB REQUIRED cairo-xlib)
set(luacairo_libs ${CAIROXLIB_LIBRARIES} ${luacairo_libs})
set(luacairo_includes ${CAIROXLIB_INCLUDE_DIRS} ${luacairo_includes})
endif(BUILD_LUA_CAIRO_XLIB)
find_program(APP_PATCH patch) find_program(APP_PATCH patch)
if(NOT APP_PATCH) if(NOT APP_PATCH)
message(FATAL_ERROR "Unable to find program 'patch'") message(FATAL_ERROR "Unable to find program 'patch'")
endif(NOT APP_PATCH) endif(NOT APP_PATCH)
endif(BUILD_LUA_CAIRO) endif(BUILD_LUA_CAIRO)
if(BUILD_X11 AND BUILD_LUA_IMLIB2) if(BUILD_LUA_IMLIB2)
pkg_search_module(IMLIB2 REQUIRED imlib2 Imlib2) pkg_search_module(IMLIB2 REQUIRED imlib2 Imlib2)
set(luaimlib2_libs ${IMLIB2_LIBS} ${IMLIB2_LDFLAGS} ${LUA_LIBRARIES}) set(luaimlib2_libs ${IMLIB2_LIBS} ${IMLIB2_LDFLAGS} ${LUA_LIBRARIES})
set(luaimlib2_includes set(luaimlib2_includes
${IMLIB2_INCLUDE_DIRS} ${IMLIB2_INCLUDE_DIRS}
${LUA_INCLUDE_DIR} ${LUA_INCLUDE_DIR}
${X11_INCLUDE_DIR}) ${X11_INCLUDE_DIR})
endif(BUILD_X11 AND BUILD_LUA_IMLIB2) endif(BUILD_LUA_IMLIB2)
if(BUILD_LUA_RSVG) if(BUILD_LUA_RSVG)
pkg_check_modules(RSVG REQUIRED librsvg-2.0>=2.52) pkg_check_modules(RSVG REQUIRED librsvg-2.0>=2.52)
set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES}) set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES})
set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIR}) set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIR})
endif(BUILD_LUA_RSVG) endif(BUILD_LUA_RSVG)
endif(BUILD_GUI)
if(BUILD_AUDACIOUS) if(BUILD_AUDACIOUS)
set(WANT_GLIB true) set(WANT_GLIB true)

2
lua/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
*.cc
cmake_install.cmake

View File

@ -22,13 +22,11 @@ include(ToLua)
add_definitions(-DTOLUA_RELEASE) add_definitions(-DTOLUA_RELEASE)
if(BUILD_X11) # NOTE: Don't chain options in IFs here, their dependency is already handled by
if(BUILD_LUA_CAIRO) # ConkyBuildOptions.cmake
include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR})
# Need the directory for -lSM if(BUILD_LUA_CAIRO)
get_filename_component(X11_SM_LIB_PATH ${X11_SM_LIB} DIRECTORY) include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR})
link_directories(${X11_SM_LIB_PATH})
# cairo_set_dash() needs this special hack to work properly if you have a # cairo_set_dash() needs this special hack to work properly if you have a
# better solution, please let me know # better solution, please let me know
@ -41,9 +39,29 @@ if(BUILD_X11)
set(lua_libs ${lua_libs} conky-cairo) set(lua_libs ${lua_libs} conky-cairo)
print_target_properties(conky-cairo) print_target_properties(conky-cairo)
endif(BUILD_LUA_CAIRO) endif(BUILD_LUA_CAIRO)
if(BUILD_LUA_IMLIB2) if(BUILD_LUA_CAIRO_XLIB)
include_directories(${luacairoxlib_includes} ${CMAKE_CURRENT_SOURCE_DIR})
# Need the directory for -lSM
get_filename_component(X11_SM_LIB_PATH ${X11_SM_LIB} DIRECTORY)
link_directories(${X11_SM_LIB_PATH})
wrap_tolua(luacairoxlib_src cairo_xlib.pkg)
add_library(conky-cairo_xlib SHARED ${luacairoxlib_src})
set_target_properties(conky-cairo_xlib PROPERTIES OUTPUT_NAME "cairo_xlib")
target_link_libraries(conky-cairo_xlib
${luacairoxlib_libs}
${luacairo_libs}
toluapp_lib_static)
set(lua_libs ${lua_libs} conky-cairo_xlib)
print_target_properties(conky-cairo_xlib)
endif(BUILD_LUA_CAIRO_XLIB)
if(BUILD_LUA_IMLIB2)
include_directories(${luaimlib2_includes} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src) include_directories(${luaimlib2_includes} ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src)
if(IMLIB2_VERSION VERSION_GREATER_EQUAL "1.10.0") if(IMLIB2_VERSION VERSION_GREATER_EQUAL "1.10.0")
@ -59,22 +77,9 @@ if(BUILD_X11)
set(lua_libs ${lua_libs} conky-imlib2) set(lua_libs ${lua_libs} conky-imlib2)
print_target_properties(conky-imlib2) print_target_properties(conky-imlib2)
endif(BUILD_LUA_IMLIB2) endif(BUILD_LUA_IMLIB2)
if(BUILD_LUA_RSVG) if(BUILD_LUA_IMLIB2)
include_directories(${luarsvg_includes} ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luarsvg_src rsvg.pkg)
add_library(conky-rsvg SHARED ${luarsvg_src})
set_target_properties(conky-rsvg PROPERTIES OUTPUT_NAME "rsvg")
target_link_libraries(conky-rsvg ${luarsvg_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-rsvg)
print_target_properties(conky-rsvg)
endif(BUILD_LUA_RSVG)
if(BUILD_LUA_CAIRO AND BUILD_LUA_IMLIB2)
include_directories(${luacairo_includes} ${luaimlib2_includes} include_directories(${luacairo_includes} ${luaimlib2_includes}
${CMAKE_CURRENT_SOURCE_DIR}) ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luacairo_imlib2_helper_src cairo_imlib2_helper.pkg) wrap_tolua(luacairo_imlib2_helper_src cairo_imlib2_helper.pkg)
@ -88,8 +93,20 @@ if(BUILD_X11)
${luaimlib2_libs} ${luaimlib2_libs}
toluapp_lib_static) toluapp_lib_static)
set(lua_libs ${lua_libs} conky-cairo_imlib2_helper) set(lua_libs ${lua_libs} conky-cairo_imlib2_helper)
endif(BUILD_LUA_CAIRO AND BUILD_LUA_IMLIB2) endif(BUILD_LUA_IMLIB2)
endif(BUILD_X11)
if(BUILD_LUA_RSVG)
include_directories(${luarsvg_includes} ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luarsvg_src rsvg.pkg)
add_library(conky-rsvg SHARED ${luarsvg_src})
set_target_properties(conky-rsvg PROPERTIES OUTPUT_NAME "rsvg")
target_link_libraries(conky-rsvg ${luarsvg_libs} toluapp_lib_static)
set(lua_libs ${lua_libs} conky-rsvg)
print_target_properties(conky-rsvg)
endif(BUILD_LUA_RSVG)
install(TARGETS ${lua_libs} install(TARGETS ${lua_libs}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}/conky LIBRARY DESTINATION ${LIB_INSTALL_DIR}/conky

View File

@ -1,12 +1,10 @@
$#include <cairo-features.h> $#include <cairo-features.h>
$#include <cairo-deprecated.h> $#include <cairo-deprecated.h>
$#include <cairo.h> $#include <cairo.h>
$#include <cairo-xlib.h>
$#include <X11/Xlib.h>
$#include <libcairo-helper.h> $#include <libcairo-helper.h>
/* /*
* This code was mostly copied from cairo.h and cairo-xlib.h with comments * This code was mostly copied from cairo.h with comments removed. The
* removed. The licence noticed below is present for the sake of clarity. * license notice below is present for the sake of clarity.
*/ */
/* cairo - a vector graphics library with display and print output /* cairo - a vector graphics library with display and print output
@ -191,33 +189,6 @@ typedef enum _cairo_filter {
CAIRO_FILTER_GAUSSIAN CAIRO_FILTER_GAUSSIAN
} cairo_filter_t; } cairo_filter_t;
cairo_surface_t *cairo_xlib_surface_create(Display * dpy,
Drawable drawable,
Visual * visual, int width, int height);
cairo_surface_t *cairo_xlib_surface_create_for_bitmap(Display * dpy,
Pixmap bitmap,
Screen * screen, int width, int height);
void cairo_xlib_surface_set_size(cairo_surface_t * surface, int width, int height);
void cairo_xlib_surface_set_drawable(cairo_surface_t * surface, Drawable
drawable, int width, int height);
Display *cairo_xlib_surface_get_display(cairo_surface_t * surface);
Drawable cairo_xlib_surface_get_drawable(cairo_surface_t * surface);
Screen *cairo_xlib_surface_get_screen(cairo_surface_t * surface);
Visual *cairo_xlib_surface_get_visual(cairo_surface_t * surface);
int cairo_xlib_surface_get_depth(cairo_surface_t * surface);
int cairo_xlib_surface_get_width(cairo_surface_t * surface);
int cairo_xlib_surface_get_height(cairo_surface_t * surface);
int cairo_version(void); int cairo_version(void);
const char *cairo_version_string(void); const char *cairo_version_string(void);

71
lua/cairo_xlib.pkg Normal file
View File

@ -0,0 +1,71 @@
$#include <cairo.h>
$#include <cairo-xlib.h>
$#include <X11/Xlib.h>
/*
* This code was mostly copied from cairo-xlib.h with comments removed. The
* license notice below is present for the sake of clarity.
*/
/* cairo - a vector graphics library with display and print output
*
* Copyright © 2002 University of Southern California
* Copyright © 2005 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*
* The Original Code is the cairo graphics library.
*
* The Initial Developer of the Original Code is University of Southern
* California.
*
* Contributor(s):
* Carl D. Worth <cworth@cworth.org>
*/
cairo_surface_t *cairo_xlib_surface_create(Display * dpy,
Drawable drawable,
Visual * visual, int width, int height);
cairo_surface_t *cairo_xlib_surface_create_for_bitmap(Display * dpy,
Pixmap bitmap,
Screen * screen, int width, int height);
void cairo_xlib_surface_set_size(cairo_surface_t * surface, int width, int height);
void cairo_xlib_surface_set_drawable(cairo_surface_t * surface, Drawable
drawable, int width, int height);
Display *cairo_xlib_surface_get_display(cairo_surface_t * surface);
Drawable cairo_xlib_surface_get_drawable(cairo_surface_t * surface);
Screen *cairo_xlib_surface_get_screen(cairo_surface_t * surface);
Visual *cairo_xlib_surface_get_visual(cairo_surface_t * surface);
int cairo_xlib_surface_get_depth(cairo_surface_t * surface);
int cairo_xlib_surface_get_width(cairo_surface_t * surface);
int cairo_xlib_surface_get_height(cairo_surface_t * surface);