minecraft-pi-reborn/mods/src/compat/x11.c

30 lines
1.2 KiB
C
Raw Normal View History

2021-06-28 02:16:37 +00:00
#include <X11/Xlib.h>
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <media-layer/core.h>
2024-02-12 05:44:38 +00:00
#include "compat-internal.h"
2021-06-28 02:16:37 +00:00
// Functions That Have Their Return Values Used
static int XTranslateCoordinates_injection(__attribute__((unused)) void *display, __attribute__((unused)) XID src_w, __attribute__((unused)) XID dest_w, int src_x, int src_y, int *dest_x_return, int *dest_y_return, __attribute__((unused)) XID *child_return) {
// Use MCPI Replacemnt Function
*dest_x_return = src_x;
*dest_y_return = src_y;
return 1;
}
static int XGetWindowAttributes_injection(__attribute__((unused)) void *display, __attribute__((unused)) XID w, XWindowAttributes *window_attributes_return) {
// Use MCPI Replacemnt Function
XWindowAttributes attributes;
attributes.x = 0;
attributes.y = 0;
media_get_framebuffer_size(&attributes.width, &attributes.height);
*window_attributes_return = attributes;
return 1;
}
// Patch X11 Calls
2024-02-12 05:44:38 +00:00
void _patch_x11_calls() {
2021-06-28 02:16:37 +00:00
// Disable X11 Calls
overwrite_call((void *) 0x132a4, (void *) XGetWindowAttributes_injection); // XGetWindowAttributes
overwrite_call((void *) 0x132d4, (void *) XTranslateCoordinates_injection); // XTranslateCoordinates
}