From e7c5fbc87341dc3bde40ee2fe1a338b84b55cd60 Mon Sep 17 00:00:00 2001 From: jfreegman Date: Thu, 27 Sep 2018 03:41:58 -0400 Subject: [PATCH] Cleanup xtra.c Privatise some functions that don't need to be public Fix struct names starting with _ char Remove unnecessary memset of Xtra struct in init_xtra() --- src/xtra.c | 48 +++++++++++++++++++++++------------------------- src/xtra.h | 1 - 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/src/xtra.c b/src/xtra.c index 6c8f7a7..d5f5b2c 100644 --- a/src/xtra.c +++ b/src/xtra.c @@ -47,7 +47,7 @@ static Atom XdndTypeList; static Atom XdndActionCopy; static Atom XdndFinished; -struct _Xtra { +struct Xtra { drop_callback on_drop; Display *display; Window terminal_window; @@ -57,14 +57,14 @@ struct _Xtra { Atom expecting_type; } Xtra; -typedef struct _Property { +typedef struct Property { unsigned char *data; int read_format; unsigned long read_num; Atom read_type; } Property; -Property read_property(Window s, Atom p) +static Property read_property(Window s, Atom p) { Atom read_type; int read_format; @@ -95,7 +95,7 @@ Property read_property(Window s, Atom p) return property; } -Atom get_dnd_type(long *a, int l) +static Atom get_dnd_type(long *a, int l) { int i = 0; @@ -281,10 +281,27 @@ void *event_loop(void *p) return (Xtra.display = NULL); } +static long unsigned int focused_window_id(void) +{ + if (!Xtra.display) { + return 0; + } + + Window focus; + int revert; + XLockDisplay(Xtra.display); + XGetInputFocus(Xtra.display, &focus, &revert); + XUnlockDisplay(Xtra.display); + return focus; +} + +int is_focused(void) +{ + return Xtra.proxy_window == focused_window_id() || Xtra.terminal_window == focused_window_id(); +} + int init_xtra(drop_callback d) { - memset(&Xtra, 0, sizeof(Xtra)); - if (!d) { return -1; } else { @@ -399,22 +416,3 @@ void terminate_xtra(void) while (Xtra.display); /* Wait for termination */ } - -long unsigned int focused_window_id(void) -{ - if (!Xtra.display) { - return 0; - } - - Window focus; - int revert; - XLockDisplay(Xtra.display); - XGetInputFocus(Xtra.display, &focus, &revert); - XUnlockDisplay(Xtra.display); - return focus; -} - -int is_focused(void) -{ - return Xtra.proxy_window == focused_window_id() || Xtra.terminal_window == focused_window_id(); -} diff --git a/src/xtra.h b/src/xtra.h index e9329e9..7b423af 100644 --- a/src/xtra.h +++ b/src/xtra.h @@ -35,7 +35,6 @@ typedef void (*drop_callback)(const char *, DropType); int init_xtra(drop_callback d); void terminate_xtra(void); -long unsigned int focused_window_id(void); int is_focused(void); /* returns bool */ #endif /* XTRA_H */