diff --git a/CMakeLists.txt b/CMakeLists.txt index 5529ae32..ae2397b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,9 +58,9 @@ include(Manpage) include_directories(include) add_subdirectory(backend) -add_subdirectory(common) add_subdirectory(types) add_subdirectory(session) add_subdirectory(render) +add_subdirectory(util) add_subdirectory(example) diff --git a/backend/CMakeLists.txt b/backend/CMakeLists.txt index 37cee892..5486b302 100644 --- a/backend/CMakeLists.txt +++ b/backend/CMakeLists.txt @@ -28,7 +28,7 @@ add_library(wlr-backend ) target_link_libraries(wlr-backend - wlr-common + wlr-util wlr-types ${WAYLAND_LIBRARIES} ${DRM_LIBRARIES} diff --git a/backend/backend.c b/backend/backend.c index e0c52a7e..a391b272 100644 --- a/backend/backend.c +++ b/backend/backend.c @@ -10,9 +10,9 @@ #include #include #include +#include #include "backend/libinput.h" #include "backend/udev.h" -#include "common/log.h" struct wlr_backend *wlr_backend_create(const struct wlr_backend_impl *impl, struct wlr_backend_state *state) { diff --git a/backend/drm/backend.c b/backend/drm/backend.c index 1a8099c0..34c03eea 100644 --- a/backend/drm/backend.c +++ b/backend/drm/backend.c @@ -8,12 +8,12 @@ #include #include #include -#include #include #include +#include +#include #include "backend/udev.h" #include "backend/drm.h" -#include "common/log.h" static bool wlr_drm_backend_init(struct wlr_backend_state *state) { wlr_drm_scan_connectors(state); diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 8a9ae63f..e4790dec 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -14,8 +14,8 @@ #include #include #include +#include #include "backend/drm.h" -#include "common/log.h" static const char *conn_name[] = { [DRM_MODE_CONNECTOR_Unknown] = "Unknown", diff --git a/backend/egl.c b/backend/egl.c index 1ce2d8a7..f46a0c83 100644 --- a/backend/egl.c +++ b/backend/egl.c @@ -2,9 +2,8 @@ #include #include #include // GBM_FORMAT_XRGB8888 - +#include #include "backend/egl.h" -#include "common/log.h" const char *egl_error(void) { switch (eglGetError()) { diff --git a/backend/libinput/backend.c b/backend/libinput/backend.c index fedab148..a3523dc0 100644 --- a/backend/libinput/backend.c +++ b/backend/libinput/backend.c @@ -3,9 +3,9 @@ #include #include #include +#include #include "backend/udev.h" #include "backend/libinput.h" -#include "common/log.h" static int wlr_libinput_open_restricted(const char *path, int flags, void *_state) { diff --git a/backend/libinput/events.c b/backend/libinput/events.c index 1f8f51c7..6cd33e3d 100644 --- a/backend/libinput/events.c +++ b/backend/libinput/events.c @@ -2,10 +2,10 @@ #include #include #include -#include #include +#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_input_device *get_appropriate_device( enum wlr_input_device_type desired_type, diff --git a/backend/libinput/keyboard.c b/backend/libinput/keyboard.c index 26d4309c..f188b09e 100644 --- a/backend/libinput/keyboard.c +++ b/backend/libinput/keyboard.c @@ -4,9 +4,8 @@ #include #include #include -#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_keyboard_state { struct libinput_device *device; diff --git a/backend/libinput/pointer.c b/backend/libinput/pointer.c index d4d3aec0..436c826a 100644 --- a/backend/libinput/pointer.c +++ b/backend/libinput/pointer.c @@ -4,9 +4,8 @@ #include #include #include -#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_pointer *wlr_libinput_pointer_create( struct libinput_device *device) { diff --git a/backend/libinput/tablet_pad.c b/backend/libinput/tablet_pad.c index 3c34b643..fdb4775e 100644 --- a/backend/libinput/tablet_pad.c +++ b/backend/libinput/tablet_pad.c @@ -4,9 +4,8 @@ #include #include #include -#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_tablet_pad *wlr_libinput_tablet_pad_create( struct libinput_device *device) { diff --git a/backend/libinput/tablet_tool.c b/backend/libinput/tablet_tool.c index 8cf2933b..e9e2951f 100644 --- a/backend/libinput/tablet_tool.c +++ b/backend/libinput/tablet_tool.c @@ -4,9 +4,8 @@ #include #include #include -#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_tablet_tool *wlr_libinput_tablet_tool_create( struct libinput_device *device) { diff --git a/backend/libinput/touch.c b/backend/libinput/touch.c index d0048ff0..b19597a3 100644 --- a/backend/libinput/touch.c +++ b/backend/libinput/touch.c @@ -4,9 +4,8 @@ #include #include #include -#include +#include #include "backend/libinput.h" -#include "common/log.h" struct wlr_touch *wlr_libinput_touch_create( struct libinput_device *device) { diff --git a/backend/multi/backend.c b/backend/multi/backend.c index e3d87ccc..d33d137c 100644 --- a/backend/multi/backend.c +++ b/backend/multi/backend.c @@ -1,9 +1,8 @@ #include #include #include -#include +#include #include "backend/multi.h" -#include "common/log.h" struct subbackend_state { struct wlr_backend *backend; diff --git a/backend/udev.c b/backend/udev.c index c84b8e31..1fecaee4 100644 --- a/backend/udev.c +++ b/backend/udev.c @@ -9,8 +9,8 @@ #include #include #include +#include #include "backend/udev.h" -#include "common/log.h" /* Tests if 'path' is KMS compatible by trying to open it. * It leaves the open device in *fd_out it it succeeds. diff --git a/backend/wayland/backend.c b/backend/wayland/backend.c index 88dd2ef1..a58c8691 100644 --- a/backend/wayland/backend.c +++ b/backend/wayland/backend.c @@ -1,14 +1,14 @@ #include #include -#include #include +#include +#include +#include #include #include #include +#include #include "backend/wayland.h" -#include "common/log.h" -#include -#include static int dispatch_events(int fd, uint32_t mask, void *data) { struct wlr_backend_state *state = data; diff --git a/backend/wayland/output.c b/backend/wayland/output.c index 551f9052..a01ff015 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -6,8 +6,8 @@ #include #include #include +#include #include "backend/wayland.h" -#include "common/log.h" static struct wl_callback_listener frame_listener; diff --git a/backend/wayland/registry.c b/backend/wayland/registry.c index 5859c2b4..ddd2a79b 100644 --- a/backend/wayland/registry.c +++ b/backend/wayland/registry.c @@ -2,8 +2,8 @@ #include #include #include +#include #include "backend/wayland.h" -#include "common/log.h" static void registry_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { diff --git a/backend/wayland/wl_seat.c b/backend/wayland/wl_seat.c index a7505f94..5e6583ba 100644 --- a/backend/wayland/wl_seat.c +++ b/backend/wayland/wl_seat.c @@ -8,8 +8,8 @@ #include #include #include +#include #include "backend/wayland.h" -#include "common/log.h" static void wlr_wl_device_destroy(struct wlr_input_device_state *state) { free(state); diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt deleted file mode 100644 index d8d52681..00000000 --- a/common/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -add_library(wlr-common STATIC - list.c - log.c -) - -target_link_libraries(wlr-common m) diff --git a/example/touch.c b/example/touch.c index 554c46c0..d2280385 100644 --- a/example/touch.c +++ b/example/touch.c @@ -11,12 +11,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include "shared.h" #include "cat.h" diff --git a/include/backend/drm.h b/include/backend/drm.h index a4995fa9..2c78e3d9 100644 --- a/include/backend/drm.h +++ b/include/backend/drm.h @@ -11,8 +11,8 @@ #include #include -#include #include +#include #include "backend/egl.h" #include "backend/udev.h" diff --git a/include/backend/libinput.h b/include/backend/libinput.h index f424053a..bb83c749 100644 --- a/include/backend/libinput.h +++ b/include/backend/libinput.h @@ -1,10 +1,10 @@ #ifndef _WLR_BACKEND_LIBINPUT_INTERNAL_H #define _WLR_BACKEND_LIBINPUT_INTERNAL_H #include -#include -#include #include +#include #include +#include #include "backend/udev.h" struct wlr_backend_state { diff --git a/include/backend/multi.h b/include/backend/multi.h index 5e6930bb..efaf61b9 100644 --- a/include/backend/multi.h +++ b/include/backend/multi.h @@ -3,7 +3,7 @@ #include #include -#include +#include struct wlr_backend_state { struct wlr_backend *backend; diff --git a/include/backend/wayland.h b/include/backend/wayland.h index 02ea3482..bf65ec50 100644 --- a/include/backend/wayland.h +++ b/include/backend/wayland.h @@ -4,9 +4,9 @@ #include #include #include -#include #include #include +#include #include "backend/egl.h" struct wlr_backend_state { diff --git a/include/wlr/common/log.h b/include/wlr/common/log.h deleted file mode 100644 index c93f9652..00000000 --- a/include/wlr/common/log.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _WLR_COMMON_LOG_H -#define _WLR_COMMON_LOG_H -#include -#include - -typedef enum { - L_SILENT = 0, - L_ERROR = 1, - L_INFO = 2, - L_DEBUG = 3, - L_LAST, -} log_importance_t; - -typedef void (*log_callback_t)(log_importance_t importance, const char *fmt, va_list args); - -void wlr_init_log(log_callback_t callback); -void wlr_log_stderr(log_importance_t verbosity, const char *fmt, va_list args); - -#endif diff --git a/include/wlr/types/wlr_output.h b/include/wlr/types/wlr_output.h index 66216d3e..8ccf87e1 100644 --- a/include/wlr/types/wlr_output.h +++ b/include/wlr/types/wlr_output.h @@ -1,7 +1,7 @@ #ifndef _WLR_TYPES_OUTPUT_H #define _WLR_TYPES_OUTPUT_H #include -#include +#include #include struct wlr_output_mode_state; diff --git a/include/wlr/common/list.h b/include/wlr/util/list.h similarity index 94% rename from include/wlr/common/list.h rename to include/wlr/util/list.h index 2bc82570..c82fbf7a 100644 --- a/include/wlr/common/list.h +++ b/include/wlr/util/list.h @@ -1,5 +1,5 @@ -#ifndef _WLR_LIST_H -#define _WLR_LIST_H +#ifndef _WLR_UTIL_LIST_H +#define _WLR_UTIL_LIST_H #include diff --git a/include/common/log.h b/include/wlr/util/log.h similarity index 71% rename from include/common/log.h rename to include/wlr/util/log.h index 98e57900..2acaa2ed 100644 --- a/include/common/log.h +++ b/include/wlr/util/log.h @@ -1,9 +1,21 @@ -#ifndef _WLR_INTERNAL_COMMON_LOG_H -#define _WLR_INTERNAL_COMMON_LOG_H +#ifndef _WLR_UTIL_LOG_H +#define _WLR_UTIL_LOG_H #include +#include #include #include -#include + +typedef enum { + L_SILENT = 0, + L_ERROR = 1, + L_INFO = 2, + L_DEBUG = 3, + L_LAST, +} log_importance_t; + +typedef void (*log_callback_t)(log_importance_t importance, const char *fmt, va_list args); + +void wlr_init_log(log_callback_t callback); #ifdef __GNUC__ #define ATTRIB_PRINTF(start, end) __attribute__((format(printf, start, end))) diff --git a/render/gles3/renderer.c b/render/gles3/renderer.c index d029c0fb..4270bd14 100644 --- a/render/gles3/renderer.c +++ b/render/gles3/renderer.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "render/gles3.h" static struct { diff --git a/render/gles3/util.c b/render/gles3/util.c index 1f216182..a3aa87f3 100644 --- a/render/gles3/util.c +++ b/render/gles3/util.c @@ -1,7 +1,7 @@ #include #include #include -#include "common/log.h" +#include #include "render/gles3.h" const char *gles3_strerror(GLenum err) { diff --git a/session/CMakeLists.txt b/session/CMakeLists.txt index bd83068b..23077c12 100644 --- a/session/CMakeLists.txt +++ b/session/CMakeLists.txt @@ -8,7 +8,7 @@ set(sources ) set(libs - wlr-common + wlr-util ${WAYLAND_LIBRARIES} ) diff --git a/session/direct.c b/session/direct.c index c2b155e5..74f2faf1 100644 --- a/session/direct.c +++ b/session/direct.c @@ -7,7 +7,7 @@ #include #include #include -#include "common/log.h" +#include const struct session_impl session_direct; diff --git a/session/logind.c b/session/logind.c index 191791f3..6eb837ed 100644 --- a/session/logind.c +++ b/session/logind.c @@ -12,7 +12,7 @@ #include #include #include -#include "common/log.h" +#include enum { DRM_MAJOR = 226 }; diff --git a/session/session.c b/session/session.c index dbdd8156..9de93b1d 100644 --- a/session/session.c +++ b/session/session.c @@ -2,7 +2,7 @@ #include #include #include -#include "common/log.h" +#include extern const struct session_impl session_logind; extern const struct session_impl session_direct; diff --git a/types/CMakeLists.txt b/types/CMakeLists.txt index 58f8a651..72d885c9 100644 --- a/types/CMakeLists.txt +++ b/types/CMakeLists.txt @@ -14,6 +14,6 @@ add_library(wlr-types ) target_link_libraries(wlr-types - wlr-common + wlr-util ${WAYLAND_LIBRARIES} ) diff --git a/types/wlr_input_device.c b/types/wlr_input_device.c index 3a9611cc..f146c186 100644 --- a/types/wlr_input_device.c +++ b/types/wlr_input_device.c @@ -9,8 +9,7 @@ #include #include #include -#include -#include "common/log.h" +#include struct wlr_input_device *wlr_input_device_create( enum wlr_input_device_type type, diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c index bd6718a7..26dd2977 100644 --- a/types/wlr_keyboard.c +++ b/types/wlr_keyboard.c @@ -3,7 +3,6 @@ #include #include #include -#include struct wlr_keyboard *wlr_keyboard_create(struct wlr_keyboard_impl *impl, struct wlr_keyboard_state *state) { diff --git a/types/wlr_output.c b/types/wlr_output.c index f639a2c4..6daac31c 100644 --- a/types/wlr_output.c +++ b/types/wlr_output.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include static const float transforms[][4] = { [WL_OUTPUT_TRANSFORM_NORMAL] = { diff --git a/types/wlr_pointer.c b/types/wlr_pointer.c index 2c9b8735..fc1ae808 100644 --- a/types/wlr_pointer.c +++ b/types/wlr_pointer.c @@ -3,7 +3,6 @@ #include #include #include -#include struct wlr_pointer *wlr_pointer_create(struct wlr_pointer_impl *impl, struct wlr_pointer_state *state) { diff --git a/types/wlr_tablet_pad.c b/types/wlr_tablet_pad.c index 97c53bb4..80c6187d 100644 --- a/types/wlr_tablet_pad.c +++ b/types/wlr_tablet_pad.c @@ -3,7 +3,6 @@ #include #include #include -#include struct wlr_tablet_pad *wlr_tablet_pad_create(struct wlr_tablet_pad_impl *impl, struct wlr_tablet_pad_state *state) { diff --git a/types/wlr_tablet_tool.c b/types/wlr_tablet_tool.c index cca3e31d..1e939c3b 100644 --- a/types/wlr_tablet_tool.c +++ b/types/wlr_tablet_tool.c @@ -3,7 +3,6 @@ #include #include #include -#include struct wlr_tablet_tool *wlr_tablet_tool_create(struct wlr_tablet_tool_impl *impl, struct wlr_tablet_tool_state *state) { diff --git a/types/wlr_touch.c b/types/wlr_touch.c index a6b7d9ea..e698decd 100644 --- a/types/wlr_touch.c +++ b/types/wlr_touch.c @@ -3,7 +3,6 @@ #include #include #include -#include struct wlr_touch *wlr_touch_create(struct wlr_touch_impl *impl, struct wlr_touch_state *state) { diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt new file mode 100644 index 00000000..5a057889 --- /dev/null +++ b/util/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(wlr-util STATIC + list.c + log.c +) + +target_link_libraries(wlr-util m) diff --git a/common/list.c b/util/list.c similarity index 98% rename from common/list.c rename to util/list.c index 095fbced..94159036 100644 --- a/common/list.c +++ b/util/list.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include list_t *list_create(void) { list_t *list = malloc(sizeof(list_t)); diff --git a/common/log.c b/util/log.c similarity index 97% rename from common/log.c rename to util/log.c index 90eedf4c..760ef18a 100644 --- a/common/log.c +++ b/util/log.c @@ -6,11 +6,9 @@ #include #include #include -#include "wlr/common/log.h" -#include "common/log.h" +#include static bool colored = true; -static log_callback_t log_callback = wlr_log_stderr; static const char *verbosity_colors[] = { [L_SILENT] = "", @@ -19,10 +17,6 @@ static const char *verbosity_colors[] = { [L_DEBUG ] = "\x1B[1;30m", }; -void wlr_log_init(log_callback_t callback) { - log_callback = callback; -} - void wlr_log_stderr(log_importance_t verbosity, const char *fmt, va_list args) { // prefix the time to the log message struct tm result; @@ -48,6 +42,12 @@ void wlr_log_stderr(log_importance_t verbosity, const char *fmt, va_list args) { fprintf(stderr, "\n"); } +static log_callback_t log_callback = wlr_log_stderr; + +void wlr_log_init(log_callback_t callback) { + log_callback = callback; +} + void _wlr_vlog(log_importance_t verbosity, const char *fmt, va_list args) { log_callback(verbosity, fmt, args); }