Refactor arguments into one line
Parameters should not cover an area. All arguments should be on a single line (either horizontally or vertically).
This commit is contained in:
parent
caa63d6275
commit
fc4f0a4238
38
src/dbus.c
38
src/dbus.c
@ -66,7 +66,8 @@ static void on_get_capabilities(GDBusConnection *connection,
|
|||||||
GDBusMethodInvocation *invocation);
|
GDBusMethodInvocation *invocation);
|
||||||
static void on_notify(GDBusConnection *connection,
|
static void on_notify(GDBusConnection *connection,
|
||||||
const gchar *sender,
|
const gchar *sender,
|
||||||
GVariant *parameters, GDBusMethodInvocation *invocation);
|
GVariant *parameters,
|
||||||
|
GDBusMethodInvocation *invocation);
|
||||||
static void on_close_notification(GDBusConnection *connection,
|
static void on_close_notification(GDBusConnection *connection,
|
||||||
const gchar *sender,
|
const gchar *sender,
|
||||||
GVariant *parameters,
|
GVariant *parameters,
|
||||||
@ -83,7 +84,8 @@ void handle_method_call(GDBusConnection *connection,
|
|||||||
const gchar *interface_name,
|
const gchar *interface_name,
|
||||||
const gchar *method_name,
|
const gchar *method_name,
|
||||||
GVariant *parameters,
|
GVariant *parameters,
|
||||||
GDBusMethodInvocation *invocation, gpointer user_data)
|
GDBusMethodInvocation *invocation,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
if (g_strcmp0(method_name, "GetCapabilities") == 0) {
|
if (g_strcmp0(method_name, "GetCapabilities") == 0) {
|
||||||
on_get_capabilities(connection, sender, parameters, invocation);
|
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) {
|
} else if (g_strcmp0(method_name, "CloseNotification") == 0) {
|
||||||
on_close_notification(connection, sender, parameters, invocation);
|
on_close_notification(connection, sender, parameters, invocation);
|
||||||
} else if (g_strcmp0(method_name, "GetServerInformation") == 0) {
|
} else if (g_strcmp0(method_name, "GetServerInformation") == 0) {
|
||||||
on_get_server_information(connection, sender, parameters,
|
on_get_server_information(connection, sender, parameters, invocation);
|
||||||
invocation);
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "WARNING: sender: %s; unknown method_name: %s\n", sender,
|
fprintf(stderr, "WARNING: sender: %s; unknown method_name: %s\n", sender,
|
||||||
method_name);
|
method_name);
|
||||||
@ -125,7 +126,8 @@ static void on_get_capabilities(GDBusConnection *connection,
|
|||||||
|
|
||||||
static void on_notify(GDBusConnection *connection,
|
static void on_notify(GDBusConnection *connection,
|
||||||
const gchar *sender,
|
const gchar *sender,
|
||||||
GVariant *parameters, GDBusMethodInvocation *invocation)
|
GVariant *parameters,
|
||||||
|
GDBusMethodInvocation *invocation)
|
||||||
{
|
{
|
||||||
|
|
||||||
gchar *appname = NULL;
|
gchar *appname = NULL;
|
||||||
@ -342,7 +344,9 @@ void notification_closed(notification *n, enum reason reason)
|
|||||||
n->dbus_client,
|
n->dbus_client,
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications",
|
"org.freedesktop.Notifications",
|
||||||
"NotificationClosed", body, &err);
|
"NotificationClosed",
|
||||||
|
body,
|
||||||
|
&err);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
fprintf(stderr, "Unable to close notification: %s\n", err->message);
|
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,
|
n->dbus_client,
|
||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
"org.freedesktop.Notifications",
|
"org.freedesktop.Notifications",
|
||||||
"ActionInvoked", body, &err);
|
"ActionInvoked",
|
||||||
|
body,
|
||||||
|
&err);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
fprintf(stderr, "Unable to invoke action: %s\n", err->message);
|
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,
|
static void on_bus_acquired(GDBusConnection *connection,
|
||||||
const gchar *name, gpointer user_data)
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
guint registration_id;
|
guint registration_id;
|
||||||
|
|
||||||
@ -383,7 +390,9 @@ static void on_bus_acquired(GDBusConnection *connection,
|
|||||||
"/org/freedesktop/Notifications",
|
"/org/freedesktop/Notifications",
|
||||||
introspection_data->interfaces[0],
|
introspection_data->interfaces[0],
|
||||||
&interface_vtable,
|
&interface_vtable,
|
||||||
NULL, NULL, &err);
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&err);
|
||||||
|
|
||||||
if (registration_id == 0) {
|
if (registration_id == 0) {
|
||||||
fprintf(stderr, "Unable to register dbus connection: %s\n", err->message);
|
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,
|
static void on_name_acquired(GDBusConnection *connection,
|
||||||
const gchar *name, gpointer user_data)
|
const gchar *name,
|
||||||
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
dbus_conn = connection;
|
dbus_conn = connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void on_name_lost(GDBusConnection *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");
|
fprintf(stderr, "Name Lost. Is Another notification daemon running?\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -455,7 +466,10 @@ int initdbus(void)
|
|||||||
"org.freedesktop.Notifications",
|
"org.freedesktop.Notifications",
|
||||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||||
on_bus_acquired,
|
on_bus_acquired,
|
||||||
on_name_acquired, on_name_lost, NULL, NULL);
|
on_name_acquired,
|
||||||
|
on_name_lost,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
return owner_id;
|
return owner_id;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,8 @@ void notification_run_script(notification *n)
|
|||||||
if (pid2) {
|
if (pid2) {
|
||||||
exit(0);
|
exit(0);
|
||||||
} else {
|
} else {
|
||||||
int ret = execlp(n->script, n->script,
|
int ret = execlp(n->script,
|
||||||
|
n->script,
|
||||||
appname,
|
appname,
|
||||||
summary,
|
summary,
|
||||||
body,
|
body,
|
||||||
@ -225,8 +226,11 @@ void notification_free(notification *n)
|
|||||||
* to point to the first char, which occurs after replacement.
|
* to point to the first char, which occurs after replacement.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void notification_replace_single_field(char **haystack, char **needle,
|
void notification_replace_single_field(char **haystack,
|
||||||
const char *replacement, enum markup_mode markup_mode) {
|
char **needle,
|
||||||
|
const char *replacement,
|
||||||
|
enum markup_mode markup_mode)
|
||||||
|
{
|
||||||
|
|
||||||
assert(*needle[0] == '%');
|
assert(*needle[0] == '%');
|
||||||
// needle has to point into haystack (but not on the last char)
|
// needle has to point into haystack (but not on the last char)
|
||||||
|
@ -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);
|
int notification_is_duplicate(const notification *a, const notification *b);
|
||||||
void notification_run_script(notification *n);
|
void notification_run_script(notification *n);
|
||||||
void notification_print(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_update_text_to_render(notification *n);
|
||||||
void notification_do_action(notification *n);
|
void notification_do_action(notification *n);
|
||||||
|
|
||||||
|
@ -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);
|
return string_replace_at(haystack, (start - haystack), strlen(needle), replacement);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *string_replace_all(const char *needle, const char *replacement,
|
char *string_replace_all(const char *needle, const char *replacement, char *haystack)
|
||||||
char *haystack)
|
|
||||||
{
|
{
|
||||||
char *start;
|
char *start;
|
||||||
int needle_pos;
|
int needle_pos;
|
||||||
|
@ -8,15 +8,13 @@
|
|||||||
char *string_replace_char(char needle, char replacement, char *haystack);
|
char *string_replace_char(char needle, char replacement, char *haystack);
|
||||||
|
|
||||||
/* replace all occurrences of needle with replacement in haystack */
|
/* replace all occurrences of needle with replacement in haystack */
|
||||||
char *string_replace_all(const char *needle, const char *replacement,
|
char *string_replace_all(const char *needle, const char *replacement, char *haystack);
|
||||||
char *haystack);
|
|
||||||
|
|
||||||
/* replace <len> characters with <repl> at position <pos> of the string <buf> */
|
/* replace <len> characters with <repl> at position <pos> of the string <buf> */
|
||||||
char *string_replace_at(char *buf, int pos, int len, const char *repl);
|
char *string_replace_at(char *buf, int pos, int len, const char *repl);
|
||||||
|
|
||||||
/* replace needle with replacement in haystack */
|
/* replace needle with replacement in haystack */
|
||||||
char *string_replace(const char *needle, const char *replacement,
|
char *string_replace(const char *needle, const char *replacement, char *haystack);
|
||||||
char *haystack);
|
|
||||||
|
|
||||||
char *string_append(char *a, const char *b, const char *sep);
|
char *string_append(char *a, const char *b, const char *sep);
|
||||||
|
|
||||||
|
@ -210,9 +210,15 @@ screen_info *get_active_screen()
|
|||||||
unsigned int dummy_ui;
|
unsigned int dummy_ui;
|
||||||
Window dummy_win;
|
Window dummy_win;
|
||||||
|
|
||||||
XQueryPointer(xctx.dpy, root, &dummy_win,
|
XQueryPointer(xctx.dpy,
|
||||||
&dummy_win, &x, &y, &dummy,
|
root,
|
||||||
&dummy, &dummy_ui);
|
&dummy_win,
|
||||||
|
&dummy_win,
|
||||||
|
&x,
|
||||||
|
&y,
|
||||||
|
&dummy,
|
||||||
|
&dummy,
|
||||||
|
&dummy_ui);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.f_mode == FOLLOW_KEYBOARD) {
|
if (settings.f_mode == FOLLOW_KEYBOARD) {
|
||||||
@ -278,9 +284,18 @@ static Window get_focused_window(void)
|
|||||||
Atom netactivewindow =
|
Atom netactivewindow =
|
||||||
XInternAtom(xctx.dpy, "_NET_ACTIVE_WINDOW", false);
|
XInternAtom(xctx.dpy, "_NET_ACTIVE_WINDOW", false);
|
||||||
|
|
||||||
XGetWindowProperty(xctx.dpy, root, netactivewindow, 0L,
|
XGetWindowProperty(xctx.dpy,
|
||||||
sizeof(Window), false, XA_WINDOW,
|
root,
|
||||||
&type, &format, &nitems, &bytes_after, &prop_return);
|
netactivewindow,
|
||||||
|
0L,
|
||||||
|
sizeof(Window),
|
||||||
|
false,
|
||||||
|
XA_WINDOW,
|
||||||
|
&type,
|
||||||
|
&format,
|
||||||
|
&nitems,
|
||||||
|
&bytes_after,
|
||||||
|
&prop_return);
|
||||||
if (prop_return) {
|
if (prop_return) {
|
||||||
focused = *(Window *) prop_return;
|
focused = *(Window *) prop_return;
|
||||||
XFree(prop_return);
|
XFree(prop_return);
|
||||||
|
83
src/x11/x.c
83
src/x11/x.c
@ -743,8 +743,14 @@ static void setopacity(Window win, unsigned long opacity)
|
|||||||
{
|
{
|
||||||
Atom _NET_WM_WINDOW_OPACITY =
|
Atom _NET_WM_WINDOW_OPACITY =
|
||||||
XInternAtom(xctx.dpy, "_NET_WM_WINDOW_OPACITY", false);
|
XInternAtom(xctx.dpy, "_NET_WM_WINDOW_OPACITY", false);
|
||||||
XChangeProperty(xctx.dpy, win, _NET_WM_WINDOW_OPACITY, XA_CARDINAL, 32,
|
XChangeProperty(xctx.dpy,
|
||||||
PropModeReplace, (unsigned char *)&opacity, 1L);
|
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
|
* Main Dispatcher for XEvents
|
||||||
*/
|
*/
|
||||||
gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback,
|
gboolean x_mainloop_fd_dispatch(GSource *source, GSourceFunc callback, gpointer user_data)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
unsigned int state;
|
unsigned int state;
|
||||||
@ -1045,9 +1050,14 @@ static void x_set_wm(Window win)
|
|||||||
XInternAtom(xctx.dpy, "_NET_WM_NAME", false);
|
XInternAtom(xctx.dpy, "_NET_WM_NAME", false);
|
||||||
|
|
||||||
XStoreName(xctx.dpy, win, title);
|
XStoreName(xctx.dpy, win, title);
|
||||||
XChangeProperty(xctx.dpy, win, _net_wm_title,
|
XChangeProperty(xctx.dpy,
|
||||||
XInternAtom(xctx.dpy, "UTF8_STRING", false), 8,
|
win,
|
||||||
PropModeReplace, (unsigned char *) title, strlen(title));
|
_net_wm_title,
|
||||||
|
XInternAtom(xctx.dpy, "UTF8_STRING", false),
|
||||||
|
8,
|
||||||
|
PropModeReplace,
|
||||||
|
(unsigned char *)title,
|
||||||
|
strlen(title));
|
||||||
|
|
||||||
/* set window class */
|
/* set window class */
|
||||||
char *class = settings.class != NULL ? settings.class : "Dunst";
|
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[0] = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE_NOTIFICATION", false);
|
||||||
data[1] = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE_UTILITY", false);
|
data[1] = XInternAtom(xctx.dpy, "_NET_WM_WINDOW_TYPE_UTILITY", false);
|
||||||
|
|
||||||
XChangeProperty(xctx.dpy, win, net_wm_window_type, XA_ATOM, 32,
|
XChangeProperty(xctx.dpy,
|
||||||
PropModeReplace, (unsigned char *) data, 2L);
|
win,
|
||||||
|
net_wm_window_type,
|
||||||
|
XA_ATOM,
|
||||||
|
32,
|
||||||
|
PropModeReplace,
|
||||||
|
(unsigned char *)data,
|
||||||
|
2L);
|
||||||
|
|
||||||
/* set state above */
|
/* set state above */
|
||||||
Atom net_wm_state =
|
Atom net_wm_state =
|
||||||
@ -1099,13 +1115,18 @@ static void x_win_setup(void)
|
|||||||
ButtonReleaseMask | FocusChangeMask| StructureNotifyMask;
|
ButtonReleaseMask | FocusChangeMask| StructureNotifyMask;
|
||||||
|
|
||||||
screen_info *scr = get_active_screen();
|
screen_info *scr = get_active_screen();
|
||||||
xctx.win =
|
xctx.win = XCreateWindow(xctx.dpy,
|
||||||
XCreateWindow(xctx.dpy, root, scr->dim.x, scr->dim.y, scr->dim.w,
|
root,
|
||||||
1, 0, DefaultDepth(xctx.dpy,
|
scr->dim.x,
|
||||||
DefaultScreen(xctx.dpy)),
|
scr->dim.y,
|
||||||
CopyFromParent, DefaultVisual(xctx.dpy,
|
scr->dim.w,
|
||||||
DefaultScreen(xctx.dpy)),
|
1,
|
||||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
|
0,
|
||||||
|
DefaultDepth(xctx.dpy, DefaultScreen(xctx.dpy)),
|
||||||
|
CopyFromParent,
|
||||||
|
DefaultVisual(xctx.dpy, DefaultScreen(xctx.dpy)),
|
||||||
|
CWOverrideRedirect | CWBackPixmap | CWEventMask,
|
||||||
|
&wa);
|
||||||
|
|
||||||
x_set_wm(xctx.win);
|
x_set_wm(xctx.win);
|
||||||
settings.transparency =
|
settings.transparency =
|
||||||
@ -1135,8 +1156,16 @@ void x_win_show(void)
|
|||||||
x_shortcut_grab(&settings.context_ks);
|
x_shortcut_grab(&settings.context_ks);
|
||||||
|
|
||||||
x_shortcut_setup_error_handler();
|
x_shortcut_setup_error_handler();
|
||||||
XGrabButton(xctx.dpy, AnyButton, AnyModifier, xctx.win, false,
|
XGrabButton(xctx.dpy,
|
||||||
BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
|
AnyButton,
|
||||||
|
AnyModifier,
|
||||||
|
xctx.win,
|
||||||
|
false,
|
||||||
|
BUTTONMASK,
|
||||||
|
GrabModeAsync,
|
||||||
|
GrabModeSync,
|
||||||
|
None,
|
||||||
|
None);
|
||||||
if (x_shortcut_tear_down_error_handler()) {
|
if (x_shortcut_tear_down_error_handler()) {
|
||||||
fprintf(stderr, "Unable to grab mouse button(s)\n");
|
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();
|
x_shortcut_setup_error_handler();
|
||||||
|
|
||||||
if (ks->is_valid) {
|
if (ks->is_valid) {
|
||||||
XGrabKey(xctx.dpy, ks->code, ks->mask, root,
|
XGrabKey(xctx.dpy,
|
||||||
true, GrabModeAsync, GrabModeAsync);
|
ks->code,
|
||||||
XGrabKey(xctx.dpy, ks->code, ks->mask | x_numlock_mod() , root,
|
ks->mask,
|
||||||
true, GrabModeAsync, GrabModeAsync);
|
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()) {
|
if (x_shortcut_tear_down_error_handler()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user