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

Propagate error down, show dialog.

Fix positioning dialog.
This commit is contained in:
Dave Davenport 2016-03-05 11:08:32 +01:00
parent 881ca572df
commit 72dfe2ad4c
9 changed files with 32 additions and 24 deletions

View file

@ -304,7 +304,7 @@ indent: $(rofi_SOURCES) $(top_srcdir)/config/config.def.c $(helper_test_SOURCES)
.PHONY: cppcheck
cppcheck: $(rofi_SOURCES)
cppcheck --std=c99 --platform=unix64 --enable=all -Uerror_dialog -I $(top_srcdir)/include/ $^
cppcheck --std=c99 --platform=unix64 --enable=all -Uerror_dialog --inconclusive -I $(top_srcdir)/include/ $^
.PHONY: ohcount

View file

@ -82,7 +82,7 @@ typedef enum _KeyBindingAction
* Parse the keybindings.
* This should be called after the setting system is initialized.
*/
void parse_keys_abe ( void );
gboolean parse_keys_abe ( void );
/**
* Setup the keybindings

View file

@ -1,5 +1,6 @@
#ifndef X11_ROFI_HELPER_H
#define X11_ROFI_HELPER_H
#include <glib.h>
#include <cairo.h>
#include <xcb/xcb.h>
@ -83,7 +84,7 @@ unsigned int x11_canonalize_mask ( unsigned int mask );
*
* Parse key from user input string.
*/
void x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key );
gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key );
/**
* @param display The connection to the X server.

View file

@ -100,7 +100,7 @@ void setup_abe ( void )
}
}
void parse_keys_abe ( void )
gboolean parse_keys_abe ( void )
{
for ( int iter = 0; iter < NUM_ABE; iter++ ) {
char *keystr = g_strdup ( abe[iter].keystr );
@ -114,12 +114,16 @@ void parse_keys_abe ( void )
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 ) );
if ( !x11_parse_key ( entry, &( kb->modmask ), &( kb->keysym ) ) ) {
g_free ( keystr );
return FALSE;
}
abe[iter].num_bindings++;
}
g_free ( keystr );
}
return TRUE;
}
void cleanup_abe ( void )

View file

@ -534,9 +534,8 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
}
TICK_N ( "Config sanity check" );
// Parse the keybindings.
parse_keys_abe ();
// Check if there is error dialog.
if ( rofi_view_get_active ( ) != NULL ) {
if ( !parse_keys_abe () ) {
// Error dialog
return G_SOURCE_REMOVE;
}
TICK_N ( "Parse ABE" );

View file

@ -37,8 +37,6 @@
#include <xkbcommon/xkbcommon-x11.h>
#include <xcb/xkb.h>
#include <xcb/xcb_ewmh.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <cairo.h>
#include <cairo-xcb.h>
@ -1720,6 +1718,9 @@ int rofi_view_error_dialog ( const char *msg, int markup )
// resize window vertically to suit
state->h = state->line_height + ( state->border ) * 2;
// Calculte window position.
calculate_window_position ( state );
// Move the window to the correct x,y position.
uint16_t mask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y | XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
uint32_t vals[] = { state->x, state->y, state->w, state->h };
@ -1733,6 +1734,8 @@ int rofi_view_error_dialog ( const char *msg, int markup )
if ( xcb->sncontext != NULL ) {
sn_launchee_context_complete ( xcb->sncontext );
}
// Set it has current window.
rofi_view_set_active ( state );
return TRUE;
}

View file

@ -379,7 +379,7 @@ unsigned int x11_canonalize_mask ( unsigned int mask )
}
// convert a Mod+key arg to mod mask and keysym
void x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key )
gboolean x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key )
{
GString *str = g_string_new ( "" );
unsigned int modmask = 0;
@ -464,10 +464,11 @@ void x11_parse_key ( char *combo, unsigned int *mod, xkb_keysym_t *key )
if ( str->len > 0 ) {
show_error_message ( str->str, TRUE );
g_string_free ( str, TRUE );
return;
return FALSE;
}
g_string_free ( str, TRUE );
*key = sym;
return TRUE;
}
void x11_set_window_opacity ( xcb_window_t box, unsigned int opacity )