1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

Indent file, split out opacity code.

This commit is contained in:
QC 2014-07-30 20:54:16 +02:00
parent f1f4e55d43
commit c2ccd37312
2 changed files with 24 additions and 16 deletions

View file

@ -97,6 +97,10 @@ typedef struct _Switcher
Switcher *switchers = NULL;
int num_switchers = 0;
void window_set_opacity ( Display *display, Window box, unsigned int opacity );
int switcher_get ( const char *name )
{
for ( int i = 0; i < num_switchers; i++ ) {
@ -969,6 +973,15 @@ static int levenshtein ( const char *s, const char *t )
return dist ( 0, 0 );
}
void window_set_opacity ( Display *display, Window box, unsigned int opacity )
{
// Hack to set window opacity.
unsigned int opacity_set = ( unsigned int ) ( ( opacity / 100.0 ) * UINT32_MAX );
XChangeProperty ( display, box, netatoms[_NET_WM_WINDOW_OPACITY],
XA_CARDINAL, 32, PropModeReplace,
( unsigned char * ) &opacity_set, 1L );
}
Window create_window ( Display *display )
{
Screen *screen = DefaultScreenOfDisplay ( display );
@ -991,12 +1004,7 @@ Window create_window ( Display *display )
// Set the WM_NAME
XStoreName ( display, box, "rofi" );
// Hack to set window opacity.
unsigned int opacity_set = ( unsigned int ) ( ( config.window_opacity / 100.0 ) * UINT32_MAX );
XChangeProperty ( display, box, netatoms[_NET_WM_WINDOW_OPACITY],
XA_CARDINAL, 32, PropModeReplace,
( unsigned char * ) &opacity_set, 1L );
window_set_opacity ( display, box, config.window_opacity );
return box;
}
@ -1010,8 +1018,8 @@ Window create_window ( Display *display )
static void calculate_window_position ( const workarea *mon, int *x, int *y, int w, int h )
{
// Default location is center.
*y = mon->y + ( mon->h - h - config.menu_bw * 2) / 2;
*x = mon->x + ( mon->w - w - config.menu_bw * 2) / 2;
*y = mon->y + ( mon->h - h - config.menu_bw * 2 ) / 2;
*x = mon->x + ( mon->w - w - config.menu_bw * 2 ) / 2;
// Determine window location
switch ( config.location )
{
@ -2042,9 +2050,9 @@ static void setup_switchers ( void )
char *savept;
char *switcher_str = strdup ( config.switchers );
char *token;
for ( token = strtok_r ( switcher_str, "," ,&savept);
token != NULL;
token = strtok_r ( NULL, ",",&savept ) ) {
for ( token = strtok_r ( switcher_str, ",", &savept );
token != NULL;
token = strtok_r ( NULL, ",", &savept ) ) {
if ( strcasecmp ( token, "window" ) == 0 ) {
switchers = (Switcher *) realloc ( switchers, sizeof ( Switcher ) * ( num_switchers + 1 ) );
copy_string ( switchers[num_switchers].name, "window", 32 );

View file

@ -124,9 +124,9 @@ SwitcherMode script_switcher_dialog ( char **input, void *data )
unsigned int length = 0;
char **list = get_script_output ( options->script_path, &length );
char *prompt = NULL;
if(asprintf(&(prompt), "%s:", options->name) <= 0) {
fprintf(stderr, "Failed to allocate string.\n");
abort();
if ( asprintf ( &( prompt ), "%s:", options->name ) <= 0 ) {
fprintf ( stderr, "Failed to allocate string.\n" );
abort ();
}
@ -167,7 +167,7 @@ SwitcherMode script_switcher_dialog ( char **input, void *data )
}
} while ( list != NULL );
free(prompt);
free ( prompt );
return retv;
}
@ -191,7 +191,7 @@ ScriptOptions *script_switcher_parse_setup ( const char *str )
// TODO: This is naive and can be improved.
for ( char *token = strtok_r ( parse, ":", &endp ); token != NULL; token = strtok_r ( NULL, ":", &endp ) ) {
if ( index == 0 ) {
sw->name = strdup(token);
sw->name = strdup ( token );
}
else if ( index == 1 ) {
sw->script_path = strdup ( token );