diff --git a/src/dbus.c b/src/dbus.c index 634355c..66f168d 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -61,20 +61,21 @@ static const char *introspection_xml = ""; static void on_get_capabilities(GDBusConnection *connection, - const gchar *sender, - const GVariant *parameters, - GDBusMethodInvocation *invocation); -static void on_notify(GDBusConnection *connection, - const gchar *sender, - GVariant *parameters, GDBusMethodInvocation *invocation); -static void on_close_notification(GDBusConnection *connection, const gchar *sender, - GVariant *parameters, + const GVariant *parameters, GDBusMethodInvocation *invocation); +static void on_notify(GDBusConnection *connection, + const gchar *sender, + GVariant *parameters, + GDBusMethodInvocation *invocation); +static void on_close_notification(GDBusConnection *connection, + const gchar *sender, + GVariant *parameters, + GDBusMethodInvocation *invocation); static void on_get_server_information(GDBusConnection *connection, - const gchar *sender, - const GVariant *parameters, - GDBusMethodInvocation *invocation); + const gchar *sender, + const GVariant *parameters, + GDBusMethodInvocation *invocation); static RawImage *get_raw_image_from_data_hint(GVariant *icon_data); void handle_method_call(GDBusConnection *connection, @@ -83,7 +84,8 @@ void handle_method_call(GDBusConnection *connection, const gchar *interface_name, const gchar *method_name, GVariant *parameters, - GDBusMethodInvocation *invocation, gpointer user_data) + GDBusMethodInvocation *invocation, + gpointer user_data) { if (g_strcmp0(method_name, "GetCapabilities") == 0) { on_get_capabilities(connection, sender, parameters, invocation); @@ -92,8 +94,7 @@ void handle_method_call(GDBusConnection *connection, } else if (g_strcmp0(method_name, "CloseNotification") == 0) { on_close_notification(connection, sender, parameters, invocation); } else if (g_strcmp0(method_name, "GetServerInformation") == 0) { - on_get_server_information(connection, sender, parameters, - invocation); + on_get_server_information(connection, sender, parameters, invocation); } else { fprintf(stderr, "WARNING: sender: %s; unknown method_name: %s\n", sender, method_name); @@ -101,9 +102,9 @@ void handle_method_call(GDBusConnection *connection, } static void on_get_capabilities(GDBusConnection *connection, - const gchar *sender, - const GVariant *parameters, - GDBusMethodInvocation *invocation) + const gchar *sender, + const GVariant *parameters, + GDBusMethodInvocation *invocation) { GVariantBuilder *builder; GVariant *value; @@ -124,8 +125,9 @@ static void on_get_capabilities(GDBusConnection *connection, } static void on_notify(GDBusConnection *connection, - const gchar *sender, - GVariant *parameters, GDBusMethodInvocation *invocation) + const gchar *sender, + GVariant *parameters, + GDBusMethodInvocation *invocation) { gchar *appname = NULL; @@ -297,9 +299,9 @@ static void on_notify(GDBusConnection *connection, } static void on_close_notification(GDBusConnection *connection, - const gchar *sender, - GVariant *parameters, - GDBusMethodInvocation *invocation) + const gchar *sender, + GVariant *parameters, + GDBusMethodInvocation *invocation) { guint32 id; g_variant_get(parameters, "(u)", &id); @@ -310,9 +312,9 @@ static void on_close_notification(GDBusConnection *connection, } static void on_get_server_information(GDBusConnection *connection, - const gchar *sender, - const GVariant *parameters, - GDBusMethodInvocation *invocation) + const gchar *sender, + const GVariant *parameters, + GDBusMethodInvocation *invocation) { GVariant *value; @@ -342,7 +344,9 @@ void notification_closed(notification *n, enum reason reason) n->dbus_client, "/org/freedesktop/Notifications", "org.freedesktop.Notifications", - "NotificationClosed", body, &err); + "NotificationClosed", + body, + &err); if (err) { fprintf(stderr, "Unable to close notification: %s\n", err->message); @@ -360,7 +364,9 @@ void action_invoked(notification *n, const char *identifier) n->dbus_client, "/org/freedesktop/Notifications", "org.freedesktop.Notifications", - "ActionInvoked", body, &err); + "ActionInvoked", + body, + &err); if (err) { fprintf(stderr, "Unable to invoke action: %s\n", err->message); @@ -373,7 +379,8 @@ static const GDBusInterfaceVTable interface_vtable = { }; static void on_bus_acquired(GDBusConnection *connection, - const gchar *name, gpointer user_data) + const gchar *name, + gpointer user_data) { guint registration_id; @@ -383,7 +390,9 @@ static void on_bus_acquired(GDBusConnection *connection, "/org/freedesktop/Notifications", introspection_data->interfaces[0], &interface_vtable, - NULL, NULL, &err); + NULL, + NULL, + &err); if (registration_id == 0) { fprintf(stderr, "Unable to register dbus connection: %s\n", err->message); @@ -392,13 +401,15 @@ static void on_bus_acquired(GDBusConnection *connection, } static void on_name_acquired(GDBusConnection *connection, - const gchar *name, gpointer user_data) + const gchar *name, + gpointer user_data) { dbus_conn = connection; } static void on_name_lost(GDBusConnection *connection, - const gchar *name, gpointer user_data) + const gchar *name, + gpointer user_data) { fprintf(stderr, "Name Lost. Is Another notification daemon running?\n"); exit(1); @@ -455,7 +466,10 @@ int initdbus(void) "org.freedesktop.Notifications", G_BUS_NAME_OWNER_FLAGS_NONE, on_bus_acquired, - on_name_acquired, on_name_lost, NULL, NULL); + on_name_acquired, + on_name_lost, + NULL, + NULL); return owner_id; } diff --git a/src/notification.c b/src/notification.c index a4be3a1..b5a880b 100644 --- a/src/notification.c +++ b/src/notification.c @@ -92,7 +92,8 @@ void notification_run_script(notification *n) if (pid2) { exit(0); } else { - int ret = execlp(n->script, n->script, + int ret = execlp(n->script, + n->script, appname, summary, body, @@ -225,8 +226,11 @@ void notification_free(notification *n) * to point to the first char, which occurs after replacement. * */ -void notification_replace_single_field(char **haystack, char **needle, - const char *replacement, enum markup_mode markup_mode) { +void notification_replace_single_field(char **haystack, + char **needle, + const char *replacement, + enum markup_mode markup_mode) +{ assert(*needle[0] == '%'); // needle has to point into haystack (but not on the last char) diff --git a/src/notification.h b/src/notification.h index 29b6c6c..c7da691 100644 --- a/src/notification.h +++ b/src/notification.h @@ -75,7 +75,10 @@ int notification_cmp_data(const void *a, const void *b, void *data); int notification_is_duplicate(const notification *a, const notification *b); void notification_run_script(notification *n); void notification_print(notification *n); -void notification_replace_single_field(char **haystack, char **needle, const char *replacement, enum markup_mode markup_mode); +void notification_replace_single_field(char **haystack, + char **needle, + const char *replacement, + enum markup_mode markup_mode); void notification_update_text_to_render(notification *n); void notification_do_action(notification *n); diff --git a/src/utils.c b/src/utils.c index a726d4b..015e593 100644 --- a/src/utils.c +++ b/src/utils.c @@ -52,8 +52,7 @@ char *string_replace(const char *needle, const char *replacement, char *haystack return string_replace_at(haystack, (start - haystack), strlen(needle), replacement); } -char *string_replace_all(const char *needle, const char *replacement, - char *haystack) +char *string_replace_all(const char *needle, const char *replacement, char *haystack) { char *start; int needle_pos; diff --git a/src/utils.h b/src/utils.h index 8dc353b..18333d9 100644 --- a/src/utils.h +++ b/src/utils.h @@ -8,15 +8,13 @@ char *string_replace_char(char needle, char replacement, char *haystack); /* replace all occurrences of needle with replacement in haystack */ -char *string_replace_all(const char *needle, const char *replacement, - char *haystack); +char *string_replace_all(const char *needle, const char *replacement, char *haystack); /* replace characters with at position of the string */ char *string_replace_at(char *buf, int pos, int len, const char *repl); /* replace needle with replacement in haystack */ -char *string_replace(const char *needle, const char *replacement, - char *haystack); +char *string_replace(const char *needle, const char *replacement, char *haystack); char *string_append(char *a, const char *b, const char *sep); diff --git a/src/x11/screen.c b/src/x11/screen.c index ae7fb93..ee1f35b 100644 --- a/src/x11/screen.c +++ b/src/x11/screen.c @@ -210,9 +210,15 @@ screen_info *get_active_screen() unsigned int dummy_ui; Window dummy_win; - XQueryPointer(xctx.dpy, root, &dummy_win, - &dummy_win, &x, &y, &dummy, - &dummy, &dummy_ui); + XQueryPointer(xctx.dpy, + root, + &dummy_win, + &dummy_win, + &x, + &y, + &dummy, + &dummy, + &dummy_ui); } if (settings.f_mode == FOLLOW_KEYBOARD) { @@ -278,9 +284,18 @@ static Window get_focused_window(void) Atom netactivewindow = XInternAtom(xctx.dpy, "_NET_ACTIVE_WINDOW", false); - XGetWindowProperty(xctx.dpy, root, netactivewindow, 0L, - sizeof(Window), false, XA_WINDOW, - &type, &format, &nitems, &bytes_after, &prop_return); + XGetWindowProperty(xctx.dpy, + root, + netactivewindow, + 0L, + sizeof(Window), + false, + XA_WINDOW, + &type, + &format, + &nitems, + &bytes_after, + &prop_return); if (prop_return) { focused = *(Window *) prop_return; XFree(prop_return); diff --git a/src/x11/x.c b/src/x11/x.c index c2ed312..cb8e171 100644 --- a/src/x11/x.c +++ b/src/x11/x.c @@ -743,8 +743,14 @@ static void setopacity(Window win, unsigned long opacity) { Atom _NET_WM_WINDOW_OPACITY = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_OPACITY", false); - XChangeProperty(xctx.dpy, win, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32, - PropModeReplace, (unsigned char *)&opacity, 1L); + XChangeProperty(xctx.dpy, + win, + _NET_WM_WINDOW_OPACITY, + XA_CARDINAL, + 32, + PropModeReplace, + (unsigned char *)&opacity, + 1L); } /* @@ -825,8 +831,7 @@ gboolean x_mainloop_fd_check(GSource *source) /* * Main Dispatcher for XEvents */ -gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback, - gpointer user_data) +gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback, gpointer user_data) { XEvent ev; unsigned int state; @@ -1045,9 +1050,14 @@ static void x_set_wm(Window win) XInternAtom(xctx.dpy, "_NET_WM_NAME", false); XStoreName(xctx.dpy, win, title); - XChangeProperty(xctx.dpy, win, _net_wm_title, - XInternAtom(xctx.dpy, "UTF8_STRING", false), 8, - PropModeReplace, (unsigned char *) title, strlen(title)); + XChangeProperty(xctx.dpy, + win, + _net_wm_title, + XInternAtom(xctx.dpy, "UTF8_STRING", false), + 8, + PropModeReplace, + (unsigned char *)title, + strlen(title)); /* set window class */ char *class = settings.class != NULL ? settings.class : "Dunst"; @@ -1062,8 +1072,14 @@ static void x_set_wm(Window win) data[0] = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", false); data[1] = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE_UTILITY", false); - XChangeProperty(xctx.dpy, win, net_wm_window_type, XA_ATOM, 32, - PropModeReplace, (unsigned char *) data, 2L); + XChangeProperty(xctx.dpy, + win, + net_wm_window_type, + XA_ATOM, + 32, + PropModeReplace, + (unsigned char *)data, + 2L); /* set state above */ Atom net_wm_state = @@ -1099,13 +1115,18 @@ static void x_win_setup(void) ButtonReleaseMask | FocusChangeMask| StructureNotifyMask; screen_info *scr = get_active_screen(); - xctx.win = - XCreateWindow(xctx.dpy, root, scr->dim.x, scr->dim.y, scr->dim.w, - 1, 0, DefaultDepth(xctx.dpy, - DefaultScreen(xctx.dpy)), - CopyFromParent, DefaultVisual(xctx.dpy, - DefaultScreen(xctx.dpy)), - CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa); + xctx.win = XCreateWindow(xctx.dpy, + root, + scr->dim.x, + scr->dim.y, + scr->dim.w, + 1, + 0, + DefaultDepth(xctx.dpy, DefaultScreen(xctx.dpy)), + CopyFromParent, + DefaultVisual(xctx.dpy, DefaultScreen(xctx.dpy)), + CWOverrideRedirect | CWBackPixmap | CWEventMask, + &wa); x_set_wm(xctx.win); settings.transparency = @@ -1135,8 +1156,16 @@ void x_win_show(void) x_shortcut_grab(&settings.context_ks); x_shortcut_setup_error_handler(); - XGrabButton(xctx.dpy, AnyButton, AnyModifier, xctx.win, false, - BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); + XGrabButton(xctx.dpy, + AnyButton, + AnyModifier, + xctx.win, + false, + BUTTONMASK, + GrabModeAsync, + GrabModeSync, + None, + None); if (x_shortcut_tear_down_error_handler()) { fprintf(stderr, "Unable to grab mouse button(s)\n"); } @@ -1237,10 +1266,20 @@ int x_shortcut_grab(keyboard_shortcut *ks) x_shortcut_setup_error_handler(); if (ks->is_valid) { - XGrabKey(xctx.dpy, ks->code, ks->mask, root, - true, GrabModeAsync, GrabModeAsync); - XGrabKey(xctx.dpy, ks->code, ks->mask | x_numlock_mod() , root, - true, GrabModeAsync, GrabModeAsync); + XGrabKey(xctx.dpy, + ks->code, + ks->mask, + root, + true, + GrabModeAsync, + GrabModeAsync); + XGrabKey(xctx.dpy, + ks->code, + ks->mask | x_numlock_mod(), + root, + true, + GrabModeAsync, + GrabModeAsync); } if (x_shortcut_tear_down_error_handler()) {