summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/rofi.h6
-rw-r--r--source/dialogs/combi.c6
-rw-r--r--source/dialogs/dmenu.c6
-rw-r--r--source/dialogs/drun.c6
-rw-r--r--source/dialogs/run.c12
-rw-r--r--source/dialogs/script.c6
-rw-r--r--source/dialogs/ssh.c6
-rw-r--r--source/dialogs/window.c22
8 files changed, 38 insertions, 32 deletions
diff --git a/include/rofi.h b/include/rofi.h
index 28b66197..81230f4b 100644
--- a/include/rofi.h
+++ b/include/rofi.h
@@ -42,7 +42,7 @@ typedef enum
typedef SwitcherMode ( *switcher_callback )( char **input, void *data );
typedef void ( *switcher_free )( Switcher *data );
-typedef char * ( *get_display_value )( unsigned int selected_line, struct _Switcher *data, int *state, int get_entry );
+typedef char * ( *get_display_value )( unsigned int selected_line, const Switcher *data, int *state, int get_entry );
/**
* State returned by the rofi window.
*/
@@ -79,7 +79,7 @@ typedef enum
*
* @returns 1 when it matches, 0 if not.
*/
-typedef int ( *menu_match_cb )( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *data );
+typedef int ( *menu_match_cb )( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *data );
/**
* @param sw the Switcher to show.
@@ -297,7 +297,7 @@ struct _Switcher
get_display_value mgrv;
- int (*is_not_ascii)( struct _Switcher *sw, unsigned int index );
+ int (*is_not_ascii)( const struct _Switcher *sw, unsigned int index );
// Pointer to private data.
void *private_data;
diff --git a/source/dialogs/combi.c b/source/dialogs/combi.c
index c7ed3632..f31ffee2 100644
--- a/source/dialogs/combi.c
+++ b/source/dialogs/combi.c
@@ -174,7 +174,7 @@ static SwitcherMode combi_mode_result ( int mretv, char **input, unsigned int se
return MODE_EXIT;
}
static int combi_mode_match ( char **tokens, int not_ascii,
- int case_sensitive, unsigned int index, Switcher *sw )
+ int case_sensitive, unsigned int index, const Switcher *sw )
{
CombiModePrivateData *pd = sw->private_data;
@@ -196,7 +196,7 @@ static int combi_mode_match ( char **tokens, int not_ascii,
abort ();
return 0;
}
-static char * combi_mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
+static char * combi_mgrv ( unsigned int selected_line,const Switcher *sw, int *state, int get_entry )
{
CombiModePrivateData *pd = sw->private_data;
if ( !get_entry ) {
@@ -219,7 +219,7 @@ static char * combi_mgrv ( unsigned int selected_line, Switcher *sw, int *state,
return NULL;
}
-static int combi_is_not_ascii ( Switcher *sw, unsigned int index )
+static int combi_is_not_ascii ( const Switcher *sw, unsigned int index )
{
CombiModePrivateData *pd = sw->private_data;
for ( unsigned i = 0; i < pd->num_switchers; i++ ) {
diff --git a/source/dialogs/dmenu.c b/source/dialogs/dmenu.c
index eeecef52..67562dbd 100644
--- a/source/dialogs/dmenu.c
+++ b/source/dialogs/dmenu.c
@@ -137,7 +137,7 @@ static void parse_ranges ( char *input, struct range_pair **list, unsigned int *
}
}
-static char *get_display_data ( unsigned int index, Switcher *data, int *state, int get_entry )
+static char *get_display_data ( unsigned int index, const Switcher *data, int *state, int get_entry )
{
Switcher *sw = (Switcher *) data;
DmenuModePrivateData *pd = (DmenuModePrivateData *) sw->private_data;
@@ -279,13 +279,13 @@ static void dmenu_mode_init ( Switcher *sw )
pd->cmd_list = get_dmenu ( &( pd->cmd_list_length ) );
}
-static int dmenu_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
+static int dmenu_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
{
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
-static int dmenu_is_not_ascii ( Switcher *sw, unsigned int index )
+static int dmenu_is_not_ascii ( const Switcher *sw, unsigned int index )
{
DmenuModePrivateData *rmpd = (DmenuModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
diff --git a/source/dialogs/drun.c b/source/dialogs/drun.c
index 85d0ecf5..6819e0fb 100644
--- a/source/dialogs/drun.c
+++ b/source/dialogs/drun.c
@@ -264,7 +264,7 @@ static void drun_mode_destroy ( Switcher *sw )
}
}
-static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
+static char *mgrv ( unsigned int selected_line, const Switcher *sw, int *state, int get_entry )
{
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
*state |= MARKUP;
@@ -290,7 +290,7 @@ static int drun_token_match ( char **tokens,
int not_ascii,
int case_sensitive,
unsigned int index,
- Switcher *data )
+ const Switcher *data )
{
DRunModePrivateData *rmpd = (DRunModePrivateData *) data->private_data;
if ( rmpd->entry_list[index].name &&
@@ -310,7 +310,7 @@ static unsigned int drun_mode_get_num_entries ( Switcher *sw )
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
return pd->cmd_list_length;
}
-static int drun_is_not_ascii ( Switcher *sw, unsigned int index )
+static int drun_is_not_ascii ( const Switcher *sw, unsigned int index )
{
DRunModePrivateData *pd = (DRunModePrivateData *) sw->private_data;
if ( pd->entry_list[index].generic_name ) {
diff --git a/source/dialogs/run.c b/source/dialogs/run.c
index 75fe7722..e1a5e3a4 100644
--- a/source/dialogs/run.c
+++ b/source/dialogs/run.c
@@ -327,20 +327,20 @@ static void run_mode_destroy ( Switcher *sw )
}
}
-static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
+static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
{
- RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
+ const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int run_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
+static int run_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
{
- RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
+ const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
-static int run_is_not_ascii ( Switcher *sw, unsigned int index )
+static int run_is_not_ascii ( const Switcher *sw, unsigned int index )
{
- RunModePrivateData *rmpd = (RunModePrivateData *) sw->private_data;
+ const RunModePrivateData *rmpd = (const RunModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
}
Switcher run_mode =
diff --git a/source/dialogs/script.c b/source/dialogs/script.c
index b67d5be8..ea586258 100644
--- a/source/dialogs/script.c
+++ b/source/dialogs/script.c
@@ -157,19 +157,19 @@ static void script_mode_destroy ( Switcher *sw )
sw->private_data = NULL;
}
}
-static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
+static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
{
ScriptModePrivateData *rmpd = sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int script_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
+static int script_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
{
ScriptModePrivateData *rmpd = sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
-static int script_is_not_ascii ( Switcher *sw, unsigned int index )
+static int script_is_not_ascii ( const Switcher *sw, unsigned int index )
{
ScriptModePrivateData *rmpd = sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
diff --git a/source/dialogs/ssh.c b/source/dialogs/ssh.c
index 7b870c0f..2920480d 100644
--- a/source/dialogs/ssh.c
+++ b/source/dialogs/ssh.c
@@ -377,18 +377,18 @@ static void ssh_mode_destroy ( Switcher *sw )
}
}
-static char *mgrv ( unsigned int selected_line, Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
+static char *mgrv ( unsigned int selected_line, const Switcher *sw, G_GNUC_UNUSED int *state, int get_entry )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int ssh_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, Switcher *sw )
+static int ssh_token_match ( char **tokens, int not_ascii, int case_sensitive, unsigned int index, const Switcher *sw )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return token_match ( tokens, rmpd->cmd_list[index], not_ascii, case_sensitive );
}
-static int ssh_is_not_ascii ( Switcher *sw, unsigned int index )
+static int ssh_is_not_ascii ( const Switcher *sw, unsigned int index )
{
SSHModePrivateData *rmpd = (SSHModePrivateData *) sw->private_data;
return is_not_ascii ( rmpd->cmd_list[index] );
diff --git a/source/dialogs/window.c b/source/dialogs/window.c
index a922cd9f..787ec3c7 100644
--- a/source/dialogs/window.c
+++ b/source/dialogs/window.c
@@ -322,12 +322,15 @@ typedef struct _SwitcherModePrivateData
static int window_match ( char **tokens,
__attribute__( ( unused ) ) int not_ascii,
- int case_sensitive, unsigned int index, Switcher *sw )
+ int case_sensitive, unsigned int index, const Switcher *sw )
{
SwitcherModePrivateData *rmpd = (SwitcherModePrivateData *) sw->private_data;
int match = 1;
- winlist *ids = ( winlist * ) rmpd->ids;
- client *c = window_client ( display, ids->array[index] );
+ const winlist *ids = ( winlist * ) rmpd->ids;
+ // Want to pull directly out of cache, X calls are not thread safe.
+ int idx = winlist_find ( cache_client, ids->array[index]);
+ g_assert ( idx >= 0 ) ;
+ client *c = cache_client->data[idx];
if ( tokens ) {
for ( int j = 0; match && tokens != NULL && tokens[j] != NULL; j++ ) {
@@ -557,7 +560,7 @@ static void window_mode_destroy ( Switcher *sw )
}
}
-static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int get_entry )
+static char *mgrv ( unsigned int selected_line, const Switcher *sw, int *state, int get_entry )
{
SwitcherModePrivateData *rmpd = sw->private_data;
if ( window_client ( display, rmpd->ids->array[selected_line] )->demands ) {
@@ -569,11 +572,14 @@ static char *mgrv ( unsigned int selected_line, Switcher *sw, int *state, int ge
return get_entry ? g_strdup ( rmpd->cmd_list[selected_line] ) : NULL;
}
-static int window_is_not_ascii ( Switcher *sw, unsigned int index )
+static int window_is_not_ascii ( const Switcher *sw, unsigned int index )
{
- SwitcherModePrivateData *rmpd = sw->private_data;
- winlist *ids = ( winlist * ) rmpd->ids;
- client *c = window_client ( display, ids->array[index] );
+ const SwitcherModePrivateData *rmpd = sw->private_data;
+ const winlist *ids = ( winlist * ) rmpd->ids;
+ // Want to pull directly out of cache, X calls are not thread safe.
+ int idx = winlist_find ( cache_client, ids->array[index]);
+ g_assert ( idx >= 0 ) ;
+ client *c = cache_client->data[idx];
return is_not_ascii ( c->role ) || is_not_ascii ( c->class ) || is_not_ascii ( c->title ) || is_not_ascii ( c->name );
}