Don't indent top-level comments
This commit is contained in:
parent
7e58e5c64c
commit
8cadd8f905
44
menu.c
44
menu.c
@ -47,12 +47,12 @@ void regex_teardown(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Exctract all urls from a given string.
|
* Exctract all urls from a given string.
|
||||||
*
|
*
|
||||||
* Return: a string of urls separated by \n
|
* Return: a string of urls separated by \n
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
char *extract_urls(const char *to_match)
|
char *extract_urls(const char *to_match)
|
||||||
{
|
{
|
||||||
char *urls = NULL;
|
char *urls = NULL;
|
||||||
@ -87,10 +87,10 @@ char *extract_urls(const char *to_match)
|
|||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open url in browser.
|
* Open url in browser.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void open_browser(const char *url)
|
void open_browser(const char *url)
|
||||||
{
|
{
|
||||||
int browser_pid1 = fork();
|
int browser_pid1 = fork();
|
||||||
@ -111,10 +111,10 @@ void open_browser(const char *url)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Notify the corresponding client
|
* Notify the corresponding client
|
||||||
* that an action has been invoked
|
* that an action has been invoked
|
||||||
*/
|
*/
|
||||||
void invoke_action(const char *action)
|
void invoke_action(const char *action)
|
||||||
{
|
{
|
||||||
notification *invoked = NULL;
|
notification *invoked = NULL;
|
||||||
@ -153,10 +153,10 @@ void invoke_action(const char *action)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dispatch whatever has been returned
|
* Dispatch whatever has been returned
|
||||||
* by the menu.
|
* by the menu.
|
||||||
*/
|
*/
|
||||||
void dispatch_menu_result(const char *input)
|
void dispatch_menu_result(const char *input)
|
||||||
{
|
{
|
||||||
char *in = strdup(input);
|
char *in = strdup(input);
|
||||||
@ -182,10 +182,10 @@ void dispatch_menu_result(const char *input)
|
|||||||
free(in);
|
free(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the context menu that let's the user
|
* Open the context menu that let's the user
|
||||||
* select urls/actions/etc
|
* select urls/actions/etc
|
||||||
*/
|
*/
|
||||||
void context_menu(void)
|
void context_menu(void)
|
||||||
{
|
{
|
||||||
char *dmenu_input = NULL;
|
char *dmenu_input = NULL;
|
||||||
|
@ -21,10 +21,10 @@
|
|||||||
|
|
||||||
int next_notification_id = 1;
|
int next_notification_id = 1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* print a human readable representation
|
* print a human readable representation
|
||||||
* of the given notification to stdout.
|
* of the given notification to stdout.
|
||||||
*/
|
*/
|
||||||
void notification_print(notification * n)
|
void notification_print(notification * n)
|
||||||
{
|
{
|
||||||
printf("{\n");
|
printf("{\n");
|
||||||
@ -60,10 +60,10 @@ void notification_print(notification * n)
|
|||||||
printf("}\n");
|
printf("}\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run the script associated with the
|
* Run the script associated with the
|
||||||
* given notification.
|
* given notification.
|
||||||
*/
|
*/
|
||||||
void notification_run_script(notification * n)
|
void notification_run_script(notification * n)
|
||||||
{
|
{
|
||||||
if (!n->script || strlen(n->script) < 1)
|
if (!n->script || strlen(n->script) < 1)
|
||||||
@ -115,10 +115,10 @@ void notification_run_script(notification * n)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to compare to given
|
* Helper function to compare to given
|
||||||
* notifications.
|
* notifications.
|
||||||
*/
|
*/
|
||||||
int notification_cmp(const void *va, const void *vb)
|
int notification_cmp(const void *va, const void *vb)
|
||||||
{
|
{
|
||||||
notification *a = (notification *) va;
|
notification *a = (notification *) va;
|
||||||
@ -134,18 +134,18 @@ int notification_cmp(const void *va, const void *vb)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrapper for notification_cmp to match glib's
|
* Wrapper for notification_cmp to match glib's
|
||||||
* compare functions signature.
|
* compare functions signature.
|
||||||
*/
|
*/
|
||||||
int notification_cmp_data(const void *va, const void *vb, void *data)
|
int notification_cmp_data(const void *va, const void *vb, void *data)
|
||||||
{
|
{
|
||||||
return notification_cmp(va, vb);
|
return notification_cmp(va, vb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Free the memory used by the given notification.
|
* Free the memory used by the given notification.
|
||||||
*/
|
*/
|
||||||
void notification_free(notification * n)
|
void notification_free(notification * n)
|
||||||
{
|
{
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
@ -180,9 +180,9 @@ void notification_free(notification * n)
|
|||||||
free(n);
|
free(n);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Strip any markup from text
|
* Strip any markup from text
|
||||||
*/
|
*/
|
||||||
char *notification_strip_markup(char *str)
|
char *notification_strip_markup(char *str)
|
||||||
{
|
{
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
@ -202,9 +202,9 @@ char *notification_strip_markup(char *str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Quote a text string for rendering with pango
|
* Quote a text string for rendering with pango
|
||||||
*/
|
*/
|
||||||
char *notification_quote_markup(char *str)
|
char *notification_quote_markup(char *str)
|
||||||
{
|
{
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
@ -220,10 +220,10 @@ char *notification_quote_markup(char *str)
|
|||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Replace all occurrences of "needle" with a quoted "replacement",
|
* Replace all occurrences of "needle" with a quoted "replacement",
|
||||||
* according to the allow_markup/plain_text settings.
|
* according to the allow_markup/plain_text settings.
|
||||||
*/
|
*/
|
||||||
char *notification_replace_format(const char *needle, const char *replacement,
|
char *notification_replace_format(const char *needle, const char *replacement,
|
||||||
char *haystack, bool allow_markup,
|
char *haystack, bool allow_markup,
|
||||||
bool plain_text) {
|
bool plain_text) {
|
||||||
@ -302,10 +302,10 @@ char *notification_extract_markup_urls(char **str_ptr) {
|
|||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the given notification and add it to
|
* Initialize the given notification and add it to
|
||||||
* the queue. Replace notification with id if id > 0.
|
* the queue. Replace notification with id if id > 0.
|
||||||
*/
|
*/
|
||||||
int notification_init(notification * n, int id)
|
int notification_init(notification * n, int id)
|
||||||
{
|
{
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
@ -501,15 +501,15 @@ int notification_init(notification * n, int id)
|
|||||||
return n->id;
|
return n->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the notification that has id.
|
* Close the notification that has id.
|
||||||
*
|
*
|
||||||
* reasons:
|
* reasons:
|
||||||
* -1 -> notification is a replacement, no NotificationClosed signal emitted
|
* -1 -> notification is a replacement, no NotificationClosed signal emitted
|
||||||
* 1 -> the notification expired
|
* 1 -> the notification expired
|
||||||
* 2 -> the notification was dismissed by the user_data
|
* 2 -> the notification was dismissed by the user_data
|
||||||
* 3 -> The notification was closed by a call to CloseNotification
|
* 3 -> The notification was closed by a call to CloseNotification
|
||||||
*/
|
*/
|
||||||
int notification_close_by_id(int id, int reason)
|
int notification_close_by_id(int id, int reason)
|
||||||
{
|
{
|
||||||
notification *target = NULL;
|
notification *target = NULL;
|
||||||
@ -544,9 +544,9 @@ int notification_close_by_id(int id, int reason)
|
|||||||
return reason;
|
return reason;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Close the given notification. SEE notification_close_by_id.
|
* Close the given notification. SEE notification_close_by_id.
|
||||||
*/
|
*/
|
||||||
int notification_close(notification * n, int reason)
|
int notification_close(notification * n, int reason)
|
||||||
{
|
{
|
||||||
if (n == NULL)
|
if (n == NULL)
|
||||||
|
130
x.c
130
x.c
@ -713,9 +713,9 @@ static void setopacity(Window win, unsigned long opacity)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Returns the modifier which is NumLock.
|
* Returns the modifier which is NumLock.
|
||||||
*/
|
*/
|
||||||
static KeySym x_numlock_mod()
|
static KeySym x_numlock_mod()
|
||||||
{
|
{
|
||||||
static KeyCode nl = 0;
|
static KeyCode nl = 0;
|
||||||
@ -766,10 +766,10 @@ end:
|
|||||||
return sym;
|
return sym;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to use glib's mainloop mechanic
|
* Helper function to use glib's mainloop mechanic
|
||||||
* with Xlib
|
* with Xlib
|
||||||
*/
|
*/
|
||||||
gboolean x_mainloop_fd_prepare(GSource * source, gint * timeout)
|
gboolean x_mainloop_fd_prepare(GSource * source, gint * timeout)
|
||||||
{
|
{
|
||||||
if (timeout)
|
if (timeout)
|
||||||
@ -779,18 +779,18 @@ gboolean x_mainloop_fd_prepare(GSource * source, gint * timeout)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helper function to use glib's mainloop mechanic
|
* Helper function to use glib's mainloop mechanic
|
||||||
* with Xlib
|
* with Xlib
|
||||||
*/
|
*/
|
||||||
gboolean x_mainloop_fd_check(GSource * source)
|
gboolean x_mainloop_fd_check(GSource * source)
|
||||||
{
|
{
|
||||||
return XPending(xctx.dpy) > 0;
|
return XPending(xctx.dpy) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 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)
|
||||||
{
|
{
|
||||||
@ -854,9 +854,9 @@ gboolean x_mainloop_fd_dispatch(GSource * source, GSourceFunc callback,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check whether the user is currently idle.
|
* Check whether the user is currently idle.
|
||||||
*/
|
*/
|
||||||
bool x_is_idle(void)
|
bool x_is_idle(void)
|
||||||
{
|
{
|
||||||
XScreenSaverQueryInfo(xctx.dpy, DefaultRootWindow(xctx.dpy),
|
XScreenSaverQueryInfo(xctx.dpy, DefaultRootWindow(xctx.dpy),
|
||||||
@ -868,9 +868,9 @@ bool x_is_idle(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* TODO move to x_mainloop_* */
|
/* TODO move to x_mainloop_* */
|
||||||
/*
|
/*
|
||||||
* Handle incoming mouse click events
|
* Handle incoming mouse click events
|
||||||
*/
|
*/
|
||||||
static void x_handle_click(XEvent ev)
|
static void x_handle_click(XEvent ev)
|
||||||
{
|
{
|
||||||
if (ev.xbutton.button == Button3) {
|
if (ev.xbutton.button == Button3) {
|
||||||
@ -898,10 +898,10 @@ static void x_handle_click(XEvent ev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the window that currently has
|
* Return the window that currently has
|
||||||
* the keyboard focus.
|
* the keyboard focus.
|
||||||
*/
|
*/
|
||||||
static Window get_focused_window(void)
|
static Window get_focused_window(void)
|
||||||
{
|
{
|
||||||
Window focused = 0;
|
Window focused = 0;
|
||||||
@ -925,10 +925,10 @@ static Window get_focused_window(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
/*
|
/*
|
||||||
* Select the screen on which the Window
|
* Select the screen on which the Window
|
||||||
* should be displayed.
|
* should be displayed.
|
||||||
*/
|
*/
|
||||||
static int select_screen(XineramaScreenInfo * info, int info_len)
|
static int select_screen(XineramaScreenInfo * info, int info_len)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -991,10 +991,10 @@ sc_cleanup:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update the information about the monitor
|
* Update the information about the monitor
|
||||||
* geometry.
|
* geometry.
|
||||||
*/
|
*/
|
||||||
static void x_screen_info(screen_info * scr)
|
static void x_screen_info(screen_info * scr)
|
||||||
{
|
{
|
||||||
#ifdef XINERAMA
|
#ifdef XINERAMA
|
||||||
@ -1037,9 +1037,9 @@ void x_free(void)
|
|||||||
XCloseDisplay(xctx.dpy);
|
XCloseDisplay(xctx.dpy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup X11 stuff
|
* Setup X11 stuff
|
||||||
*/
|
*/
|
||||||
void x_setup(void)
|
void x_setup(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1147,9 +1147,9 @@ static void x_set_wm(Window win)
|
|||||||
PropModeReplace, (unsigned char *) data, 1L);
|
PropModeReplace, (unsigned char *) data, 1L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the window
|
* Setup the window
|
||||||
*/
|
*/
|
||||||
static void x_win_setup(void)
|
static void x_win_setup(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -1193,9 +1193,9 @@ static void x_win_setup(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Show the window and grab shortcuts.
|
* Show the window and grab shortcuts.
|
||||||
*/
|
*/
|
||||||
void x_win_show(void)
|
void x_win_show(void)
|
||||||
{
|
{
|
||||||
/* window is already mapped or there's nothing to show */
|
/* window is already mapped or there's nothing to show */
|
||||||
@ -1218,9 +1218,9 @@ void x_win_show(void)
|
|||||||
xctx.visible = true;
|
xctx.visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Hide the window and ungrab unused keyboard_shortcuts
|
* Hide the window and ungrab unused keyboard_shortcuts
|
||||||
*/
|
*/
|
||||||
void x_win_hide()
|
void x_win_hide()
|
||||||
{
|
{
|
||||||
x_shortcut_ungrab(&settings.close_ks);
|
x_shortcut_ungrab(&settings.close_ks);
|
||||||
@ -1233,9 +1233,9 @@ void x_win_hide()
|
|||||||
xctx.visible = false;
|
xctx.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse a string into a modifier mask.
|
* Parse a string into a modifier mask.
|
||||||
*/
|
*/
|
||||||
KeySym x_shortcut_string_to_mask(const char *str)
|
KeySym x_shortcut_string_to_mask(const char *str)
|
||||||
{
|
{
|
||||||
if (!strcmp(str, "ctrl")) {
|
if (!strcmp(str, "ctrl")) {
|
||||||
@ -1257,9 +1257,9 @@ KeySym x_shortcut_string_to_mask(const char *str)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Error handler for grabbing mouse and keyboard errors.
|
* Error handler for grabbing mouse and keyboard errors.
|
||||||
*/
|
*/
|
||||||
static int GrabXErrorHandler(Display * display, XErrorEvent * e)
|
static int GrabXErrorHandler(Display * display, XErrorEvent * e)
|
||||||
{
|
{
|
||||||
dunst_grab_errored = true;
|
dunst_grab_errored = true;
|
||||||
@ -1286,9 +1286,9 @@ static int FollowXErrorHandler(Display * display, XErrorEvent * e)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the Error handler.
|
* Setup the Error handler.
|
||||||
*/
|
*/
|
||||||
static void x_shortcut_setup_error_handler(void)
|
static void x_shortcut_setup_error_handler(void)
|
||||||
{
|
{
|
||||||
dunst_grab_errored = false;
|
dunst_grab_errored = false;
|
||||||
@ -1305,9 +1305,9 @@ static void x_follow_setup_error_handler(void)
|
|||||||
XSetErrorHandler(FollowXErrorHandler);
|
XSetErrorHandler(FollowXErrorHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tear down the Error handler.
|
* Tear down the Error handler.
|
||||||
*/
|
*/
|
||||||
static int x_shortcut_tear_down_error_handler(void)
|
static int x_shortcut_tear_down_error_handler(void)
|
||||||
{
|
{
|
||||||
XFlush(xctx.dpy);
|
XFlush(xctx.dpy);
|
||||||
@ -1324,9 +1324,9 @@ static int x_follow_tear_down_error_handler(void)
|
|||||||
return dunst_follow_errored;
|
return dunst_follow_errored;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Grab the given keyboard shortcut.
|
* Grab the given keyboard shortcut.
|
||||||
*/
|
*/
|
||||||
int x_shortcut_grab(keyboard_shortcut * ks)
|
int x_shortcut_grab(keyboard_shortcut * ks)
|
||||||
{
|
{
|
||||||
if (!ks->is_valid)
|
if (!ks->is_valid)
|
||||||
@ -1351,9 +1351,9 @@ int x_shortcut_grab(keyboard_shortcut * ks)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ungrab the given keyboard shortcut.
|
* Ungrab the given keyboard shortcut.
|
||||||
*/
|
*/
|
||||||
void x_shortcut_ungrab(keyboard_shortcut * ks)
|
void x_shortcut_ungrab(keyboard_shortcut * ks)
|
||||||
{
|
{
|
||||||
Window root;
|
Window root;
|
||||||
@ -1364,9 +1364,9 @@ void x_shortcut_ungrab(keyboard_shortcut * ks)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the keyboard shortcut.
|
* Initialize the keyboard shortcut.
|
||||||
*/
|
*/
|
||||||
void x_shortcut_init(keyboard_shortcut * ks)
|
void x_shortcut_init(keyboard_shortcut * ks)
|
||||||
{
|
{
|
||||||
if (ks == NULL || ks->str == NULL)
|
if (ks == NULL || ks->str == NULL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user