summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorDave Davenport <qball@gmpclient.org>2016-03-05 11:08:32 +0100
committerDave Davenport <qball@gmpclient.org>2016-03-05 11:08:32 +0100
commit72dfe2ad4c37d98b789019bb0f2b2bd3fc9e8971 (patch)
treee05391a8b7d6e5293b4f5f9801b061282a1fff99 /source
parent881ca572df59e2b39e4a123af68e46068b35a424 (diff)
Propagate error down, show dialog.
Fix positioning dialog.
Diffstat (limited to 'source')
-rw-r--r--source/keyb.c8
-rw-r--r--source/rofi.c5
-rw-r--r--source/view.c9
-rw-r--r--source/x11-helper.c5
-rw-r--r--source/xrmoptions.c4
5 files changed, 19 insertions, 12 deletions
diff --git a/source/keyb.c b/source/keyb.c
index db4fc515..9916a276 100644
--- a/source/keyb.c
+++ b/source/keyb.c
@@ -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 )
diff --git a/source/rofi.c b/source/rofi.c
index 4055316d..967f7a80 100644
--- a/source/rofi.c
+++ b/source/rofi.c
@@ -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" );
diff --git a/source/view.c b/source/view.c
index 814d6a98..21c5ce7c 100644
--- a/source/view.c
+++ b/source/view.c
@@ -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>
@@ -471,7 +469,7 @@ static xcb_window_t __create_window ( MenuFlags menu_flags )
{ 0,
0,
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS |
- XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION,map };
+ XCB_EVENT_MASK_KEY_RELEASE | XCB_EVENT_MASK_STRUCTURE_NOTIFY | XCB_EVENT_MASK_FOCUS_CHANGE | XCB_EVENT_MASK_BUTTON_1_MOTION, map };
xcb_window_t box = xcb_generate_id ( xcb->connection );
xcb_create_window ( xcb->connection,
@@ -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;
}
diff --git a/source/x11-helper.c b/source/x11-helper.c
index c0fc3b8b..76991586 100644
--- a/source/x11-helper.c
+++ b/source/x11-helper.c
@@ -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 )
diff --git a/source/xrmoptions.c b/source/xrmoptions.c
index 3fb83fce..6fff1015 100644
--- a/source/xrmoptions.c
+++ b/source/xrmoptions.c
@@ -332,9 +332,9 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
{
- char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
+ char *name = window_get_text_prop ( xcb_stuff_get_root_window ( xcb ), XCB_ATOM_RESOURCE_MANAGER );
if ( name ) {
- XrmDatabase xDB = XrmGetStringDatabase ( name );
+ XrmDatabase xDB = XrmGetStringDatabase ( name );
__config_parse_xresource_options_dynamic ( xDB );
XrmDestroyDatabase ( xDB );
g_free ( name );