app: remove all calls to gdk_window_process_updated()

- remove gimp_widget_flush_expose()
- remove the "now" argument to gimp_display_shell_flush() and make it
  only update widget states
- rename gimp_display_flush_whenever() to gimp_display_flush_update_region()
  and call gimp_display_shell_flush() separately in the only case we
  passed FALSE to flush_whenever()
- remove th flush_now interval logic from GimpDisplay, as soon as we
  have exposed the canvas, we are in the loop for the next frame clock
  tick anyway, so delaying a useless and removed process_updates serves
  no purpose
- in gimptool-progress.c, create the invisible grab widget also for
  non-cencelable cases, so we can always safely run the main loop
  manually to make the progress updates visible
- in gimp-gegl-apply-operation.c, always run the main loop manually
  to make the progress updates visible
- in gimpstatusbar.c, leave some FIXME comments as reminder that
  we might need the same logic as in gimptool-progress.c
This commit is contained in:
Michael Natterer 2018-07-01 16:19:54 +02:00
parent 2ab5558b22
commit 3089a20167
14 changed files with 78 additions and 140 deletions

View file

@ -50,8 +50,6 @@
#include "gimp-intl.h"
#define FLUSH_NOW_INTERVAL 20000 /* 20 ms in microseconds */
#define PAINT_AREA_CHUNK_WIDTH 32
#define PAINT_AREA_CHUNK_HEIGHT 32
@ -78,8 +76,6 @@ struct _GimpDisplayPrivate
GtkWidget *shell;
cairo_region_t *update_region;
guint64 last_flush_now;
};
#define GIMP_DISPLAY_GET_PRIVATE(display) \
@ -121,8 +117,7 @@ static gboolean gimp_display_progress_message (GimpProgress *progre
static void gimp_display_progress_canceled (GimpProgress *progress,
GimpDisplay *display);
static void gimp_display_flush_whenever (GimpDisplay *display,
gboolean now);
static void gimp_display_flush_update_region (GimpDisplay *display);
static void gimp_display_paint_area (GimpDisplay *display,
gint x,
gint y,
@ -802,7 +797,9 @@ gimp_display_flush (GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_DISPLAY (display));
gimp_display_flush_whenever (display, FALSE);
gimp_display_flush_update_region (display);
gimp_display_shell_flush (gimp_display_get_shell (display));
}
void
@ -810,15 +807,14 @@ gimp_display_flush_now (GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_DISPLAY (display));
gimp_display_flush_whenever (display, TRUE);
gimp_display_flush_update_region (display);
}
/* private functions */
static void
gimp_display_flush_whenever (GimpDisplay *display,
gboolean now)
gimp_display_flush_update_region (GimpDisplay *display)
{
GimpDisplayPrivate *private = GIMP_DISPLAY_GET_PRIVATE (display);
@ -843,22 +839,6 @@ gimp_display_flush_whenever (GimpDisplay *display,
g_clear_pointer (&private->update_region, cairo_region_destroy);
}
if (now)
{
guint64 now = g_get_monotonic_time ();
if ((now - private->last_flush_now) > FLUSH_NOW_INTERVAL)
{
gimp_display_shell_flush (gimp_display_get_shell (display), now);
private->last_flush_now = now;
}
}
else
{
gimp_display_shell_flush (gimp_display_get_shell (display), now);
}
}
static void

View file

@ -1691,20 +1691,14 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
}
void
gimp_display_shell_flush (GimpDisplayShell *shell,
gboolean now)
gimp_display_shell_flush (GimpDisplayShell *shell)
{
GimpImageWindow *window;
GimpContext *context;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
if (now)
{
gdk_window_process_updates (gtk_widget_get_window (shell->canvas),
FALSE);
}
else
{
GimpImageWindow *window = gimp_display_shell_get_window (shell);
GimpContext *context;
window = gimp_display_shell_get_window (shell);
gimp_display_shell_title_update (shell);
@ -1724,7 +1718,6 @@ gimp_display_shell_flush (GimpDisplayShell *shell,
{
gimp_ui_manager_update (shell->popup_manager, shell->display);
}
}
}
/**

View file

@ -293,8 +293,7 @@ gboolean gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
gint *width,
gint *height);
void gimp_display_shell_flush (GimpDisplayShell *shell,
gboolean now);
void gimp_display_shell_flush (GimpDisplayShell *shell);
void gimp_display_shell_pause (GimpDisplayShell *shell);
void gimp_display_shell_resume (GimpDisplayShell *shell);

View file

@ -446,7 +446,10 @@ gimp_statusbar_progress_start (GimpProgress *progress,
statusbar->progress_shown = TRUE;
}
#if 0
/* FIXME flush_expose */
gimp_widget_flush_expose (bar);
#endif
gimp_statusbar_override_window_title (statusbar);
@ -503,11 +506,12 @@ gimp_statusbar_progress_set_text (GimpProgress *progress,
if (statusbar->progress_active)
{
GtkWidget *bar = statusbar->progressbar;
gimp_statusbar_replace (statusbar, "progress", NULL, "%s", message);
#if 0
/* FIXME flush_expose */
gimp_widget_flush_expose (bar);
#endif
gimp_statusbar_override_window_title (statusbar);
}
@ -545,7 +549,10 @@ gimp_statusbar_progress_set_value (GimpProgress *progress,
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (bar),
percentage);
#if 0
/* FIXME flush_expose */
gimp_widget_flush_expose (bar);
#endif
}
}
}
@ -580,7 +587,10 @@ gimp_statusbar_progress_pulse (GimpProgress *progress)
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (bar));
#if 0
/* FIXME flush_expose */
gimp_widget_flush_expose (bar);
#endif
}
}
}

View file

@ -75,7 +75,7 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
GeglBuffer *cache,
const GeglRectangle *valid_rects,
gint n_valid_rects,
gboolean cancellable)
gboolean cancelable)
{
GeglNode *gegl;
GeglNode *effect;
@ -183,13 +183,13 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
gimp_progress_set_text_literal (progress, undo_desc);
progress_started = FALSE;
cancellable = FALSE;
cancelable = FALSE;
}
else
{
gimp_progress_start (progress, cancellable, "%s", undo_desc);
gimp_progress_start (progress, cancelable, "%s", undo_desc);
if (cancellable)
if (cancelable)
g_signal_connect (progress, "cancel",
G_CALLBACK (gimp_gegl_apply_operation_cancel),
&cancel);
@ -255,7 +255,6 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
value * rect_pixels) /
(gdouble) all_pixels);
if (cancellable)
while (! cancel && g_main_context_pending (NULL))
g_main_context_iteration (NULL, FALSE);
}
@ -279,7 +278,6 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
{
gimp_progress_set_value (progress, value);
if (cancellable)
while (! cancel && g_main_context_pending (NULL))
g_main_context_iteration (NULL, FALSE);
}
@ -306,7 +304,7 @@ gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
{
gimp_progress_end (progress);
if (cancellable)
if (cancelable)
g_signal_handlers_disconnect_by_func (progress,
gimp_gegl_apply_operation_cancel,
&cancel);

View file

@ -44,7 +44,7 @@ gboolean gimp_gegl_apply_cached_operation (GeglBuffer *src_buffer,
GeglBuffer *cache,
const GeglRectangle *valid_rects,
gint n_valid_rects,
gboolean cancellable);
gboolean cancelable);
/* apply specific operations */

View file

@ -457,10 +457,6 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool)
if (draw_tool->item)
gimp_display_shell_add_tool_item (shell, draw_tool->item);
#if 0
gimp_display_shell_flush (shell, TRUE);
#endif
draw_tool->last_draw_time = g_get_monotonic_time ();
#if 0

View file

@ -44,7 +44,7 @@
/* local function prototypes */
static GimpProgress * gimp_tool_progress_start (GimpProgress *progress,
gboolean cancellable,
gboolean cancelable,
const gchar *message);
static void gimp_tool_progress_end (GimpProgress *progress);
static gboolean gimp_tool_progress_is_active (GimpProgress *progress);
@ -84,7 +84,8 @@ gimp_tool_progress_button_press (GtkWidget *widget,
const GdkEventButton *bevent,
GimpTool *tool)
{
if (bevent->type == GDK_BUTTON_PRESS &&
if (tool->progress_cancelable &&
bevent->type == GDK_BUTTON_PRESS &&
bevent->button == 1)
{
GtkWidget *event_widget;
@ -115,7 +116,8 @@ gimp_tool_progress_key_press (GtkWidget *widget,
const GdkEventKey *kevent,
GimpTool *tool)
{
if (kevent->keyval == GDK_KEY_Escape)
if (tool->progress_cancelable &&
kevent->keyval == GDK_KEY_Escape)
{
gimp_progress_cancel (GIMP_PROGRESS (tool));
}
@ -125,7 +127,7 @@ gimp_tool_progress_key_press (GtkWidget *widget,
static GimpProgress *
gimp_tool_progress_start (GimpProgress *progress,
gboolean cancellable,
gboolean cancelable,
const gchar *message)
{
GimpTool *tool = GIMP_TOOL (progress);
@ -150,12 +152,9 @@ gimp_tool_progress_start (GimpProgress *progress,
gimp_progress_start (GIMP_PROGRESS (tool->progress), FALSE,
"%s", message);
gimp_widget_flush_expose (shell->canvas);
tool->progress_display = tool->display;
if (cancellable)
{
tool->progress_grab_widget = gtk_invisible_new ();
gtk_widget_show (tool->progress_grab_widget);
gtk_grab_add (tool->progress_grab_widget);
@ -166,7 +165,8 @@ gimp_tool_progress_start (GimpProgress *progress,
g_signal_connect (tool->progress_grab_widget, "key-press-event",
G_CALLBACK (gimp_tool_progress_key_press),
tool);
}
tool->progress_cancelable;
return progress;
}
@ -183,15 +183,13 @@ gimp_tool_progress_end (GimpProgress *progress)
gimp_progress_end (GIMP_PROGRESS (tool->progress));
gimp_display_shell_remove_unrotated_item (shell, tool->progress);
tool->progress = NULL;
tool->progress_display = NULL;
if (tool->progress_grab_widget)
{
gtk_grab_remove (tool->progress_grab_widget);
gtk_widget_destroy (tool->progress_grab_widget);
tool->progress = NULL;
tool->progress_display = NULL;
tool->progress_grab_widget = NULL;
}
tool->progress_cancelable = FALSE;
}
}
@ -210,12 +208,7 @@ gimp_tool_progress_set_text (GimpProgress *progress,
GimpTool *tool = GIMP_TOOL (progress);
if (tool->progress)
{
GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);
gimp_progress_set_text_literal (GIMP_PROGRESS (tool->progress), message);
gimp_widget_flush_expose (shell->canvas);
}
}
static void
@ -225,12 +218,7 @@ gimp_tool_progress_set_value (GimpProgress *progress,
GimpTool *tool = GIMP_TOOL (progress);
if (tool->progress)
{
GimpDisplayShell *shell = gimp_display_get_shell (tool->progress_display);
gimp_progress_set_value (GIMP_PROGRESS (tool->progress), percentage);
gimp_widget_flush_expose (shell->canvas);
}
}
static gdouble

View file

@ -75,6 +75,7 @@ struct _GimpTool
GimpCanvasItem *progress;
GimpDisplay *progress_display;
GtkWidget *progress_grab_widget;
gboolean progress_cancelable;
};
struct _GimpToolClass

View file

@ -98,6 +98,9 @@ gimp_transform_tool_real_transform (GimpTransformTool *tr_tool,
progress = gimp_progress_start (GIMP_PROGRESS (tool), FALSE,
"%s", klass->progress_text);
while (g_main_context_pending (NULL))
g_main_context_iteration (NULL, FALSE);
if (orig_buffer)
{
/* this happens when transforming a selection cut out of a

View file

@ -374,8 +374,6 @@ gimp_overlay_child_draw (GimpOverlayBox *box,
{
cairo_surface_t *surface;
gdk_window_process_updates (child->window, FALSE);
surface = gdk_offscreen_window_get_surface (child->window);
cairo_save (cr);

View file

@ -135,10 +135,6 @@ gimp_progress_box_progress_start (GimpProgress *progress,
box->cancellable = cancellable;
box->value = 0.0;
if (gtk_widget_is_drawable (box->progress))
gdk_window_process_updates (gtk_widget_get_window (box->progress),
TRUE);
return progress;
}
@ -179,10 +175,6 @@ gimp_progress_box_progress_set_text (GimpProgress *progress,
GimpProgressBox *box = GIMP_PROGRESS_BOX (progress);
gtk_label_set_text (GTK_LABEL (box->label), message);
if (gtk_widget_is_drawable (box->progress))
gdk_window_process_updates (gtk_widget_get_window (box->progress),
TRUE);
}
}
@ -205,8 +197,6 @@ gimp_progress_box_progress_set_value (GimpProgress *progress,
(percentage - gtk_progress_bar_get_fraction (bar))) > 1.0)
{
gtk_progress_bar_set_fraction (bar, box->value);
gimp_widget_flush_expose (box->progress);
}
}
}
@ -231,10 +221,6 @@ gimp_progress_box_progress_pulse (GimpProgress *progress)
GtkProgressBar *bar = GTK_PROGRESS_BAR (box->progress);
gtk_progress_bar_pulse (bar);
if (gtk_widget_is_drawable (box->progress))
gdk_window_process_updates (gtk_widget_get_window (box->progress),
TRUE);
}
}

View file

@ -1505,18 +1505,6 @@ gimp_tools_set_tool_options_gui (GimpToolOptions *tool_options,
widget ? (GDestroyNotify) g_object_unref : NULL);
}
void
gimp_widget_flush_expose (GtkWidget *widget)
{
g_return_if_fail (GTK_IS_WIDGET (widget));
if (! gtk_widget_is_drawable (widget))
return;
gdk_window_process_updates (gtk_widget_get_window (widget), FALSE);
gdk_display_flush (gtk_widget_get_display (widget));
}
gboolean
gimp_widget_get_fully_opaque (GtkWidget *widget)
{

View file

@ -101,8 +101,6 @@ GtkWidget * gimp_tools_get_tool_options_gui (GimpToolOptions *tool_o
void gimp_tools_set_tool_options_gui (GimpToolOptions *tool_options,
GtkWidget *widget);
void gimp_widget_flush_expose (GtkWidget *widget);
gboolean gimp_widget_get_fully_opaque (GtkWidget *widget);
void gimp_widget_set_fully_opaque (GtkWidget *widget,
gboolean fully_opaque);