From 3b297ee80dbddcfbf9f8e08bf3fd65e286b762df Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 1 Jun 2021 10:44:23 +0200 Subject: [PATCH] Re-indent the code using indenter. --- config/config.c | 2 +- include/mode.h | 20 ++-- include/widgets/widget-internal.h | 2 +- include/xcb.h | 6 +- source/dialogs/drun.c | 13 +- source/dialogs/filebrowser.c | 18 +-- source/dialogs/help-keys.c | 1 - source/dialogs/run.c | 4 +- source/dialogs/script.c | 29 ++--- source/dialogs/ssh.c | 3 +- source/dialogs/window.c | 33 ++--- source/helper.c | 18 +-- source/rofi-icon-fetcher.c | 4 +- source/rofi.c | 15 +-- source/view.c | 27 +++-- source/widgets/textbox.c | 9 +- source/widgets/widget.c | 2 +- source/xcb.c | 193 +++++++++++++++--------------- source/xrmoptions.c | 3 +- 19 files changed, 206 insertions(+), 196 deletions(-) diff --git a/config/config.c b/config/config.c index 039e0426..420a7ab9 100644 --- a/config/config.c +++ b/config/config.c @@ -173,5 +173,5 @@ Settings config = { /** normalize match */ .normalize_match = FALSE, /** steal focus */ - .steal_focus = FALSE + .steal_focus = FALSE }; diff --git a/include/mode.h b/include/mode.h index 76aff22e..fd4f8ae6 100644 --- a/include/mode.h +++ b/include/mode.h @@ -66,25 +66,25 @@ typedef enum typedef enum { /** Entry is selected. */ - MENU_OK = 0x00010000, + MENU_OK = 0x00010000, /** User canceled the operation. (e.g. pressed escape) */ - MENU_CANCEL = 0x00020000, + MENU_CANCEL = 0x00020000, /** User requested a mode switch */ - MENU_NEXT = 0x00040000, + MENU_NEXT = 0x00040000, /** Custom (non-matched) input was entered. */ - MENU_CUSTOM_INPUT = 0x00080000, + MENU_CUSTOM_INPUT = 0x00080000, /** User wanted to delete entry from history. */ - MENU_ENTRY_DELETE = 0x00100000, + MENU_ENTRY_DELETE = 0x00100000, /** User wants to jump to another switcher. */ - MENU_QUICK_SWITCH = 0x00200000, + MENU_QUICK_SWITCH = 0x00200000, /** User wants to jump to custom command. */ - MENU_CUSTOM_COMMAND= 0x00800000, + MENU_CUSTOM_COMMAND = 0x00800000, /** Go to the previous menu. */ - MENU_PREVIOUS = 0x00400000, + MENU_PREVIOUS = 0x00400000, /** Bindings specifics */ - MENU_CUSTOM_ACTION = 0x10000000, + MENU_CUSTOM_ACTION = 0x10000000, /** Mask */ - MENU_LOWER_MASK = 0x0000FFFF + MENU_LOWER_MASK = 0x0000FFFF } MenuReturn; /** diff --git a/include/widgets/widget-internal.h b/include/widgets/widget-internal.h index 3106d063..ece8094a 100644 --- a/include/widgets/widget-internal.h +++ b/include/widgets/widget-internal.h @@ -55,7 +55,7 @@ struct _widget RofiPadding border_radius; /** Cursor that is set when the widget is hovered */ - RofiCursorType cursor_type; + RofiCursorType cursor_type; /** enabled or not */ gboolean enabled; diff --git a/include/xcb.h b/include/xcb.h index 90a896b7..cc6dd2e1 100644 --- a/include/xcb.h +++ b/include/xcb.h @@ -132,12 +132,12 @@ int monitor_active ( workarea *mon ); * * Stores old input focus for reverting and set focus to rofi. */ -void rofi_xcb_set_input_focus(xcb_window_t w); +void rofi_xcb_set_input_focus ( xcb_window_t w ); /** * IF set, revert the focus back to the original applications. */ -void rofi_xcb_revert_input_focus(void); +void rofi_xcb_revert_input_focus ( void ); /** * Depth of visual @@ -235,6 +235,6 @@ cairo_surface_t *x11_helper_get_screenshot_surface_window ( xcb_window_t window, * * Blur the content of the surface with radius and deviation. */ -void cairo_image_surface_blur(cairo_surface_t* surface, double radius, double deviation); +void cairo_image_surface_blur ( cairo_surface_t* surface, double radius, double deviation ); #endif diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c index ee5616d5..b20f5b25 100644 --- a/source/dialogs/drun.c +++ b/source/dialogs/drun.c @@ -400,7 +400,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const } else if ( !g_strcmp0 ( key, "Service" ) ) { desktop_entry_type = DRUN_DESKTOP_ENTRY_TYPE_SERVICE; - g_debug("Service file detected."); + g_debug ( "Service file detected." ); } else { g_debug ( "[%s] [%s] Skipping desktop file: Not of type Application or Link (%s)", id, path, key ); @@ -575,7 +575,7 @@ static void read_desktop_file ( DRunModePrivateData *pd, const char *root, const pd->entry_list[pd->cmd_list_length].type = desktop_entry_type; if ( desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_APPLICATION || - desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_SERVICE) { + desktop_entry_type == DRUN_DESKTOP_ENTRY_TYPE_SERVICE ) { pd->entry_list[pd->cmd_list_length].exec = g_key_file_get_string ( kf, action, "Exec", NULL ); } else { @@ -726,9 +726,11 @@ static gint drun_int_sort_list ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED if ( da->sort_index < 0 && db->sort_index < 0 ) { if ( da->name == NULL && db->name == NULL ) { return 0; - } else if ( da->name == NULL ) { + } + else if ( da->name == NULL ) { return -1; - } else if ( db->name == NULL ) { + } + else if ( db->name == NULL ) { return 1; } return g_utf8_collate ( da->name, db->name ); @@ -1078,7 +1080,8 @@ static ModeMode drun_mode_result ( Mode *sw, int mretv, char **input, unsigned i rmpd->cmd_list_length--; } retv = RELOAD_DIALOG; - } else if ( mretv & MENU_CUSTOM_COMMAND ) { + } + else if ( mretv & MENU_CUSTOM_COMMAND ) { retv = ( mretv & MENU_LOWER_MASK ); } return retv; diff --git a/source/dialogs/filebrowser.c b/source/dialogs/filebrowser.c index 3df1f678..c9637285 100644 --- a/source/dialogs/filebrowser.c +++ b/source/dialogs/filebrowser.c @@ -97,8 +97,8 @@ static void free_list ( FileBrowserModePrivateData *pd ) static gint compare ( gconstpointer a, gconstpointer b, G_GNUC_UNUSED gpointer data ) { - FBFile *fa = (FBFile*) a; - FBFile *fb = (FBFile*) b; + FBFile *fa = (FBFile *) a; + FBFile *fb = (FBFile *) b; if ( fa->type != fb->type ) { return fa->type - fb->type; } @@ -239,9 +239,11 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un } else if ( mretv & MENU_QUICK_SWITCH ) { retv = ( mretv & MENU_LOWER_MASK ); - } else if ( mretv & MENU_CUSTOM_COMMAND ) { + } + else if ( mretv & MENU_CUSTOM_COMMAND ) { retv = ( mretv & MENU_LOWER_MASK ); - } else if ( ( mretv & MENU_OK ) ) { + } + else if ( ( mretv & MENU_OK ) ) { if ( selected_line < pd->array_length ) { if ( pd->array[selected_line].type == UP ) { GFile *new = g_file_get_parent ( pd->current_dir ); @@ -265,10 +267,10 @@ static ModeMode file_browser_mode_result ( Mode *sw, int mretv, char **input, un return RESET_DIALOG; } else if ( pd->array[selected_line].type == RFILE ) { - char *d = g_filename_from_utf8 ( pd->array[selected_line].path, -1, NULL, NULL, NULL ); - char *d_esc = g_shell_quote(d); - char *cmd = g_strdup_printf ( "xdg-open %s", d_esc ); - g_free(d_esc); + char *d = g_filename_from_utf8 ( pd->array[selected_line].path, -1, NULL, NULL, NULL ); + char *d_esc = g_shell_quote ( d ); + char *cmd = g_strdup_printf ( "xdg-open %s", d_esc ); + g_free ( d_esc ); g_free ( d ); char *cdir = g_file_get_path ( pd->current_dir ); helper_execute_command ( cdir, cmd, FALSE, NULL ); diff --git a/source/dialogs/help-keys.c b/source/dialogs/help-keys.c index 6fc1e37f..a82d82c4 100644 --- a/source/dialogs/help-keys.c +++ b/source/dialogs/help-keys.c @@ -71,7 +71,6 @@ static ModeMode help_keys_mode_result ( G_GNUC_UNUSED Mode *sw, G_GNUC_UNUSED char **input, G_GNUC_UNUSED unsigned int selected_line ) { - if ( mretv & MENU_CUSTOM_COMMAND ) { int retv = ( mretv & MENU_LOWER_MASK ); return retv; diff --git a/source/dialogs/run.c b/source/dialogs/run.c index 23b31e8b..a4aa7bc1 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -391,8 +391,8 @@ static ModeMode run_mode_result ( Mode *sw, int mretv, char **input, unsigned in retv = RELOAD_DIALOG; run_mode_destroy ( sw ); run_mode_init ( sw ); - - } else if ( mretv & MENU_CUSTOM_COMMAND ) { + } + else if ( mretv & MENU_CUSTOM_COMMAND ) { retv = ( mretv & MENU_LOWER_MASK ); } return retv; diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 14ca2df8..9bc33af7 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -284,23 +284,24 @@ static ModeMode script_mode_result ( Mode *sw, int mretv, char **input, unsigned unsigned int new_length = 0; if ( ( mretv & MENU_CUSTOM_COMMAND ) ) { - if ( rmpd->use_hot_keys ) { - script_mode_reset_highlight ( sw ); - if ( selected_line != UINT32_MAX ) { - new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) ); + if ( rmpd->use_hot_keys ) { + script_mode_reset_highlight ( sw ); + if ( selected_line != UINT32_MAX ) { + new_list = execute_executor ( sw, rmpd->cmd_list[selected_line].entry, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), &( rmpd->cmd_list[selected_line] ) ); + } + else { + if ( rmpd->no_custom == FALSE ) { + new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL ); + } + else { + return RELOAD_DIALOG; + } + } } else { - if ( rmpd->no_custom == FALSE ) { - new_list = execute_executor ( sw, *input, &new_length, 10 + ( mretv & MENU_LOWER_MASK ), NULL ); - } - else { - return RELOAD_DIALOG; - } + retv = ( mretv & MENU_LOWER_MASK ); + return retv; } - } else { - retv = ( mretv & MENU_LOWER_MASK ); - return retv; - } } else if ( ( mretv & MENU_OK ) && rmpd->cmd_list[selected_line].entry != NULL ) { if ( rmpd->cmd_list[selected_line].nonselectable ) { diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 76f0d75f..75991f42 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -606,7 +606,8 @@ static ModeMode ssh_mode_result ( Mode *sw, int mretv, char **input, unsigned in retv = RELOAD_DIALOG; ssh_mode_destroy ( sw ); ssh_mode_init ( sw ); - } else if ( mretv & MENU_CUSTOM_COMMAND ) { + } + else if ( mretv & MENU_CUSTOM_COMMAND ) { retv = ( mretv & MENU_LOWER_MASK ); } return retv; diff --git a/source/dialogs/window.c b/source/dialogs/window.c index d2e2d792..289ed9c7 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -342,15 +342,15 @@ static client* window_client ( ModeModePrivateData *pd, xcb_window_t win ) g_free ( tmp_title ); char *tmp_role = window_get_text_prop ( c->window, netatoms[WM_WINDOW_ROLE] ); - c->role = g_markup_escape_text ( tmp_role ? tmp_role : "", -1 ); - pd->role_len = MAX ( c->role ? g_utf8_strlen ( c->role, -1 ) : 0, pd->role_len ); + c->role = g_markup_escape_text ( tmp_role ? tmp_role : "", -1 ); + pd->role_len = MAX ( c->role ? g_utf8_strlen ( c->role, -1 ) : 0, pd->role_len ); g_free ( tmp_role ); cky = xcb_icccm_get_wm_class ( xcb->connection, c->window ); xcb_icccm_get_wm_class_reply_t wcr; if ( xcb_icccm_get_wm_class_reply ( xcb->connection, cky, &wcr, NULL ) ) { - c->class = g_markup_escape_text( wcr.class_name, -1 ); - c->name = g_markup_escape_text( wcr.instance_name, -1 ); + c->class = g_markup_escape_text ( wcr.class_name, -1 ); + c->name = g_markup_escape_text ( wcr.instance_name, -1 ); pd->name_len = MAX ( c->name ? g_utf8_strlen ( c->name, -1 ) : 0, pd->name_len ); xcb_icccm_get_wm_class_reply_wipe ( &wcr ); } @@ -496,7 +496,7 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) current_desktop = 0; } - g_debug("Get list from: %d", xcb->screen_nbr); + g_debug ( "Get list from: %d", xcb->screen_nbr ); c = xcb_ewmh_get_client_list_stacking ( &xcb->ewmh, xcb->screen_nbr ); xcb_ewmh_get_windows_reply_t clients = { 0, }; if ( xcb_ewmh_get_client_list_stacking_reply ( &xcb->ewmh, c, &clients, NULL ) ) { @@ -566,29 +566,29 @@ static void _window_mode_load_data ( Mode *sw, unsigned int cd ) char *output = NULL; if ( pango_parse_markup ( _window_name_list_entry ( names.strings, names.strings_len, c->wmdesktop ), -1, 0, NULL, &output, NULL, NULL ) ) { - c->wmdesktopstr = g_strdup ( _window_name_list_entry ( names.strings, names.strings_len, c->wmdesktop ) ); + c->wmdesktopstr = g_strdup ( _window_name_list_entry ( names.strings, names.strings_len, c->wmdesktop ) ); c->wmdesktopstr_len = g_utf8_strlen ( output, -1 ); - pd->wmdn_len = MAX ( pd->wmdn_len, c->wmdesktopstr_len ); + pd->wmdn_len = MAX ( pd->wmdn_len, c->wmdesktopstr_len ); g_free ( output ); } else { c->wmdesktopstr = g_strdup ( "Invalid name" ); - pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); + pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); } } else { c->wmdesktopstr = g_markup_escape_text ( _window_name_list_entry ( names.strings, names.strings_len, c->wmdesktop ), -1 ); - pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); + pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); } } else { c->wmdesktopstr = g_strdup_printf ( "%u", (uint32_t) c->wmdesktop ); - pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); + pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); } } else { c->wmdesktopstr = g_strdup ( "" ); - pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); + pd->wmdn_len = MAX ( pd->wmdn_len, g_utf8_strlen ( c->wmdesktopstr, -1 ) ); } if ( cd && c->wmdesktop != current_desktop ) { continue; @@ -727,7 +727,8 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i retv = RELOAD_DIALOG; } g_free ( lf_cmd ); - } else if ( mretv & MENU_CUSTOM_COMMAND ) { + } + else if ( mretv & MENU_CUSTOM_COMMAND ) { retv = ( mretv & MENU_LOWER_MASK ); } return retv; @@ -756,20 +757,20 @@ static void helper_eval_add_str ( GString *str, const char *input, int l, int ma // g_utf8 does not work with NULL string. const char *input_nn = input ? input : ""; // Both l and max_len are in characters, not bytes. - int spaces = 0; + int spaces = 0; if ( l == 0 ) { spaces = MAX ( 0, max_len - nc ); g_string_append ( str, input_nn ); } else { if ( nc > l ) { - int bl = g_utf8_offset_to_pointer ( input_nn, l ) - input_nn; + int bl = g_utf8_offset_to_pointer ( input_nn, l ) - input_nn; char *tmp = g_markup_escape_text ( input_nn, bl ); g_string_append ( str, tmp ); g_free ( tmp ); } else { - spaces = l - nc; + spaces = l - nc; char *tmp = g_markup_escape_text ( input_nn, -1 ); g_string_append ( str, tmp ); g_free ( tmp ); @@ -811,7 +812,7 @@ static gboolean helper_eval_cb ( const GMatchInfo *info, GString *str, gpointer else if ( match[1] == 'r' ) { helper_eval_add_str ( str, d->c->role, l, d->pd->role_len, g_utf8_strlen ( d->c->role, -1 ) ); } - + g_free ( match ); } return FALSE; diff --git a/source/helper.c b/source/helper.c index 874ceea2..3e5eb702 100644 --- a/source/helper.c +++ b/source/helper.c @@ -179,11 +179,11 @@ static gchar *fuzzy_to_regex ( const char * input ) return retv; } -static gchar *prefix_regex (const char * input) +static gchar *prefix_regex ( const char * input ) { - gchar *r = g_regex_escape_string(input, -1); - char *retv = g_strconcat("\\b", r, NULL); - g_free(r); + gchar *r = g_regex_escape_string ( input, -1 ); + char *retv = g_strconcat ( "\\b", r, NULL ); + g_free ( r ); return retv; } @@ -257,9 +257,9 @@ static rofi_int_matcher * create_regex ( const char *input, int case_sensitive ) g_free ( r ); break; case MM_PREFIX: - r = prefix_regex(input); - retv = R(r, case_sensitive); - g_free(r); + r = prefix_regex ( input ); + retv = R ( r, case_sensitive ); + g_free ( r ); break; default: r = g_regex_escape_string ( input, -1 ); @@ -645,7 +645,7 @@ int config_sanity_check ( void ) else if ( g_strcmp0 ( config.matching, "normal" ) == 0 ) { config.matching_method = MM_NORMAL;; } - else if (g_strcmp0 (config.matching, "prefix") == 0) { + else if ( g_strcmp0 ( config.matching, "prefix" ) == 0 ) { config.matching_method = MM_PREFIX; } else { @@ -710,7 +710,7 @@ int config_sanity_check ( void ) if ( g_strcmp0 ( config.monitor, "-3" ) == 0 ) { // On -3, set to location 1. - config.location = 1; + config.location = 1; } if ( found_error ) { diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 99fe3180..2e443578 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -233,9 +233,9 @@ static cairo_surface_t * rofi_icon_fetcher_get_surface_from_pixbuf ( GdkPixbuf cairo_surface_flush ( surface ); while ( pixels < pixels_end ) { - line = pixels; + line = pixels; const guchar *line_end = line + lo; - guchar *cline = cpixels; + guchar *cline = cpixels; while ( line < line_end ) { if ( alpha ) { diff --git a/source/rofi.c b/source/rofi.c index d31d3946..ba7d0940 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -96,7 +96,7 @@ void rofi_add_error_message ( GString *str ) G_MODULE_EXPORT char *config_path = NULL; /** Path to the configuration file in the new format */ /** Array holding all activated modi. */ -Mode **modi = NULL; +Mode **modi = NULL; /** List of (possibly uninitialized) modi's */ Mode ** available_modi = NULL; @@ -114,10 +114,9 @@ NkBindings *bindings = NULL; GMainLoop *main_loop = NULL; /** Flag indicating we are in dmenu mode. */ -static int dmenu_mode = FALSE; +static int dmenu_mode = FALSE; /** Rofi's return code */ -int return_code = EXIT_SUCCESS; - +int return_code = EXIT_SUCCESS; void process_result ( RofiViewState *state ); @@ -795,7 +794,6 @@ int main ( int argc, char *argv[] ) return EXIT_FAILURE; } - { const char *ro_pid = g_getenv ( "ROFI_OUTSIDE" ); if ( ro_pid != NULL ) { @@ -840,7 +838,7 @@ int main ( int argc, char *argv[] ) if ( find_arg ( "-config" ) < 0 ) { const char *cpath = g_get_user_config_dir (); if ( cpath ) { - config_path = g_build_filename ( cpath, "rofi", "config.rasi", NULL ); + config_path = g_build_filename ( cpath, "rofi", "config.rasi", NULL ); } } else { @@ -1067,7 +1065,6 @@ int main ( int argc, char *argv[] ) return return_code; } - /** List of error messages.*/ extern GList *list_of_error_msgs; int rofi_theme_rasi_validate ( const char *filename ) @@ -1078,8 +1075,8 @@ int rofi_theme_rasi_validate ( const char *filename ) } for ( GList *iter = g_list_first ( list_of_error_msgs ); - iter != NULL; iter = g_list_next ( iter ) ) { - fputs ( ((GString*)iter->data)->str, stderr ); + iter != NULL; iter = g_list_next ( iter ) ) { + fputs ( ( (GString *) iter->data )->str, stderr ); } return EXIT_FAILURE; diff --git a/source/view.c b/source/view.c index 43b56ab8..f344e4eb 100644 --- a/source/view.c +++ b/source/view.c @@ -725,8 +725,8 @@ static void rofi_view_setup_fake_transparency ( widget *win, const char* const f else { CacheState.fake_bg = cairo_image_surface_create ( CAIRO_FORMAT_ARGB32, CacheState.mon.w, CacheState.mon.h ); - int blur = rofi_theme_get_integer ( WIDGET ( win ), "blur", 0 ); - cairo_t *dr = cairo_create ( CacheState.fake_bg ); + int blur = rofi_theme_get_integer ( WIDGET ( win ), "blur", 0 ); + cairo_t *dr = cairo_create ( CacheState.fake_bg ); if ( CacheState.fake_bgrel ) { cairo_set_source_surface ( dr, s, 0, 0 ); } @@ -736,9 +736,9 @@ static void rofi_view_setup_fake_transparency ( widget *win, const char* const f cairo_paint ( dr ); cairo_destroy ( dr ); cairo_surface_destroy ( s ); - if ( blur > 0 ){ - cairo_image_surface_blur( CacheState.fake_bg, (double)blur, 0 ); - TICK_N("BLUR"); + if ( blur > 0 ) { + cairo_image_surface_blur ( CacheState.fake_bg, (double) blur, 0 ); + TICK_N ( "BLUR" ); } } } @@ -879,7 +879,7 @@ void __create_window ( MenuFlags menu_flags ) TICK_N ( "setup window name and class" ); const char *transparency = rofi_theme_get_string ( WIDGET ( win ), "transparency", NULL ); if ( transparency ) { - rofi_view_setup_fake_transparency ( WIDGET (win), transparency ); + rofi_view_setup_fake_transparency ( WIDGET ( win ), transparency ); } else if ( config.fake_transparency && config.fake_background ) { rofi_view_setup_fake_transparency ( WIDGET ( win ), config.fake_background ); @@ -1517,12 +1517,13 @@ static X11CursorType rofi_cursor_type_to_x11_cursor_type ( RofiCursorType type ) return CURSOR_DEFAULT; } -static RofiCursorType rofi_view_resolve_cursor ( RofiViewState *state, gint x, gint y ) { +static RofiCursorType rofi_view_resolve_cursor ( RofiViewState *state, gint x, gint y ) +{ widget *target = widget_find_mouse_target ( WIDGET ( state->main_window ), WIDGET_TYPE_UNKNOWN, x, y ); return target != NULL - ? target->cursor_type - : ROFI_CURSOR_DEFAULT; + ? target->cursor_type + : ROFI_CURSOR_DEFAULT; } static void rofi_view_set_cursor ( RofiCursorType type ) @@ -1900,7 +1901,7 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget, static void rofi_view_ping_mouse ( RofiViewState *state ) { xcb_query_pointer_cookie_t pointer_cookie = xcb_query_pointer ( xcb->connection, CacheState.main_window ); - xcb_query_pointer_reply_t *pointer_reply = xcb_query_pointer_reply ( xcb->connection, pointer_cookie, NULL ); + xcb_query_pointer_reply_t *pointer_reply = xcb_query_pointer_reply ( xcb->connection, pointer_cookie, NULL ); if ( pointer_reply == NULL ) { return; @@ -1986,7 +1987,7 @@ RofiViewState *rofi_view_create ( Mode *sw, /* When Override Redirect, the WM will not let us know we can take focus, so just steal it */ if ( ( ( menu_flags & MENU_NORMAL_WINDOW ) == 0 ) ) { - rofi_xcb_set_input_focus(CacheState.main_window); + rofi_xcb_set_input_focus ( CacheState.main_window ); } if ( xcb->sncontext != NULL ) { @@ -2041,7 +2042,7 @@ int rofi_view_error_dialog ( const char *msg, int markup ) void rofi_view_hide ( void ) { if ( CacheState.main_window != XCB_WINDOW_NONE ) { - rofi_xcb_revert_input_focus(); + rofi_xcb_revert_input_focus (); xcb_unmap_window ( xcb->connection, CacheState.main_window ); display_early_cleanup (); } @@ -2073,7 +2074,7 @@ void rofi_view_cleanup () if ( CacheState.main_window != XCB_WINDOW_NONE ) { g_debug ( "Unmapping and free'ing window" ); xcb_unmap_window ( xcb->connection, CacheState.main_window ); - rofi_xcb_revert_input_focus(); + rofi_xcb_revert_input_focus (); xcb_free_gc ( xcb->connection, CacheState.gc ); xcb_free_pixmap ( xcb->connection, CacheState.edit_pixmap ); xcb_destroy_window ( xcb->connection, CacheState.main_window ); diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c index cd58ad00..709e37d7 100644 --- a/source/widgets/textbox.c +++ b/source/widgets/textbox.c @@ -135,7 +135,7 @@ static void textbox_initialize_font ( textbox *tb ) if ( helper_validate_font ( tbfc->pfd, font ) ) { tbfc->metrics = pango_context_get_metrics ( p_context, tbfc->pfd, NULL ); - PangoLayout *layout = pango_layout_new ( p_context ); + PangoLayout *layout = pango_layout_new ( p_context ); pango_layout_set_font_description ( layout, tbfc->pfd ); pango_layout_set_text ( layout, "aAjb", -1 ); PangoRectangle rect; @@ -188,10 +188,11 @@ textbox* textbox_create ( widget *parent, WidgetType type, const char *name, Tex } // Allow overriding of markup. - if ( rofi_theme_get_boolean ( WIDGET ( tb ), "markup", (tb->flags&TB_MARKUP) == TB_MARKUP ) ) { + if ( rofi_theme_get_boolean ( WIDGET ( tb ), "markup", ( tb->flags & TB_MARKUP ) == TB_MARKUP ) ) { tb->flags |= TB_MARKUP; - } else { - tb->flags &= (~TB_MARKUP); + } + else { + tb->flags &= ( ~TB_MARKUP ); } const char *txt = rofi_theme_get_string ( WIDGET ( tb ), "str", text ); diff --git a/source/widgets/widget.c b/source/widgets/widget.c index 95ddd52a..81ff0d5e 100644 --- a/source/widgets/widget.c +++ b/source/widgets/widget.c @@ -87,7 +87,7 @@ void widget_init ( widget *wid, widget *parent, WidgetType type, const char *nam wid->border_radius = rofi_theme_get_padding ( wid, "border-radius", wid->def_border_radius ); wid->margin = rofi_theme_get_padding ( wid, "margin", wid->def_margin ); - wid->cursor_type = rofi_theme_get_cursor_type ( wid, "cursor", ROFI_CURSOR_DEFAULT ); + wid->cursor_type = rofi_theme_get_cursor_type ( wid, "cursor", ROFI_CURSOR_DEFAULT ); // enabled by default wid->enabled = rofi_theme_get_boolean ( wid, "enabled", TRUE ); diff --git a/source/xcb.c b/source/xcb.c index 0e3c9594..9842a358 100644 --- a/source/xcb.c +++ b/source/xcb.c @@ -100,7 +100,7 @@ static xcb_visualtype_t *root_visual = NULL; xcb_atom_t netatoms[NUM_NETATOMS]; const char *netatom_names[] = { EWMH_ATOMS ( ATOM_CHAR ) }; -xcb_cursor_t cursors[NUM_CURSORS] = { XCB_CURSOR_NONE, XCB_CURSOR_NONE, XCB_CURSOR_NONE }; +xcb_cursor_t cursors[NUM_CURSORS] = { XCB_CURSOR_NONE, XCB_CURSOR_NONE, XCB_CURSOR_NONE }; const struct { @@ -108,8 +108,8 @@ const struct const char *traditional_name; } cursor_names[] = { { "default", "left_ptr" }, - { "pointer", "hand" }, - { "text", "xterm" } + { "pointer", "hand" }, + { "text", "xterm" } }; static xcb_visualtype_t * lookup_visual ( xcb_screen_t *s, xcb_visualid_t visual ) @@ -131,77 +131,84 @@ static xcb_visualtype_t * lookup_visual ( xcb_screen_t *s, xcb_visualid_t visu * http://macslow.thepimp.net. I'm not entirely sure he's proud of it, but it has * proved immeasurably useful for me. */ -static uint32_t* create_kernel(double radius, double deviation, uint32_t *sum2) { - int size = 2 * (int)(radius) + 1; - uint32_t* kernel = (uint32_t*)(g_malloc(sizeof(uint32_t) * (size + 1))); - double radiusf = fabs(radius) + 1.0; - double value = -radius; - double sum = 0.0; - int i; +static uint32_t* create_kernel ( double radius, double deviation, uint32_t *sum2 ) +{ + int size = 2 * (int) ( radius ) + 1; + uint32_t* kernel = (uint32_t *) ( g_malloc ( sizeof ( uint32_t ) * ( size + 1 ) ) ); + double radiusf = fabs ( radius ) + 1.0; + double value = -radius; + double sum = 0.0; + int i; - if(deviation == 0.0) { - deviation = sqrt( -(radiusf * radiusf) / (2.0 * log(1.0 / 255.0))); + if ( deviation == 0.0 ) { + deviation = sqrt ( -( radiusf * radiusf ) / ( 2.0 * log ( 1.0 / 255.0 ) ) ); } - kernel[0] = size; + kernel[0] = size; - for(i = 0; i < size; i++) { - kernel[1 + i] = INT16_MAX / (2.506628275 * deviation) * exp(-((value * value) / (2.0 * (deviation * deviation)))) ; + for ( i = 0; i < size; i++ ) { + kernel[1 + i] = INT16_MAX / ( 2.506628275 * deviation ) * exp ( -( ( value * value ) / ( 2.0 * ( deviation * deviation ) ) ) ); - sum += kernel[1 + i]; - value += 1.0; - } + sum += kernel[1 + i]; + value += 1.0; + } *sum2 = sum; - return kernel; + return kernel; } -void cairo_image_surface_blur(cairo_surface_t* surface, double radius, double deviation) +void cairo_image_surface_blur ( cairo_surface_t* surface, double radius, double deviation ) { - uint32_t* horzBlur; - uint32_t * kernel = 0; + uint32_t * horzBlur; + uint32_t * kernel = 0; cairo_format_t format; - unsigned int channels; + unsigned int channels; - if(cairo_surface_status(surface)) return ; + if ( cairo_surface_status ( surface ) ) { + return; + } - uint8_t *data = cairo_image_surface_get_data(surface); - format = cairo_image_surface_get_format(surface); - const int width = cairo_image_surface_get_width(surface); - const int height = cairo_image_surface_get_height(surface); - const int stride = cairo_image_surface_get_stride(surface); + uint8_t *data = cairo_image_surface_get_data ( surface ); + format = cairo_image_surface_get_format ( surface ); + const int width = cairo_image_surface_get_width ( surface ); + const int height = cairo_image_surface_get_height ( surface ); + const int stride = cairo_image_surface_get_stride ( surface ); - if(format == CAIRO_FORMAT_ARGB32) channels = 4; - else return ; + if ( format == CAIRO_FORMAT_ARGB32 ) { + channels = 4; + } + else{ + return; + } - horzBlur = (uint32_t*)(g_malloc(sizeof(uint32_t) * height * stride)); - TICK(); + horzBlur = (uint32_t *) ( g_malloc ( sizeof ( uint32_t ) * height * stride ) ); + TICK (); uint32_t sum = 0; - kernel = create_kernel(radius, deviation, &sum); - TICK_N("BLUR: kernel"); + kernel = create_kernel ( radius, deviation, &sum ); + TICK_N ( "BLUR: kernel" ); /* Horizontal pass. */ uint32_t *horzBlur_ptr = horzBlur; - for(int iY = 0; iY < height; iY++) { - const int iYs = iY*stride; - for(int iX = 0; iX < width; iX++) { - uint32_t red = 0; - uint32_t green = 0; - uint32_t blue = 0; - uint32_t alpha = 0; - int offset = (int)(kernel[0]) / -2; + for ( int iY = 0; iY < height; iY++ ) { + const int iYs = iY * stride; + for ( int iX = 0; iX < width; iX++ ) { + uint32_t red = 0; + uint32_t green = 0; + uint32_t blue = 0; + uint32_t alpha = 0; + int offset = (int) ( kernel[0] ) / -2; - for(int i = 0; i < (int)(kernel[0]); i++) { + for ( int i = 0; i < (int) ( kernel[0] ); i++ ) { int x = iX + offset; - if(x < 0 || x >= width){ + if ( x < 0 || x >= width ) { offset++; continue; } - uint8_t *dataPtr = &data[iYs + x * channels]; - const uint32_t kernip1 = kernel[i + 1]; + uint8_t *dataPtr = &data[iYs + x * channels]; + const uint32_t kernip1 = kernel[i + 1]; blue += kernip1 * dataPtr[0]; green += kernip1 * dataPtr[1]; @@ -210,35 +217,34 @@ void cairo_image_surface_blur(cairo_surface_t* surface, double radius, double de offset++; } - - *horzBlur_ptr++ = blue/sum; - *horzBlur_ptr++ = green/sum; - *horzBlur_ptr++ = red/sum; - *horzBlur_ptr++ = alpha/sum; + *horzBlur_ptr++ = blue / sum; + *horzBlur_ptr++ = green / sum; + *horzBlur_ptr++ = red / sum; + *horzBlur_ptr++ = alpha / sum; } } - TICK_N("BLUR: hori"); + TICK_N ( "BLUR: hori" ); /* Vertical pass. */ - for(int iY = 0; iY < height; iY++) { - for(int iX = 0; iX < width; iX++) { - uint32_t red = 0; - uint32_t green = 0; - uint32_t blue = 0; - uint32_t alpha = 0; - int offset = (int)(kernel[0]) / -2; + for ( int iY = 0; iY < height; iY++ ) { + for ( int iX = 0; iX < width; iX++ ) { + uint32_t red = 0; + uint32_t green = 0; + uint32_t blue = 0; + uint32_t alpha = 0; + int offset = (int) ( kernel[0] ) / -2; - const int iXs = iX*channels; - for(int i = 0; i < (int)(kernel[0]); i++) { + const int iXs = iX * channels; + for ( int i = 0; i < (int) ( kernel[0] ); i++ ) { int y = iY + offset; - if(y < 0 || y >= height) { + if ( y < 0 || y >= height ) { offset++; continue; } - uint32_t *dataPtr = &horzBlur[y * stride + iXs]; - const uint32_t kernip1 = kernel[i + 1]; + uint32_t *dataPtr = &horzBlur[y * stride + iXs]; + const uint32_t kernip1 = kernel[i + 1]; blue += kernip1 * dataPtr[0]; green += kernip1 * dataPtr[1]; @@ -248,23 +254,20 @@ void cairo_image_surface_blur(cairo_surface_t* surface, double radius, double de offset++; } - - *data++ = blue/sum; - *data++ = green/sum; - *data++ = red/sum; - *data++ = alpha/sum; + *data++ = blue / sum; + *data++ = green / sum; + *data++ = red / sum; + *data++ = alpha / sum; } } - TICK_N("BLUR: vert"); + TICK_N ( "BLUR: vert" ); - free(kernel); - free(horzBlur); + free ( kernel ); + free ( horzBlur ); - return ; + return; } - - cairo_surface_t *x11_helper_get_screenshot_surface_window ( xcb_window_t window, int size ) { xcb_get_geometry_cookie_t cookie; @@ -824,11 +827,11 @@ static int monitor_active_from_id_focused ( int mon_id, workarea *mon ) mon->w = r->width; mon->h = r->height; retv = TRUE; - if ( (current_window_manager&WM_ROOT_WINDOW_OFFSET) == WM_ROOT_WINDOW_OFFSET ){ - mon->x += r->x; - mon->y += r->y; + if ( ( current_window_manager & WM_ROOT_WINDOW_OFFSET ) == WM_ROOT_WINDOW_OFFSET ) { + mon->x += r->x; + mon->y += r->y; } - g_debug("mon pos: %d %d %d-%d", mon->x, mon->y, mon->w, mon->h); + g_debug ( "mon pos: %d %d %d-%d", mon->x, mon->y, mon->w, mon->h ); } else if ( mon_id == -4 ) { monitor_dimensions ( t->dst_x, t->dst_y, mon ); @@ -1051,10 +1054,9 @@ static void main_loop_x11_event_handler_view ( xcb_generic_event_t *event ) case XCB_CLIENT_MESSAGE: { xcb_client_message_event_t *cme = (xcb_client_message_event_t *) event; - xcb_atom_t atom = cme->data.data32[0]; - xcb_timestamp_t time = cme->data.data32[1]; - if ( atom == netatoms[WM_TAKE_FOCUS] ) - { + xcb_atom_t atom = cme->data.data32[0]; + xcb_timestamp_t time = cme->data.data32[1]; + if ( atom == netatoms[WM_TAKE_FOCUS] ) { xcb_set_input_focus ( xcb->connection, XCB_INPUT_FOCUS_NONE, cme->window, time ); xcb_flush ( xcb->connection ); } @@ -1211,25 +1213,27 @@ void rofi_xcb_set_input_focus ( xcb_window_t w ) xcb->focus_revert = 0; return; } - xcb_generic_error_t *error; - xcb_get_input_focus_reply_t *freply; + xcb_generic_error_t *error; + xcb_get_input_focus_reply_t *freply; xcb_get_input_focus_cookie_t fcookie = xcb_get_input_focus ( xcb->connection ); freply = xcb_get_input_focus_reply ( xcb->connection, fcookie, &error ); if ( error != NULL ) { g_warning ( "Could not get input focus (error %d), will revert focus to best effort", error->error_code ); free ( error ); xcb->focus_revert = 0; - } else { + } + else { xcb->focus_revert = freply->focus; } xcb_set_input_focus ( xcb->connection, XCB_INPUT_FOCUS_POINTER_ROOT, w, XCB_CURRENT_TIME ); xcb_flush ( xcb->connection ); } -void rofi_xcb_revert_input_focus (void) +void rofi_xcb_revert_input_focus ( void ) { - if ( xcb->focus_revert == 0 ) + if ( xcb->focus_revert == 0 ) { return; + } xcb_set_input_focus ( xcb->connection, XCB_INPUT_FOCUS_POINTER_ROOT, xcb->focus_revert, XCB_CURRENT_TIME ); xcb_flush ( xcb->connection ); @@ -1355,7 +1359,7 @@ static void x11_helper_discover_window_manager ( void ) current_window_manager = WM_DO_NOT_CHANGE_CURRENT_DESKTOP | WM_PANGO_WORKSPACE_NAMES; } else if ( g_strcmp0 ( wtitle.strings, "bspwm" ) == 0 ) { - current_window_manager = WM_ROOT_WINDOW_OFFSET; + current_window_manager = WM_ROOT_WINDOW_OFFSET; } } xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle ); @@ -1526,11 +1530,12 @@ static void x11_create_visual_and_colormap ( void ) } } -static void x11_lookup_cursors ( void ) { +static void x11_lookup_cursors ( void ) +{ xcb_cursor_context_t *ctx; - if ( xcb_cursor_context_new( xcb->connection, xcb->screen, &ctx ) < 0 ) { - return; + if ( xcb_cursor_context_new ( xcb->connection, xcb->screen, &ctx ) < 0 ) { + return; } for ( int i = 0; i < NUM_CURSORS; ++i ) { @@ -1683,7 +1688,7 @@ void x11_set_cursor ( xcb_window_t window, X11CursorType type ) } if ( cursors[type] == XCB_CURSOR_NONE ) { - return; + return; } xcb_change_window_attributes ( xcb->connection, window, XCB_CW_CURSOR, &( cursors[type] ) ); diff --git a/source/xrmoptions.c b/source/xrmoptions.c index db1b1c07..427bb5dd 100644 --- a/source/xrmoptions.c +++ b/source/xrmoptions.c @@ -155,7 +155,7 @@ static XrmOption xrmOptions[] = { "Cycle through the results list", CONFIG_DEFAULT }, { xrm_Boolean, "sidebar-mode", { .num = &config.sidebar_mode }, NULL, "Enable sidebar-mode", CONFIG_DEFAULT }, - { xrm_Boolean, "hover-select", { .snum = &config.hover_select }, NULL, + { xrm_Boolean, "hover-select", { .snum = &config.hover_select }, NULL, "Enable hover-select", CONFIG_DEFAULT }, { xrm_SNumber, "eh", { .snum = &config.element_height }, NULL, "Row height (in chars)", CONFIG_DEFAULT }, @@ -259,7 +259,6 @@ void config_parser_add_option ( XrmOptionType type, const char *key, void **valu num_extra_options++; } - /** * Parse an option from the commandline vector. */