From 2cc261c619976c73dbd5f2b8ae6eb9f6d457e201 Mon Sep 17 00:00:00 2001 From: mannol Date: Sun, 12 Oct 2014 22:54:18 +0200 Subject: [PATCH] Some random fixups --- src/notify.c | 2 +- src/toxic.c | 19 ++++++++++--------- src/xtra.c | 14 +++++++------- src/xtra.h | 8 ++++---- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/notify.c b/src/notify.c index 25c7639..74d0130 100644 --- a/src/notify.c +++ b/src/notify.c @@ -119,7 +119,7 @@ static bool notifications_are_disabled(uint64_t flags) { bool res = flags & NT_RESTOL && Control.cooldown > get_unix_time(); #ifdef X11 - return res || (flags & NT_NOFOCUS && xtra_is_this_focused()); + return res || (flags & NT_NOFOCUS && is_focused()); #else return res; #endif diff --git a/src/toxic.c b/src/toxic.c index 98cb1d8..4f101aa 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -128,15 +128,20 @@ void exit_toxic_success(Tox *m) free(BLOCK_FILE); free(user_settings); -#ifdef SOUND_NOTIFY -// sound_notify(NULL, self_log_out, NT_ALWAYS, NULL); -#endif /* SOUND_NOTIFY */ terminate_notify(); #ifdef AUDIO terminate_audio(); #endif /* AUDIO */ + tox_kill(m); endwin(); + +#ifdef X11 + /* We have to terminate xtra last coz reasons + * Please don't call this anywhere else coz trust me + */ + terminate_xtra(); +#endif /* X11 */ exit(EXIT_SUCCESS); } @@ -1010,7 +1015,7 @@ int main(int argc, char *argv[]) int settings_err = settings_load(user_settings, p); #ifdef X11 - xtra_init(cb); + init_xtra(cb); #endif Tox *m = init_tox(); @@ -1041,7 +1046,7 @@ int main(int argc, char *argv[]) if (pthread_create(&cqueue_thread.tid, NULL, thread_cqueue, (void *) m) != 0) exit_toxic_err("failed in main", FATALERR_THREAD_CREATE); - #ifdef AUDIO +#ifdef AUDIO av = init_audio(prompt, m); @@ -1055,10 +1060,6 @@ int main(int argc, char *argv[]) #endif /* AUDIO */ init_notify(60, 3000); - -#ifdef SOUND_NOTIFY -// sound_notify(prompt, self_log_in, 0, NULL); -#endif /* SOUND_NOTIFY */ const char *msg; diff --git a/src/xtra.c b/src/xtra.c index 1afbf14..adaec88 100644 --- a/src/xtra.c +++ b/src/xtra.c @@ -231,13 +231,13 @@ void *event_loop(void* p) /* Actual XTRA termination * Please call xtra_terminate() at exit - * otherwise bad stuff happens + * otherwise HEWUSAGUDBOI happens */ if (Xtra.display) XCloseDisplay(Xtra.display); return (Xtra.display = NULL); } -int xtra_init(drop_callback d) +int init_xtra(drop_callback d) { memset(&Xtra, 0, sizeof(Xtra)); @@ -247,7 +247,7 @@ int xtra_init(drop_callback d) XInitThreads(); if ( !(Xtra.display = XOpenDisplay(NULL))) return -1; - Xtra.terminal_window = xtra_focused_window_id(); + Xtra.terminal_window = focused_window_id(); { /* Create an invisible window which will act as proxy for the DnD operation. */ @@ -317,7 +317,7 @@ int xtra_init(drop_callback d) return 0; } -void xtra_terminate() +void terminate_xtra() { if (!Xtra.display) return; @@ -337,7 +337,7 @@ void xtra_terminate() while (Xtra.display); /* Wait for termination */ } -long unsigned int xtra_focused_window_id() +long unsigned int focused_window_id() { if (!Xtra.display) return 0; @@ -349,7 +349,7 @@ long unsigned int xtra_focused_window_id() return focus; } -int xtra_is_this_focused() +int is_focused() { - return Xtra.proxy_window == xtra_focused_window_id(); + return Xtra.proxy_window == focused_window_id(); } diff --git a/src/xtra.h b/src/xtra.h index 89a096d..a2acee6 100644 --- a/src/xtra.h +++ b/src/xtra.h @@ -11,9 +11,9 @@ DropType; typedef void (*drop_callback) (const char*, DropType); -int xtra_init(drop_callback d); -void xtra_terminate(); -long unsigned int xtra_focused_window_id(); -int xtra_is_this_focused(); /* returns bool */ +int init_xtra(drop_callback d); +void terminate_xtra(); +long unsigned int focused_window_id(); +int is_focused(); /* returns bool */ #endif /* XTRA_H */ \ No newline at end of file