mirror of
https://github.com/davatorium/rofi.git
synced 2024-11-18 13:54:36 -05:00
Indent code.
This commit is contained in:
parent
8ee37012d1
commit
3f4d58ef53
16 changed files with 89 additions and 91 deletions
|
@ -219,7 +219,6 @@ int rofi_scorer_fuzzy_evaluate ( const char *pattern, glong plen, const char *st
|
|||
*/
|
||||
int utf8_strncmp ( const char *a, const char* b, size_t n );
|
||||
|
||||
|
||||
/**
|
||||
* @param wd The work directory (optional)
|
||||
* @param cmd The cmd to execute
|
||||
|
|
|
@ -262,8 +262,8 @@ int x11_modifier_active ( unsigned int mask, int key );
|
|||
*/
|
||||
void x11_disable_decoration ( xcb_window_t window );
|
||||
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
/** Default EWHM compatible window manager */
|
||||
WM_EWHM = 0,
|
||||
/** I3 Window manager */
|
||||
|
|
|
@ -69,16 +69,18 @@ static void combi_mode_parse_switchers ( Mode *sw )
|
|||
sizeof ( CombiMode ) * ( pd->num_switchers + 1 ) );
|
||||
|
||||
Mode *mode = rofi_collect_modi_search ( token );
|
||||
if ( mode ){
|
||||
if ( mode ) {
|
||||
pd->switchers[pd->num_switchers].disable = FALSE;
|
||||
pd->switchers[pd->num_switchers++].mode = mode;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If not build in, use custom switchers.
|
||||
Mode *sw = script_switcher_parse_setup ( token );
|
||||
if ( sw != NULL ) {
|
||||
pd->switchers[pd->num_switchers].disable = FALSE;
|
||||
pd->switchers[pd->num_switchers++].mode = sw;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Report error, don't continue.
|
||||
fprintf ( stderr, "Invalid script switcher: %s\n", token );
|
||||
token = NULL;
|
||||
|
|
|
@ -473,7 +473,7 @@ static int dmenu_token_match ( const Mode *sw, GRegex **tokens, unsigned int ind
|
|||
static char *dmenu_get_message ( const Mode *sw )
|
||||
{
|
||||
DmenuModePrivateData *pd = (DmenuModePrivateData *) mode_get_private_data ( sw );
|
||||
if ( pd->message ){
|
||||
if ( pd->message ) {
|
||||
return g_strdup ( pd->message );
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -70,7 +70,6 @@ typedef struct
|
|||
unsigned int cmd_list_length;
|
||||
} RunModePrivateData;
|
||||
|
||||
|
||||
/**
|
||||
* @param cmd The cmd to execute
|
||||
* @param run_in_term Indicate if command should be run in a terminal
|
||||
|
|
|
@ -76,11 +76,9 @@ static char **get_script_output ( const char *command, unsigned int *length )
|
|||
|
||||
static char **execute_executor ( Mode *sw, const char *result, unsigned int *length )
|
||||
{
|
||||
char **retv = NULL;
|
||||
|
||||
char *arg = g_shell_quote ( result );
|
||||
char *command = g_strdup_printf ( "%s %s", (const char *) sw->ed, arg );
|
||||
retv = get_script_output ( command, length );
|
||||
char **retv = get_script_output ( command, length );
|
||||
g_free ( command );
|
||||
g_free ( arg );
|
||||
return retv;
|
||||
|
|
|
@ -284,10 +284,9 @@ static char ** get_ssh ( unsigned int *length )
|
|||
retv = read_hosts_file ( retv, length );
|
||||
}
|
||||
|
||||
FILE *fd = NULL;
|
||||
const char *hd = g_get_home_dir ();
|
||||
path = g_build_filename ( hd, ".ssh", "config", NULL );
|
||||
fd = fopen ( path, "r" );
|
||||
FILE *fd = fopen ( path, "r" );
|
||||
|
||||
if ( fd != NULL ) {
|
||||
char *buffer = NULL;
|
||||
|
|
|
@ -338,7 +338,7 @@ static int window_match ( const Mode *sw, GRegex **tokens, unsigned int index )
|
|||
// If hack not in place it would not match queries spanning multiple fields.
|
||||
// e.g. when searching 'title element' and 'class element'
|
||||
GRegex *ftokens[2] = { tokens[j], NULL };
|
||||
if ( !test && c->title != NULL && c->title[0] != '\0' ) {
|
||||
if ( c->title != NULL && c->title[0] != '\0' ) {
|
||||
test = helper_token_match ( ftokens, c->title );
|
||||
}
|
||||
|
||||
|
@ -578,8 +578,7 @@ static ModeMode window_mode_result ( Mode *sw, int mretv, G_GNUC_UNUSED char **i
|
|||
}
|
||||
else {
|
||||
rofi_view_hide ();
|
||||
if ( (current_window_manager&(WM_AWESOME|WM_OPENBOX)) != 0 )
|
||||
{
|
||||
if ( ( current_window_manager & ( WM_AWESOME | WM_OPENBOX ) ) != 0 ) {
|
||||
// Get the desktop of the client to switch to
|
||||
uint32_t wmdesktop = 0;
|
||||
xcb_get_property_cookie_t cookie;
|
||||
|
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
#include <libgwater-xcb.h>
|
||||
|
||||
|
||||
#include "xcb-internal.h"
|
||||
#include "xkb-internal.h"
|
||||
|
||||
|
@ -415,7 +414,7 @@ unsigned int num_available_modi = 0;
|
|||
*/
|
||||
Mode * rofi_collect_modi_search ( const char *name )
|
||||
{
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ){
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ) {
|
||||
if ( g_strcmp0 ( name, available_modi[i]->name ) == 0 ) {
|
||||
return available_modi[i];
|
||||
}
|
||||
|
@ -431,7 +430,7 @@ static gboolean rofi_collect_modi_add ( Mode *mode )
|
|||
{
|
||||
Mode *m = rofi_collect_modi_search ( mode->name );
|
||||
if ( m == NULL ) {
|
||||
available_modi = g_realloc ( available_modi, sizeof(Mode *)*(num_available_modi+1));
|
||||
available_modi = g_realloc ( available_modi, sizeof ( Mode * ) * ( num_available_modi + 1 ) );
|
||||
// Set mode.
|
||||
available_modi[num_available_modi] = mode;
|
||||
num_available_modi++;
|
||||
|
@ -445,27 +444,28 @@ static void rofi_collect_modi_dir ( const char *base_dir )
|
|||
GDir *dir = g_dir_open ( base_dir, 0, NULL );
|
||||
if ( dir ) {
|
||||
const char *dn = NULL;
|
||||
while ( ( dn = g_dir_read_name ( dir ) ) )
|
||||
{
|
||||
while ( ( dn = g_dir_read_name ( dir ) ) ) {
|
||||
if ( !g_str_has_suffix ( dn, G_MODULE_SUFFIX ) ) {
|
||||
continue;
|
||||
}
|
||||
char *fn = g_build_filename ( PLUGIN_PATH, dn, NULL );
|
||||
GModule *mod = g_module_open ( fn, G_MODULE_BIND_LAZY|G_MODULE_BIND_LOCAL );
|
||||
GModule *mod = g_module_open ( fn, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL );
|
||||
if ( mod ) {
|
||||
Mode *m = NULL;
|
||||
if ( g_module_symbol ( mod, "mode", (gpointer *)&m) ){
|
||||
if ( g_module_symbol ( mod, "mode", (gpointer *) &m ) ) {
|
||||
if ( m->abi_version != ABI_VERSION ) {
|
||||
fprintf(stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION);
|
||||
fprintf ( stderr, "ABI version of plugin does not match: %08X expecting: %08X\n", m->abi_version, ABI_VERSION );
|
||||
g_module_close ( mod );
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
m->module = mod;
|
||||
if ( ! rofi_collect_modi_add ( m ) ) {
|
||||
if ( !rofi_collect_modi_add ( m ) ) {
|
||||
g_module_close ( mod );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fprintf(stderr, "Symbol 'mode' not found in module: %s\n", fn);
|
||||
}
|
||||
else {
|
||||
fprintf ( stderr, "Symbol 'mode' not found in module: %s\n", fn );
|
||||
g_module_close ( mod );
|
||||
}
|
||||
}
|
||||
|
@ -500,13 +500,13 @@ static void rofi_collect_modi ( void )
|
|||
*/
|
||||
static void rofi_collect_modi_setup ( void )
|
||||
{
|
||||
for ( unsigned int i = 0; i < num_available_modi ; i++ ) {
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ) {
|
||||
mode_set_config ( available_modi[i] );
|
||||
}
|
||||
}
|
||||
static void rofi_collect_modi_destroy ( void )
|
||||
{
|
||||
for ( unsigned int i = 0; i < num_available_modi ; i++ ) {
|
||||
for ( unsigned int i = 0; i < num_available_modi; i++ ) {
|
||||
if ( available_modi[i]->module ) {
|
||||
g_module_close ( available_modi[i]->module );
|
||||
}
|
||||
|
@ -533,14 +533,16 @@ static int add_mode ( const char * token )
|
|||
if ( mode ) {
|
||||
modi[num_modi] = mode;
|
||||
num_modi++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// If not build in, use custom modi.
|
||||
Mode *sw = script_switcher_parse_setup ( token );
|
||||
if ( sw != NULL ) {
|
||||
modi[num_modi] = sw;
|
||||
mode_set_config ( sw );
|
||||
num_modi++;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Report error, don't continue.
|
||||
fprintf ( stderr, "Invalid script switcher: %s\n", token );
|
||||
}
|
||||
|
@ -922,7 +924,7 @@ int main ( int argc, char *argv[] )
|
|||
|
||||
// Get DISPLAY, first env, then argument.
|
||||
// We never modify display_str content.
|
||||
char *display_str = ( char *)g_getenv ( "DISPLAY" );
|
||||
char *display_str = ( char *) g_getenv ( "DISPLAY" );
|
||||
find_arg_str ( "-display", &display_str );
|
||||
|
||||
xcb->connection = xcb_connect ( display_str, &xcb->screen_nbr );
|
||||
|
@ -947,7 +949,7 @@ int main ( int argc, char *argv[] )
|
|||
free ( errors );
|
||||
}
|
||||
// Discover the current active window manager.
|
||||
x11_helper_discover_window_manager();
|
||||
x11_helper_discover_window_manager ();
|
||||
TICK_N ( "Setup XCB" );
|
||||
|
||||
if ( xkb_x11_setup_xkb_extension ( xcb->connection, XKB_X11_MIN_MAJOR_XKB_VERSION, XKB_X11_MIN_MINOR_XKB_VERSION,
|
||||
|
|
|
@ -374,19 +374,19 @@ static void rofi_view_window_update_size ( RofiViewState * state )
|
|||
widget_resize ( WIDGET ( state->main_window ), state->width, state->height );
|
||||
}
|
||||
|
||||
|
||||
static void rofi_view_reload_message_bar ( RofiViewState *state )
|
||||
{
|
||||
if ( state->mesg_box == NULL ){
|
||||
return ;
|
||||
if ( state->mesg_box == NULL ) {
|
||||
return;
|
||||
}
|
||||
char *msg = mode_get_message ( state->sw );
|
||||
if ( msg ) {
|
||||
textbox_text ( state->mesg_tb, msg );
|
||||
widget_enable ( WIDGET (state->mesg_box ) );
|
||||
widget_enable ( WIDGET ( state->mesg_box ) );
|
||||
g_free ( msg );
|
||||
} else {
|
||||
widget_disable ( WIDGET (state->mesg_box ) );
|
||||
}
|
||||
else {
|
||||
widget_disable ( WIDGET ( state->mesg_box ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1679,7 +1679,7 @@ int rofi_view_error_dialog ( const char *msg, int markup )
|
|||
// Need to resize otherwise calculated desired height is wrong.
|
||||
widget_resize ( WIDGET ( state->main_window ), state->width, 100 );
|
||||
// resize window vertically to suit
|
||||
state->height = widget_get_desired_height ( WIDGET (state->main_window));
|
||||
state->height = widget_get_desired_height ( WIDGET ( state->main_window ) );
|
||||
|
||||
// Calculte window position.
|
||||
rofi_view_calculate_window_position ( state );
|
||||
|
|
|
@ -53,9 +53,9 @@ static int box_get_desired_height ( widget *wid )
|
|||
{
|
||||
box *b = (box *) wid;
|
||||
int spacing = distance_get_pixel ( b->spacing, b->type == BOX_VERTICAL ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL );
|
||||
int active_widgets = 0;
|
||||
int height = 0;
|
||||
if ( b->type == BOX_VERTICAL ) {
|
||||
int active_widgets = 0;
|
||||
for ( GList *iter = g_list_first ( b->children ); iter != NULL; iter = g_list_next ( iter ) ) {
|
||||
widget * child = (widget *) iter->data;
|
||||
if ( !child->enabled ) {
|
||||
|
|
|
@ -336,7 +336,6 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
|
||||
int cursor_x = 0;
|
||||
int cursor_y = 0;
|
||||
int cursor_width = 2; //MAX ( 2, font_height / 10 );
|
||||
int cursor_height = font_height;
|
||||
|
||||
if ( tb->changed ) {
|
||||
|
@ -372,7 +371,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
x = ( ( tb->widget.w - tw - widget_padding_get_padding_width ( WIDGET ( tb ) ) - offset ) ) / 2;
|
||||
}
|
||||
|
||||
int top = widget_padding_get_top ( WIDGET (tb) );
|
||||
int top = widget_padding_get_top ( WIDGET ( tb ) );
|
||||
y = top + ( pango_font_metrics_get_ascent ( tb->metrics ) - pango_layout_get_baseline ( tb->layout ) ) / PANGO_SCALE;
|
||||
|
||||
rofi_theme_get_color ( WIDGET ( tb ), "foreground", draw );
|
||||
|
@ -380,6 +379,7 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
rofi_theme_get_color ( WIDGET ( tb ), "text", draw );
|
||||
// draw the cursor
|
||||
if ( tb->flags & TB_EDITABLE && tb->blink ) {
|
||||
int cursor_width = 2; //MAX ( 2, font_height / 10 );
|
||||
cairo_rectangle ( draw, x + cursor_x, y + cursor_y, cursor_width, cursor_height );
|
||||
cairo_fill ( draw );
|
||||
}
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
/** Log domain for this module */
|
||||
#define LOG_DOMAIN "X11Helper"
|
||||
|
||||
|
||||
WindowManager current_window_manager = WM_EWHM;
|
||||
|
||||
/**
|
||||
|
@ -932,20 +931,21 @@ void x11_helper_discover_window_manager ( void )
|
|||
|
||||
if ( xcb_ewmh_get_supporting_wm_check_reply ( &xcb->ewmh, cc, &wm_win, NULL ) ) {
|
||||
xcb_ewmh_get_utf8_strings_reply_t wtitle;
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked(&(xcb->ewmh), wm_win );
|
||||
if ( xcb_ewmh_get_wm_name_reply(&(xcb->ewmh), cookie, &wtitle, (void *)0))
|
||||
{
|
||||
if ( wtitle.strings_len > 0 ){
|
||||
xcb_get_property_cookie_t cookie = xcb_ewmh_get_wm_name_unchecked ( &( xcb->ewmh ), wm_win );
|
||||
if ( xcb_ewmh_get_wm_name_reply ( &( xcb->ewmh ), cookie, &wtitle, (void *) 0 ) ) {
|
||||
if ( wtitle.strings_len > 0 ) {
|
||||
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Found window manager: %s", wtitle.strings );
|
||||
if ( g_strcmp0(wtitle.strings, "i3") == 0 ){
|
||||
if ( g_strcmp0 ( wtitle.strings, "i3" ) == 0 ) {
|
||||
current_window_manager = WM_I3;
|
||||
} else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ){
|
||||
}
|
||||
else if ( g_strcmp0 ( wtitle.strings, "awesome" ) == 0 ) {
|
||||
current_window_manager = WM_AWESOME;
|
||||
} else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ){
|
||||
}
|
||||
else if ( g_strcmp0 ( wtitle.strings, "Openbox" ) == 0 ) {
|
||||
current_window_manager = WM_OPENBOX;
|
||||
}
|
||||
}
|
||||
xcb_ewmh_get_utf8_strings_reply_wipe(&wtitle);
|
||||
xcb_ewmh_get_utf8_strings_reply_wipe ( &wtitle );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue