app: reduce redraws on statusbar

This change reduces redraws due to spurious status updates.
Before this change, the status would be unset, then set again to the
same value it was previously. Each turn around setting and unsetting
causes a redraw.

On macOS this redraw causes a full screen redraw. With this
optimization, when the status message is unchanged, no redraw occurs.

This is because `gimp_tool_push_status` checks to see if the message
has changed.
This commit is contained in:
Lukas Oberhuber 2022-01-19 19:46:34 +00:00 committed by Jehan
parent 6ceaf14470
commit b4099de8cd
1 changed files with 11 additions and 5 deletions

View File

@ -607,6 +607,7 @@ gimp_paint_tool_oper_update (GimpTool *tool,
GimpDisplayShell *shell = gimp_display_get_shell (display);
GimpImage *image = gimp_display_get_image (display);
GList *drawables;
gchar *status = NULL;
if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
{
@ -621,8 +622,6 @@ gimp_paint_tool_oper_update (GimpTool *tool,
draw_tool->display != display)
gimp_draw_tool_stop (draw_tool);
gimp_tool_pop_status (tool, display);
if (tool->display &&
tool->display != display &&
gimp_display_get_image (tool->display) == image)
@ -642,7 +641,6 @@ gimp_paint_tool_oper_update (GimpTool *tool,
(g_list_length (drawables) > 1 && paint_tool->can_multi_paint)) &&
proximity)
{
gchar *status;
gboolean constrain_mask = gimp_get_constrain_behavior_mask ();
core->cur_coords = *coords;
@ -703,8 +701,6 @@ gimp_paint_tool_oper_update (GimpTool *tool,
NULL);
paint_tool->draw_line = FALSE;
}
gimp_tool_push_status (tool, display, "%s", status);
g_free (status);
paint_tool->cursor_x = core->cur_coords.x;
paint_tool->cursor_y = core->cur_coords.y;
@ -717,6 +713,16 @@ gimp_paint_tool_oper_update (GimpTool *tool,
gimp_draw_tool_stop (draw_tool);
}
if (status != NULL)
{
gimp_tool_push_status (tool, display, "%s", status);
g_free (status);
}
else
{
gimp_tool_pop_status (tool, display);
}
GIMP_TOOL_CLASS (parent_class)->oper_update (tool, coords, state, proximity,
display);