mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
DisplayServer: dirty hack for #477
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "common/thread.h"
|
||||
#include <wayland-client.h>
|
||||
#include <sys/socket.h>
|
||||
#include <assert.h>
|
||||
|
||||
typedef struct WaylandData
|
||||
{
|
||||
@@ -70,13 +71,11 @@ static void waylandOutputModeListener(void* data, FF_MAYBE_UNUSED struct wl_outp
|
||||
display->refreshRate = refreshRate;
|
||||
}
|
||||
|
||||
#ifdef WL_OUTPUT_SCALE_SINCE_VERSION
|
||||
static void waylandOutputScaleListener(void* data, FF_MAYBE_UNUSED struct wl_output* output, int32_t scale)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
display->scale = scale;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void waylandOutputGeometryListener(void *data,
|
||||
FF_MAYBE_UNUSED struct wl_output *output,
|
||||
@@ -93,7 +92,6 @@ static void waylandOutputGeometryListener(void *data,
|
||||
display->transform = (enum wl_output_transform) transform;
|
||||
}
|
||||
|
||||
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||
static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_output *output, const char *name)
|
||||
{
|
||||
WaylandDisplay* display = data;
|
||||
@@ -103,7 +101,6 @@ static void waylandOutputNameListener(void *data, FF_MAYBE_UNUSED struct wl_outp
|
||||
display->type = FF_DISPLAY_TYPE_EXTERNAL;
|
||||
ffStrbufAppendS(&display->name, name);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* registry, uint32_t name, uint32_t version)
|
||||
{
|
||||
@@ -121,34 +118,20 @@ static void waylandOutputHandler(WaylandData* wldata, struct wl_registry* regist
|
||||
};
|
||||
ffStrbufInit(&display.name);
|
||||
|
||||
struct wl_output_listener outputListener = {
|
||||
.mode = waylandOutputModeListener,
|
||||
.geometry = waylandOutputGeometryListener,
|
||||
|
||||
#ifdef WL_OUTPUT_DONE_SINCE_VERSION
|
||||
.done = (void*) stubListener,
|
||||
#else
|
||||
#warning wl_output_listener::done is not supported
|
||||
#endif
|
||||
|
||||
#ifdef WL_OUTPUT_SCALE_SINCE_VERSION
|
||||
.scale = waylandOutputScaleListener,
|
||||
#else
|
||||
#warning wl_output_listener::scale is not supported
|
||||
#endif
|
||||
|
||||
#ifdef WL_OUTPUT_NAME_SINCE_VERSION
|
||||
.name = waylandOutputNameListener,
|
||||
#else
|
||||
#warning wl_output_listener::name is not supported
|
||||
#endif
|
||||
|
||||
#ifdef WL_OUTPUT_DESCRIPTION_SINCE_VERSION
|
||||
.description = (void*) stubListener,
|
||||
#else
|
||||
#warning wl_output_listener::description is not supported
|
||||
#endif
|
||||
// Dirty hack for #477
|
||||
// The order of these callbacks MUST follow `struct wl_output_listener`
|
||||
void* outputListener[] = {
|
||||
waylandOutputGeometryListener, // geometry
|
||||
waylandOutputModeListener, // mode
|
||||
stubListener, // done
|
||||
waylandOutputScaleListener, // scale
|
||||
waylandOutputNameListener, // name
|
||||
stubListener, // description
|
||||
};
|
||||
static_assert(
|
||||
sizeof(outputListener) >= sizeof(struct wl_output_listener),
|
||||
"sizeof(outputListener) is too small. Please report it to fastfetch github issue"
|
||||
);
|
||||
|
||||
wldata->ffwl_proxy_add_listener(output, (void(**)(void)) &outputListener, &display);
|
||||
wldata->ffwl_display_roundtrip(wldata->display);
|
||||
|
||||
Reference in New Issue
Block a user