summaryrefslogtreecommitdiffstats
path: root/source/view.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/view.c')
-rw-r--r--source/view.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/source/view.c b/source/view.c
index 1dba430c..721d065b 100644
--- a/source/view.c
+++ b/source/view.c
@@ -551,23 +551,24 @@ static RofiViewState * __rofi_view_state_create ( void )
{
return g_malloc0 ( sizeof ( RofiViewState ) );
}
-/**
- * Structure with data to process by each worker thread.
- */
-typedef struct _thread_state
+
+typedef struct _thread_state_view
{
+ thread_state st;
+
+ GCond *cond;
+ GMutex *mutex;
+ unsigned int *acount;
+
RofiViewState *state;
unsigned int start;
unsigned int stop;
unsigned int count;
- GCond *cond;
- GMutex *mutex;
- unsigned int *acount;
const char *pattern;
glong plen;
- void ( *callback )( struct _thread_state *t, gpointer data );
-}thread_state;
+
+} thread_state_view;
/**
* @param data A thread_state object.
* @param user_data User data to pass to thread_state callback
@@ -578,14 +579,11 @@ static void rofi_view_call_thread ( gpointer data, gpointer user_data )
{
thread_state *t = (thread_state *) data;
t->callback ( t, user_data );
- g_mutex_lock ( t->mutex );
- ( *( t->acount ) )--;
- g_cond_signal ( t->cond );
- g_mutex_unlock ( t->mutex );
}
-static void filter_elements ( thread_state *t, G_GNUC_UNUSED gpointer user_data )
+static void filter_elements ( thread_state *ts, G_GNUC_UNUSED gpointer user_data )
{
+ thread_state_view *t = (thread_state_view *)ts;
for ( unsigned int i = t->start; i < t->stop; i++ ) {
int match = mode_token_match ( t->state->sw, t->state->tokens, i );
// If each token was matched, add it to list.
@@ -606,6 +604,12 @@ static void filter_elements ( thread_state *t, G_GNUC_UNUSED gpointer user_data
t->count++;
}
}
+ if ( t->acount != NULL ) {
+ g_mutex_lock ( t->mutex );
+ ( *( t->acount ) )--;
+ g_cond_signal ( t->cond );
+ g_mutex_unlock ( t->mutex );
+ }
}
static void rofi_view_setup_fake_transparency ( const char* const fake_background )
{
@@ -931,6 +935,11 @@ static void update_callback ( textbox *t, unsigned int index, void *udata, TextB
cairo_surface_t *icon = mode_get_icon ( state->sw, state->line_map[index], icon_height );
textbox_icon ( t, icon );
+ if ( state->cur_icon ) {
+ if ( index == listview_get_selected ( state->list_view ) ){
+ icon_set_surface ( state->cur_icon, icon );
+ }
+ }
if ( state->tokens && config.show_match ) {
RofiHighlightColorStyle th = { ROFI_HL_BOLD | ROFI_HL_UNDERLINE, { 0.0, 0.0, 0.0, 0.0 } };
@@ -988,6 +997,12 @@ void rofi_view_update ( RofiViewState *state, gboolean qr )
if ( state->overlay ) {
widget_draw ( WIDGET ( state->overlay ), d );
}
+
+ int selected = listview_get_selected ( state->list_view );
+ cairo_surface_t *icon = mode_get_icon ( state->sw, state->line_map[selected], 32);
+ if ( state->cur_icon ) {
+ icon_set_surface ( state->cur_icon, icon );
+ }
TICK_N ( "widgets" );
cairo_surface_flush ( CacheState.edit_surf );
if ( qr ) {
@@ -1029,7 +1044,7 @@ static void rofi_view_refilter ( RofiViewState *state )
* For large lists with 8 threads I see a factor three speedup of the whole function.
*/
unsigned int nt = MAX ( 1, state->num_lines / 500 );
- thread_state states[nt];
+ thread_state_view states[nt];
GCond cond;
GMutex mutex;
g_mutex_init ( &mutex );
@@ -1046,7 +1061,7 @@ static void rofi_view_refilter ( RofiViewState *state )
states[i].acount = &count;
states[i].plen = plen;
states[i].pattern = pattern;
- states[i].callback = filter_elements;
+ states[i].st.callback = filter_elements;
if ( i > 0 ) {
g_thread_pool_push ( tpool, &states[i], NULL );
}
@@ -1637,6 +1652,13 @@ static void rofi_view_add_widget ( RofiViewState *state, widget *parent_widget,
textbox *t = textbox_create ( parent_widget, WIDGET_TYPE_TEXTBOX_TEXT, name, TB_AUTOHEIGHT | TB_WRAP, NORMAL, "", 0, 0 );
box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
}
+ else if ( g_ascii_strncasecmp ( name, "icon", 4 ) == 0 ) {
+ icon *t = icon_create ( parent_widget, name );
+ box_add ( (box *) parent_widget, WIDGET ( t ), TRUE );
+ if ( rofi_theme_get_boolean ( WIDGET ( t ), "show-current", FALSE ) ) {
+ state->cur_icon = t;
+ }
+ }
else {
wid = (widget *) box_create ( parent_widget, name, ROFI_ORIENTATION_VERTICAL );
box_add ( (box *) parent_widget, WIDGET ( wid ), TRUE );