You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.3 KiB
92 lines
2.3 KiB
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <unistd.h>
|
|
|
|
#include <sys/mman.h>
|
|
|
|
#include <wayland-client.h>
|
|
|
|
#include "drm-lease-v1.prot.h"
|
|
|
|
#define ASSERT(cond, msg)\
|
|
if(!(cond)) {\
|
|
fprintf(stderr, "Runtime assertion %s at %s:%d failed: %s\n", #cond, __FILE__, __LINE__, msg);\
|
|
exit(-1);\
|
|
}
|
|
|
|
struct wp_drm_lease_device_v1** devs;
|
|
size_t devs_size = 0;
|
|
|
|
uint8_t done = 0;
|
|
|
|
void device_drm_fd(void *data,
|
|
struct wp_drm_lease_device_v1 *wp_drm_lease_device_v1,
|
|
int32_t fd){}
|
|
|
|
void device_connector(void *data,
|
|
struct wp_drm_lease_device_v1 *wp_drm_lease_device_v1,
|
|
struct wp_drm_lease_connector_v1 *id) {
|
|
printf("Connector Found\n");
|
|
}
|
|
|
|
void device_done(void *data,
|
|
struct wp_drm_lease_device_v1 *wp_drm_lease_device_v1){
|
|
printf("All connectors sent.\n");
|
|
done = 1;
|
|
}
|
|
|
|
void device_released(void *data,
|
|
struct wp_drm_lease_device_v1 *wp_drm_lease_device_v1){}
|
|
|
|
const struct wp_drm_lease_device_v1_listener device_callbacks = {
|
|
.drm_fd = device_drm_fd,
|
|
.connector = device_connector,
|
|
.done = device_done,
|
|
.released = device_released,
|
|
};
|
|
|
|
void handle_global(
|
|
void* data,
|
|
struct wl_registry* registry,
|
|
uint32_t name,
|
|
const char* interface,
|
|
uint32_t version) {
|
|
if(strcmp(interface, wp_drm_lease_device_v1_interface.name) == 0) {
|
|
struct wp_drm_lease_device_v1* dev = wl_registry_bind(registry, name, &wp_drm_lease_device_v1_interface, version);
|
|
devs_size += 1;
|
|
devs = realloc(devs, devs_size*sizeof(void*));
|
|
devs[devs_size-1] = dev;
|
|
wp_drm_lease_device_v1_add_listener(dev, &device_callbacks, NULL);
|
|
printf("Bound %d\n", devs_size);
|
|
}
|
|
}
|
|
|
|
void handle_global_remove(
|
|
void* data,
|
|
struct wl_registry* registry,
|
|
uint32_t name) {
|
|
// Who cares
|
|
}
|
|
|
|
const struct wl_registry_listener reg_callbacks = {
|
|
.global = handle_global,
|
|
.global_remove = handle_global_remove,
|
|
};
|
|
|
|
int main(int argc, char* argv[]) {
|
|
devs = malloc(sizeof(void*));
|
|
|
|
struct wl_display* dpy = wl_display_connect(NULL);
|
|
ASSERT(dpy != NULL, "Unable to connect to Wayland");
|
|
|
|
struct wl_registry* registry = wl_display_get_registry(dpy);
|
|
wl_registry_add_listener(registry, ®_callbacks, NULL);
|
|
wl_display_roundtrip(dpy);
|
|
|
|
printf("Waiting for connectors.\n");
|
|
while(!done) {}
|
|
|
|
return 0;
|
|
}
|