Getting rid of prebuilts, libwayland should be built from sources.

This commit is contained in:
Twaik Yont 2023-02-17 16:59:20 +02:00
parent 540dcbebc8
commit 85c65566d4
38 changed files with 5781 additions and 13039 deletions

View File

@ -57,12 +57,6 @@ android {
}
}
sourceSets {
main {
jniLibs.srcDirs 'src/main/jni/prebuilt'
}
}
packagingOptions {
jniLibs {
// This will allow us to use shared libraries inside *.apk, without unpacking
@ -73,6 +67,14 @@ android {
}
}
task patchWayland {
println("Patch can fail here, it is normal if a patch was already applied")
ant.patch(patchfile: "${project.projectDir}/src/main/jni/wayland.patch", dir: "${project.projectDir}/src/main/jni/wayland/src")
ant.patch(patchfile: "${project.projectDir}/src/main/jni/wayland2.patch", dir: "${project.projectDir}/src/main/jni/wayland")
}
tasks.matching { it.name.toLowerCase().contains("ndk") && !it.name.toLowerCase().contains("clean") }
.all { it.dependsOn(patchWayland) }
wayland {
out waylandOut

View File

@ -52,8 +52,6 @@ public class LorieService extends Service implements View.OnApplyWindowInsetsLis
static final String ACTION_PREFERENCES_CHANGED = "com.termux.x11.preferences_changed";
private static LorieService instance = null;
//private
//static
long compositor;
private static final ServiceEventListener listener = new ServiceEventListener();
private static MainActivity act;

View File

@ -196,7 +196,8 @@ public class MainActivity extends AppCompatActivity implements View.OnApplyWindo
handler.postDelayed(() -> {
Rect r = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(r);
boolean isSoftKbdVisible = Objects.requireNonNull(ViewCompat.getRootWindowInsets(kbd)).isVisible(WindowInsetsCompat.Type.ime());
WindowInsetsCompat rootInsets = WindowInsetsCompat.toWindowInsetsCompat(kbd.getRootWindowInsets());
boolean isSoftKbdVisible = rootInsets.isVisible(WindowInsetsCompat.Type.ime());
kbd.setVisibility(isSoftKbdVisible ? View.VISIBLE : View.INVISIBLE);
FrameLayout.LayoutParams p = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);

View File

@ -1,3 +1,23 @@
ROOT_PATH := $(call my-dir)
include $(ROOT_PATH)/lorie/Android.mk
include $(ROOT_PATH)/starter/Android.mk
LOCAL_PATH:= $(ROOT_PATH)/wayland/src
include $(CLEAR_VARS)
LOCAL_MODULE := wayland-server
LOCAL_SRC_FILES := \
connection.c \
event-loop.c \
wayland-protocol.c \
wayland-server.c \
wayland-shm.c \
wayland-os.c \
wayland-util.c
#LOCAL_SRC_FILES += ../../lorie/utils/log.cpp
#LOCAL_CFLAGS := -finstrument-functions
#LOCAL_LDFLAGS := -llog
LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/..
include $(BUILD_SHARED_LIBRARY)

View File

@ -13,9 +13,9 @@ LOCAL_SRC_FILES := \
lorie_wayland_server.cpp \
$(wildcard $(WAYLAND_GENERATED)/*.cpp)
LOCAL_CFLAGS := -finstrument-functions
LOCAL_CXXFLAGS := -std=c++20
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/scanner $(LOCAL_PATH)/../prebuilt/include $(WAYLAND_GENERATED)
#LOCAL_CXXFLAGS += -finstrument-functions
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/../wayland/src $(LOCAL_PATH)/../wayland $(WAYLAND_GENERATED)
LOCAL_LDLIBS := -lEGL -lGLESv2 -llog -landroid
LOCAL_LDFLAGS := -L$(LOCAL_PATH)/../prebuilt/$(TARGET_ARCH_ABI) -lwayland-server
LOCAL_SHARED_LIBRARIES := wayland-server
include $(BUILD_SHARED_LIBRARY)

View File

@ -307,7 +307,7 @@ static void killAllLogcats() {
}
if (strstr(link, "/logcat") != nullptr) {
if (kill(pid, SIGKILL) < 0) {
LOGE("kill %d (%s): %s", pid, link, strerror);
LOGE("kill %d (%s): %s", pid, link, strerror(errno));
}
}
}

View File

@ -163,7 +163,6 @@ lorie_compositor::lorie_compositor() {
wm_base->on__destroy = [=]() { wm_base->destroy(); };
};
LogInit();
LOGV("Starting compositor");
wl_display_init_shm (*this);
add_fd_listener(queue.get_fd(), WL_EVENT_READABLE, [&](int, uint){ queue.run(); return 0; });

View File

@ -1,37 +1,23 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#pragma clang diagnostic push
#pragma ide diagnostic ignored "OCUnusedMacroInspection"
#ifdef ANDROID
#include <android/log.h>
#ifndef LOG_TAG
#define LOG_TAG "LorieNative"
#endif
#define LOG_VERBOSE 2
#define LOG_DEBUG 3
#define LOG_INFO 4
#define LOG_WARN 5
#define LOG_ERROR 6
#define LOG_FATAL 7
#define LOG_PROFILER 8
void
LogInit(void);
void
LogMessage(int priority, const char *format, ...);
#define LOG(prio, ...) LogMessage(prio, __VA_ARGS__)
#define LOGI(...) LOG(LOG_INFO, __VA_ARGS__)
#define LOGW(...) LOG(LOG_WARN, __VA_ARGS__)
#define LOGD(...) LOG(LOG_DEBUG, __VA_ARGS__)
#define LOGV(...) LOG(LOG_VERBOSE, __VA_ARGS__)
#define LOGE(...) LOG(LOG_ERROR, __VA_ARGS__)
#define LOGF(...) LOG(LOG_FATAL, __VA_ARGS__)
#define LOGP(...) LOG(LOG_PROFILER, __VA_ARGS__)
#ifdef DBG
#undef DBG
#ifndef LOG
#define LOG(prio, ...) __android_log_print(prio, LOG_TAG, __VA_ARGS__)
#endif
#define DBG LOGD("Here! %s %d", __FILE__, __LINE__)
#ifdef __cplusplus
}
#define LOGI(...) LOG(ANDROID_LOG_INFO, __VA_ARGS__)
#define LOGW(...) LOG(ANDROID_LOG_WARN, __VA_ARGS__)
#define LOGD(...) LOG(ANDROID_LOG_DEBUG, __VA_ARGS__)
#define LOGV(...) LOG(ANDROID_LOG_VERBOSE, __VA_ARGS__)
#define LOGE(...) LOG(ANDROID_LOG_ERROR, __VA_ARGS__)
#define LOGF(...) LOG(ANDROID_LOG_FATAL, __VA_ARGS__)
#endif
#pragma clang diagnostic pop

187
app/src/main/jni/lorie/utils/log.cpp Normal file → Executable file
View File

@ -1,3 +1,5 @@
#pragma ide diagnostic ignored "readability-inconsistent-declaration-parameter-name"
#pragma ide diagnostic ignored "bugprone-reserved-identifier"
#include <dlfcn.h> // for dladdr
#include <cxxabi.h> // for __cxa_demangle
#include <cstdarg>
@ -5,171 +7,68 @@
#include <string>
#include <iostream>
#include <log.h>
#define LOG(prio, ...) { \
__android_log_print(prio, "LorieProfile", __VA_ARGS__); \
char p = ((prio == ANDROID_LOG_VERBOSE)?'V': \
((prio == ANDROID_LOG_DEBUG) ?'D': \
((prio == ANDROID_LOG_INFO) ?'I': \
((prio == ANDROID_LOG_WARN) ?'W': \
((prio == ANDROID_LOG_ERROR) ?'E': \
((prio == ANDROID_LOG_FATAL) ?'F':'U')))))); \
printf("%s/%c: ", "LorieProfile", p); \
printf(__VA_ARGS__); \
printf("\n"); \
}
#include "../include/log.h"
#include <pthread.h>
#include <unistd.h>
#if defined(__ANDROID__)
#include <android/log.h>
#endif
static int enabled = 0;
bool enabled = true;
#define no_instrument void __attribute__((no_instrument_function)) __attribute__ ((visibility ("default")))
using namespace std;
extern "C" {
extern void *blacklist[];
#define skip_blacklisted(f) for (int z=0; blacklist[z]!=NULL; z++) if (blacklist[z]==f) return;
static bool lock_needed =
#ifndef __ANDROID__
true;
#else
false;
#endif
static pthread_mutex_t lock;
// see https://github.com/littlstar/asprintf.c/blob/master/asprintf.c
static int
_vasprintf_ (char **str, const char *fmt, va_list args) {
char *dest = NULL;
int size = 0;
va_list tmpa;
va_copy(tmpa, args);
size = vsnprintf(dest, size, fmt, tmpa);
va_end(tmpa);
if (size < 0) { return -1; }
*str = (char *) malloc(size + 1);
if (NULL == *str) { return -1; }
size = vsprintf(*str, fmt, args);
return size;
}
static int
_asprintf_ (char **str, const char *fmt, ...) {
int size = 0;
va_list args;
va_start(args, fmt);
size = _vasprintf_(str, fmt, args);
va_end(args);
return size;
}
void defaultLogFn(int priority, const char *format, va_list ap) {
char *buffer;
char *prio = NULL;
switch (priority) {
case LOG_VERBOSE: prio = (char*)"V: "; break;
case LOG_DEBUG: prio = (char*)"D: "; break;
case LOG_INFO: prio = (char*)"I: "; break;
case LOG_WARN: prio = (char*)"W: "; break;
case LOG_ERROR: prio = (char*)"E: "; break;
case LOG_FATAL: prio = (char*)"F: "; break;
case LOG_PROFILER: prio = (char*)"P: "; break;
default: prio = (char*)"D: ";
}
_asprintf_(&buffer, "%s%s\n", prio, format);
vprintf(buffer, ap);
free(buffer);
if (priority == LOG_FATAL) exit(1);
}
#if defined(__ANDROID__)
void androidLogFn(int prio, const char *format, va_list ap) {
__android_log_vprint(prio, "LorieNative", format, ap);
if (prio == LOG_FATAL) exit(1);
}
#endif
static void (*logFunction)(int, const char*, va_list) =
#if !defined(__ANDROID__)
defaultLogFn;
#else
androidLogFn;
#endif
static void LogMessageInternal(int priority, const char *format, ...) {
if (logFunction == NULL) return;
va_list argptr;
va_start(argptr, format);
logFunction(priority, format, argptr);
va_end(argptr);
}
void LogMessage(int priority, const char *format, ...) {
if (logFunction == NULL) return;
if (lock_needed) pthread_mutex_lock(&::lock);
va_list argptr;
va_start(argptr, format);
logFunction(priority, format, argptr);
va_end(argptr);
if (lock_needed) pthread_mutex_unlock(&::lock);
}
void LogInit(void) {
if (lock_needed && pthread_mutex_init(&::lock, NULL) != 0) {
LogMessageInternal(LOG_ERROR, "Logger mutex init failed\n");
return;
}
LOGD("Logging initialized");
}
#define skip_blacklisted(f) for (int z=0; blacklist[z]!=NULL; z++) if (blacklist[z]==(f)) return
static thread_local int level = -1;
void print_func(void *func, int enter);
no_instrument __attribute__((__constructor__(5))) i() {
if (getenv("LORIE_DEBUG"))
enabled = true;
if (getenv("LORIE_NDEBUG"))
enabled = false;
}
void __attribute__((no_instrument_function)) __cyg_profile_func_enter (void *this_fn, void *call_site);
void __attribute__((no_instrument_function)) __cyg_profile_func_exit (void *this_fn, void *call_site);
no_instrument print_func(void *func, int enter) {
Dl_info info;
if (dladdr(func, &info) && info.dli_sname != nullptr) {
int status;
char *demangled = abi::__cxa_demangle(info.dli_sname,nullptr, nullptr, &status);
LOGD("%d%*c%s %s", gettid(), level, ' ', enter ? ">" : "<", status == 0 ? demangled : info.dli_sname);
free(demangled);
}
}
void __attribute__((no_instrument_function))
__cyg_profile_func_enter (void *func, void *caller) {
if (!enabled) return;
no_instrument __cyg_profile_func_enter (void *func, [[maybe_unused]] void *caller) {
if (!enabled) return;
skip_blacklisted(func);
level++;
print_func(func, 1);
}
void __attribute__((no_instrument_function))
__cyg_profile_func_exit (void *func, void *caller) {
if (!enabled) return;
no_instrument __cyg_profile_func_exit (void *func, [[maybe_unused]] void *caller) {
if (!enabled) return;
skip_blacklisted(func);
print_func(func, 0);
level--;
}
void print_func(void *func, int enter) {
Dl_info info;
if (dladdr(func, &info) && info.dli_sname != NULL) {
char *demangled = NULL;
int status;
demangled = abi::__cxa_demangle(info.dli_sname, NULL, 0, &status);
LOGP("%*c%s %s", level, ' ', enter ? ">" : "<", status == 0 ? demangled : info.dli_sname);
free(demangled);
}
}
void *blacklist[] = {
(void*) _vasprintf_,
(void*) _asprintf_,
(void*) defaultLogFn,
#if defined(__ANDROID__)
(void*) androidLogFn,
#endif
(void*) LogInit,
(void*) LogMessage,
(void*) LogMessageInternal,
(void*) __cyg_profile_func_enter,
(void*) __cyg_profile_func_exit,
(void*) print_func
(void*) __cyg_profile_func_enter,
(void*) __cyg_profile_func_exit,
(void*) print_func
};
} // extern "C"

View File

@ -1,21 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := android-support
LOCAL_SRC_FILES:= $(TARGET_ARCH_ABI)/libandroid-support.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ffi
LOCAL_SRC_FILES:= $(TARGET_ARCH_ABI)/libffi.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := expat
LOCAL_SRC_FILES:= $(TARGET_ARCH_ABI)/libexpat.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := wayland-server
LOCAL_SRC_FILES:= $(TARGET_ARCH_ABI)/libwayland-server.so
include $(PREBUILT_SHARED_LIBRARY)

View File

@ -1,21 +0,0 @@
LOCAL_PATH := $(call my-dir)
define ev-prebuilt
include $$(CLEAR_VARS)
LOCAL_MODULE := $(strip $1)
LOCAL_SRC_FILES:= $$(TARGET_ARCH_ABI)/lib$(strip $1).so
include $$(PREBUILT_SHARED_LIBRARY)
endef
prebuilt = $(eval $(call ev-prebuilt, $1))
# libs are prebuilt with termux
$(info $(call ev-prebuilt, android-support))
$(info $(call ev-prebuilt, ffi))
$(info $(call ev-prebuilt, expat))
$(info $(call ev-prebuilt, wayland-server))
$(call prebuilt, android-support)
$(call prebuilt, ffi)
$(call prebuilt, expat)
$(call prebuilt, wayland-server)

View File

@ -1,675 +0,0 @@
/*
* Copyright © 2008 Kristian Høgsberg
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WAYLAND_SERVER_CORE_H
#define WAYLAND_SERVER_CORE_H
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include "wayland-util.h"
#include "wayland-version.h"
#ifdef __cplusplus
extern "C" {
#endif
enum {
WL_EVENT_READABLE = 0x01,
WL_EVENT_WRITABLE = 0x02,
WL_EVENT_HANGUP = 0x04,
WL_EVENT_ERROR = 0x08
};
/** File descriptor dispatch function type
*
* Functions of this type are used as callbacks for file descriptor events.
*
* \param fd The file descriptor delivering the event.
* \param mask Describes the kind of the event as a bitwise-or of:
* \c WL_EVENT_READABLE, \c WL_EVENT_WRITABLE, \c WL_EVENT_HANGUP,
* \c WL_EVENT_ERROR.
* \param data The user data argument of the related wl_event_loop_add_fd()
* call.
* \return If the event source is registered for re-check with
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
* If not registered, the return value is ignored and should be zero.
*
* \sa wl_event_loop_add_fd()
* \memberof wl_event_source
*/
typedef int (*wl_event_loop_fd_func_t)(int fd, uint32_t mask, void *data);
/** Timer dispatch function type
*
* Functions of this type are used as callbacks for timer expiry.
*
* \param data The user data argument of the related wl_event_loop_add_timer()
* call.
* \return If the event source is registered for re-check with
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
* If not registered, the return value is ignored and should be zero.
*
* \sa wl_event_loop_add_timer()
* \memberof wl_event_source
*/
typedef int (*wl_event_loop_timer_func_t)(void *data);
/** Signal dispatch function type
*
* Functions of this type are used as callbacks for (POSIX) signals.
*
* \param signal_number
* \param data The user data argument of the related wl_event_loop_add_signal()
* call.
* \return If the event source is registered for re-check with
* wl_event_source_check(): 0 for all done, 1 for needing a re-check.
* If not registered, the return value is ignored and should be zero.
*
* \sa wl_event_loop_add_signal()
* \memberof wl_event_source
*/
typedef int (*wl_event_loop_signal_func_t)(int signal_number, void *data);
/** Idle task function type
*
* Functions of this type are used as callbacks before blocking in
* wl_event_loop_dispatch().
*
* \param data The user data argument of the related wl_event_loop_add_idle()
* call.
*
* \sa wl_event_loop_add_idle() wl_event_loop_dispatch()
* \memberof wl_event_source
*/
typedef void (*wl_event_loop_idle_func_t)(void *data);
/** \struct wl_event_loop
*
* \brief An event loop context
*
* Usually you create an event loop context, add sources to it, and call
* wl_event_loop_dispatch() in a loop to process events.
*
* \sa wl_event_source
*/
/** \struct wl_event_source
*
* \brief An abstract event source
*
* This is the generic type for fd, timer, signal, and idle sources.
* Functions that operate on specific source types must not be used with
* a different type, even if the function signature allows it.
*/
struct wl_event_loop *
wl_event_loop_create(void);
void
wl_event_loop_destroy(struct wl_event_loop *loop);
struct wl_event_source *
wl_event_loop_add_fd(struct wl_event_loop *loop,
int fd, uint32_t mask,
wl_event_loop_fd_func_t func,
void *data);
int
wl_event_source_fd_update(struct wl_event_source *source, uint32_t mask);
struct wl_event_source *
wl_event_loop_add_timer(struct wl_event_loop *loop,
wl_event_loop_timer_func_t func,
void *data);
struct wl_event_source *
wl_event_loop_add_signal(struct wl_event_loop *loop,
int signal_number,
wl_event_loop_signal_func_t func,
void *data);
int
wl_event_source_timer_update(struct wl_event_source *source,
int ms_delay);
int
wl_event_source_remove(struct wl_event_source *source);
void
wl_event_source_check(struct wl_event_source *source);
int
wl_event_loop_dispatch(struct wl_event_loop *loop, int timeout);
void
wl_event_loop_dispatch_idle(struct wl_event_loop *loop);
struct wl_event_source *
wl_event_loop_add_idle(struct wl_event_loop *loop,
wl_event_loop_idle_func_t func,
void *data);
int
wl_event_loop_get_fd(struct wl_event_loop *loop);
struct wl_listener;
typedef void (*wl_notify_func_t)(struct wl_listener *listener, void *data);
void
wl_event_loop_add_destroy_listener(struct wl_event_loop *loop,
struct wl_listener *listener);
struct wl_listener *
wl_event_loop_get_destroy_listener(struct wl_event_loop *loop,
wl_notify_func_t notify);
struct wl_display *
wl_display_create(void);
void
wl_display_destroy(struct wl_display *display);
struct wl_event_loop *
wl_display_get_event_loop(struct wl_display *display);
int
wl_display_add_socket(struct wl_display *display, const char *name);
const char *
wl_display_add_socket_auto(struct wl_display *display);
int
wl_display_add_socket_fd(struct wl_display *display, int sock_fd);
void
wl_display_terminate(struct wl_display *display);
void
wl_display_run(struct wl_display *display);
void
wl_display_flush_clients(struct wl_display *display);
void
wl_display_destroy_clients(struct wl_display *display);
struct wl_client;
typedef void (*wl_global_bind_func_t)(struct wl_client *client, void *data,
uint32_t version, uint32_t id);
uint32_t
wl_display_get_serial(struct wl_display *display);
uint32_t
wl_display_next_serial(struct wl_display *display);
void
wl_display_add_destroy_listener(struct wl_display *display,
struct wl_listener *listener);
void
wl_display_add_client_created_listener(struct wl_display *display,
struct wl_listener *listener);
struct wl_listener *
wl_display_get_destroy_listener(struct wl_display *display,
wl_notify_func_t notify);
struct wl_global *
wl_global_create(struct wl_display *display,
const struct wl_interface *interface,
int version,
void *data, wl_global_bind_func_t bind);
void
wl_global_remove(struct wl_global *global);
void
wl_global_destroy(struct wl_global *global);
/** A filter function for wl_global objects
*
* \param client The client object
* \param global The global object to show or hide
* \param data The user data pointer
*
* A filter function enables the server to decide which globals to
* advertise to each client.
*
* When a wl_global filter is set, the given callback function will be
* called during wl_global advertisement and binding.
*
* This function should return true if the global object should be made
* visible to the client or false otherwise.
*/
typedef bool (*wl_display_global_filter_func_t)(const struct wl_client *client,
const struct wl_global *global,
void *data);
void
wl_display_set_global_filter(struct wl_display *display,
wl_display_global_filter_func_t filter,
void *data);
const struct wl_interface *
wl_global_get_interface(const struct wl_global *global);
void *
wl_global_get_user_data(const struct wl_global *global);
void
wl_global_set_user_data(struct wl_global *global, void *data);
struct wl_client *
wl_client_create(struct wl_display *display, int fd);
struct wl_list *
wl_display_get_client_list(struct wl_display *display);
struct wl_list *
wl_client_get_link(struct wl_client *client);
struct wl_client *
wl_client_from_link(struct wl_list *link);
/** Iterate over a list of clients. */
#define wl_client_for_each(client, list) \
for (client = wl_client_from_link((list)->next); \
wl_client_get_link(client) != (list); \
client = wl_client_from_link(wl_client_get_link(client)->next))
void
wl_client_destroy(struct wl_client *client);
void
wl_client_flush(struct wl_client *client);
void
wl_client_get_credentials(struct wl_client *client,
pid_t *pid, uid_t *uid, gid_t *gid);
int
wl_client_get_fd(struct wl_client *client);
void
wl_client_add_destroy_listener(struct wl_client *client,
struct wl_listener *listener);
struct wl_listener *
wl_client_get_destroy_listener(struct wl_client *client,
wl_notify_func_t notify);
struct wl_resource *
wl_client_get_object(struct wl_client *client, uint32_t id);
void
wl_client_post_no_memory(struct wl_client *client);
void
wl_client_post_implementation_error(struct wl_client *client,
const char* msg, ...) WL_PRINTF(2,3);
void
wl_client_add_resource_created_listener(struct wl_client *client,
struct wl_listener *listener);
typedef enum wl_iterator_result (*wl_client_for_each_resource_iterator_func_t)(
struct wl_resource *resource,
void *user_data);
void
wl_client_for_each_resource(struct wl_client *client,
wl_client_for_each_resource_iterator_func_t iterator,
void *user_data);
/** \class wl_listener
*
* \brief A single listener for Wayland signals
*
* wl_listener provides the means to listen for wl_signal notifications. Many
* Wayland objects use wl_listener for notification of significant events like
* object destruction.
*
* Clients should create wl_listener objects manually and can register them as
* listeners to signals using #wl_signal_add, assuming the signal is
* directly accessible. For opaque structs like wl_event_loop, adding a
* listener should be done through provided accessor methods. A listener can
* only listen to one signal at a time.
*
* \code
* struct wl_listener your_listener;
*
* your_listener.notify = your_callback_method;
*
* // Direct access
* wl_signal_add(&some_object->destroy_signal, &your_listener);
*
* // Accessor access
* wl_event_loop *loop = ...;
* wl_event_loop_add_destroy_listener(loop, &your_listener);
* \endcode
*
* If the listener is part of a larger struct, #wl_container_of can be used
* to retrieve a pointer to it:
*
* \code
* void your_listener(struct wl_listener *listener, void *data)
* {
* struct your_data *data;
*
* your_data = wl_container_of(listener, data, your_member_name);
* }
* \endcode
*
* If you need to remove a listener from a signal, use wl_list_remove().
*
* \code
* wl_list_remove(&your_listener.link);
* \endcode
*
* \sa wl_signal
*/
struct wl_listener {
struct wl_list link;
wl_notify_func_t notify;
};
/** \class wl_signal
*
* \brief A source of a type of observable event
*
* Signals are recognized points where significant events can be observed.
* Compositors as well as the server can provide signals. Observers are
* wl_listener's that are added through #wl_signal_add. Signals are emitted
* using #wl_signal_emit, which will invoke all listeners until that
* listener is removed by wl_list_remove() (or whenever the signal is
* destroyed).
*
* \sa wl_listener for more information on using wl_signal
*/
struct wl_signal {
struct wl_list listener_list;
};
/** Initialize a new \ref wl_signal for use.
*
* \param signal The signal that will be initialized
*
* \memberof wl_signal
*/
static inline void
wl_signal_init(struct wl_signal *signal)
{
wl_list_init(&signal->listener_list);
}
/** Add the specified listener to this signal.
*
* \param signal The signal that will emit events to the listener
* \param listener The listener to add
*
* \memberof wl_signal
*/
static inline void
wl_signal_add(struct wl_signal *signal, struct wl_listener *listener)
{
wl_list_insert(signal->listener_list.prev, &listener->link);
}
/** Gets the listener struct for the specified callback.
*
* \param signal The signal that contains the specified listener
* \param notify The listener that is the target of this search
* \return the list item that corresponds to the specified listener, or NULL
* if none was found
*
* \memberof wl_signal
*/
static inline struct wl_listener *
wl_signal_get(struct wl_signal *signal, wl_notify_func_t notify)
{
struct wl_listener *l;
wl_list_for_each(l, &signal->listener_list, link)
if (l->notify == notify)
return l;
return NULL;
}
/** Emits this signal, notifying all registered listeners.
*
* \param signal The signal object that will emit the signal
* \param data The data that will be emitted with the signal
*
* \memberof wl_signal
*/
static inline void
wl_signal_emit(struct wl_signal *signal, void *data)
{
struct wl_listener *l, *next;
wl_list_for_each_safe(l, next, &signal->listener_list, link)
l->notify(l, data);
}
typedef void (*wl_resource_destroy_func_t)(struct wl_resource *resource);
/*
* Post an event to the client's object referred to by 'resource'.
* 'opcode' is the event number generated from the protocol XML
* description (the event name). The variable arguments are the event
* parameters, in the order they appear in the protocol XML specification.
*
* The variable arguments' types are:
* - type=uint: uint32_t
* - type=int: int32_t
* - type=fixed: wl_fixed_t
* - type=string: (const char *) to a nil-terminated string
* - type=array: (struct wl_array *)
* - type=fd: int, that is an open file descriptor
* - type=new_id: (struct wl_object *) or (struct wl_resource *)
* - type=object: (struct wl_object *) or (struct wl_resource *)
*/
void
wl_resource_post_event(struct wl_resource *resource,
uint32_t opcode, ...);
void
wl_resource_post_event_array(struct wl_resource *resource,
uint32_t opcode, union wl_argument *args);
void
wl_resource_queue_event(struct wl_resource *resource,
uint32_t opcode, ...);
void
wl_resource_queue_event_array(struct wl_resource *resource,
uint32_t opcode, union wl_argument *args);
/* msg is a printf format string, variable args are its args. */
void
wl_resource_post_error(struct wl_resource *resource,
uint32_t code, const char *msg, ...) WL_PRINTF(3, 4);
void
wl_resource_post_no_memory(struct wl_resource *resource);
struct wl_display *
wl_client_get_display(struct wl_client *client);
struct wl_resource *
wl_resource_create(struct wl_client *client,
const struct wl_interface *interface,
int version, uint32_t id);
void
wl_resource_set_implementation(struct wl_resource *resource,
const void *implementation,
void *data,
wl_resource_destroy_func_t destroy);
void
wl_resource_set_dispatcher(struct wl_resource *resource,
wl_dispatcher_func_t dispatcher,
const void *implementation,
void *data,
wl_resource_destroy_func_t destroy);
void
wl_resource_destroy(struct wl_resource *resource);
uint32_t
wl_resource_get_id(struct wl_resource *resource);
struct wl_list *
wl_resource_get_link(struct wl_resource *resource);
struct wl_resource *
wl_resource_from_link(struct wl_list *resource);
struct wl_resource *
wl_resource_find_for_client(struct wl_list *list, struct wl_client *client);
struct wl_client *
wl_resource_get_client(struct wl_resource *resource);
void
wl_resource_set_user_data(struct wl_resource *resource, void *data);
void *
wl_resource_get_user_data(struct wl_resource *resource);
int
wl_resource_get_version(struct wl_resource *resource);
void
wl_resource_set_destructor(struct wl_resource *resource,
wl_resource_destroy_func_t destroy);
int
wl_resource_instance_of(struct wl_resource *resource,
const struct wl_interface *interface,
const void *implementation);
const char *
wl_resource_get_class(struct wl_resource *resource);
void
wl_resource_add_destroy_listener(struct wl_resource *resource,
struct wl_listener *listener);
struct wl_listener *
wl_resource_get_destroy_listener(struct wl_resource *resource,
wl_notify_func_t notify);
#define wl_resource_for_each(resource, list) \
for (resource = 0, resource = wl_resource_from_link((list)->next); \
wl_resource_get_link(resource) != (list); \
resource = wl_resource_from_link(wl_resource_get_link(resource)->next))
#define wl_resource_for_each_safe(resource, tmp, list) \
for (resource = 0, tmp = 0, \
resource = wl_resource_from_link((list)->next), \
tmp = wl_resource_from_link((list)->next->next); \
wl_resource_get_link(resource) != (list); \
resource = tmp, \
tmp = wl_resource_from_link(wl_resource_get_link(resource)->next))
struct wl_shm_buffer *
wl_shm_buffer_get(struct wl_resource *resource);
void
wl_shm_buffer_begin_access(struct wl_shm_buffer *buffer);
void
wl_shm_buffer_end_access(struct wl_shm_buffer *buffer);
void *
wl_shm_buffer_get_data(struct wl_shm_buffer *buffer);
int32_t
wl_shm_buffer_get_stride(struct wl_shm_buffer *buffer);
uint32_t
wl_shm_buffer_get_format(struct wl_shm_buffer *buffer);
int32_t
wl_shm_buffer_get_width(struct wl_shm_buffer *buffer);
int32_t
wl_shm_buffer_get_height(struct wl_shm_buffer *buffer);
struct wl_shm_pool *
wl_shm_buffer_ref_pool(struct wl_shm_buffer *buffer);
void
wl_shm_pool_unref(struct wl_shm_pool *pool);
int
wl_display_init_shm(struct wl_display *display);
uint32_t *
wl_display_add_shm_format(struct wl_display *display, uint32_t format);
struct wl_shm_buffer *
wl_shm_buffer_create(struct wl_client *client,
uint32_t id, int32_t width, int32_t height,
int32_t stride, uint32_t format) WL_DEPRECATED;
void
wl_log_set_handler_server(wl_log_func_t handler);
enum wl_protocol_logger_type {
WL_PROTOCOL_LOGGER_REQUEST,
WL_PROTOCOL_LOGGER_EVENT,
};
struct wl_protocol_logger_message {
struct wl_resource *resource;
int message_opcode;
const struct wl_message *message;
int arguments_count;
const union wl_argument *arguments;
};
typedef void (*wl_protocol_logger_func_t)(void *user_data,
enum wl_protocol_logger_type direction,
const struct wl_protocol_logger_message *message);
struct wl_protocol_logger *
wl_display_add_protocol_logger(struct wl_display *display,
wl_protocol_logger_func_t, void *user_data);
void
wl_protocol_logger_destroy(struct wl_protocol_logger *logger);
#ifdef __cplusplus
}
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,106 +0,0 @@
/*
* Copyright © 2008 Kristian Høgsberg
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/** \file
*
* \brief Include the server API, deprecations and protocol C API.
*
* \warning Use of this header file is discouraged. Prefer including
* wayland-server-core.h instead, which does not include the
* server protocol header and as such only defines the library
* API, excluding the deprecated API below.
*/
#ifndef WAYLAND_SERVER_H
#define WAYLAND_SERVER_H
#include <stdint.h>
#include "wayland-server-core.h"
#ifdef __cplusplus
extern "C" {
#endif
/*
* The user can set this macro to hide the wl_object, wl_resource and wl_buffer
* objects alongside the associated API.
*
* The structs were meant to be opaque, although we missed that in the early days.
*
* NOTE: the list of structs, functions, etc in this section MUST NEVER GROW.
* Otherwise we will break forward compatibility and applications that used to
* build fine will no longer be able to do so.
*/
#ifndef WL_HIDE_DEPRECATED
struct wl_object {
const struct wl_interface *interface;
const void *implementation;
uint32_t id;
};
struct wl_resource {
struct wl_object object;
wl_resource_destroy_func_t destroy;
struct wl_list link;
struct wl_signal destroy_signal;
struct wl_client *client;
void *data;
};
uint32_t
wl_client_add_resource(struct wl_client *client,
struct wl_resource *resource) WL_DEPRECATED;
struct wl_resource *
wl_client_add_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation,
uint32_t id, void *data) WL_DEPRECATED;
struct wl_resource *
wl_client_new_object(struct wl_client *client,
const struct wl_interface *interface,
const void *implementation, void *data) WL_DEPRECATED;
struct wl_global *
wl_display_add_global(struct wl_display *display,
const struct wl_interface *interface,
void *data,
wl_global_bind_func_t bind) WL_DEPRECATED;
void
wl_display_remove_global(struct wl_display *display,
struct wl_global *global) WL_DEPRECATED;
#endif
#ifdef __cplusplus
}
#endif
#include "wayland-server-protocol.h"
#endif

View File

@ -1,765 +0,0 @@
/*
* Copyright © 2008 Kristian Høgsberg
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
/** \file wayland-util.h
*
* \brief Utility classes, functions, and macros.
*/
#ifndef WAYLAND_UTIL_H
#define WAYLAND_UTIL_H
#include <math.h>
#include <stddef.h>
#include <inttypes.h>
#include <stdarg.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Visibility attribute */
#if defined(__GNUC__) && __GNUC__ >= 4
#define WL_EXPORT __attribute__ ((visibility("default")))
#else
#define WL_EXPORT
#endif
/** Deprecated attribute */
#if defined(__GNUC__) && __GNUC__ >= 4
#define WL_DEPRECATED __attribute__ ((deprecated))
#else
#define WL_DEPRECATED
#endif
/**
* Printf-style argument attribute
*
* \param x Ordinality of the format string argument
* \param y Ordinality of the argument to check against the format string
*
* \sa https://gcc.gnu.org/onlinedocs/gcc-3.2.1/gcc/Function-Attributes.html
*/
#if defined(__GNUC__) && __GNUC__ >= 4
#define WL_PRINTF(x, y) __attribute__((__format__(__printf__, x, y)))
#else
#define WL_PRINTF(x, y)
#endif
/** \class wl_object
*
* \brief A protocol object.
*
* A `wl_object` is an opaque struct identifying the protocol object
* underlying a `wl_proxy` or `wl_resource`.
*
* \note Functions accessing a `wl_object` are not normally used by client code.
* Clients should normally use the higher level interface generated by the
* scanner to interact with compositor objects.
*
*/
struct wl_object;
/**
* Protocol message signature
*
* A wl_message describes the signature of an actual protocol message, such as a
* request or event, that adheres to the Wayland protocol wire format. The
* protocol implementation uses a wl_message within its demarshal machinery for
* decoding messages between a compositor and its clients. In a sense, a
* wl_message is to a protocol message like a class is to an object.
*
* The `name` of a wl_message is the name of the corresponding protocol message.
*
* The `signature` is an ordered list of symbols representing the data types
* of message arguments and, optionally, a protocol version and indicators for
* nullability. A leading integer in the `signature` indicates the _since_
* version of the protocol message. A `?` preceding a data type symbol indicates
* that the following argument type is nullable. While it is a protocol violation
* to send messages with non-nullable arguments set to `NULL`, event handlers in
* clients might still get called with non-nullable object arguments set to
* `NULL`. This can happen when the client destroyed the object being used as
* argument on its side and an event referencing that object was sent before the
* server knew about its destruction. As this race cannot be prevented, clients
* should - as a general rule - program their event handlers such that they can
* handle object arguments declared non-nullable being `NULL` gracefully.
*
* When no arguments accompany a message, `signature` is an empty string.
*
* Symbols:
*
* * `i`: int
* * `u`: uint
* * `f`: fixed
* * `s`: string
* * `o`: object
* * `n`: new_id
* * `a`: array
* * `h`: fd
* * `?`: following argument is nullable
*
* While demarshaling primitive arguments is straightforward, when demarshaling
* messages containing `object` or `new_id` arguments, the protocol
* implementation often must determine the type of the object. The `types` of a
* wl_message is an array of wl_interface references that correspond to `o` and
* `n` arguments in `signature`, with `NULL` placeholders for arguments with
* non-object types.
*
* Consider the protocol event wl_display `delete_id` that has a single `uint`
* argument. The wl_message is:
*
* \code
* { "delete_id", "u", [NULL] }
* \endcode
*
* Here, the message `name` is `"delete_id"`, the `signature` is `"u"`, and the
* argument `types` is `[NULL]`, indicating that the `uint` argument has no
* corresponding wl_interface since it is a primitive argument.
*
* In contrast, consider a `wl_foo` interface supporting protocol request `bar`
* that has existed since version 2, and has two arguments: a `uint` and an
* object of type `wl_baz_interface` that may be `NULL`. Such a `wl_message`
* might be:
*
* \code
* { "bar", "2u?o", [NULL, &wl_baz_interface] }
* \endcode
*
* Here, the message `name` is `"bar"`, and the `signature` is `"2u?o"`. Notice
* how the `2` indicates the protocol version, the `u` indicates the first
* argument type is `uint`, and the `?o` indicates that the second argument
* is an object that may be `NULL`. Lastly, the argument `types` array indicates
* that no wl_interface corresponds to the first argument, while the type
* `wl_baz_interface` corresponds to the second argument.
*
* \sa wl_argument
* \sa wl_interface
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Wire-Format">Wire Format</a>
*/
struct wl_message {
/** Message name */
const char *name;
/** Message signature */
const char *signature;
/** Object argument interfaces */
const struct wl_interface **types;
};
/**
* Protocol object interface
*
* A wl_interface describes the API of a protocol object defined in the Wayland
* protocol specification. The protocol implementation uses a wl_interface
* within its marshalling machinery for encoding client requests.
*
* The `name` of a wl_interface is the name of the corresponding protocol
* interface, and `version` represents the version of the interface. The members
* `method_count` and `event_count` represent the number of `methods` (requests)
* and `events` in the respective wl_message members.
*
* For example, consider a protocol interface `foo`, marked as version `1`, with
* two requests and one event.
*
* \code
* <interface name="foo" version="1">
* <request name="a"></request>
* <request name="b"></request>
* <event name="c"></event>
* </interface>
* \endcode
*
* Given two wl_message arrays `foo_requests` and `foo_events`, a wl_interface
* for `foo` might be:
*
* \code
* struct wl_interface foo_interface = {
* "foo", 1,
* 2, foo_requests,
* 1, foo_events
* };
* \endcode
*
* \note The server side of the protocol may define interface <em>implementation
* types</em> that incorporate the term `interface` in their name. Take
* care to not confuse these server-side `struct`s with a wl_interface
* variable whose name also ends in `interface`. For example, while the
* server may define a type `struct wl_foo_interface`, the client may
* define a `struct wl_interface wl_foo_interface`.
*
* \sa wl_message
* \sa wl_proxy
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Interfaces">Interfaces</a>
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-Versioning">Versioning</a>
*/
struct wl_interface {
/** Interface name */
const char *name;
/** Interface version */
int version;
/** Number of methods (requests) */
int method_count;
/** Method (request) signatures */
const struct wl_message *methods;
/** Number of events */
int event_count;
/** Event signatures */
const struct wl_message *events;
};
/** \class wl_list
*
* \brief Doubly-linked list
*
* On its own, an instance of `struct wl_list` represents the sentinel head of
* a doubly-linked list, and must be initialized using wl_list_init().
* When empty, the list head's `next` and `prev` members point to the list head
* itself, otherwise `next` references the first element in the list, and `prev`
* refers to the last element in the list.
*
* Use the `struct wl_list` type to represent both the list head and the links
* between elements within the list. Use wl_list_empty() to determine if the
* list is empty in O(1).
*
* All elements in the list must be of the same type. The element type must have
* a `struct wl_list` member, often named `link` by convention. Prior to
* insertion, there is no need to initialize an element's `link` - invoking
* wl_list_init() on an individual list element's `struct wl_list` member is
* unnecessary if the very next operation is wl_list_insert(). However, a
* common idiom is to initialize an element's `link` prior to removal - ensure
* safety by invoking wl_list_init() before wl_list_remove().
*
* Consider a list reference `struct wl_list foo_list`, an element type as
* `struct element`, and an element's link member as `struct wl_list link`.
*
* The following code initializes a list and adds three elements to it.
*
* \code
* struct wl_list foo_list;
*
* struct element {
* int foo;
* struct wl_list link;
* };
* struct element e1, e2, e3;
*
* wl_list_init(&foo_list);
* wl_list_insert(&foo_list, &e1.link); // e1 is the first element
* wl_list_insert(&foo_list, &e2.link); // e2 is now the first element
* wl_list_insert(&e2.link, &e3.link); // insert e3 after e2
* \endcode
*
* The list now looks like <em>[e2, e3, e1]</em>.
*
* The `wl_list` API provides some iterator macros. For example, to iterate
* a list in ascending order:
*
* \code
* struct element *e;
* wl_list_for_each(e, foo_list, link) {
* do_something_with_element(e);
* }
* \endcode
*
* See the documentation of each iterator for details.
* \sa http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/list.h
*/
struct wl_list {
/** Previous list element */
struct wl_list *prev;
/** Next list element */
struct wl_list *next;
};
/**
* Initializes the list.
*
* \param list List to initialize
*
* \memberof wl_list
*/
void
wl_list_init(struct wl_list *list);
/**
* Inserts an element into the list, after the element represented by \p list.
* When \p list is a reference to the list itself (the head), set the containing
* struct of \p elm as the first element in the list.
*
* \note If \p elm is already part of a list, inserting it again will lead to
* list corruption.
*
* \param list List element after which the new element is inserted
* \param elm Link of the containing struct to insert into the list
*
* \memberof wl_list
*/
void
wl_list_insert(struct wl_list *list, struct wl_list *elm);
/**
* Removes an element from the list.
*
* \note This operation leaves \p elm in an invalid state.
*
* \param elm Link of the containing struct to remove from the list
*
* \memberof wl_list
*/
void
wl_list_remove(struct wl_list *elm);
/**
* Determines the length of the list.
*
* \note This is an O(n) operation.
*
* \param list List whose length is to be determined
*
* \return Number of elements in the list
*
* \memberof wl_list
*/
int
wl_list_length(const struct wl_list *list);
/**
* Determines if the list is empty.
*
* \param list List whose emptiness is to be determined
*
* \return 1 if empty, or 0 if not empty
*
* \memberof wl_list
*/
int
wl_list_empty(const struct wl_list *list);
/**
* Inserts all of the elements of one list into another, after the element
* represented by \p list.
*
* \note This leaves \p other in an invalid state.
*
* \param list List element after which the other list elements will be inserted
* \param other List of elements to insert
*
* \memberof wl_list
*/
void
wl_list_insert_list(struct wl_list *list, struct wl_list *other);
/**
* Retrieves a pointer to a containing struct, given a member name.
*
* This macro allows "conversion" from a pointer to a member to its containing
* struct. This is useful if you have a contained item like a wl_list,
* wl_listener, or wl_signal, provided via a callback or other means, and would
* like to retrieve the struct that contains it.
*
* To demonstrate, the following example retrieves a pointer to
* `example_container` given only its `destroy_listener` member:
*
* \code
* struct example_container {
* struct wl_listener destroy_listener;
* // other members...
* };
*
* void example_container_destroy(struct wl_listener *listener, void *data)
* {
* struct example_container *ctr;
*
* ctr = wl_container_of(listener, ctr, destroy_listener);
* // destroy ctr...
* }
* \endcode
*
* \note `sample` need not be a valid pointer. A null or uninitialised pointer
* is sufficient.
*
* \param ptr Valid pointer to the contained member
* \param sample Pointer to a struct whose type contains \p ptr
* \param member Named location of \p ptr within the \p sample type
*
* \return The container for the specified pointer
*/
#define wl_container_of(ptr, sample, member) \
(__typeof__(sample))((char *)(ptr) - \
offsetof(__typeof__(*sample), member))
/**
* Iterates over a list.
*
* This macro expresses a for-each iterator for wl_list. Given a list and
* wl_list link member name (often named `link` by convention), this macro
* assigns each element in the list to \p pos, which can then be referenced in
* a trailing code block. For example, given a wl_list of `struct message`
* elements:
*
* \code
* struct message {
* char *contents;
* wl_list link;
* };
*
* struct wl_list *message_list;
* // Assume message_list now "contains" many messages
*
* struct message *m;
* wl_list_for_each(m, message_list, link) {
* do_something_with_message(m);
* }
* \endcode
*
* \param pos Cursor that each list element will be assigned to
* \param head Head of the list to iterate over
* \param member Name of the link member within the element struct
*
* \relates wl_list
*/
#define wl_list_for_each(pos, head, member) \
for (pos = wl_container_of((head)->next, pos, member); \
&pos->member != (head); \
pos = wl_container_of(pos->member.next, pos, member))
/**
* Iterates over a list, safe against removal of the list element.
*
* \note Only removal of the current element, \p pos, is safe. Removing
* any other element during traversal may lead to a loop malfunction.
*
* \sa wl_list_for_each()
*
* \param pos Cursor that each list element will be assigned to
* \param tmp Temporary pointer of the same type as \p pos
* \param head Head of the list to iterate over
* \param member Name of the link member within the element struct
*
* \relates wl_list
*/
#define wl_list_for_each_safe(pos, tmp, head, member) \
for (pos = wl_container_of((head)->next, pos, member), \
tmp = wl_container_of((pos)->member.next, tmp, member); \
&pos->member != (head); \
pos = tmp, \
tmp = wl_container_of(pos->member.next, tmp, member))
/**
* Iterates backwards over a list.
*
* \sa wl_list_for_each()
*
* \param pos Cursor that each list element will be assigned to
* \param head Head of the list to iterate over
* \param member Name of the link member within the element struct
*
* \relates wl_list
*/
#define wl_list_for_each_reverse(pos, head, member) \
for (pos = wl_container_of((head)->prev, pos, member); \
&pos->member != (head); \
pos = wl_container_of(pos->member.prev, pos, member))
/**
* Iterates backwards over a list, safe against removal of the list element.
*
* \note Only removal of the current element, \p pos, is safe. Removing
* any other element during traversal may lead to a loop malfunction.
*
* \sa wl_list_for_each()
*
* \param pos Cursor that each list element will be assigned to
* \param tmp Temporary pointer of the same type as \p pos
* \param head Head of the list to iterate over
* \param member Name of the link member within the element struct
*
* \relates wl_list
*/
#define wl_list_for_each_reverse_safe(pos, tmp, head, member) \
for (pos = wl_container_of((head)->prev, pos, member), \
tmp = wl_container_of((pos)->member.prev, tmp, member); \
&pos->member != (head); \
pos = tmp, \
tmp = wl_container_of(pos->member.prev, tmp, member))
/**
* \class wl_array
*
* Dynamic array
*
* A wl_array is a dynamic array that can only grow until released. It is
* intended for relatively small allocations whose size is variable or not known
* in advance. While construction of a wl_array does not require all elements to
* be of the same size, wl_array_for_each() does require all elements to have
* the same type and size.
*
*/
struct wl_array {
/** Array size */
size_t size;
/** Allocated space */
size_t alloc;
/** Array data */
void *data;
};
/**
* Initializes the array.
*
* \param array Array to initialize
*
* \memberof wl_array
*/
void
wl_array_init(struct wl_array *array);
/**
* Releases the array data.
*
* \note Leaves the array in an invalid state.
*
* \param array Array whose data is to be released
*
* \memberof wl_array
*/
void
wl_array_release(struct wl_array *array);
/**
* Increases the size of the array by \p size bytes.
*
* \param array Array whose size is to be increased
* \param size Number of bytes to increase the size of the array by
*
* \return A pointer to the beginning of the newly appended space, or NULL when
* resizing fails.
*
* \memberof wl_array
*/
void *
wl_array_add(struct wl_array *array, size_t size);
/**
* Copies the contents of \p source to \p array.
*
* \param array Destination array to copy to
* \param source Source array to copy from
*
* \return 0 on success, or -1 on failure
*
* \memberof wl_array
*/
int
wl_array_copy(struct wl_array *array, struct wl_array *source);
/**
* Iterates over an array.
*
* This macro expresses a for-each iterator for wl_array. It assigns each
* element in the array to \p pos, which can then be referenced in a trailing
* code block. \p pos must be a pointer to the array element type, and all
* array elements must be of the same type and size.
*
* \param pos Cursor that each array element will be assigned to
* \param array Array to iterate over
*
* \relates wl_array
* \sa wl_list_for_each()
*/
#define wl_array_for_each(pos, array) \
for (pos = (array)->data; \
(const char *) pos < ((const char *) (array)->data + (array)->size); \
(pos)++)
/**
* Fixed-point number
*
* A `wl_fixed_t` is a 24.8 signed fixed-point number with a sign bit, 23 bits
* of integer precision and 8 bits of decimal precision. Consider `wl_fixed_t`
* as an opaque struct with methods that facilitate conversion to and from
* `double` and `int` types.
*/
typedef int32_t wl_fixed_t;
/**
* Converts a fixed-point number to a floating-point number.
*
* \param f Fixed-point number to convert
*
* \return Floating-point representation of the fixed-point argument
*/
static inline double
wl_fixed_to_double(wl_fixed_t f)
{
union {
double d;
int64_t i;
} u;
u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f;
return u.d - (3LL << 43);
}
/**
* Converts a floating-point number to a fixed-point number.
*
* \param d Floating-point number to convert
*
* \return Fixed-point representation of the floating-point argument
*/
static inline wl_fixed_t
wl_fixed_from_double(double d)
{
union {
double d;
int64_t i;
} u;
u.d = d + (3LL << (51 - 8));
return (wl_fixed_t)u.i;
}
/**
* Converts a fixed-point number to an integer.
*
* \param f Fixed-point number to convert
*
* \return Integer component of the fixed-point argument
*/
static inline int
wl_fixed_to_int(wl_fixed_t f)
{
return f / 256;
}
/**
* Converts an integer to a fixed-point number.
*
* \param i Integer to convert
*
* \return Fixed-point representation of the integer argument
*/
static inline wl_fixed_t
wl_fixed_from_int(int i)
{
return i * 256;
}
/**
* Protocol message argument data types
*
* This union represents all of the argument types in the Wayland protocol wire
* format. The protocol implementation uses wl_argument within its marshalling
* machinery for dispatching messages between a client and a compositor.
*
* \sa wl_message
* \sa wl_interface
* \sa <a href="https://wayland.freedesktop.org/docs/html/ch04.html#sect-Protocol-wire-Format">Wire Format</a>
*/
union wl_argument {
int32_t i; /**< `int` */
uint32_t u; /**< `uint` */
wl_fixed_t f; /**< `fixed` */
const char *s; /**< `string` */
struct wl_object *o; /**< `object` */
uint32_t n; /**< `new_id` */
struct wl_array *a; /**< `array` */
int32_t h; /**< `fd` */
};
/**
* Dispatcher function type alias
*
* A dispatcher is a function that handles the emitting of callbacks in client
* code. For programs directly using the C library, this is done by using
* libffi to call function pointers. When binding to languages other than C,
* dispatchers provide a way to abstract the function calling process to be
* friendlier to other function calling systems.
*
* A dispatcher takes five arguments: The first is the dispatcher-specific
* implementation associated with the target object. The second is the object
* upon which the callback is being invoked (either wl_proxy or wl_resource).
* The third and fourth arguments are the opcode and the wl_message
* corresponding to the callback. The final argument is an array of arguments
* received from the other process via the wire protocol.
*
* \param "const void *" Dispatcher-specific implementation data
* \param "void *" Callback invocation target (wl_proxy or `wl_resource`)
* \param uint32_t Callback opcode
* \param "const struct wl_message *" Callback message signature
* \param "union wl_argument *" Array of received arguments
*
* \return 0 on success, or -1 on failure
*/
typedef int (*wl_dispatcher_func_t)(const void *, void *, uint32_t,
const struct wl_message *,
union wl_argument *);
/**
* Log function type alias
*
* The C implementation of the Wayland protocol abstracts the details of
* logging. Users may customize the logging behavior, with a function conforming
* to the `wl_log_func_t` type, via `wl_log_set_handler_client` and
* `wl_log_set_handler_server`.
*
* A `wl_log_func_t` must conform to the expectations of `vprintf`, and
* expects two arguments: a string to write and a corresponding variable
* argument list. While the string to write may contain format specifiers and
* use values in the variable argument list, the behavior of any `wl_log_func_t`
* depends on the implementation.
*
* \note Take care to not confuse this with `wl_protocol_logger_func_t`, which
* is a specific server-side logger for requests and events.
*
* \param "const char *" String to write to the log, containing optional format
* specifiers
* \param "va_list" Variable argument list
*
* \sa wl_log_set_handler_client
* \sa wl_log_set_handler_server
*/
typedef void (*wl_log_func_t)(const char *, va_list) WL_PRINTF(1, 0);
/**
* Return value of an iterator function
*
* \sa wl_client_for_each_resource_iterator_func_t
* \sa wl_client_for_each_resource
*/
enum wl_iterator_result {
/** Stop the iteration */
WL_ITERATOR_STOP,
/** Continue the iteration */
WL_ITERATOR_CONTINUE
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,34 +0,0 @@
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef WAYLAND_VERSION_H
#define WAYLAND_VERSION_H
#define WAYLAND_VERSION_MAJOR 1
#define WAYLAND_VERSION_MINOR 19
#define WAYLAND_VERSION_MICRO 0
#define WAYLAND_VERSION "1.19.0"
#endif

View File

@ -1,98 +0,0 @@
/*
* Copyright © 2012 Daniel Stone
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
#ifndef _XKBCOMMON_COMPAT_H
#define _XKBCOMMON_COMPAT_H
/**
* Renamed keymap API.
*/
#define xkb_group_index_t xkb_layout_index_t
#define xkb_group_mask_t xkb_layout_mask_t
#define xkb_map_compile_flags xkb_keymap_compile_flags
#define XKB_GROUP_INVALID XKB_LAYOUT_INVALID
#define XKB_STATE_DEPRESSED \
(XKB_STATE_MODS_DEPRESSED | XKB_STATE_LAYOUT_DEPRESSED)
#define XKB_STATE_LATCHED \
(XKB_STATE_MODS_LATCHED | XKB_STATE_LAYOUT_LATCHED)
#define XKB_STATE_LOCKED \
(XKB_STATE_MODS_LOCKED | XKB_STATE_LAYOUT_LOCKED)
#define XKB_STATE_EFFECTIVE \
(XKB_STATE_DEPRESSED | XKB_STATE_LATCHED | XKB_STATE_LOCKED | \
XKB_STATE_MODS_EFFECTIVE | XKB_STATE_LAYOUT_EFFECTIVE)
#define xkb_map_new_from_names(context, names, flags) \
xkb_keymap_new_from_names(context, names, flags)
#define xkb_map_new_from_file(context, file, format, flags) \
xkb_keymap_new_from_file(context, file, format, flags)
#define xkb_map_new_from_string(context, string, format, flags) \
xkb_keymap_new_from_string(context, string, format, flags)
#define xkb_map_get_as_string(keymap) \
xkb_keymap_get_as_string(keymap, XKB_KEYMAP_FORMAT_TEXT_V1)
#define xkb_map_ref(keymap) xkb_keymap_ref(keymap)
#define xkb_map_unref(keymap) xkb_keymap_unref(keymap)
#define xkb_map_num_mods(keymap) xkb_keymap_num_mods(keymap)
#define xkb_map_mod_get_name(keymap, idx) xkb_keymap_mod_get_name(keymap, idx)
#define xkb_map_mod_get_index(keymap, str) xkb_keymap_mod_get_index(keymap, str)
#define xkb_key_mod_index_is_consumed(state, key, mod) \
xkb_state_mod_index_is_consumed(state, key, mod)
#define xkb_key_mod_mask_remove_consumed(state, key, modmask) \
xkb_state_mod_mask_remove_consumed(state, key, modmask)
#define xkb_map_num_groups(keymap) xkb_keymap_num_layouts(keymap)
#define xkb_key_num_groups(keymap, key) \
xkb_keymap_num_layouts_for_key(keymap, key)
#define xkb_map_group_get_name(keymap, idx) \
xkb_keymap_layout_get_name(keymap, idx)
#define xkb_map_group_get_index(keymap, str) \
xkb_keymap_layout_get_index(keymap, str)
#define xkb_map_num_leds(keymap) xkb_keymap_num_leds(keymap)
#define xkb_map_led_get_name(keymap, idx) xkb_keymap_led_get_name(keymap, idx)
#define xkb_map_led_get_index(keymap, str) \
xkb_keymap_led_get_index(keymap, str)
#define xkb_key_repeats(keymap, key) xkb_keymap_key_repeats(keymap, key)
#define xkb_key_get_syms(state, key, syms_out) \
xkb_state_key_get_syms(state, key, syms_out)
#define xkb_state_group_name_is_active(state, name, type) \
xkb_state_layout_name_is_active(state, name, type)
#define xkb_state_group_index_is_active(state, idx, type) \
xkb_state_layout_index_is_active(state, idx, type)
#define xkb_state_serialize_group(state, component) \
xkb_state_serialize_layout(state, component)
#define xkb_state_get_map(state) xkb_state_get_keymap(state)
/* Not needed anymore, since there's NO_FLAGS. */
#define XKB_MAP_COMPILE_PLACEHOLDER XKB_KEYMAP_COMPILE_NO_FLAGS
#define XKB_MAP_COMPILE_NO_FLAGS XKB_KEYMAP_COMPILE_NO_FLAGS
#endif

View File

@ -1,500 +0,0 @@
/*
* Copyright © 2013 Ran Benita
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _XKBCOMMON_COMPOSE_H
#define _XKBCOMMON_COMPOSE_H
#include <xkbcommon/xkbcommon.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file
* libxkbcommon Compose API - support for Compose and dead-keys.
*/
/**
* @defgroup compose Compose and dead-keys support
* Support for Compose and dead-keys.
* @since 0.5.0
*
* @{
*/
/**
* @page compose-overview Overview
* @parblock
*
* Compose and dead-keys are a common feature of many keyboard input
* systems. They extend the range of the keysysm that can be produced
* directly from a keyboard by using a sequence of key strokes, instead
* of just one.
*
* Here are some example sequences, in the libX11 Compose file format:
*
* <dead_acute> <a> : "á" aacute # LATIN SMALL LETTER A WITH ACUTE
* <Multi_key> <A> <T> : "@" at # COMMERCIAL AT
*
* When the user presses a key which produces the `<dead_acute>` keysym,
* nothing initially happens (thus the key is dubbed a "dead-key"). But
* when the user enters `<a>`, "á" is "composed", in place of "a". If
* instead the user had entered a keysym which does not follow
* `<dead_acute>` in any compose sequence, the sequence is said to be
* "cancelled".
*
* Compose files define many such sequences. For a description of the
* common file format for Compose files, see the Compose(5) man page.
*
* A successfuly-composed sequence has two results: a keysym and a UTF-8
* string. At least one of the two is defined for each sequence. If only
* a keysym is given, the keysym's string representation is used for the
* result string (using xkb_keysym_to_utf8()).
*
* This library provides low-level support for Compose file parsing and
* processing. Higher-level APIs (such as libX11's `Xutf8LookupString`(3))
* may be built upon it, or it can be used directly.
*
* @endparblock
*/
/**
* @page compose-conflicting Conflicting Sequences
* @parblock
*
* To avoid ambiguity, a sequence is not allowed to be a prefix of another.
* In such a case, the conflict is resolved thus:
*
* 1. A longer sequence overrides a shorter one.
* 2. An equal sequence overrides an existing one.
* 3. A shorter sequence does not override a longer one.
*
* Sequences of length 1 are allowed.
*
* @endparblock
*/
/**
* @page compose-cancellation Cancellation Behavior
* @parblock
*
* What should happen when a sequence is cancelled? For example, consider
* there are only the above sequences, and the input keysyms are
* `<dead_acute> <b>`. There are a few approaches:
*
* 1. Swallow the cancelling keysym; that is, no keysym is produced.
* This is the approach taken by libX11.
* 2. Let the cancelling keysym through; that is, `<b>` is produced.
* 3. Replay the entire sequence; that is, `<dead_acute> <b>` is produced.
* This is the approach taken by Microsoft Windows (approximately;
* instead of `<dead_acute>`, the underlying key is used. This is
* difficult to simulate with XKB keymaps).
*
* You can program whichever approach best fits users' expectations.
*
* @endparblock
*/
/**
* @struct xkb_compose_table
* Opaque Compose table object.
*
* The compose table holds the definitions of the Compose sequences, as
* gathered from Compose files. It is immutable.
*/
struct xkb_compose_table;
/**
* @struct xkb_compose_state
* Opaque Compose state object.
*
* The compose state maintains state for compose sequence matching, such
* as which possible sequences are being matched, and the position within
* these sequences. It acts as a simple state machine wherein keysyms are
* the input, and composed keysyms and strings are the output.
*
* The compose state is usually associated with a keyboard device.
*/
struct xkb_compose_state;
/** Flags affecting Compose file compilation. */
enum xkb_compose_compile_flags {
/** Do not apply any flags. */
XKB_COMPOSE_COMPILE_NO_FLAGS = 0
};
/** The recognized Compose file formats. */
enum xkb_compose_format {
/** The classic libX11 Compose text format, described in Compose(5). */
XKB_COMPOSE_FORMAT_TEXT_V1 = 1
};
/**
* @page compose-locale Compose Locale
* @parblock
*
* Compose files are locale dependent:
* - Compose files are written for a locale, and the locale is used when
* searching for the appropriate file to use.
* - Compose files may reference the locale internally, with directives
* such as \%L.
*
* As such, functions like xkb_compose_table_new_from_locale() require
* a `locale` parameter. This will usually be the current locale (see
* locale(7) for more details). You may also want to allow the user to
* explicitly configure it, so he can use the Compose file of a given
* locale, but not use that locale for other things.
*
* You may query the current locale as follows:
* @code
* const char *locale;
* locale = setlocale(LC_CTYPE, NULL);
* @endcode
*
* This will only give useful results if the program had previously set
* the current locale using setlocale(3), with `LC_CTYPE` or `LC_ALL`
* and a non-NULL argument.
*
* If you prefer not to use the locale system of the C runtime library,
* you may nevertheless obtain the user's locale directly using
* environment variables, as described in locale(7). For example,
* @code
* const char *locale;
* locale = getenv("LC_ALL");
* if (!locale || !*locale)
* locale = getenv("LC_CTYPE");
* if (!locale || !*locale)
* locale = getenv("LANG");
* if (!locale || !*locale)
* locale = "C";
* @endcode
*
* Note that some locales supported by the C standard library may not
* have a Compose file assigned.
*
* @endparblock
*/
/**
* Create a compose table for a given locale.
*
* The locale is used for searching the file-system for an appropriate
* Compose file. The search order is described in Compose(5). It is
* affected by the following environment variables:
*
* 1. `XCOMPOSEFILE` - see Compose(5).
* 2. `XDG_CONFIG_HOME` - before `$HOME/.XCompose` is checked,
* `$XDG_CONFIG_HOME/XCompose` is checked (with a fall back to
* `$HOME/.config/XCompose` if `XDG_CONFIG_HOME` is not defined).
* This is a libxkbcommon extension to the search procedure in
* Compose(5) (since libxkbcommon 1.0.0). Note that other
* implementations, such as libX11, might not find a Compose file in
* this path.
* 3. `HOME` - see Compose(5).
* 4. `XLOCALEDIR` - if set, used as the base directory for the system's
* X locale files, e.g. `/usr/share/X11/locale`, instead of the
* preconfigured directory.
*
* @param context
* The library context in which to create the compose table.
* @param locale
* The current locale. See @ref compose-locale.
* \n
* The value is copied, so it is safe to pass the result of getenv(3)
* (or similar) without fear of it being invalidated by a subsequent
* setenv(3) (or similar).
* @param flags
* Optional flags for the compose table, or 0.
*
* @returns A compose table for the given locale, or NULL if the
* compilation failed or a Compose file was not found.
*
* @memberof xkb_compose_table
*/
struct xkb_compose_table *
xkb_compose_table_new_from_locale(struct xkb_context *context,
const char *locale,
enum xkb_compose_compile_flags flags);
/**
* Create a new compose table from a Compose file.
*
* @param context
* The library context in which to create the compose table.
* @param file
* The Compose file to compile.
* @param locale
* The current locale. See @ref compose-locale.
* @param format
* The text format of the Compose file to compile.
* @param flags
* Optional flags for the compose table, or 0.
*
* @returns A compose table compiled from the given file, or NULL if
* the compilation failed.
*
* @memberof xkb_compose_table
*/
struct xkb_compose_table *
xkb_compose_table_new_from_file(struct xkb_context *context,
FILE *file,
const char *locale,
enum xkb_compose_format format,
enum xkb_compose_compile_flags flags);
/**
* Create a new compose table from a memory buffer.
*
* This is just like xkb_compose_table_new_from_file(), but instead of
* a file, gets the table as one enormous string.
*
* @see xkb_compose_table_new_from_file()
* @memberof xkb_compose_table
*/
struct xkb_compose_table *
xkb_compose_table_new_from_buffer(struct xkb_context *context,
const char *buffer, size_t length,
const char *locale,
enum xkb_compose_format format,
enum xkb_compose_compile_flags flags);
/**
* Take a new reference on a compose table.
*
* @returns The passed in object.
*
* @memberof xkb_compose_table
*/
struct xkb_compose_table *
xkb_compose_table_ref(struct xkb_compose_table *table);
/**
* Release a reference on a compose table, and possibly free it.
*
* @param table The object. If it is NULL, this function does nothing.
*
* @memberof xkb_compose_table
*/
void
xkb_compose_table_unref(struct xkb_compose_table *table);
/** Flags for compose state creation. */
enum xkb_compose_state_flags {
/** Do not apply any flags. */
XKB_COMPOSE_STATE_NO_FLAGS = 0
};
/**
* Create a new compose state object.
*
* @param table
* The compose table the state will use.
* @param flags
* Optional flags for the compose state, or 0.
*
* @returns A new compose state, or NULL on failure.
*
* @memberof xkb_compose_state
*/
struct xkb_compose_state *
xkb_compose_state_new(struct xkb_compose_table *table,
enum xkb_compose_state_flags flags);
/**
* Take a new reference on a compose state object.
*
* @returns The passed in object.
*
* @memberof xkb_compose_state
*/
struct xkb_compose_state *
xkb_compose_state_ref(struct xkb_compose_state *state);
/**
* Release a reference on a compose state object, and possibly free it.
*
* @param state The object. If NULL, do nothing.
*
* @memberof xkb_compose_state
*/
void
xkb_compose_state_unref(struct xkb_compose_state *state);
/**
* Get the compose table which a compose state object is using.
*
* @returns The compose table which was passed to xkb_compose_state_new()
* when creating this state object.
*
* This function does not take a new reference on the compose table; you
* must explicitly reference it yourself if you plan to use it beyond the
* lifetime of the state.
*
* @memberof xkb_compose_state
*/
struct xkb_compose_table *
xkb_compose_state_get_compose_table(struct xkb_compose_state *state);
/** Status of the Compose sequence state machine. */
enum xkb_compose_status {
/** The initial state; no sequence has started yet. */
XKB_COMPOSE_NOTHING,
/** In the middle of a sequence. */
XKB_COMPOSE_COMPOSING,
/** A complete sequence has been matched. */
XKB_COMPOSE_COMPOSED,
/** The last sequence was cancelled due to an unmatched keysym. */
XKB_COMPOSE_CANCELLED
};
/** The effect of a keysym fed to xkb_compose_state_feed(). */
enum xkb_compose_feed_result {
/** The keysym had no effect - it did not affect the status. */
XKB_COMPOSE_FEED_IGNORED,
/** The keysym started, advanced or cancelled a sequence. */
XKB_COMPOSE_FEED_ACCEPTED
};
/**
* Feed one keysym to the Compose sequence state machine.
*
* This function can advance into a compose sequence, cancel a sequence,
* start a new sequence, or do nothing in particular. The resulting
* status may be observed with xkb_compose_state_get_status().
*
* Some keysyms, such as keysyms for modifier keys, are ignored - they
* have no effect on the status or otherwise.
*
* The following is a description of the possible status transitions, in
* the format CURRENT STATUS => NEXT STATUS, given a non-ignored input
* keysym `keysym`:
*
@verbatim
NOTHING or CANCELLED or COMPOSED =>
NOTHING if keysym does not start a sequence.
COMPOSING if keysym starts a sequence.
COMPOSED if keysym starts and terminates a single-keysym sequence.
COMPOSING =>
COMPOSING if keysym advances any of the currently possible
sequences but does not terminate any of them.
COMPOSED if keysym terminates one of the currently possible
sequences.
CANCELLED if keysym does not advance any of the currently
possible sequences.
@endverbatim
*
* The current Compose formats do not support multiple-keysyms.
* Therefore, if you are using a function such as xkb_state_key_get_syms()
* and it returns more than one keysym, consider feeding XKB_KEY_NoSymbol
* instead.
*
* @param state
* The compose state object.
* @param keysym
* A keysym, usually obtained after a key-press event, with a
* function such as xkb_state_key_get_one_sym().
*
* @returns Whether the keysym was ignored. This is useful, for example,
* if you want to keep a record of the sequence matched thus far.
*
* @memberof xkb_compose_state
*/
enum xkb_compose_feed_result
xkb_compose_state_feed(struct xkb_compose_state *state,
xkb_keysym_t keysym);
/**
* Reset the Compose sequence state machine.
*
* The status is set to XKB_COMPOSE_NOTHING, and the current sequence
* is discarded.
*
* @memberof xkb_compose_state
*/
void
xkb_compose_state_reset(struct xkb_compose_state *state);
/**
* Get the current status of the compose state machine.
*
* @see xkb_compose_status
* @memberof xkb_compose_state
**/
enum xkb_compose_status
xkb_compose_state_get_status(struct xkb_compose_state *state);
/**
* Get the result Unicode/UTF-8 string for a composed sequence.
*
* See @ref compose-overview for more details. This function is only
* useful when the status is XKB_COMPOSE_COMPOSED.
*
* @param[in] state
* The compose state.
* @param[out] buffer
* A buffer to write the string into.
* @param[in] size
* Size of the buffer.
*
* @warning If the buffer passed is too small, the string is truncated
* (though still NUL-terminated).
*
* @returns
* The number of bytes required for the string, excluding the NUL byte.
* If the sequence is not complete, or does not have a viable result
* string, returns 0, and sets `buffer` to the empty string (if possible).
* @returns
* You may check if truncation has occurred by comparing the return value
* with the size of `buffer`, similarly to the `snprintf`(3) function.
* You may safely pass NULL and 0 to `buffer` and `size` to find the
* required size (without the NUL-byte).
*
* @memberof xkb_compose_state
**/
int
xkb_compose_state_get_utf8(struct xkb_compose_state *state,
char *buffer, size_t size);
/**
* Get the result keysym for a composed sequence.
*
* See @ref compose-overview for more details. This function is only
* useful when the status is XKB_COMPOSE_COMPOSED.
*
* @returns The result keysym. If the sequence is not complete, or does
* not specify a result keysym, returns XKB_KEY_NoSymbol.
*
* @memberof xkb_compose_state
**/
xkb_keysym_t
xkb_compose_state_get_one_sym(struct xkb_compose_state *state);
/** @} */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _XKBCOMMON_COMPOSE_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +0,0 @@
/*
* Copyright © 2012 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Author: Daniel Stone <daniel@fooishbar.org>
*/
#ifndef _XKBCOMMON_NAMES_H
#define _XKBCOMMON_NAMES_H
/**
* @file
* @brief Predefined names for common modifiers and LEDs.
*/
#define XKB_MOD_NAME_SHIFT "Shift"
#define XKB_MOD_NAME_CAPS "Lock"
#define XKB_MOD_NAME_CTRL "Control"
#define XKB_MOD_NAME_ALT "Mod1"
#define XKB_MOD_NAME_NUM "Mod2"
#define XKB_MOD_NAME_LOGO "Mod4"
#define XKB_LED_NAME_CAPS "Caps Lock"
#define XKB_LED_NAME_NUM "Num Lock"
#define XKB_LED_NAME_SCROLL "Scroll Lock"
#endif

View File

@ -1,244 +0,0 @@
/*
* Copyright © 2013 Ran Benita
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _XKBCOMMON_X11_H
#define _XKBCOMMON_X11_H
#include <xcb/xcb.h>
#include <xkbcommon/xkbcommon.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file
* libxkbcommon-x11 API - Additional X11 support for xkbcommon.
*/
/**
* @defgroup x11 X11 support
* Additional X11 support for xkbcommon.
* @since 0.4.0
*
* @{
*/
/**
* @page x11-overview Overview
* @parblock
*
* The xkbcommon-x11 module provides a means for creating an xkb_keymap
* corresponding to the currently active keymap on the X server. To do
* so, it queries the XKB X11 extension using the xcb-xkb library. It
* can be used as a replacement for Xlib's keyboard handling.
*
* Following is an example workflow using xkbcommon-x11. A complete
* example may be found in the tools/interactive-x11.c file in the
* xkbcommon source repository. On startup:
*
* 1. Connect to the X server using xcb_connect().
* 2. Setup the XKB X11 extension. You can do this either by using the
* xcb_xkb_use_extension() request directly, or by using the
* xkb_x11_setup_xkb_extension() helper function.
*
* The XKB extension supports using separate keymaps and states for
* different keyboard devices. The devices are identified by an integer
* device ID and are managed by another X11 extension, XInput. The
* original X11 protocol only had one keyboard device, called the "core
* keyboard", which is still supported as a "virtual device".
*
* 3. We will use the core keyboard as an example. To get its device ID,
* use either the xcb_xkb_get_device_info() request directly, or the
* xkb_x11_get_core_keyboard_device_id() helper function.
* 4. Create an initial xkb_keymap for this device, using the
* xkb_x11_keymap_new_from_device() function.
* 5. Create an initial xkb_state for this device, using the
* xkb_x11_state_new_from_device() function.
*
* @note At this point, you may consider setting various XKB controls and
* XKB per-client flags. For example, enabling detectable autorepeat: \n
* https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Detectable_Autorepeat
*
* Next, you need to react to state changes (e.g. a modifier was pressed,
* the layout was changed) and to keymap changes (e.g. a tool like xkbcomp,
* setxkbmap or xmodmap was used):
*
* 6. Select to listen to at least the following XKB events:
* NewKeyboardNotify, MapNotify, StateNotify; using the
* xcb_xkb_select_events_aux() request.
* 7. When NewKeyboardNotify or MapNotify are received, recreate the
* xkb_keymap and xkb_state as described above.
* 8. When StateNotify is received, update the xkb_state accordingly
* using the xkb_state_update_mask() function.
*
* @note It is also possible to use the KeyPress/KeyRelease @p state
* field to find the effective modifier and layout state, instead of
* using XkbStateNotify: \n
* https://www.x.org/releases/current/doc/kbproto/xkbproto.html#Computing_A_State_Field_from_an_XKB_State
* \n However, XkbStateNotify is more accurate.
*
* @note There is no need to call xkb_state_update_key(); the state is
* already synchronized.
*
* Finally, when a key event is received, you can use ordinary xkbcommon
* functions, like xkb_state_key_get_one_sym() and xkb_state_key_get_utf8(),
* as you normally would.
*
* @endparblock
*/
/**
* The minimal compatible major version of the XKB X11 extension which
* this library can use.
*/
#define XKB_X11_MIN_MAJOR_XKB_VERSION 1
/**
* The minimal compatible minor version of the XKB X11 extension which
* this library can use (for the minimal major version).
*/
#define XKB_X11_MIN_MINOR_XKB_VERSION 0
/** Flags for the xkb_x11_setup_xkb_extension() function. */
enum xkb_x11_setup_xkb_extension_flags {
/** Do not apply any flags. */
XKB_X11_SETUP_XKB_EXTENSION_NO_FLAGS = 0
};
/**
* Setup the XKB X11 extension for this X client.
*
* The xkbcommon-x11 library uses various XKB requests. Before doing so,
* an X client must notify the server that it will be using the extension.
* This function (or an XCB equivalent) must be called before any other
* function in this library is used.
*
* Some X servers may not support or disable the XKB extension. If you
* want to support such servers, you need to use a different fallback.
*
* You may call this function several times; it is idempotent.
*
* @param connection
* An XCB connection to the X server.
* @param major_xkb_version
* See @p minor_xkb_version.
* @param minor_xkb_version
* The XKB extension version to request. To operate correctly, you
* must have (major_xkb_version, minor_xkb_version) >=
* (XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION),
* though this is not enforced.
* @param flags
* Optional flags, or 0.
* @param[out] major_xkb_version_out
* See @p minor_xkb_version_out.
* @param[out] minor_xkb_version_out
* Backfilled with the compatible XKB extension version numbers picked
* by the server. Can be NULL.
* @param[out] base_event_out
* Backfilled with the XKB base (also known as first) event code, needed
* to distinguish XKB events. Can be NULL.
* @param[out] base_error_out
* Backfilled with the XKB base (also known as first) error code, needed
* to distinguish XKB errors. Can be NULL.
*
* @returns 1 on success, or 0 on failure.
*/
int
xkb_x11_setup_xkb_extension(xcb_connection_t *connection,
uint16_t major_xkb_version,
uint16_t minor_xkb_version,
enum xkb_x11_setup_xkb_extension_flags flags,
uint16_t *major_xkb_version_out,
uint16_t *minor_xkb_version_out,
uint8_t *base_event_out,
uint8_t *base_error_out);
/**
* Get the keyboard device ID of the core X11 keyboard.
*
* @param connection An XCB connection to the X server.
*
* @returns A device ID which may be used with other xkb_x11_* functions,
* or -1 on failure.
*/
int32_t
xkb_x11_get_core_keyboard_device_id(xcb_connection_t *connection);
/**
* Create a keymap from an X11 keyboard device.
*
* This function queries the X server with various requests, fetches the
* details of the active keymap on a keyboard device, and creates an
* xkb_keymap from these details.
*
* @param context
* The context in which to create the keymap.
* @param connection
* An XCB connection to the X server.
* @param device_id
* An XInput device ID (in the range 0-127) with input class KEY.
* Passing values outside of this range is an error (the XKB protocol
* predates the XInput2 protocol, which first allowed IDs > 127).
* @param flags
* Optional flags for the keymap, or 0.
*
* @returns A keymap retrieved from the X server, or NULL on failure.
*
* @memberof xkb_keymap
*/
struct xkb_keymap *
xkb_x11_keymap_new_from_device(struct xkb_context *context,
xcb_connection_t *connection,
int32_t device_id,
enum xkb_keymap_compile_flags flags);
/**
* Create a new keyboard state object from an X11 keyboard device.
*
* This function is the same as xkb_state_new(), only pre-initialized
* with the state of the device at the time this function is called.
*
* @param keymap
* The keymap for which to create the state.
* @param connection
* An XCB connection to the X server.
* @param device_id
* An XInput 1 device ID (in the range 0-255) with input class KEY.
* Passing values outside of this range is an error.
*
* @returns A new keyboard state object, or NULL on failure.
*
* @memberof xkb_state
*/
struct xkb_state *
xkb_x11_state_new_from_device(struct xkb_keymap *keymap,
xcb_connection_t *connection,
int32_t device_id);
/** @} */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _XKBCOMMON_X11_H */

File diff suppressed because it is too large Load Diff

View File

@ -1,782 +0,0 @@
/*
* Copyright © 2020 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef _XKBREGISTRY_H_
#define _XKBREGISTRY_H_
#include <stdarg.h>
#include <stdbool.h>
/**
* @file
* @brief Query for available RMLVO
*
*/
#ifdef __cplusplus
extern "C" {
#endif
/**
* @defgroup registry Query for available RMLVO
*
* The libxkbregistry API to query for available rules, models, layouts,
* variants and options (RMLVO). libxkbregistry is a separate library to
* libxkbcommon.
*
* This library is the replacement for clients currently parsing evdev.xml
* directly. The library is intended to provide easy access to the set of
* **possible** MLVO configurations for a given ruleset. It is not a library to
* apply these configurations, merely to enumerate them. The intended users of
* this library are the configuration UIs that allow a user to select their
* keyboard layout of choice.
*
* @{
*/
/**
* @struct rxkb_context
*
* Opaque top level library context object.
*
* The context contains general library state, like include paths and parsed
* data. Objects are created in a specific context, and multiple contexts
* may coexist simultaneously. Objects from different contexts are
* completely separated and do not share any memory or state.
*/
struct rxkb_context;
/**
* @struct rxkb_model
*
* Opaque struct representing an XKB model.
*/
struct rxkb_model;
/**
* @struct rxkb_layout
*
* Opaque struct representing an XKB layout, including an optional variant.
* Where the variant is NULL, the layout is the base layout.
*
* For example, "us" is the base layout, "us(intl)" is the "intl" variant of the
* layout "us".
*/
struct rxkb_layout;
/**
* @struct rxkb_option_group
*
* Opaque struct representing an option group. Option groups divide the
* individual options into logical groups. Their main purpose is to indicate
* whether some options are mutually exclusive or not.
*/
struct rxkb_option_group;
/**
* @struct rxkb_option
*
* Opaque struct representing an XKB option. Options are grouped inside an @ref
* rxkb_option_group.
*/
struct rxkb_option;
/**
*
* @struct rxkb_iso639_code
*
* Opaque struct representing an ISO 639-3 code (e.g. "eng", "fra"). There
* is no guarantee that two identical ISO codes share the same struct. You
* must not rely on the pointer value of this struct.
*
* See https://iso639-3.sil.org/code_tables/639/data for a list of codes.
*/
struct rxkb_iso639_code;
/**
*
* @struct rxkb_iso3166_code
*
* Opaque struct representing an ISO 3166 Alpha 2 code (e.g. "US", "FR").
* There is no guarantee that two identical ISO codes share the same struct.
* You must not rely on the pointer value of this struct.
*
* See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes for a list
* of codes.
*/
struct rxkb_iso3166_code;
/**
* Describes the popularity of an item. Historically, some highly specialized or
* experimental definitions are excluded from the default list and shipped in
* separate files. If these extra definitions are loaded (see @ref
* RXKB_CONTEXT_LOAD_EXOTIC_RULES), the popularity of the item is set
* accordingly.
*
* If the exotic items are not loaded, all items will have the standard
* popularity.
*/
enum rxkb_popularity {
RXKB_POPULARITY_STANDARD = 1,
RXKB_POPULARITY_EXOTIC,
};
/**
* Flags for context creation.
*/
enum rxkb_context_flags {
RXKB_CONTEXT_NO_FLAGS = 0,
/**
* Skip the default include paths. This requires the caller to call
* rxkb_context_include_path_append() or
* rxkb_context_include_path_append_default().
*/
RXKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0),
/**
* Load the extra items that are considered too exotic for the default list.
*
* For historical reasons, xkeyboard-config ships those exotic rules in a
* separate file (e.g. `evdev.extras.xml`). Where the exotic rules are
* requested, libxkbregistry will look for and load `$ruleset.extras.xml`
* in the include paths, see rxkb_context_include_path_append() for details
* on the lookup behavior.
*/
RXKB_CONTEXT_LOAD_EXOTIC_RULES = (1 << 1),
};
/**
* Create a new xkb registry context.
*
* The context has an initial refcount of 1. Use rxkb_context_unref() to release
* memory associated with this context.
*
* Creating a context does not parse the files yet, use
* rxkb_context_parse().
*
* @param flags Flags affecting context behavior
* @return A new xkb registry context or NULL on failure
*/
struct rxkb_context *
rxkb_context_new(enum rxkb_context_flags flags);
/** Specifies a logging level. */
enum rxkb_log_level {
RXKB_LOG_LEVEL_CRITICAL = 10, /**< Log critical internal errors only. */
RXKB_LOG_LEVEL_ERROR = 20, /**< Log all errors. */
RXKB_LOG_LEVEL_WARNING = 30, /**< Log warnings and errors. */
RXKB_LOG_LEVEL_INFO = 40, /**< Log information, warnings, and errors. */
RXKB_LOG_LEVEL_DEBUG = 50 /**< Log everything. */
};
/**
* Set the current logging level.
*
* @param ctx The context in which to set the logging level.
* @param level The logging level to use. Only messages from this level
* and below will be logged.
*
* The default level is RXKB_LOG_LEVEL_ERROR. The environment variable
* RXKB_LOG_LEVEL, if set at the time the context was created, overrides the
* default value. It may be specified as a level number or name.
*/
void
rxkb_context_set_log_level(struct rxkb_context *ctx,
enum rxkb_log_level level);
/**
* Get the current logging level.
*/
enum rxkb_log_level
rxkb_context_get_log_level(struct rxkb_context *ctx);
/**
* Set a custom function to handle logging messages.
*
* @param ctx The context in which to use the set logging function.
* @param log_fn The function that will be called for logging messages.
* Passing NULL restores the default function, which logs to stderr.
*
* By default, log messages from this library are printed to stderr. This
* function allows you to replace the default behavior with a custom
* handler. The handler is only called with messages which match the
* current logging level and verbosity settings for the context.
* level is the logging level of the message. @a format and @a args are
* the same as in the vprintf(3) function.
*
* You may use rxkb_context_set_user_data() on the context, and then call
* rxkb_context_get_user_data() from within the logging function to provide
* it with additional private context.
*/
void
rxkb_context_set_log_fn(struct rxkb_context *ctx,
void (*log_fn)(struct rxkb_context *ctx,
enum rxkb_log_level level,
const char *format, va_list args));
/**
* Parse the given ruleset. This can only be called once per context and once
* parsed the data in the context is considered constant and will never
* change.
*
* This function parses all files with the given ruleset name. See
* rxkb_context_include_path_append() for details.
*
* If this function returns false, libxkbregistry failed to parse the xml files.
* This is usually caused by invalid files on the host and should be debugged by
* the host's administrator using external tools. Callers should reduce the
* include paths to known good paths and/or fall back to a default RMLVO set.
*
* If this function returns false, the context should be be considered dead and
* must be released with rxkb_context_unref().
*
* @param ctx The xkb registry context
* @param ruleset The ruleset to parse, e.g. "evdev"
* @return true on success or false on failure
*/
bool
rxkb_context_parse(struct rxkb_context *ctx, const char *ruleset);
/**
* Parse the default ruleset as configured at build time. See
* rxkb_context_parse() for details.
*/
bool
rxkb_context_parse_default_ruleset(struct rxkb_context *ctx);
/**
* Increases the refcount of this object by one and returns the object.
*
* @param ctx The xkb registry context
* @return The passed in object
*/
struct rxkb_context*
rxkb_context_ref(struct rxkb_context *ctx);
/**
* Decreases the refcount of this object by one. Where the refcount of an
* object hits zero, associated resources will be freed.
*
* @param ctx The xkb registry context
* @return always NULL
*/
struct rxkb_context*
rxkb_context_unref(struct rxkb_context *ctx);
/**
* Assign user-specific data. libxkbregistry will not look at or modify the
* data, it will merely return the same pointer in
* rxkb_context_get_user_data().
*
* @param ctx The xkb registry context
* @param user_data User-specific data pointer
*/
void
rxkb_context_set_user_data(struct rxkb_context *ctx, void *user_data);
/**
* Return the pointer passed into rxkb_context_get_user_data().
*
* @param ctx The xkb registry context
* @return User-specific data pointer
*/
void *
rxkb_context_get_user_data(struct rxkb_context *ctx);
/**
* Append a new entry to the context's include path.
*
* The include path handling is optimized for the most common use-case: a set of
* system files that provide a complete set of MLVO and some
* custom MLVO provided by a user **in addition** to the system set.
*
* The include paths should be given so that the least complete path is
* specified first and the most complete path is appended last. For example:
*
* @code
* ctx = rxkb_context_new(RXKB_CONTEXT_NO_DEFAULT_INCLUDES);
* rxkb_context_include_path_append(ctx, "/home/user/.config/xkb");
* rxkb_context_include_path_append(ctx, "/usr/share/X11/xkb");
* rxkb_context_parse(ctx, "evdev");
* @endcode
*
* The above example reflects the default behavior unless @ref
* RXKB_CONTEXT_NO_DEFAULT_INCLUDES is provided.
*
* Loading of the files is in **reverse order**, i.e. the last path appended is
* loaded first - in this case the ``/usr/share/X11/xkb`` path.
* Any models, layouts, variants and options defined in the "evdev" ruleset
* are loaded into the context. Then, any RMLVO found in the "evdev" ruleset of
* the user's path (``/home/user/.config/xkb`` in this example) are **appended**
* to the existing set.
*
* Note that data from previously loaded include paths is never overwritten,
* only appended to. It is not not possible to change the system-provided data,
* only to append new models, layouts, variants and options to it.
*
* In other words, to define a new variant of the "us" layout called "banana",
* the following XML is sufficient.
*
* @verbatim
* <xkbConfigRegistry version="1.1">
* <layoutList>
* <layout>
* <configItem>
* <name>us</name>
* </configItem>
* <variantList>
* <variant>
* <configItem>
* <name>banana</name>
* <description>English (Banana)</description>
* </configItem>
* </variant>
* </layout>
* </layoutList>
* </xkbConfigRegistry>
* @endverbatim
*
* The list of models, options and all other layouts (including "us" and its
* variants) is taken from the system files. The resulting list of layouts will
* thus have a "us" keyboard layout with the variant "banana" and all other
* system-provided variants (dvorak, colemak, intl, etc.)
*
* This function must be called before rxkb_context_parse() or
* rxkb_context_parse_default_ruleset().
*
* @returns true on success, or false if the include path could not be added
* or is inaccessible.
*/
bool
rxkb_context_include_path_append(struct rxkb_context *ctx, const char *path);
/**
* Append the default include paths to the context's include path.
* See rxkb_context_include_path_append() for details about the merge order.
*
* This function must be called before rxkb_context_parse() or
* rxkb_context_parse_default_ruleset().
*
* @returns true on success, or false if the include path could not be added
* or is inaccessible.
*/
bool
rxkb_context_include_path_append_default(struct rxkb_context *ctx);
/**
* Return the first model for this context. Use this to start iterating over
* the models, followed by calls to rxkb_model_next(). Models are not sorted.
*
* The refcount of the returned model is not increased. Use rxkb_model_ref() if
* you need to keep this struct outside the immediate scope.
*
* @return The first model in the model list.
*/
struct rxkb_model *
rxkb_model_first(struct rxkb_context *ctx);
/**
* Return the next model for this context. Returns NULL when no more models
* are available.
*
* The refcount of the returned model is not increased. Use rxkb_model_ref() if
* you need to keep this struct outside the immediate scope.
*
* @return the next model or NULL at the end of the list
*/
struct rxkb_model *
rxkb_model_next(struct rxkb_model *m);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_model *
rxkb_model_ref(struct rxkb_model *m);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_model *
rxkb_model_unref(struct rxkb_model *m);
/**
* Return the name of this model. This is the value for M in RMLVO, to be used
* with libxkbcommon.
*/
const char *
rxkb_model_get_name(struct rxkb_model *m);
/**
* Return a human-readable description of this model. This function may return
* NULL.
*/
const char *
rxkb_model_get_description(struct rxkb_model *m);
/**
* Return the vendor name for this model. This function may return NULL.
*/
const char *
rxkb_model_get_vendor(struct rxkb_model *m);
/**
* Return the popularity for this model.
*/
enum rxkb_popularity
rxkb_model_get_popularity(struct rxkb_model *m);
/**
* Return the first layout for this context. Use this to start iterating over
* the layouts, followed by calls to rxkb_layout_next(). Layouts are not sorted.
*
* The refcount of the returned layout is not increased. Use rxkb_layout_ref() if
* you need to keep this struct outside the immediate scope.
*
* @return The first layout in the layout list.
*/
struct rxkb_layout *
rxkb_layout_first(struct rxkb_context *ctx);
/**
* Return the next layout for this context. Returns NULL when no more layouts
* are available.
*
* The refcount of the returned layout is not increased. Use rxkb_layout_ref()
* if you need to keep this struct outside the immediate scope.
*
* @return the next layout or NULL at the end of the list
*/
struct rxkb_layout *
rxkb_layout_next(struct rxkb_layout *l);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_layout *
rxkb_layout_ref(struct rxkb_layout *l);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_layout *
rxkb_layout_unref(struct rxkb_layout *l);
/**
* Return the name of this layout. This is the value for L in RMLVO, to be used
* with libxkbcommon.
*/
const char *
rxkb_layout_get_name(struct rxkb_layout *l);
/**
* Return the variant of this layout. This is the value for V in RMLVO, to be
* used with libxkbcommon.
*
* A variant does not stand on its own, it always depends on the base layout.
* e.g. there may be multiple variants called "intl" but there is only one
* "us(intl)".
*
* Where the variant is NULL, the layout is the base layout (e.g. "us").
*/
const char *
rxkb_layout_get_variant(struct rxkb_layout *l);
/**
* Return a short (one-word) description of this layout. This function may
* return NULL.
*/
const char *
rxkb_layout_get_brief(struct rxkb_layout *l);
/**
* Return a human-readable description of this layout. This function may return
* NULL.
*/
const char *
rxkb_layout_get_description(struct rxkb_layout *l);
/**
* Return the popularity for this layout.
*/
enum rxkb_popularity
rxkb_layout_get_popularity(struct rxkb_layout *l);
/**
* Return the first option group for this context. Use this to start iterating
* over the option groups, followed by calls to rxkb_option_group_next().
* Option groups are not sorted.
*
* The refcount of the returned option group is not increased. Use
* rxkb_option_group_ref() if you need to keep this struct outside the immediate
* scope.
*
* @return The first option group in the option group list.
*/
struct rxkb_option_group *
rxkb_option_group_first(struct rxkb_context *ctx);
/**
* Return the next option group for this context. Returns NULL when no more
* option groups are available.
*
* The refcount of the returned option group is not increased. Use
* rxkb_option_group_ref() if you need to keep this struct outside the immediate
* scope.
*
* @return the next option group or NULL at the end of the list
*/
struct rxkb_option_group *
rxkb_option_group_next(struct rxkb_option_group *g);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_option_group *
rxkb_option_group_ref(struct rxkb_option_group *g);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_option_group *
rxkb_option_group_unref(struct rxkb_option_group *g);
/**
* Return the name of this option group. This is **not** the value for O in
* RMLVO, the name can be used for internal sorting in the caller. This function
* may return NULL.
*/
const char *
rxkb_option_group_get_name(struct rxkb_option_group *m);
/**
* Return a human-readable description of this option group. This function may
* return NULL.
*/
const char *
rxkb_option_group_get_description(struct rxkb_option_group *m);
/**
* @return true if multiple options within this option group can be selected
* simultaneously, false if all options within this option group
* are mutually exclusive.
*/
bool
rxkb_option_group_allows_multiple(struct rxkb_option_group *g);
/**
* Return the popularity for this option group.
*/
enum rxkb_popularity
rxkb_option_group_get_popularity(struct rxkb_option_group *g);
/**
* Return the first option for this option group. Use this to start iterating
* over the options, followed by calls to rxkb_option_next(). Options are not
* sorted.
*
* The refcount of the returned option is not increased. Use rxkb_option_ref()
* if you need to keep this struct outside the immediate scope.
*
* @return The first option in the option list.
*/
struct rxkb_option *
rxkb_option_first(struct rxkb_option_group *group);
/**
* Return the next option for this option group. Returns NULL when no more
* options are available.
*
* The refcount of the returned options is not increased. Use rxkb_option_ref()
* if you need to keep this struct outside the immediate scope.
*
* @returns The next option or NULL at the end of the list
*/
struct rxkb_option *
rxkb_option_next(struct rxkb_option *o);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_option *
rxkb_option_ref(struct rxkb_option *o);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_option *
rxkb_option_unref(struct rxkb_option *o);
/**
* Return the name of this option. This is the value for O in RMLVO, to be used
* with libxkbcommon.
*/
const char *
rxkb_option_get_name(struct rxkb_option *o);
/**
* Return a short (one-word) description of this option. This function may
* return NULL.
*/
const char *
rxkb_option_get_brief(struct rxkb_option *o);
/**
* Return a human-readable description of this option. This function may return
* NULL.
*/
const char *
rxkb_option_get_description(struct rxkb_option *o);
/**
* Return the popularity for this option.
*/
enum rxkb_popularity
rxkb_option_get_popularity(struct rxkb_option *o);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_iso639_code *
rxkb_iso639_code_ref(struct rxkb_iso639_code *iso639);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_iso639_code *
rxkb_iso639_code_unref(struct rxkb_iso639_code *iso639);
/**
* Return the ISO 639-3 code for this code (e.g. "eng", "fra").
*/
const char *
rxkb_iso639_code_get_code(struct rxkb_iso639_code *iso639);
/**
* Return the first ISO 639 for this layout. Use this to start iterating over
* the codes, followed by calls to rxkb_iso639_code_next(). Codes are not
* sorted.
*
* The refcount of the returned code is not increased. Use rxkb_iso639_code_ref()
* if you need to keep this struct outside the immediate scope.
*
* @return The first code in the code list.
*/
struct rxkb_iso639_code *
rxkb_layout_get_iso639_first(struct rxkb_layout *layout);
/**
* Return the next code in the list. Returns NULL when no more codes
* are available.
*
* The refcount of the returned codes is not increased. Use
* rxkb_iso639_code_ref() if you need to keep this struct outside the immediate
* scope.
*
* @returns The next code or NULL at the end of the list
*/
struct rxkb_iso639_code *
rxkb_iso639_code_next(struct rxkb_iso639_code *iso639);
/**
* Increase the refcount of the argument by one.
*
* @returns The argument passed in to this function.
*/
struct rxkb_iso3166_code *
rxkb_iso3166_code_ref(struct rxkb_iso3166_code *iso3166);
/**
* Decrease the refcount of the argument by one. When the refcount hits zero,
* all memory associated with this struct is freed.
*
* @returns always NULL
*/
struct rxkb_iso3166_code *
rxkb_iso3166_code_unref(struct rxkb_iso3166_code *iso3166);
/**
* Return the ISO 3166 Alpha 2 code for this code (e.g. "US", "FR").
*/
const char *
rxkb_iso3166_code_get_code(struct rxkb_iso3166_code *iso3166);
/**
* Return the first ISO 3166 for this layout. Use this to start iterating over
* the codes, followed by calls to rxkb_iso3166_code_next(). Codes are not
* sorted.
*
* The refcount of the returned code is not increased. Use
* rxkb_iso3166_code_ref() if you need to keep this struct outside the immediate
* scope.
*
* @return The first code in the code list.
*/
struct rxkb_iso3166_code *
rxkb_layout_get_iso3166_first(struct rxkb_layout *layout);
/**
* Return the next code in the list. Returns NULL when no more codes
* are available.
*
* The refcount of the returned codes is not increased. Use
* rxkb_iso3166_code_ref() if you need to keep this struct outside the immediate
* scope.
*
* @returns The next code or NULL at the end of the list
*/
struct rxkb_iso3166_code *
rxkb_iso3166_code_next(struct rxkb_iso3166_code *iso3166);
/** @} */
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* _XKBREGISTRY_H_ */

@ -0,0 +1 @@
Subproject commit a782152de0f032050e842cce263a8777bd2c9ca3

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,41 @@
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..87aec55
--- /dev/null
+++ b/config.h
@@ -0,0 +1,35 @@
+/*
+ * Autogenerated by the Meson build system.
+ * Do not edit, your changes will be lost.
+ */
+
+#pragma once
+
+#define HAVE_ACCEPT4
+
+#define HAVE_BROKEN_MSG_CMSG_CLOEXEC 0
+
+#define HAVE_MEMFD_CREATE
+
+#define HAVE_MKOSTEMP
+
+#define HAVE_MREMAP
+
+#define HAVE_POSIX_FALLOCATE
+
+#define HAVE_PRCTL
+
+#define HAVE_STRNDUP
+
+#define HAVE_SYS_PRCTL_H
+
+#undef HAVE_SYS_PROCCTL_H
+
+#undef HAVE_SYS_UCRED_H
+
+#define HAVE_XUCRED_CR_PID 0
+
+#define PACKAGE "wayland"
+
+#define PACKAGE_VERSION "1.21.0"
+