Skip to content

Commit d1cfc1e

Browse files
committed
Fix wl_output listener mismatch with newer compositors
1 parent 3fe55de commit d1cfc1e

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

src/fcitx-wayland/core/wl_registry.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#include "wl_registry.h"
22
#include <cassert>
33
namespace fcitx::wayland {
4+
5+
class WlOutput;
6+
47
const struct wl_registry_listener WlRegistry::listener = {
58
[](void *data, wl_registry *wldata, uint32_t name, const char *interface,
69
uint32_t version) {

src/fcitx-wayland/core/wl_registry.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,19 @@
44
#include <wayland-client.h>
55
#include "fcitx-utils/signals.h"
66
namespace fcitx::wayland {
7+
8+
class WlOutput;
9+
10+
template <typename T>
11+
static constexpr uint32_t supportedVersion(uint32_t requested) {
12+
return requested;
13+
}
14+
15+
template <>
16+
constexpr uint32_t supportedVersion<WlOutput>(uint32_t requested) {
17+
return std::min(requested, 3u);
18+
}
19+
720
class WlRegistry final {
821
public:
922
static constexpr const char *interface = "wl_registry";
@@ -20,8 +33,10 @@ class WlRegistry final {
2033
void setUserData(void *userData) { userData_ = userData; }
2134
template <typename T>
2235
T *bind(uint32_t name, uint32_t requested_version) {
36+
uint32_t version =
37+
supportedVersion<T>(requested_version);
2338
return new T(static_cast<typename T::wlType *>(
24-
wl_registry_bind(*this, name, T::wlInterface, requested_version)));
39+
wl_registry_bind(*this, name, T::wlInterface, version)));
2540
}
2641
auto &global() { return globalSignal_; }
2742
auto &globalRemove() { return globalRemoveSignal_; }

0 commit comments

Comments
 (0)