From 4b6239ee0c080a33f579bacc8071bb5694a40ad0 Mon Sep 17 00:00:00 2001 From: Johan Malm Date: Wed, 27 Dec 2023 22:36:20 +0000 Subject: [PATCH] osd: refactor to eliminate usage of g_strcmp0() ...to allow inclusion of ./scripts/find-banned in CI No functional change intended. --- src/osd.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) diff --git a/src/osd.c b/src/osd.c index e367b97d..cff3b429 100644 --- a/src/osd.c +++ b/src/osd.c @@ -20,23 +20,6 @@ #include "window-rules.h" #include "workspaces.h" -/* is title different from app_id/class? */ -static int -is_title_different(struct view *view) -{ - switch (view->type) { - case LAB_XDG_SHELL_VIEW: - return g_strcmp0(view_get_string_prop(view, "title"), - view_get_string_prop(view, "app_id")); -#if HAVE_XWAYLAND - case LAB_XWAYLAND_VIEW: - return g_strcmp0(view_get_string_prop(view, "title"), - view_get_string_prop(view, "class")); -#endif - } - return 1; -} - static const char * get_formatted_app_id(struct view *view) { @@ -256,13 +239,18 @@ get_app_id(struct view *view) } static const char * -get_title(struct view *view) +get_title_if_different(struct view *view) { - if (is_title_different(view)) { - return view_get_string_prop(view, "title"); - } else { - return ""; + /* + * XWayland clients return WM_CLASS for 'app_id' so we don't need a + * special case for that here. + */ + const char *identifier = view_get_string_prop(view, "app_id"); + const char *title = view_get_string_prop(view, "title"); + if (!identifier) { + return title; } + return (!title || !strcmp(identifier, title)) ? NULL : title; } static void @@ -371,7 +359,7 @@ render_osd(struct server *server, cairo_t *cairo, int w, int h, break; } case LAB_FIELD_TITLE: - buf_add(&buf, get_title(*view)); + buf_add(&buf, get_title_if_different(*view)); break; default: break;