Patch 8.2.3607
Problem: GTK3 screen updating is slow.
Solution: Remove some of the GTK3-specific code. (closes #9052)
Files: src/gui.h, src/gui_gtk_x11.c
*** ../vim-8.2.3606/src/gui.h 2021-10-16 20:52:01.772842109 +0100
--- src/gui.h 2021-11-16 19:46:05.024833582 +0000
***************
*** 393,399 ****
# endif
# ifdef USE_GTK3
cairo_surface_t *surface; // drawarea surface
- gboolean by_signal; // cause of draw operation
# else
GdkGC *text_gc; // cached GC for normal text
# endif
--- 393,398 ----
*** ../vim-8.2.3606/src/gui_gtk_x11.c 2021-10-20 23:08:07.790623217 +0100
--- src/gui_gtk_x11.c 2021-11-16 20:03:07.963598701 +0000
***************
*** 618,663 ****
* Redraw the corresponding portions of the screen.
*/
#if GTK_CHECK_VERSION(3,0,0)
- static gboolean is_key_pressed = FALSE;
- static gboolean blink_mode = TRUE;
-
- static gboolean gui_gtk_is_blink_on(void);
-
- static void
- gui_gtk3_redraw(int x, int y, int width, int height)
- {
- // Range checks are left to gui_redraw_block()
- gui_redraw_block(Y_2_ROW(y), X_2_COL(x),
- Y_2_ROW(y + height - 1), X_2_COL(x + width - 1),
- GUI_MON_NOCLEAR);
- }
-
- static void
- gui_gtk3_update_cursor(cairo_t *cr)
- {
- if (gui.row == gui.cursor_row)
- {
- gui.by_signal = TRUE;
- if (State & CMDLINE)
- gui_update_cursor(TRUE, FALSE);
- else
- gui_update_cursor(TRUE, TRUE);
- gui.by_signal = FALSE;
- cairo_paint(cr);
- }
- }
-
- static gboolean
- gui_gtk3_should_draw_cursor(void)
- {
- unsigned int cond = 0;
- cond |= gui_gtk_is_blink_on();
- if (gui.cursor_col >= gui.col)
- cond |= is_key_pressed;
- cond |= gui.in_focus == FALSE;
- return cond;
- }
-
static gboolean
draw_event(GtkWidget *widget UNUSED,
cairo_t *cr,
--- 618,623 ----
***************
*** 672,679 ****
cairo_set_source_surface(cr, gui.surface, 0, 0);
- // Draw the window without the cursor.
- gui.by_signal = TRUE;
{
cairo_rectangle_list_t *list = NULL;
--- 632,637 ----
***************
*** 682,728 ****
{
int i;
- // First clear all the blocks and then redraw them. Just in case
- // some blocks overlap.
for (i = 0; i < list->num_rectangles; i++)
{
! const cairo_rectangle_t rect = list->rectangles[i];
!
! gui_mch_clear_block(Y_2_ROW((int)rect.y), 0,
! Y_2_ROW((int)(rect.y + rect.height)) - 1, Columns - 1);
! }
!
! for (i = 0; i < list->num_rectangles; i++)
! {
! const cairo_rectangle_t rect = list->rectangles[i];
!
! if (blink_mode)
! gui_gtk3_redraw(rect.x, rect.y, rect.width, rect.height);
! else
! {
! if (get_real_state() & VISUAL)
! gui_gtk3_redraw(rect.x, rect.y,
! rect.width, rect.height);
! else
! gui_redraw(rect.x, rect.y, rect.width, rect.height);
! }
}
}
cairo_rectangle_list_destroy(list);
-
- if (get_real_state() & VISUAL)
- {
- if (gui.cursor_row == gui.row && gui.cursor_col >= gui.col)
- gui_update_cursor(TRUE, TRUE);
- }
-
- cairo_paint(cr);
}
- gui.by_signal = FALSE;
-
- // Add the cursor to the window if necessary.
- if (gui_gtk3_should_draw_cursor() && blink_mode)
- gui_gtk3_update_cursor(cr);
return FALSE;
}
--- 640,654 ----
{
int i;
for (i = 0; i < list->num_rectangles; i++)
{
! const cairo_rectangle_t *rect = &list->rectangles[i];
! cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
! cairo_fill(cr);
}
}
cairo_rectangle_list_destroy(list);
}
return FALSE;
}
***************
*** 847,860 ****
static long_u blink_offtime = 250;
static guint blink_timer = 0;
- #if GTK_CHECK_VERSION(3,0,0)
- static gboolean
- gui_gtk_is_blink_on(void)
- {
- return blink_state == BLINK_ON;
- }
- #endif
-
int
gui_mch_is_blinking(void)
{
--- 773,778 ----
***************
*** 870,897 ****
void
gui_mch_set_blinking(long waittime, long on, long off)
{
- #if GTK_CHECK_VERSION(3,0,0)
- if (waittime == 0 || on == 0 || off == 0)
- {
- blink_mode = FALSE;
-
- blink_waittime = 700;
- blink_ontime = 400;
- blink_offtime = 250;
- }
- else
- {
- blink_mode = TRUE;
-
- blink_waittime = waittime;
- blink_ontime = on;
- blink_offtime = off;
- }
- #else
blink_waittime = waittime;
blink_ontime = on;
blink_offtime = off;
- #endif
}
/*
--- 788,796 ----
***************
*** 908,914 ****
--- 807,815 ----
if (blink_state == BLINK_OFF && may_call_gui_update_cursor)
{
gui_update_cursor(TRUE, FALSE);
+ #if !GTK_CHECK_VERSION(3,0,0)
gui_mch_flush();
+ #endif
}
blink_state = BLINK_NONE;
}
***************
*** 928,934 ****
--- 829,837 ----
blink_state = BLINK_ON;
blink_timer = timeout_add(blink_ontime, blink_cb, NULL);
}
+ #if !GTK_CHECK_VERSION(3,0,0)
gui_mch_flush();
+ #endif
return FALSE; // don't happen again
}
***************
*** 951,957 ****
--- 854,862 ----
blink_timer = timeout_add(blink_waittime, blink_cb, NULL);
blink_state = BLINK_ON;
gui_update_cursor(TRUE, FALSE);
+ #if !GTK_CHECK_VERSION(3,0,0)
gui_mch_flush();
+ #endif
}
}
***************
*** 1119,1129 ****
guint state;
char_u *s, *d;
- #if GTK_CHECK_VERSION(3,0,0)
- is_key_pressed = TRUE;
- gui_mch_stop_blink(TRUE);
- #endif
-
gui.event_time = event->time;
key_sym = event->keyval;
state = event->state;
--- 1024,1029 ----
***************
*** 1280,1289 ****
GdkEventKey *event,
gpointer data UNUSED)
{
- # if GTK_CHECK_VERSION(3,0,0)
- is_key_pressed = FALSE;
- gui_mch_start_blink();
- # endif
# if defined(FEAT_XIM)
gui.event_time = event->time;
/*
--- 1180,1185 ----
***************
*** 3823,3829 ****
gui.drawarea = gtk_drawing_area_new();
#if GTK_CHECK_VERSION(3,0,0)
gui.surface = NULL;
- gui.by_signal = FALSE;
#endif
// Determine which events we will filter.
--- 3719,3724 ----
***************
*** 6014,6022 ****
#if GTK_CHECK_VERSION(3,0,0)
cairo_destroy(cr);
! if (!gui.by_signal)
! gdk_window_invalidate_rect(gtk_widget_get_window(gui.drawarea),
! &area, FALSE);
#else
gdk_gc_set_clip_rectangle(gui.text_gc, NULL);
#endif
--- 5909,5916 ----
#if GTK_CHECK_VERSION(3,0,0)
cairo_destroy(cr);
! gtk_widget_queue_draw_area(gui.drawarea, area.x, area.y,
! area.width, area.height);
#else
gdk_gc_set_clip_rectangle(gui.text_gc, NULL);
#endif
***************
*** 6153,6166 ****
# else
// Give an implementation for older cairo versions if necessary.
# endif
! gdk_cairo_rectangle(cr, &rect);
cairo_fill(cr);
cairo_destroy(cr);
! if (!gui.by_signal)
! gtk_widget_queue_draw_area(gui.drawarea, rect.x, rect.y,
! rect.width, rect.height);
#else
GdkGCValues values;
GdkGC *invert_gc;
--- 6047,6059 ----
# else
// Give an implementation for older cairo versions if necessary.
# endif
! cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
cairo_fill(cr);
cairo_destroy(cr);
! gtk_widget_queue_draw_area(gui.drawarea, rect.x, rect.y,
! rect.width, rect.height);
#else
GdkGCValues values;
GdkGC *invert_gc;
***************
*** 6480,6502 ****
(col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1),
(row2 - row1 + 1) * gui.char_height
};
- GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
cairo_t * const cr = cairo_create(gui.surface);
# if GTK_CHECK_VERSION(3,22,2)
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# else
cairo_pattern_t * const pat = gdk_window_get_background_pattern(win);
if (pat != NULL)
cairo_set_source(cr, pat);
else
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# endif
! gdk_cairo_rectangle(cr, &rect);
cairo_fill(cr);
cairo_destroy(cr);
! if (!gui.by_signal)
! gdk_window_invalidate_rect(win, &rect, FALSE);
}
#else // !GTK_CHECK_VERSION(3,0,0)
gdk_gc_set_foreground(gui.text_gc, &color);
--- 6373,6395 ----
(col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1),
(row2 - row1 + 1) * gui.char_height
};
cairo_t * const cr = cairo_create(gui.surface);
# if GTK_CHECK_VERSION(3,22,2)
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# else
+ GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
cairo_pattern_t * const pat = gdk_window_get_background_pattern(win);
if (pat != NULL)
cairo_set_source(cr, pat);
else
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# endif
! cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
cairo_fill(cr);
cairo_destroy(cr);
! gtk_widget_queue_draw_area(gui.drawarea,
! rect.x, rect.y, rect.width, rect.height);
}
#else // !GTK_CHECK_VERSION(3,0,0)
gdk_gc_set_foreground(gui.text_gc, &color);
***************
*** 6528,6539 ****
else
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# endif
! gdk_cairo_rectangle(cr, &rect);
cairo_fill(cr);
cairo_destroy(cr);
! if (!gui.by_signal)
! gdk_window_invalidate_rect(win, &rect, FALSE);
}
#else
# define gui_gtk_window_clear(win) gdk_window_clear(win)
--- 6421,6432 ----
else
set_cairo_source_rgba_from_color(cr, gui.back_pixel);
# endif
! cairo_rectangle(cr, rect.x, rect.y, rect.width, rect.height);
cairo_fill(cr);
cairo_destroy(cr);
! gtk_widget_queue_draw_area(gui.drawarea,
! rect.x, rect.y, rect.width, rect.height);
}
#else
# define gui_gtk_window_clear(win) gdk_window_clear(win)
***************
*** 6624,6636 ****
gui_clear_block(
gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left,
gui.scroll_region_bot, gui.scroll_region_right);
! gui_gtk3_redraw(
FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
! if (!gui.by_signal)
! gtk_widget_queue_draw_area(gui.drawarea,
! FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
#else
if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
return; // Can't see the window
--- 6517,6525 ----
gui_clear_block(
gui.scroll_region_bot - num_lines + 1, gui.scroll_region_left,
gui.scroll_region_bot, gui.scroll_region_right);
! gtk_widget_queue_draw_area(gui.drawarea,
FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
#else
if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
return; // Can't see the window
***************
*** 6671,6686 ****
FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
FILL_X(gui.scroll_region_left), FILL_Y(row),
gui.char_width * ncols + 1, gui.char_height * src_nrows);
! gui_mch_clear_block(
row, gui.scroll_region_left,
row + num_lines - 1, gui.scroll_region_right);
! gui_gtk3_redraw(
FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
! if (!gui.by_signal)
! gtk_widget_queue_draw_area(gui.drawarea,
! FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
#else
if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
return; // Can't see the window
--- 6560,6571 ----
FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
FILL_X(gui.scroll_region_left), FILL_Y(row),
gui.char_width * ncols + 1, gui.char_height * src_nrows);
! gui_clear_block(
row, gui.scroll_region_left,
row + num_lines - 1, gui.scroll_region_right);
! gtk_widget_queue_draw_area(gui.drawarea,
FILL_X(gui.scroll_region_left), FILL_Y(row),
! gui.char_width * ncols + 1, gui.char_height * nrows);
#else
if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
return; // Can't see the window
***************
*** 7122,7130 ****
cairo_surface_destroy(bg_surf);
cairo_destroy(cr);
! if (!gui.by_signal)
! gtk_widget_queue_draw_area(gui.drawarea,
! FILL_X(col), FILL_Y(col), width, height);
}
# else // !GTK_CHECK_VERSION(3,0,0)
--- 7007,7014 ----
cairo_surface_destroy(bg_surf);
cairo_destroy(cr);
! gtk_widget_queue_draw_area(gui.drawarea,
! FILL_X(col), FILL_Y(col), width, height);
}
# else // !GTK_CHECK_VERSION(3,0,0)
*** ../vim-8.2.3606/src/version.c 2021-11-16 19:20:52.263368010 +0000
--- src/version.c 2021-11-16 19:48:09.704665392 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3607,
/**/
--
No letters of the alphabet were harmed in the creation of this message.
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///