From 8ce8a54e75248164e17626c0866adbd636e42a7b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Tue, 4 Oct 2011 07:03:30 +0200 Subject: Refactor atom name printing into a new Display_Atom_Name function Signed-off-by: Guillem Jover Reviewed-by: Alan Coopersmith --- xwininfo.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/xwininfo.c b/xwininfo.c index a97a845..096ced0 100644 --- a/xwininfo.c +++ b/xwininfo.c @@ -1633,6 +1633,18 @@ wm_hints_reply (xcb_connection_t *dpy, xcb_get_property_cookie_t cookie, #define xcb_icccm_get_wm_hints_reply wm_hints_reply #endif +static void +Display_Atom_Name (xcb_atom_t atom, const char *prefix) +{ + const char *atom_name = Get_Atom_Name (dpy, atom); + + if (atom_name) { + print_friendly_name (" %s\n", atom_name, prefix); + } else { + printf (" (unresolvable ATOM 0x%x)\n", atom); + } +} + static void Display_WM_Info (struct wininfo *w) { @@ -1697,17 +1709,8 @@ Display_WM_Info (struct wininfo *w) if (atom_count > 0) { printf (" Window type:\n"); - for (i = 0; i < atom_count; i++) { - const char *atom_name = Get_Atom_Name (dpy, atoms[i]); - - if (atom_name) { - print_friendly_name (" %s\n", atom_name, - "_NET_WM_WINDOW_TYPE_"); - } else { - printf (" (unresolvable ATOM 0x%x)\n", - atoms[i]); - } - } + for (i = 0; i < atom_count; i++) + Display_Atom_Name (atoms[i], "_NET_WM_WINDOW_TYPE_"); } } free (prop); @@ -1721,17 +1724,8 @@ Display_WM_Info (struct wininfo *w) if (atom_count > 0) { printf (" Window state:\n"); - for (i = 0; i < atom_count; i++) { - const char *atom_name = Get_Atom_Name (dpy, atoms[i]); - - if (atom_name) { - print_friendly_name (" %s\n", atom_name, - "_NET_WM_STATE_"); - } else { - printf (" (unresolvable ATOM 0x%x)\n", - atoms[i]); - } - } + for (i = 0; i < atom_count; i++) + Display_Atom_Name (atoms[i], "_NET_WM_STATE_"); } } free (prop); -- cgit v1.2.3