summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Glidic <sardemff7+git@sardemff7.net>2017-03-22 19:41:43 +0100
committerQuentin Glidic <sardemff7+git@sardemff7.net>2017-03-22 19:41:43 +0100
commitf33a0f369ec1560972ecbd38fbc6c75dc1893c63 (patch)
tree1719888c4d801e13f980c8f6e6f00494776a070b
parentff2ec4035274c81ca9b4efd6d4e1f2e0a3cfedee (diff)
view: Add back redraw idle callback
Signed-off-by: Quentin Glidic <sardemff7+git@sardemff7.net>
-rw-r--r--include/view-internal.h1
-rw-r--r--include/view.h2
-rw-r--r--source/view.c44
-rw-r--r--source/wayland.c5
-rw-r--r--source/widgets/textbox.c2
-rw-r--r--source/xcb.c1
6 files changed, 25 insertions, 30 deletions
diff --git a/include/view-internal.h b/include/view-internal.h
index d5119342..47b859b6 100644
--- a/include/view-internal.h
+++ b/include/view-internal.h
@@ -90,6 +90,7 @@ struct RofiViewState
int height;
/** Buffer pool */
display_buffer_pool *pool;
+ gboolean frame_callback;
/** Regexs used for matching */
GRegex **tokens;
diff --git a/include/view.h b/include/view.h
index 519bd688..ecb31ea7 100644
--- a/include/view.h
+++ b/include/view.h
@@ -164,7 +164,7 @@ int rofi_view_error_dialog ( const char *msg, int markup );
* Inform rofi that the last frame properly hit the screen
* and it can repaint a new one if needed
*/
-void rofi_view_frame_callback(void);
+void rofi_view_frame_callback( void );
void rofi_view_handle_keypress ( widget_modifier_mask modmask, xkb_keysym_t key, char *text, int len );
typedef enum {
ROFI_MOUSE_WHEEL_UP,
diff --git a/source/view.c b/source/view.c
index 962c9835..df8277f9 100644
--- a/source/view.c
+++ b/source/view.c
@@ -184,9 +184,6 @@ static gboolean rofi_view_repaint ( G_GNUC_UNUSED void * data )
// After a resize the edit_pixmap surface might not contain anything anymore.
// If we already re-painted, this does nothing.
rofi_view_update ( current_active_menu, FALSE );
- g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "expose event" );
- TICK_N ( "Expose" );
- // FIXME: draw
TICK_N ( "flush" );
CacheState.repaint_source = 0;
}
@@ -212,7 +209,7 @@ static void rofi_view_window_update_size ( RofiViewState * state )
{
if ( state->pool != NULL )
display_buffer_pool_free(state->pool);
- state->pool = display_buffer_pool_new(state->width, state->height);
+ state->pool = NULL;
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Re-size window based internal request: %dx%d.", state->width, state->height );
// Should wrap main window in a widget.
@@ -263,34 +260,25 @@ void rofi_view_reload ( void )
}
}
-static gboolean view_changed = FALSE;
-static gboolean frame_callback = FALSE;
-static void rofi_view_maybe_redraw ( void )
+void rofi_view_frame_callback( void )
{
- if ( ! frame_callback )
- return;
-
- // FIXME: has the view changed?
- // FIXME: maybe we have a var already?
- if ( ! view_changed )
+ RofiViewState *state = rofi_view_get_active();
+ if ( state == NULL )
return;
- // FIXME: redraw
-
- frame_callback = FALSE;
-}
-
-void rofi_view_frame_callback(void)
-{
- frame_callback = TRUE;
- rofi_view_maybe_redraw();
+ state->frame_callback = TRUE;
+ if ( widget_need_redraw ( WIDGET ( state->main_window ) ) ) {
+ rofi_view_queue_redraw();
+ }
}
void rofi_view_queue_redraw ( void )
{
- // FIXME: maybe we have a var already?
- view_changed = TRUE;
- rofi_view_maybe_redraw();
+ if ( current_active_menu && CacheState.repaint_source == 0 ) {
+ CacheState.count++;
+ g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "redraw %llu", CacheState.count );
+ CacheState.repaint_source = g_idle_add_full ( G_PRIORITY_HIGH_IDLE, rofi_view_repaint, NULL, NULL );
+ }
}
void rofi_view_restart ( RofiViewState *state )
@@ -649,6 +637,9 @@ void rofi_view_update ( RofiViewState *state, gboolean qr )
return;
}
g_log ( LOG_DOMAIN, G_LOG_LEVEL_DEBUG, "Redraw view" );
+ if ( state->pool == NULL ) {
+ state->pool = display_buffer_pool_new(state->width, state->height);
+ }
TICK ();
cairo_surface_t *surface = display_buffer_pool_get_next_buffer(state->pool);
cairo_t *d = cairo_create(surface);
@@ -1189,6 +1180,7 @@ RofiViewState *rofi_view_create ( Mode *sw,
state->refilter = TRUE;
state->finalize = finalize;
state->mouse_seen = FALSE;
+ state->frame_callback = TRUE;
// Request the lines to show.
state->num_lines = mode_get_num_entries ( sw );
@@ -1390,7 +1382,7 @@ void rofi_view_set_overlay ( RofiViewState *state, const char *text )
top_offset += widget_padding_get_top ( WIDGET ( state->main_box ) );
widget_move ( WIDGET ( state->overlay ), x_offset, top_offset );
// We want to queue a repaint.
- rofi_view_queue_redraw ( );
+ rofi_view_queue_redraw ();
}
void rofi_view_clear_input ( RofiViewState *state )
diff --git a/source/wayland.c b/source/wayland.c
index e469b57b..e4e079da 100644
--- a/source/wayland.c
+++ b/source/wayland.c
@@ -290,11 +290,12 @@ static void
wayland_frame_callback(void *data, struct wl_callback *callback, uint32_t timestamp)
{
if ( wayland->frame_cb != NULL )
+ {
wl_callback_destroy(wayland->frame_cb);
+ rofi_view_frame_callback();
+ }
wayland->frame_cb = wl_surface_frame(wayland->surface);
wl_callback_add_listener(wayland->frame_cb, &wayland_frame_wl_callback_listener, wayland);
-
- rofi_view_frame_callback();
}
static void
diff --git a/source/widgets/textbox.c b/source/widgets/textbox.c
index f7324b84..36f5634e 100644
--- a/source/widgets/textbox.c
+++ b/source/widgets/textbox.c
@@ -76,7 +76,7 @@ static gboolean textbox_blink ( gpointer data )
if ( tb->blink < 2 ) {
tb->blink = !tb->blink;
widget_queue_redraw ( WIDGET ( tb ) );
- rofi_view_queue_redraw ( );
+ rofi_view_queue_redraw ();
}
else {
tb->blink--;
diff --git a/source/xcb.c b/source/xcb.c
index 9db88e17..1e591568 100644
--- a/source/xcb.c
+++ b/source/xcb.c
@@ -512,6 +512,7 @@ void display_surface_commit(cairo_surface_t *surface)
}
xcb_flush(xcb->connection);
+ rofi_view_frame_callback();
}
// retrieve a text property from a window