On Mon Apr 29, 2024 at 5:18 PM CEST, Leon Henrik Plickat <leonhenrik.plickat@stud.uni-goettingen.de> wrote:
> Here is my alternative proposol: Remove the noop handler completely.
> Write handler functions for all events where currently noop is plugged
> in. These handlers will be empty except for a comment saying something
> like "deliberately left empty". That should make both clang and gcc
> happy.
implemented this approach and tested with clang-17 and gcc-13 and seems
to work for both now :)
Robert Günzler (2):
Remove the noop handler
Respect external CFLAGS
Makefile | 3 ++-
lswt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++-------
2 files changed, 66 insertions(+), 9 deletions(-)
base-commit: e40aef0348f0e4e2b5b55b5df27890320053bf0e
--
2.43.2
Instead we pass empty functions specified per handler.
This is to make clang happy when building with -Wpedantic. Simply
passing -Wno-error=incompatible-function-pointer-types is not an option
for gcc either, due to that not being defined.
Signed-off-by: Robert Günzler <r@gnzler.io>
---
lswt.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 64 insertions(+), 8 deletions(-)
diff --git a/lswt.c b/lswt.c
index 380f5d0..ae73264 100644
--- a/lswt.c
+++ b/lswt.c
@@ -98,8 +98,6 @@ enum UsedProtocol used_protocol;
struct wl_list toplevels;
-static void noop () {}
-
/* We want to cleanly exit on SIGINT (f.e. when Ctrl-C is pressed in WATCH mode)
* however after exiting the signal handler wl_display_dispatch() will just
* continue until the next event from the server. We can not sync in the signal
@@ -424,9 +422,18 @@ static void ext_toplevel_list_handle_toplevel
);
}
+static void ext_toplevel_list_handle_finished
+(
+ void *data,
+ struct ext_foreign_toplevel_list_v1 *list
+)
+{
+ /* deliberately left empty */
+}
+
static const struct ext_foreign_toplevel_list_v1_listener ext_toplevel_list_listener = {
.toplevel = ext_toplevel_list_handle_toplevel,
- .finished = noop,
+ .finished = ext_toplevel_list_handle_finished,
};
/************************************************************
@@ -509,13 +516,43 @@ static void zwlr_foreign_handle_handle_closed
}
}
+static void zwlr_foreign_handle_handle_output_enter
+(
+ void *data,
+ struct zwlr_foreign_toplevel_handle_v1 *handle,
+ struct wl_output *output
+)
+{
+ /* deliberately left empty */
+}
+
+static void zwlr_foreign_handle_handle_output_leave
+(
+ void *data,
+ struct zwlr_foreign_toplevel_handle_v1 *handle,
+ struct wl_output *output
+)
+{
+ /* deliberately left empty */
+}
+
+static void zwlr_foreign_handle_handle_parent
+(
+ void *data,
+ struct zwlr_foreign_toplevel_handle_v1 *handle,
+ struct zwlr_foreign_toplevel_handle_v1 *parent
+)
+{
+ /* deliberately left empty */
+}
+
static const struct zwlr_foreign_toplevel_handle_v1_listener zwlr_handle_listener = {
.app_id = zwlr_foreign_handle_handle_app_id,
.done = zwlr_foreign_handle_handle_done,
.closed = zwlr_foreign_handle_handle_closed,
- .output_enter = noop,
- .output_leave = noop,
- .parent = noop,
+ .output_enter = zwlr_foreign_handle_handle_output_enter,
+ .output_leave = zwlr_foreign_handle_handle_output_leave,
+ .parent = zwlr_foreign_handle_handle_parent,
.state = zwlr_foreign_handle_handle_state,
.title = zwlr_foreign_handle_handle_title,
};
@@ -545,9 +582,18 @@ static void zwlr_toplevel_manager_handle_toplevel
);
}
+static void zwlr_toplevel_manager_handle_finished
+(
+ void *data,
+ struct zwlr_foreign_toplevel_manager_v1 *manager
+)
+{
+ /* deliberately left empty */
+}
+
static const struct zwlr_foreign_toplevel_manager_v1_listener zwlr_toplevel_manager_listener = {
.toplevel = zwlr_toplevel_manager_handle_toplevel,
- .finished = noop,
+ .finished = zwlr_toplevel_manager_handle_finished,
};
/************************
@@ -948,9 +994,19 @@ static void registry_handle_global
}
}
+static void registry_handle_global_remove
+(
+ void *data,
+ struct wl_registry *registry,
+ uint32_t name
+)
+{
+ /* deliberately left empty */
+}
+
static const struct wl_registry_listener registry_listener = {
.global = registry_handle_global,
- .global_remove = noop,
+ .global_remove = registry_handle_global_remove,
};
static void sync_handle_done
--
2.43.2
Refs: https://bugs.gentoo.org/927846
Signed-off-by: Robert Günzler <r@gnzler.io>
---
Makefile | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index 879a7e3..5b609c7 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,8 @@ BINDIR=$(PREFIX)/bin
MANDIR=$(PREFIX)/share/man
BASHCOMPDIR=$(PREFIX)/share/bash-completion/completions
-CFLAGS=-Wall -Werror -Wextra -Wpedantic -Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result
+CFLAGS+=-Wall -Werror -Wextra -Wpedantic
+CFLAGS+=-Wno-unused-parameter -Wconversion -Wformat-security -Wformat -Wsign-conversion -Wfloat-conversion -Wunused-result
LIBS=-lwayland-client
OBJ=lswt.o wlr-foreign-toplevel-management-unstable-v1.o ext-foreign-toplevel-list-v1.o
GEN=wlr-foreign-toplevel-management-unstable-v1.c wlr-foreign-toplevel-management-unstable-v1.h ext-foreign-toplevel-list-v1.c ext-foreign-toplevel-list-v1.h
--
2.43.2