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:
parent
881ca572df
commit
72dfe2ad4c
9 changed files with 32 additions and 24 deletions
|
@ -304,7 +304,7 @@ indent: $(rofi_SOURCES) $(top_srcdir)/config/config.def.c $(helper_test_SOURCES)
|
||||||
.PHONY: cppcheck
|
.PHONY: cppcheck
|
||||||
|
|
||||||
cppcheck: $(rofi_SOURCES)
|
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
|
.PHONY: ohcount
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ typedef enum _KeyBindingAction
|
||||||
* Parse the keybindings.
|
* Parse the keybindings.
|
||||||
* This should be called after the setting system is initialized.
|
* This should be called after the setting system is initialized.
|
||||||
*/
|
*/
|
||||||
void parse_keys_abe ( void );
|
gboolean parse_keys_abe ( void );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the keybindings
|
* Setup the keybindings
|
||||||
|
|
|
@ -38,15 +38,15 @@ typedef struct
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TB_AUTOHEIGHT = 1 << 0,
|
TB_AUTOHEIGHT = 1 << 0,
|
||||||
TB_AUTOWIDTH = 1 << 1,
|
TB_AUTOWIDTH = 1 << 1,
|
||||||
TB_LEFT = 1 << 16,
|
TB_LEFT = 1 << 16,
|
||||||
TB_RIGHT = 1 << 17,
|
TB_RIGHT = 1 << 17,
|
||||||
TB_CENTER = 1 << 18,
|
TB_CENTER = 1 << 18,
|
||||||
TB_EDITABLE = 1 << 19,
|
TB_EDITABLE = 1 << 19,
|
||||||
TB_MARKUP = 1 << 20,
|
TB_MARKUP = 1 << 20,
|
||||||
TB_WRAP = 1 << 21,
|
TB_WRAP = 1 << 21,
|
||||||
TB_PASSWORD = 1 << 22,
|
TB_PASSWORD = 1 << 22,
|
||||||
} TextboxFlags;
|
} TextboxFlags;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#ifndef X11_ROFI_HELPER_H
|
#ifndef X11_ROFI_HELPER_H
|
||||||
#define X11_ROFI_HELPER_H
|
#define X11_ROFI_HELPER_H
|
||||||
|
#include <glib.h>
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ unsigned int x11_canonalize_mask ( unsigned int mask );
|
||||||
*
|
*
|
||||||
* Parse key from user input string.
|
* 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.
|
* @param display The connection to the X server.
|
||||||
|
|
|
@ -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++ ) {
|
for ( int iter = 0; iter < NUM_ABE; iter++ ) {
|
||||||
char *keystr = g_strdup ( abe[iter].keystr );
|
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 ) ) {
|
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 ) );
|
abe[iter].kb = g_realloc ( abe[iter].kb, ( abe[iter].num_bindings + 1 ) * sizeof ( KeyBinding ) );
|
||||||
KeyBinding *kb = &( abe[iter].kb[abe[iter].num_bindings] );
|
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++;
|
abe[iter].num_bindings++;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free ( keystr );
|
g_free ( keystr );
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_abe ( void )
|
void cleanup_abe ( void )
|
||||||
|
|
|
@ -534,9 +534,8 @@ static gboolean startup ( G_GNUC_UNUSED gpointer data )
|
||||||
}
|
}
|
||||||
TICK_N ( "Config sanity check" );
|
TICK_N ( "Config sanity check" );
|
||||||
// Parse the keybindings.
|
// Parse the keybindings.
|
||||||
parse_keys_abe ();
|
if ( !parse_keys_abe () ) {
|
||||||
// Check if there is error dialog.
|
// Error dialog
|
||||||
if ( rofi_view_get_active ( ) != NULL ) {
|
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
}
|
}
|
||||||
TICK_N ( "Parse ABE" );
|
TICK_N ( "Parse ABE" );
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include <xkbcommon/xkbcommon-x11.h>
|
#include <xkbcommon/xkbcommon-x11.h>
|
||||||
#include <xcb/xkb.h>
|
#include <xcb/xkb.h>
|
||||||
#include <xcb/xcb_ewmh.h>
|
#include <xcb/xcb_ewmh.h>
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
#include <cairo.h>
|
#include <cairo.h>
|
||||||
#include <cairo-xcb.h>
|
#include <cairo-xcb.h>
|
||||||
|
@ -471,7 +469,7 @@ static xcb_window_t __create_window ( MenuFlags menu_flags )
|
||||||
{ 0,
|
{ 0,
|
||||||
0,
|
0,
|
||||||
XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS | XCB_EVENT_MASK_BUTTON_RELEASE | XCB_EVENT_MASK_KEY_PRESS |
|
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_window_t box = xcb_generate_id ( xcb->connection );
|
||||||
xcb_create_window ( 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
|
// resize window vertically to suit
|
||||||
state->h = state->line_height + ( state->border ) * 2;
|
state->h = state->line_height + ( state->border ) * 2;
|
||||||
|
|
||||||
|
// Calculte window position.
|
||||||
|
calculate_window_position ( state );
|
||||||
|
|
||||||
// Move the window to the correct x,y position.
|
// 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;
|
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 };
|
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 ) {
|
if ( xcb->sncontext != NULL ) {
|
||||||
sn_launchee_context_complete ( xcb->sncontext );
|
sn_launchee_context_complete ( xcb->sncontext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set it has current window.
|
||||||
rofi_view_set_active ( state );
|
rofi_view_set_active ( state );
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -379,7 +379,7 @@ unsigned int x11_canonalize_mask ( unsigned int mask )
|
||||||
}
|
}
|
||||||
|
|
||||||
// convert a Mod+key arg to mod mask and keysym
|
// 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 ( "" );
|
GString *str = g_string_new ( "" );
|
||||||
unsigned int modmask = 0;
|
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 ) {
|
if ( str->len > 0 ) {
|
||||||
show_error_message ( str->str, TRUE );
|
show_error_message ( str->str, TRUE );
|
||||||
g_string_free ( str, TRUE );
|
g_string_free ( str, TRUE );
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
g_string_free ( str, TRUE );
|
g_string_free ( str, TRUE );
|
||||||
*key = sym;
|
*key = sym;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void x11_set_window_opacity ( xcb_window_t box, unsigned int opacity )
|
void x11_set_window_opacity ( xcb_window_t box, unsigned int opacity )
|
||||||
|
|
|
@ -332,9 +332,9 @@ static void __config_parse_xresource_options_dynamic ( XrmDatabase xDB )
|
||||||
|
|
||||||
void config_parse_xresource_options_dynamic ( xcb_stuff *xcb )
|
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 ) {
|
if ( name ) {
|
||||||
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
XrmDatabase xDB = XrmGetStringDatabase ( name );
|
||||||
__config_parse_xresource_options_dynamic ( xDB );
|
__config_parse_xresource_options_dynamic ( xDB );
|
||||||
XrmDestroyDatabase ( xDB );
|
XrmDestroyDatabase ( xDB );
|
||||||
g_free ( name );
|
g_free ( name );
|
||||||
|
|
Loading…
Reference in a new issue