A bit more clang-format

This commit is contained in:
Jasmine Iwanek
2022-11-19 08:49:04 -05:00
parent b04dd8cc8b
commit 3fe4f75108
223 changed files with 8047 additions and 7456 deletions

View File

@@ -25,40 +25,39 @@
#include <QWindow>
#include <QGuiApplication>
extern "C"
{
extern "C" {
#include <86box/plat.h>
}
static zwp_relative_pointer_manager_v1* rel_manager = nullptr;
static zwp_relative_pointer_v1* rel_pointer = nullptr;
static zwp_pointer_constraints_v1* conf_pointer_interface = nullptr;
static zwp_locked_pointer_v1* conf_pointer = nullptr;
static zwp_relative_pointer_manager_v1 *rel_manager = nullptr;
static zwp_relative_pointer_v1 *rel_pointer = nullptr;
static zwp_pointer_constraints_v1 *conf_pointer_interface = nullptr;
static zwp_locked_pointer_v1 *conf_pointer = nullptr;
static int rel_mouse_x = 0, rel_mouse_y = 0;
static int rel_mouse_x = 0, rel_mouse_y = 0;
static bool wl_init_ok = false;
void rel_mouse_event(void* data, zwp_relative_pointer_v1* zwp_relative_pointer_v1, uint32_t tstmp, uint32_t tstmpl, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_real, wl_fixed_t dy_real)
void
rel_mouse_event(void *data, zwp_relative_pointer_v1 *zwp_relative_pointer_v1, uint32_t tstmp, uint32_t tstmpl, wl_fixed_t dx, wl_fixed_t dy, wl_fixed_t dx_real, wl_fixed_t dy_real)
{
rel_mouse_x += wl_fixed_to_int(dx_real);
rel_mouse_y += wl_fixed_to_int(dy_real);
}
extern "C"
{
extern int mouse_x, mouse_y;
extern "C" {
extern int mouse_x, mouse_y;
}
void wl_mouse_poll()
void
wl_mouse_poll()
{
mouse_x = rel_mouse_x;
mouse_y = rel_mouse_y;
mouse_x = rel_mouse_x;
mouse_y = rel_mouse_y;
rel_mouse_x = 0;
rel_mouse_y = 0;
}
static struct zwp_relative_pointer_v1_listener rel_listener =
{
static struct zwp_relative_pointer_v1_listener rel_listener = {
rel_mouse_event
};
@@ -66,13 +65,11 @@ static void
display_handle_global(void *data, struct wl_registry *registry, uint32_t id,
const char *interface, uint32_t version)
{
if (!strcmp(interface, "zwp_relative_pointer_manager_v1"))
{
rel_manager = (zwp_relative_pointer_manager_v1*)wl_registry_bind(registry, id, &zwp_relative_pointer_manager_v1_interface, version);
if (!strcmp(interface, "zwp_relative_pointer_manager_v1")) {
rel_manager = (zwp_relative_pointer_manager_v1 *) wl_registry_bind(registry, id, &zwp_relative_pointer_manager_v1_interface, version);
}
if (!strcmp(interface, "zwp_pointer_constraints_v1"))
{
conf_pointer_interface = (zwp_pointer_constraints_v1*)wl_registry_bind(registry, id, &zwp_pointer_constraints_v1_interface, version);
if (!strcmp(interface, "zwp_pointer_constraints_v1")) {
conf_pointer_interface = (zwp_pointer_constraints_v1 *) wl_registry_bind(registry, id, &zwp_pointer_constraints_v1_interface, version);
}
}
@@ -82,7 +79,7 @@ display_global_remove(void *data, struct wl_registry *wl_registry, uint32_t name
plat_mouse_capture(0);
zwp_relative_pointer_manager_v1_destroy(rel_manager);
zwp_pointer_constraints_v1_destroy(conf_pointer_interface);
rel_manager = nullptr;
rel_manager = nullptr;
conf_pointer_interface = nullptr;
}
@@ -91,15 +88,14 @@ static const struct wl_registry_listener registry_listener = {
display_global_remove
};
void wl_init()
void
wl_init()
{
if (!wl_init_ok) {
wl_display* display = (wl_display*)QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_display");
if (display)
{
wl_display *display = (wl_display *) QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_display");
if (display) {
auto registry = wl_display_get_registry(display);
if (registry)
{
if (registry) {
wl_registry_add_listener(registry, &registry_listener, nullptr);
wl_display_roundtrip(display);
}
@@ -108,19 +104,24 @@ void wl_init()
}
}
void wl_mouse_capture(QWindow *window)
void
wl_mouse_capture(QWindow *window)
{
if (rel_manager) {
rel_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(rel_manager, (wl_pointer*)QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_pointer"));
rel_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(rel_manager, (wl_pointer *) QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_pointer"));
zwp_relative_pointer_v1_add_listener(rel_pointer, &rel_listener, nullptr);
}
if (conf_pointer_interface) conf_pointer = zwp_pointer_constraints_v1_lock_pointer(conf_pointer_interface, (wl_surface*)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("surface", window), (wl_pointer*)QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_pointer"), nullptr, ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
if (conf_pointer_interface)
conf_pointer = zwp_pointer_constraints_v1_lock_pointer(conf_pointer_interface, (wl_surface *) QGuiApplication::platformNativeInterface()->nativeResourceForWindow("surface", window), (wl_pointer *) QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("wl_pointer"), nullptr, ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
}
void wl_mouse_uncapture()
void
wl_mouse_uncapture()
{
if (conf_pointer) zwp_locked_pointer_v1_destroy(conf_pointer);
if (rel_pointer) zwp_relative_pointer_v1_destroy(rel_pointer);
rel_pointer = nullptr;
if (conf_pointer)
zwp_locked_pointer_v1_destroy(conf_pointer);
if (rel_pointer)
zwp_relative_pointer_v1_destroy(rel_pointer);
rel_pointer = nullptr;
conf_pointer = nullptr;
}