diff options
author | QC <qball@gmpclient.org> | 2015-09-19 12:21:30 +0200 |
---|---|---|
committer | QC <qball@gmpclient.org> | 2015-09-19 12:21:30 +0200 |
commit | 442e235c24fa33a499e51b4a2f7ff95fb4ab43ad (patch) | |
tree | c74a3fea5b7286e9d4e60f3fc656805b3a0fad07 | |
parent | 4c970fe4da46b2b463a59acdb4ec807cf83c61c4 (diff) |
Some cleanups, tweak uncrustify.
-rw-r--r-- | data/uncrustify.cfg | 2 | ||||
-rw-r--r-- | include/rofi.h | 12 | ||||
-rw-r--r-- | include/scrollbar.h | 9 | ||||
-rw-r--r-- | include/x11-helper.h | 3 | ||||
-rw-r--r-- | source/dialogs/combi.c | 9 | ||||
-rw-r--r-- | source/dialogs/dmenu.c | 18 | ||||
-rw-r--r-- | source/dialogs/run.c | 14 | ||||
-rw-r--r-- | source/dialogs/script.c | 9 | ||||
-rw-r--r-- | source/dialogs/ssh.c | 7 | ||||
-rw-r--r-- | source/dialogs/window.c | 27 | ||||
-rw-r--r-- | source/helper.c | 29 | ||||
-rw-r--r-- | source/keyb.c | 112 | ||||
-rw-r--r-- | source/rofi.c | 162 | ||||
-rw-r--r-- | source/scrollbar.c | 23 | ||||
-rw-r--r-- | source/textbox.c | 74 | ||||
-rw-r--r-- | source/x11-helper.c | 45 | ||||
-rw-r--r-- | source/xrmoptions.c | 217 | ||||
-rw-r--r-- | test/helper-test.c | 3 | ||||
-rw-r--r-- | test/textbox-test.c | 5 |
19 files changed, 508 insertions, 272 deletions
diff --git a/data/uncrustify.cfg b/data/uncrustify.cfg index 598e1684..f5b7dbf9 100644 --- a/data/uncrustify.cfg +++ b/data/uncrustify.cfg @@ -1,7 +1,7 @@ # # My favorite format # - +code_width = 100 indent_with_tabs = 0 # 1=indent to level only, 2=indent with tabs input_tab_size = 8 # original tab size output_tab_size = 4 # new tab size diff --git a/include/rofi.h b/include/rofi.h index 7a380f69..d2fc047a 100644 --- a/include/rofi.h +++ b/include/rofi.h @@ -76,7 +76,8 @@ typedef enum * * @returns 1 when it matches, 0 if not. */ -typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensitive, unsigned int index, Switcher *data ); +typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensitive, + unsigned int index, Switcher *data ); /** * @param sw the Switcher to show. @@ -96,7 +97,8 @@ typedef int ( *menu_match_cb )( char **tokens, const char *input, int case_sensi */ MenuReturn menu ( Switcher *sw, char **input, char *prompt, unsigned int *selected_line, - unsigned int *next_pos, const char *message ) __attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) ); + unsigned int *next_pos, + const char *message ) __attribute__ ( ( nonnull ( 1, 2, 3, 4 ) ) ); /** * @param sig The caught signal * @@ -272,8 +274,10 @@ struct _Switcher */ void ( *init )( struct _Switcher *sw ); char ** ( *get_data )( unsigned int *length, struct _Switcher *pd ); - int ( *match )( char **tokens, const char *input, int case_sensitive, int index, struct _Switcher *data ); - SwitcherMode ( *result )( int menu_retv, char **input, unsigned int selected_line, struct _Switcher *pd ); + int ( *match )( char **tokens, const char *input, int case_sensitive, int index, + struct _Switcher *data ); + SwitcherMode ( *result )( int menu_retv, char **input, unsigned int selected_line, + struct _Switcher *pd ); void ( *destroy )( struct _Switcher *pd ); // Token match. menu_match_cb token_match; diff --git a/include/scrollbar.h b/include/scrollbar.h index fde8c994..2e07468d 100644 --- a/include/scrollbar.h +++ b/include/scrollbar.h @@ -98,4 +98,13 @@ unsigned int scrollbar_clicked ( scrollbar *sb, int y ); * Resize the scrollbar. */ void scrollbar_resize ( scrollbar *sb, int w, int h ); + +/** + * @param sb scrollbar object + * @param x x pos in pixels + * @param y y pos in pixels + * + * Move the scrollbar. + */ +void scrollbar_move ( scrollbar *sb, int x, int y ); #endif // ROFI_SCROLLBAR_H diff --git a/include/x11-helper.h b/include/x11-helper.h index 3be10a7f..afdf3eb0 100644 --- a/include/x11-helper.h +++ b/include/x11-helper.h @@ -20,7 +20,8 @@ char* window_get_text_prop ( Display *display, Window w, Atom atom ); int window_get_atom_prop ( Display *display, Window w, Atom atom, Atom *list, int count ); void window_set_atom_prop ( Display *display, Window w, Atom prop, Atom *atoms, int count ); -int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list, int count ); +int window_get_cardinal_prop ( Display *display, Window w, Atom atom, unsigned long *list, + int count ); /** diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c index 6e3c103d..8d611a6b 100644 --- a/source/dialogs/combi.c +++ b/source/dialogs/combi.c @@ -156,7 +156,8 @@ static void combi_mode_destroy ( Switcher *sw ) sw->private_data = NULL; } } -static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int selected_line, Switcher *sw ) +static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int selected_line, + Switcher *sw ) { CombiModePrivateData *pd = sw->private_data; @@ -192,11 +193,13 @@ static const char * combi_mgrv ( unsigned int selected_line, void *sw, int *stat { CombiModePrivateData *pd = ( (Switcher *) sw )->private_data; for ( unsigned i = 0; i < pd->num_switchers; i++ ) { - if ( selected_line >= pd->starts[i] && selected_line < ( pd->starts[i] + pd->lengths[i] ) ) { + if ( selected_line >= pd->starts[i] && selected_line < + ( pd->starts[i] + pd->lengths[i] ) ) { g_free ( pd->cache ); pd->cache = g_strdup_printf ( "(%s) %s", pd->switchers[i]->name, - pd->switchers[i]->mgrv ( selected_line - pd->starts[i], (void *) pd->switchers[i], state ) ); + pd->switchers[i]->mgrv ( selected_line - pd->starts[i], + (void *) pd->switchers[i], state ) ); return pd->cache; } } diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c index 6c1cff5c..d500486a 100644 --- a/source/dialogs/dmenu.c +++ b/source/dialogs/dmenu.c @@ -169,7 +169,8 @@ static const char *get_display_data ( unsigned int index, void *data, G_GNUC_UNU * This functions outputs the formatted string to stdout, appends a newline (\n) character and * calls flush on the file descriptor. */ -static void dmenu_output_formatted_line ( const char *format, const char *string, int selected_line, const char *filter ) +static void dmenu_output_formatted_line ( const char *format, const char *string, int selected_line, + const char *filter ) { for ( int i = 0; format && format[i]; i++ ) { if ( format[i] == 'i' ) { @@ -330,8 +331,11 @@ int dmenu_switcher_dialog ( void ) * Select item mode. */ restart = 1; - if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != NULL ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); + if ( ( mretv & ( MENU_OK | MENU_QUICK_SWITCH ) ) && cmd_list[pd->selected_line] != + NULL ) { + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], + pd->selected_line, + input ); retv = TRUE; if ( ( mretv & MENU_QUICK_SWITCH ) ) { retv = 10 + ( mretv & MENU_LOWER_MASK ); @@ -349,7 +353,9 @@ int dmenu_switcher_dialog ( void ) restart = FALSE; // Normal mode if ( ( mretv & MENU_OK ) && cmd_list[pd->selected_line] != NULL ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], + pd->selected_line, + input ); if ( ( mretv & MENU_SHIFT ) ) { restart = TRUE; // Move to next line. @@ -370,7 +376,9 @@ int dmenu_switcher_dialog ( void ) } // Quick switch with entry selected. else if ( ( mretv & MENU_QUICK_SWITCH ) && pd->selected_line < UINT32_MAX ) { - dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], pd->selected_line, input ); + dmenu_output_formatted_line ( pd->format, cmd_list[pd->selected_line], + pd->selected_line, + input ); restart = FALSE; retv = 10 + ( mretv & MENU_LOWER_MASK ); diff --git a/source/dialogs/run.c b/source/dialogs/run.c index 902c1c8f..d32f0f8e 100644 --- a/source/dialogs/run.c +++ b/source/dialogs/run.c @@ -159,7 +159,8 @@ static char ** get_apps_external ( char **retv, unsigned int *length, unsigned i ( *length )++; } if ( fclose ( inp ) != 0 ) { - fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", strerror ( errno ) ); + fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", + strerror ( errno ) ); } } } @@ -243,7 +244,9 @@ static char ** get_apps ( unsigned int *length ) } // TODO: check this is still fast enough. (takes 1ms on laptop.) if ( ( *length ) > num_favorites ) { - g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func, NULL ); + g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), + sort_func, + NULL ); } g_free ( path ); @@ -258,7 +261,9 @@ static char ** get_apps ( unsigned int *length ) if ( ( *length ) > num_favorites ) { - g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), sort_func, NULL ); + g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), + sort_func, + NULL ); } // Reduce array length; ( *length ) -= removed; @@ -293,7 +298,8 @@ static char ** run_mode_get_data ( unsigned int *length, Switcher *sw ) return rmpd->cmd_list; } -static SwitcherMode run_mode_result ( int mretv, char **input, unsigned int selected_line, Switcher *sw ) +static SwitcherMode run_mode_result ( int mretv, char **input, unsigned int selected_line, + Switcher *sw ) { RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data; SwitcherMode retv = MODE_EXIT; diff --git a/source/dialogs/script.c b/source/dialogs/script.c index 69f74837..7452bd7c 100644 --- a/source/dialogs/script.c +++ b/source/dialogs/script.c @@ -66,7 +66,8 @@ static char **get_script_output ( const char *command, unsigned int *length ) ( *length )++; } if ( fclose ( inp ) != 0 ) { - fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", strerror ( errno ) ); + fprintf ( stderr, "Failed to close stdout off executor script: '%s'\n", + strerror ( errno ) ); } } } @@ -120,7 +121,8 @@ static char ** script_mode_get_data ( unsigned int *length, Switcher *sw ) return rmpd->cmd_list; } -static SwitcherMode script_mode_result ( int mretv, char **input, unsigned int selected_line, Switcher *sw ) +static SwitcherMode script_mode_result ( int mretv, char **input, unsigned int selected_line, + Switcher *sw ) { ScriptModePrivateData *rmpd = (ScriptModePrivateData *) sw->private_data; SwitcherMode retv = MODE_EXIT; @@ -178,7 +180,8 @@ Switcher *script_switcher_parse_setup ( const char *str ) char *endp = NULL; char *parse = g_strdup ( str ); unsigned int index = 0; - for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; token = strtok_r ( NULL, ":", &endp ) ) { + for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; + token = strtok_r ( NULL, ":", &endp ) ) { if ( index == 0 ) { g_strlcpy ( sw->name, token, 32 ); } diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c index 234cdfa1..ad003b19 100644 --- a/source/dialogs/ssh.c +++ b/source/dialogs/ssh.c @@ -261,7 +261,9 @@ static char ** get_ssh ( unsigned int *length ) // TODO: check this is still fast enough. (takes 1ms on laptop.) if ( ( *length ) > num_favorites ) { - g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), ssh_sort_func, NULL ); + g_qsort_with_data ( &retv[num_favorites], ( *length ) - num_favorites, sizeof ( char* ), + ssh_sort_func, + NULL ); } g_free ( path ); @@ -293,7 +295,8 @@ static char ** ssh_mode_get_data ( unsigned int *length, Switcher *sw ) *length = rmpd->cmd_list_length; return rmpd->cmd_list; } -static SwitcherMode ssh_mode_result ( int mretv, char **input, unsigned int selected_line, Switcher *sw ) +static SwitcherMode ssh_mode_result ( int mretv, char **input, unsigned int selected_line, + Switcher *sw ) { SwitcherMode retv = MODE_EXIT; SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data; diff --git a/source/dialogs/window.c b/source/dialogs/window.c index 7a39b189..85ba7f2f 100644 --- a/source/dialogs/window.c +++ b/source/dialogs/window.c @@ -270,7 +270,9 @@ static client* window_client ( Display *display, Window win ) c->states = window_get_atom_prop ( display, win, netatoms[_NET_WM_STATE], c->state, CLIENTSTATE ); - c->window_types = window_get_atom_prop ( display, win, netatoms[_NET_WM_WINDOW_TYPE], c->window_type, CLIENTWINDOWTYPE ); + c->window_types = + window_get_atom_prop ( display, win, netatoms[_NET_WM_WINDOW_TYPE], c->window_type, + CLIENTWINDOWTYPE ); char *name; if ( ( name = window_get_text_prop ( display, c->window, netatoms[_NET_WM_NAME] ) ) && name ) { @@ -282,7 +284,8 @@ static client* window_client ( Display *display, Window win ) XFree ( name ); } - name = window_get_text_prop ( display, c->window, XInternAtom ( display, "WM_WINDOW_ROLE", False ) ); + name = + window_get_text_prop ( display, c->window, XInternAtom ( display, "WM_WINDOW_ROLE", False ) ); if ( name != NULL ) { snprintf ( c->role, CLIENTROLE, "%s", name ); @@ -398,7 +401,8 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig // Get the current desktop. unsigned long current_desktop = 0; - if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_CURRENT_DESKTOP], ¤t_desktop, 1 ) ) { + if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_CURRENT_DESKTOP], + ¤t_desktop, 1 ) ) { current_desktop = 0; } @@ -442,14 +446,16 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig } // Create pattern for printing the line. - if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_NUMBER_OF_DESKTOPS], &desktops, 1 ) ) { + if ( !window_get_cardinal_prop ( display, root, netatoms[_NET_NUMBER_OF_DESKTOPS], + &desktops, 1 ) ) { desktops = 1; } if ( pd->config_i3_mode ) { sprintf ( pattern, "%%-%ds %%s", MAX ( 5, classfield ) ); } else{ - sprintf ( pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, MAX ( 5, classfield ) ); + sprintf ( pattern, "%%-%ds %%-%ds %%s", desktops < 10 ? 1 : 2, + MAX ( 5, classfield ) ); } pd->cmd_list = g_malloc0_n ( ( pd->ids->len + 1 ), sizeof ( char* ) ); @@ -463,10 +469,13 @@ static char ** _window_mode_get_data ( unsigned int *length, Switcher *sw, unsig unsigned long wmdesktop; char desktop[5]; desktop[0] = 0; - char *line = g_malloc ( strlen ( c->title ) + strlen ( c->class ) + classfield + 50 ); + char *line = g_malloc ( strlen ( c->title ) + strlen ( + c->class ) + classfield + 50 ); if ( !pd->config_i3_mode ) { // find client's desktop. - if ( !window_get_cardinal_prop ( display, c->window, netatoms[_NET_WM_DESKTOP], &wmdesktop, 1 ) ) { + if ( !window_get_cardinal_prop ( display, c->window, + netatoms[_NET_WM_DESKTOP], &wmdesktop, + 1 ) ) { // Assume the client is on all desktops. wmdesktop = 0xFFFFFFFF; } @@ -502,7 +511,9 @@ static char ** window_mode_get_data ( unsigned int *length, Switcher *sw ) { return _window_mode_get_data ( length, sw, FALSE ); } -static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input, unsigned int selected_line, Switcher *sw ) +static SwitcherMode window_mode_result ( int mretv, G_GNUC_UNUSED char **input, + unsigned int selected_line, + Switcher *sw ) { SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data; SwitcherMode retv = MODE_EXIT; diff --git a/source/helper.c b/source/helper.c index b18de247..8e2a8d0b 100644 --- a/source/helper.c +++ b/source/helper.c @@ -449,34 +449,43 @@ void remove_pid_file ( int fd ) void config_sanity_check ( ) { int found_error = FALSE; - GString *msg = g_string_new ( "<big><b>The configuration failed to validate:</b></big>\n" ); + GString *msg = g_string_new ( + "<big><b>The configuration failed to validate:</b></big>\n" ); if ( config.element_height < 1 ) { - g_string_append_printf ( msg, "\t<b>config.element_height</b>=%d is invalid. An element needs to be atleast 1 line high.\n", - config.element_height ); + g_string_append_printf ( + msg, + "\t<b>config.element_height</b>=%d is invalid. An element needs to be atleast 1 line high.\n", + config.element_height ); config.element_height = 1; found_error = TRUE; } if ( config.menu_columns == 0 ) { - g_string_append_printf ( msg, "\t<b>config.menu_columns</b>=%d is invalid. You need at least one visible column.\n", - config.menu_columns ); + g_string_append_printf ( + msg, + "\t<b>config.menu_columns</b>=%d is invalid. You need at least one visible column.\n", + config.menu_columns ); config.menu_columns = 1; found_error = TRUE; } if ( config.menu_width == 0 ) { - show_error_message ( "<b>config.menu_width</b>=0 is invalid. You cannot have a window with no width.", TRUE ); + show_error_message ( + "<b>config.menu_width</b>=0 is invalid. You cannot have a window with no width.", TRUE ); config.menu_columns = 50; found_error = TRUE; } if ( !( config.location >= WL_CENTER && config.location <= WL_WEST ) ) { - g_string_append_printf ( msg, "\t<b>config.location</b>=%d is invalid. Value should be between %d and %d.\n", - config.location, WL_CENTER, WL_WEST ); + g_string_append_printf ( + msg, "\t<b>config.location</b>=%d is invalid. Value should be between %d and %d.\n", + config.location, WL_CENTER, WL_WEST ); config.location = WL_CENTER; found_error = 1; } if ( 0 ) { if ( !( config.line_margin <= 50 ) ) { - g_string_append_printf ( msg, "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n", - config.line_margin, 0, 50 ); + g_string_append_printf ( + msg, + "\t<b>config.line_margin</b>=%d is invalid. Value should be between %d and %d.\n", + config.line_margin, 0, 50 ); config.line_margin = 2; found_error = 1; } diff --git a/source/keyb.c b/source/keyb.c index 17028b2d..9b14448e 100644 --- a/source/keyb.c +++ b/source/keyb.c @@ -34,36 +34,63 @@ extern unsigned int NumlockMask; */ DefaultBinding bindings[NUM_ABE] = { - { .id = PASTE_PRIMARY, .name = "kb-primary-paste", .keybinding = "Control+Shift+v,Shift+Insert", }, - { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = "Control+v,Insert", }, - { .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = "Control+u", }, - { .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = "Control+a", }, - { .id = MOVE_END, .name = "kb-move-end", .keybinding = "Control+e", }, + { .id = PASTE_PRIMARY, .name = "kb-primary-paste", + .keybinding = + "Control+Shift+v,Shift+Insert", }, + { .id = PASTE_SECONDARY, .name = "kb-secondary-paste", .keybinding = + "Control+v,Insert", }, + { .id = CLEAR_LINE, .name = "kb-clear-line", .keybinding = + "Control+u", }, + { .id = MOVE_FRONT, .name = "kb-move-front", .keybinding = + "Control+a", }, + { .id = MOVE_END, .name = "kb-move-end", .keybinding = + "Control+e", }, { .id = MOVE_WORD_BACK, .name = "kb-move-word-back", .keybinding = "Alt+b", }, { .id = MOVE_WORD_FORWARD, .name = "kb-move-word-forward", .keybinding = "Alt+f", }, - { .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = "Left,Control+b" }, - { .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = "Right,Control+f" }, - { .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = "Control+Alt+h", }, - { .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = "Control+Alt+d", }, - { .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = "Delete,Control+d", }, - { .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = "BackSpace,Control+h", }, - { .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = "Control+j,Control+m,Return,KP_Enter", }, - { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = "Control+Return", }, - { .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = "Shift+Return", }, - { .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = "Shift+Right,Control+Tab" }, - { .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = "Shift+Left,Control+Shift+Tab" }, - { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = "grave,dead_grave" }, - { .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = "Shift+Delete" }, - { .id = ROW_LEFT, .name = "kb-row-left", .keybinding = "Control+Page_Up" }, - { .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = "Control+Page_Down" }, - { .id = ROW_UP, .name = "kb-row-up", .keybinding = "Up,Control+p,Shift+Tab" }, - { .id = ROW_DOWN, .name = "kb-row-down", .keybinding = "Down,Control+n" }, + { .id = MOVE_CHAR_BACK, .name = "kb-move-char-back", .keybinding = + "Left,Control+b" }, + { .id = MOVE_CHAR_FORWARD, .name = "kb-move-char-forward", .keybinding = + "Right,Control+f" }, + { .id = REMOVE_WORD_BACK, .name = "kb-remove-word-back", .keybinding = + "Control+Alt+h", }, + { .id = REMOVE_WORD_FORWARD, .name = "kb-remove-word-forward", .keybinding = + "Control+Alt+d", }, + { .id = REMOVE_CHAR_FORWARD, .name = "kb-remove-char-forward", .keybinding = + "Delete,Control+d", }, + { .id = REMOVE_CHAR_BACK, .name = "kb-remove-char-back", .keybinding = + "BackSpace,Control+h", }, + { .id = ACCEPT_ENTRY, .name = "kb-accept-entry", .keybinding = + "Control+j,Control+m,Return,KP_Enter", }, + { .id = ACCEPT_CUSTOM, .name = "kb-accept-custom", .keybinding = + "Control+Return", }, + { .id = ACCEPT_ENTRY_CONTINUE, .name = "kb-accept-entry-continue", .keybinding = + "Shift+Return", }, + { .id = MODE_NEXT, .name = "kb-mode-next", .keybinding = + "Shift+Right,Control+Tab" }, + { .id = MODE_PREVIOUS, .name = "kb-mode-previous", .keybinding = + "Shift+Left,Control+Shift+Tab" }, + { .id = TOGGLE_CASE_SENSITIVITY, .name = "kb-toggle-case-sensitivity", .keybinding = + "grave,dead_grave" }, + { .id = DELETE_ENTRY, .name = "kb-delete-entry", .keybinding = + "Shift+Delete" }, + { .id = ROW_LEFT, .name = "kb-row-left", .keybinding = + "Control+Page_Up" }, + { .id = ROW_RIGHT, .name = "kb-row-right", .keybinding = + "Control+Page_Down" }, + { .id = ROW_UP, .name = "kb-row-up", .keybinding = + "Up,Control+p,Shift+Tab" }, + { .id = ROW_DOWN, .name = "kb-row-down", .keybinding = + "Down,Control+n" }, { .id = ROW_TAB, .name = "kb-row-tab", .keybinding = "Tab" }, { .id = PAGE_PREV, .name = "kb-page-prev", .keybinding = "Page_Up" }, - { .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = "Page_Down" }, - { .id = ROW_FIRST, .name = "kb-row-first", .keybinding = "Home,KP_Home" }, - { .id = ROW_LAST, .name = "kb-row-last", .keybinding = "End,KP_End" }, - { .id = ROW_SELECT, .name = "kb-row-select", .keybinding = "Control+space" }, + { .id = PAGE_NEXT, .name = "kb-page-next", .keybinding = + "Page_Down" }, + { .id = ROW_FIRST, .name = "kb-row-first", .keybinding = + "Home,KP_Home" }, + { .id = ROW_LAST, .name = "kb-row-last", .keybinding = + "End,KP_End" }, + { .id = ROW_SELECT, .name = "kb-row-select", .keybinding = + "Control+space" }, { .id = CANCEL, .name = "kb-cancel", .keybinding = "Escape" }, { .id = CUSTOM_1, .name = "kb-custom-1", .keybinding = "Alt+1" }, { .id = CUSTOM_2, .name = "kb-custom-2", .keybinding = "Alt+2" }, @@ -75,15 +102,24 @@ DefaultBinding bindings[NUM_ABE] = { .id = CUSTOM_8, .name = "kb-custom-8", .keybinding = "Alt+8" }, { .id = CUSTOM_9, .name = "kb-custom-9", .keybinding = "Alt+9" }, { .id = CUSTOM_10, .name = "kb-custom-10", .keybinding = "Alt+0" }, - { .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = "Alt+Shift+1" }, - { .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = "Alt+Shift+2" }, - { .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = "Alt+Shift+3" }, - { .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = "Alt+Shift+4" }, - { .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = "Alt+Shift+5" }, - { .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = "Alt+Shift+6" }, - { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = "Alt+Shift+7" }, - { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = "Alt+Shift+8" }, - { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = "Alt+Shift+9" }, + { .id = CUSTOM_11, .name = "kb-custom-11", .keybinding = + "Alt+Shift+1" }, + { .id = CUSTOM_12, .name = "kb-custom-12", .keybinding = + "Alt+Shift+2" }, + { .id = CUSTOM_13, .name = "kb-custom-13", .keybinding = + "Alt+Shift+3" }, + { .id = CUSTOM_14, .name = "kb-custom-14", .keybinding = + "Alt+Shift+4" }, + { .id = CUSTOM_15, .name = "kb-custom-15", .keybinding = + "Alt+Shift+5" }, + { .id = CUSTOM_16, .name = "kb-custom-16", .keybinding = + "Alt+Shift+6" }, + { .id = CUSTOM_17, .name = "kb-custom-17", .keybinding = + "Alt+Shift+7" }, + { .id = CUSTOM_18, .name = "kb-custom-18", .keybinding = + "Alt+Shift+8" }, + { .id = CUSTOM_19, .name = "kb-custom-19", .keybinding = + "Alt+Shift+9" }, }; @@ -113,8 +149,10 @@ void parse_keys_abe ( void ) abe[iter].num_bindings = 0; // Iter over bindings. - for ( char *entry = strtok_r ( keystr, ",", &sp ); entry != NULL; entry = strtok_r ( NULL, ",", &sp ) ) { - abe[iter].kb = g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) ); + for ( char *entry = strtok_r ( keystr, ",", &sp ); entry != NULL; + entry = strtok_r ( NULL, ",", &sp ) ) { + abe[iter].kb = + g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) ); KeyBinding *kb = &( abe[iter].kb[abe[iter].num_bindings] ); x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ) ); abe[iter].num_bindings++; diff --git a/source/rofi.c b/source/rofi.c index 39912d00..763ce15e 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -54,8 +54,7 @@ #include "x11-helper.h" #include "xrmoptions.h" #include "dialogs/dialogs.h" -// -// TEMP + SwitcherMode switcher_run ( char **input, Switcher *sw ); typedef enum _MainLoopEvent @@ -63,34 +62,30 @@ typedef enum _MainLoopEvent ML_XEVENT, ML_TIMEOUT } MainLoopEvent; +typedef struct _Mode +{ + Switcher *sw; + textbox *tb; +} Mode; // Pidfile. +extern Atom netatoms[NUM_NETATOMS]; char *pidfile = NULL; const char *cache_dir = NULL; SnDisplay *sndisplay = NULL; SnLauncheeContext *sncontext = NULL; Display *display = NULL; char *display_str = NULL; - -extern Atom netatoms[NUM_NETATOMS]; Window main_window = None; GC gc = NULL; Colormap map = None; -XVisualInfo vinfo; - unsigned int normal_window_mode = FALSE; - -typedef struct _Mode -{ - Switcher *sw; - textbox *tb; -} Mode; // Array of switchers. -Mode *switchers = NULL; -// Number of switchers. -unsigned int num_switchers = 0; +Mode *switchers = NULL; +unsigned int num_switchers = 0; // Current selected switcher. -unsigned int curr_switcher = 0; +unsigned int curr_switcher = 0; +XVisualInfo vinfo; /** * @param name Name of the switcher to lookup. @@ -122,15 +117,12 @@ static inline MainLoopEvent wait_for_xevent_or_timeout ( Display *display, int x |