Reorganize wlr-common

This commit is contained in:
Drew DeVault 2017-06-21 12:10:07 -04:00
parent fd91244e83
commit f4453d104d
46 changed files with 71 additions and 91 deletions

View File

@ -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)

View File

@ -28,7 +28,7 @@ add_library(wlr-backend
)
target_link_libraries(wlr-backend
wlr-common
wlr-util
wlr-types
${WAYLAND_LIBRARIES}
${DRM_LIBRARIES}

View File

@ -10,9 +10,9 @@
#include <wlr/backend/libinput.h>
#include <wlr/backend/wayland.h>
#include <wlr/backend/multi.h>
#include <wlr/util/log.h>
#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) {

View File

@ -8,12 +8,12 @@
#include <xf86drm.h>
#include <sys/stat.h>
#include <wlr/session.h>
#include <wlr/common/list.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/list.h>
#include <wlr/util/log.h>
#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);

View File

@ -14,8 +14,8 @@
#include <wayland-server.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h>
#include "backend/drm.h"
#include "common/log.h"
static const char *conn_name[] = {
[DRM_MODE_CONNECTOR_Unknown] = "Unknown",

View File

@ -2,9 +2,8 @@
#include <EGL/eglext.h>
#include <GLES3/gl3.h>
#include <gbm.h> // GBM_FORMAT_XRGB8888
#include <wlr/util/log.h>
#include "backend/egl.h"
#include "common/log.h"
const char *egl_error(void) {
switch (eglGetError()) {

View File

@ -3,9 +3,9 @@
#include <libinput.h>
#include <wlr/session.h>
#include <wlr/backend/interface.h>
#include <wlr/util/log.h>
#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) {

View File

@ -2,10 +2,10 @@
#include <assert.h>
#include <libinput.h>
#include <wlr/session.h>
#include <wlr/common/list.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/util/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_input_device *get_appropriate_device(
enum wlr_input_device_type desired_type,

View File

@ -4,9 +4,8 @@
#include <wlr/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/common/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_keyboard_state {
struct libinput_device *device;

View File

@ -4,9 +4,8 @@
#include <wlr/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/common/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_pointer *wlr_libinput_pointer_create(
struct libinput_device *device) {

View File

@ -4,9 +4,8 @@
#include <wlr/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/common/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_tablet_pad *wlr_libinput_tablet_pad_create(
struct libinput_device *device) {

View File

@ -4,9 +4,8 @@
#include <wlr/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/common/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_tablet_tool *wlr_libinput_tablet_tool_create(
struct libinput_device *device) {

View File

@ -4,9 +4,8 @@
#include <wlr/session.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/common/list.h>
#include <wlr/util/log.h>
#include "backend/libinput.h"
#include "common/log.h"
struct wlr_touch *wlr_libinput_touch_create(
struct libinput_device *device) {

View File

@ -1,9 +1,8 @@
#include <stdbool.h>
#include <stdlib.h>
#include <wlr/backend/interface.h>
#include <wlr/common/log.h>
#include <wlr/util/log.h>
#include "backend/multi.h"
#include "common/log.h"
struct subbackend_state {
struct wlr_backend *backend;

View File

@ -9,8 +9,8 @@
#include <xf86drmMode.h>
#include <wayland-server.h>
#include <wlr/session.h>
#include <wlr/util/log.h>
#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.

View File

@ -1,14 +1,14 @@
#include <stdlib.h>
#include <stdint.h>
#include <wayland-server.h>
#include <assert.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <wayland-server.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/util/log.h>
#include "backend/wayland.h"
#include "common/log.h"
#include <EGL/egl.h>
#include <EGL/eglext.h>
static int dispatch_events(int fd, uint32_t mask, void *data) {
struct wlr_backend_state *state = data;

View File

@ -6,8 +6,8 @@
#include <wayland-client.h>
#include <GLES3/gl3.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/util/log.h>
#include "backend/wayland.h"
#include "common/log.h"
static struct wl_callback_listener frame_listener;

View File

@ -2,8 +2,8 @@
#include <stdlib.h>
#include <string.h>
#include <wayland-client.h>
#include <wlr/util/log.h>
#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) {

View File

@ -8,8 +8,8 @@
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/util/log.h>
#include "backend/wayland.h"
#include "common/log.h"
static void wlr_wl_device_destroy(struct wlr_input_device_state *state) {
free(state);

View File

@ -1,6 +0,0 @@
add_library(wlr-common STATIC
list.c
log.c
)
target_link_libraries(wlr-common m)

View File

@ -11,12 +11,12 @@
#include <wayland-server-protocol.h>
#include <xkbcommon/xkbcommon.h>
#include <GLES3/gl3.h>
#include <wlr/common/list.h>
#include <wlr/render/matrix.h>
#include <wlr/render/gles3.h>
#include <wlr/render.h>
#include <wlr/backend.h>
#include <wlr/session.h>
#include <wlr/util/list.h>
#include "shared.h"
#include "cat.h"

View File

@ -11,8 +11,8 @@
#include <gbm.h>
#include <wlr/session.h>
#include <wlr/common/list.h>
#include <wlr/backend/drm.h>
#include <wlr/util/list.h>
#include "backend/egl.h"
#include "backend/udev.h"

View File

@ -1,10 +1,10 @@
#ifndef _WLR_BACKEND_LIBINPUT_INTERNAL_H
#define _WLR_BACKEND_LIBINPUT_INTERNAL_H
#include <libinput.h>
#include <wlr/backend/interface.h>
#include <wlr/common/list.h>
#include <wayland-server-core.h>
#include <wlr/backend/interface.h>
#include <wlr/interfaces/wlr_input_device.h>
#include <wlr/util/list.h>
#include "backend/udev.h"
struct wlr_backend_state {

View File

@ -3,7 +3,7 @@
#include <wlr/backend/interface.h>
#include <wlr/backend/multi.h>
#include <wlr/common/list.h>
#include <wlr/util/list.h>
struct wlr_backend_state {
struct wlr_backend *backend;

View File

@ -4,9 +4,9 @@
#include <wayland-client.h>
#include <wayland-server.h>
#include <wayland-egl.h>
#include <wlr/common/list.h>
#include <wlr/backend/wayland.h>
#include <wlr/types/wlr_input_device.h>
#include <wlr/util/list.h>
#include "backend/egl.h"
struct wlr_backend_state {

View File

@ -1,19 +0,0 @@
#ifndef _WLR_COMMON_LOG_H
#define _WLR_COMMON_LOG_H
#include <stdbool.h>
#include <stdarg.h>
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

View File

@ -1,7 +1,7 @@
#ifndef _WLR_TYPES_OUTPUT_H
#define _WLR_TYPES_OUTPUT_H
#include <wayland-server.h>
#include <wlr/common/list.h>
#include <wlr/util/list.h>
#include <stdbool.h>
struct wlr_output_mode_state;

View File

@ -1,5 +1,5 @@
#ifndef _WLR_LIST_H
#define _WLR_LIST_H
#ifndef _WLR_UTIL_LIST_H
#define _WLR_UTIL_LIST_H
#include <stddef.h>

View File

@ -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 <stdbool.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>
#include <wlr/common/log.h>
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)))

View File

@ -7,7 +7,7 @@
#include <wlr/render.h>
#include <wlr/render/interface.h>
#include <wlr/render/matrix.h>
#include <common/log.h>
#include <wlr/util/log.h>
#include "render/gles3.h"
static struct {

View File

@ -1,7 +1,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <GLES3/gl3.h>
#include "common/log.h"
#include <wlr/util/log.h>
#include "render/gles3.h"
const char *gles3_strerror(GLenum err) {

View File

@ -8,7 +8,7 @@ set(sources
)
set(libs
wlr-common
wlr-util
${WAYLAND_LIBRARIES}
)

View File

@ -7,7 +7,7 @@
#include <unistd.h>
#include <wayland-server.h>
#include <wlr/session/interface.h>
#include "common/log.h"
#include <wlr/util/log.h>
const struct session_impl session_direct;

View File

@ -12,7 +12,7 @@
#include <fcntl.h>
#include <wayland-server.h>
#include <wlr/session/interface.h>
#include "common/log.h"
#include <wlr/util/log.h>
enum { DRM_MAJOR = 226 };

View File

@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wlr/session.h>
#include <wlr/session/interface.h>
#include "common/log.h"
#include <wlr/util/log.h>
extern const struct session_impl session_logind;
extern const struct session_impl session_direct;

View File

@ -14,6 +14,6 @@ add_library(wlr-types
)
target_link_libraries(wlr-types
wlr-common
wlr-util
${WAYLAND_LIBRARIES}
)

View File

@ -9,8 +9,7 @@
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/common/list.h>
#include "common/log.h"
#include <wlr/util/log.h>
struct wlr_input_device *wlr_input_device_create(
enum wlr_input_device_type type,

View File

@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_keyboard.h>
#include <wlr/interfaces/wlr_keyboard.h>
#include <wlr/common/list.h>
struct wlr_keyboard *wlr_keyboard_create(struct wlr_keyboard_impl *impl,
struct wlr_keyboard_state *state) {

View File

@ -4,7 +4,7 @@
#include <wayland-server.h>
#include <wlr/types/wlr_output.h>
#include <wlr/interfaces/wlr_output.h>
#include <wlr/common/list.h>
#include <wlr/util/list.h>
static const float transforms[][4] = {
[WL_OUTPUT_TRANSFORM_NORMAL] = {

View File

@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_pointer.h>
#include <wlr/interfaces/wlr_pointer.h>
#include <wlr/common/list.h>
struct wlr_pointer *wlr_pointer_create(struct wlr_pointer_impl *impl,
struct wlr_pointer_state *state) {

View File

@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_tablet_pad.h>
#include <wlr/interfaces/wlr_tablet_pad.h>
#include <wlr/common/list.h>
struct wlr_tablet_pad *wlr_tablet_pad_create(struct wlr_tablet_pad_impl *impl,
struct wlr_tablet_pad_state *state) {

View File

@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_tablet_tool.h>
#include <wlr/interfaces/wlr_tablet_tool.h>
#include <wlr/common/list.h>
struct wlr_tablet_tool *wlr_tablet_tool_create(struct wlr_tablet_tool_impl *impl,
struct wlr_tablet_tool_state *state) {

View File

@ -3,7 +3,6 @@
#include <wayland-server.h>
#include <wlr/types/wlr_touch.h>
#include <wlr/interfaces/wlr_touch.h>
#include <wlr/common/list.h>
struct wlr_touch *wlr_touch_create(struct wlr_touch_impl *impl,
struct wlr_touch_state *state) {

6
util/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
add_library(wlr-util STATIC
list.c
log.c
)
target_link_libraries(wlr-util m)

View File

@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <stddef.h>
#include <wlr/common/list.h>
#include <wlr/util/list.h>
list_t *list_create(void) {
list_t *list = malloc(sizeof(list_t));

View File

@ -6,11 +6,9 @@
#include <unistd.h>
#include <string.h>
#include <time.h>
#include "wlr/common/log.h"
#include "common/log.h"
#include <wlr/util/log.h>
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);
}