Commit 5f5e0bf5 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Refactored the GimpDisplayShell update/draw code:

2003-02-21  Michael Natterer  <mitch@gimp.org>

	Refactored the GimpDisplayShell update/draw code:

	* app/display/gimpdisplayshell.[ch]: removed the display_areas
	list which used to hold the GimpAreas to update. Instead, simply
	queue draws using gtk_widget_queue_draw[_area]() in
	gimp_display_shell_expose_area(), _expose_full() and
	_expose_guide(). Made all _draw() functions public because they
	are now called from the "expose_event" handler.  Removed rendering
	from gimp_display_shell_flush() because stuff is now flushed
	automatically by the gtk idle renderer.

	* app/display/gimpdisplayshell-callbacks.c
	(gimp_display_shell_canvas_expose): draw everything here (the code
	removed from gimp_display_shell_flush() without the GimpArea list).
	(gimp_display_shell_canvas_tool_events): return "return_val", not
	TRUE if gimp->busy is TRUE. Fixes unupdated (windowk bg color)
	display areas. Fixes bug #106595.

	* app/display/gimpdisplay.c
	* app/display/gimpdisplayshell-cursor.c
	* app/display/gimpdisplayshell-filter-dialog.c
	* app/display/gimpdisplayshell-handlers.c
	* app/display/gimpdisplayshell-selection.c
	* app/gui/view-commands.c: changed accordingly. Removed calls to
	gimp_display_shell_flush() all over the place.

	* app/display/gimpdisplayshell-scroll.c: replaced lots of code by
	a single call to gdk_window_scroll().
parent 99d52e76
2003-02-21 Michael Natterer <mitch@gimp.org>
Refactored the GimpDisplayShell update/draw code:
* app/display/gimpdisplayshell.[ch]: removed the display_areas
list which used to hold the GimpAreas to update. Instead, simply
queue draws using gtk_widget_queue_draw[_area]() in
gimp_display_shell_expose_area(), _expose_full() and
_expose_guide(). Made all _draw() functions public because they
are now called from the "expose_event" handler. Removed rendering
from gimp_display_shell_flush() because stuff is now flushed
automatically by the gtk idle renderer.
* app/display/gimpdisplayshell-callbacks.c
(gimp_display_shell_canvas_expose): draw everything here (the code
removed from gimp_display_shell_flush() without the GimpArea list).
(gimp_display_shell_canvas_tool_events): return "return_val", not
TRUE if gimp->busy is TRUE. Fixes unupdated (windowk bg color)
display areas. Fixes bug #106595.
* app/display/gimpdisplay.c
* app/display/gimpdisplayshell-cursor.c
* app/display/gimpdisplayshell-filter-dialog.c
* app/display/gimpdisplayshell-handlers.c
* app/display/gimpdisplayshell-selection.c
* app/gui/view-commands.c: changed accordingly. Removed calls to
gimp_display_shell_flush() all over the place.
* app/display/gimpdisplayshell-scroll.c: replaced lots of code by
a single call to gdk_window_scroll().
2003-02-21 Sven Neumann <sven@gimp.org>
 
* INSTALL: fixed URL of libart package, spotted by Michael J. Hammel.
......
......@@ -186,7 +186,6 @@ view_toggle_selection_cmd_callback (GtkWidget *widget,
if (GTK_CHECK_MENU_ITEM (widget)->active == shell->select->hidden)
{
gimp_display_shell_selection_toggle (shell->select);
gimp_display_shell_flush (shell);
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->menubar_factory),
"/View/Show Selection",
......@@ -211,7 +210,6 @@ view_toggle_layer_boundary_cmd_callback (GtkWidget *widget,
if (GTK_CHECK_MENU_ITEM (widget)->active == shell->select->layer_hidden)
{
gimp_display_shell_selection_toggle_layer (shell->select);
gimp_display_shell_flush (shell);
gimp_item_factory_set_active (GTK_ITEM_FACTORY (shell->menubar_factory),
"/View/Show Layer Boundary",
......
......@@ -585,8 +585,6 @@ gimp_display_idlerender_callback (gpointer data)
gimp_display_paint_area (gdisp, workx, worky, workw, workh);
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell));
gdisp->idle_render.x += CHUNK_WIDTH;
if (gdisp->idle_render.x >=
......@@ -673,6 +671,5 @@ gimp_display_paint_area (GimpDisplay *gdisp,
gimp_display_shell_transform_xy (shell, x, y, &x1, &y1, FALSE);
gimp_display_shell_transform_xy (shell, x + w, y + h, &x2, &y2, FALSE);
gimp_display_shell_add_expose_area (shell,
x1, y1, (x2 - x1), (y2 - y1));
gimp_display_shell_expose_area (shell, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -585,8 +585,6 @@ gimp_display_idlerender_callback (gpointer data)
gimp_display_paint_area (gdisp, workx, worky, workw, workh);
gimp_display_shell_flush (GIMP_DISPLAY_SHELL (gdisp->shell));
gdisp->idle_render.x += CHUNK_WIDTH;
if (gdisp->idle_render.x >=
......@@ -673,6 +671,5 @@ gimp_display_paint_area (GimpDisplay *gdisp,
gimp_display_shell_transform_xy (shell, x, y, &x1, &y1, FALSE);
gimp_display_shell_transform_xy (shell, x + w, y + h, &x2, &y2, FALSE);
gimp_display_shell_add_expose_area (shell,
x1, y1, (x2 - x1), (y2 - y1));
gimp_display_shell_expose_area (shell, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -318,25 +318,38 @@ gimp_display_shell_canvas_expose (GtkWidget *widget,
GdkEventExpose *eevent,
GimpDisplayShell *shell)
{
glong x1, y1, x2, y2;
GdkRectangle *rects;
gint n_rects;
gint i;
x1 = eevent->area.x;
y1 = eevent->area.y;
x2 = (eevent->area.x + eevent->area.width);
y2 = (eevent->area.y + eevent->area.height);
/* pause the currently active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
x1 = CLAMP (x1, 0, shell->disp_width);
y1 = CLAMP (y1, 0, shell->disp_height);
x2 = CLAMP (x2, 0, shell->disp_width);
y2 = CLAMP (y2, 0, shell->disp_height);
gdk_region_get_rectangles (eevent->region, &rects, &n_rects);
if ((x2 - x1) && (y2 - y1))
{
gimp_display_shell_add_expose_area (shell,
x1, y1,
(x2 - x1), (y2 - y1));
gimp_display_shell_flush (shell);
}
for (i = 0; i < n_rects; i++)
gimp_display_shell_draw_area (shell,
rects[i].x,
rects[i].y,
rects[i].width,
rects[i].height);
g_free (rects);
/* draw the guides */
gimp_display_shell_draw_guides (shell);
/* and the cursor (if we have a software cursor) */
if (shell->have_cursor)
gimp_display_shell_draw_cursor (shell);
/* restart (and recalculate) the selection boundaries */
gimp_display_shell_selection_start (shell->select, TRUE);
/* start the currently active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
return TRUE;
}
......@@ -1095,7 +1108,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
/* if we reached this point in gimp_busy mode, return now */
if (gimp->busy)
return TRUE;
return return_val;
/* cursor update support */
......@@ -1304,9 +1317,6 @@ gimp_display_shell_color_button_changed (GtkWidget *widget,
gimp_display_shell_set_padding (shell,
GIMP_DISPLAY_PADDING_MODE_CUSTOM,
&color);
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
void
......@@ -1343,9 +1353,6 @@ gimp_display_shell_color_button_menu_callback (gpointer callback_data,
gimp_display_shell_set_padding (shell, callback_action,
&shell->padding_color);
}
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
}
......@@ -1661,8 +1668,8 @@ gimp_display_shell_compress_motion (GimpDisplayShell *shell)
for (list = requeued_events; list; list = g_list_next (list))
{
gdk_event_put ((GdkEvent*) list->data);
gdk_event_free ((GdkEvent*) list->data);
gdk_event_put ((GdkEvent *) list->data);
gdk_event_free ((GdkEvent *) list->data);
}
g_list_free (requeued_events);
......
......@@ -115,7 +115,6 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
{
GimpImage *gimage;
gboolean new_cursor;
gboolean flush = FALSE;
gint t_x = -1;
gint t_y = -1;
......@@ -134,25 +133,17 @@ gimp_display_shell_update_cursor (GimpDisplayShell *shell,
x != shell->cursor_x ||
y != shell->cursor_y))
{
gimp_display_shell_add_expose_area (shell,
shell->cursor_x - 7,
shell->cursor_y - 7,
15, 15);
gimp_display_shell_expose_area (shell,
shell->cursor_x - 7,
shell->cursor_y - 7,
15, 15);
if (! new_cursor)
{
shell->have_cursor = FALSE;
flush = TRUE;
}
shell->have_cursor = FALSE;
}
shell->have_cursor = new_cursor;
shell->cursor_x = x;
shell->cursor_y = y;
if (new_cursor || flush)
{
gimp_display_shell_flush (shell);
}
if (x > 0 && y > 0)
{
......
......@@ -56,7 +56,6 @@
#include "tools/tool_manager.h"
#include "gimpdisplay.h"
#include "gimpdisplay-area.h"
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-cursor.h"
......@@ -90,13 +89,6 @@ static void gimp_display_shell_destroy (GtkObject *object
static gboolean gimp_display_shell_delete_event (GtkWidget *widget,
GdkEventAny *aevent);
static void gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
static void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
static void gimp_display_shell_close_warning_dialog (GimpDisplayShell *shell,
GimpImage *gimage);
static void gimp_display_shell_close_warning_callback (GtkWidget *widget,
......@@ -207,8 +199,6 @@ gimp_display_shell_init (GimpDisplayShell *shell)
shell->select = NULL;
shell->display_areas = NULL;
shell->hsbdata = NULL;
shell->vsbdata = NULL;
......@@ -340,8 +330,6 @@ gimp_display_shell_destroy (GtkObject *object)
shell->select = NULL;
}
shell->display_areas = gimp_display_area_list_free (shell->display_areas);
gimp_display_shell_filter_detach_all (shell);
if (shell->render_buf)
......@@ -1052,23 +1040,15 @@ gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
}
void
gimp_display_shell_add_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
{
GimpArea *area;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
area = gimp_area_new (CLAMP (x, 0, shell->disp_width),
CLAMP (y, 0, shell->disp_height),
CLAMP (x + w, 0, shell->disp_width),
CLAMP (y + h, 0, shell->disp_height));
shell->display_areas = gimp_display_area_list_process (shell->display_areas,
area);
gtk_widget_queue_draw_area (shell->canvas, x, y, w, h);
}
void
......@@ -1093,11 +1073,11 @@ gimp_display_shell_expose_guide (GimpDisplayShell *shell,
switch (guide->orientation)
{
case GIMP_ORIENTATION_HORIZONTAL:
gimp_display_shell_add_expose_area (shell, 0, y, shell->disp_width, 1);
gimp_display_shell_expose_area (shell, 0, y, shell->disp_width, 1);
break;
case GIMP_ORIENTATION_VERTICAL:
gimp_display_shell_add_expose_area (shell, x, 0, 1, shell->disp_height);
gimp_display_shell_expose_area (shell, x, 0, 1, shell->disp_height);
break;
default:
......@@ -1110,10 +1090,7 @@ gimp_display_shell_expose_full (GimpDisplayShell *shell)
{
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
gimp_display_shell_add_expose_area (shell,
0, 0,
shell->disp_width,
shell->disp_height);
gtk_widget_queue_draw (shell->canvas);
}
void
......@@ -1130,49 +1107,8 @@ gimp_display_shell_flush (GimpDisplayShell *shell)
/* update the gdisplay's info dialog */
info_window_update (shell->gdisp);
if (shell->display_areas)
{
GSList *list;
GimpArea *area;
/* stop the currently active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
for (list = shell->display_areas; list; list = g_slist_next (list))
{
/* Paint the area specified by the GimpArea */
area = (GimpArea *) list->data;
gimp_display_shell_display_area (shell,
area->x1,
area->y1,
(area->x2 - area->x1),
(area->y2 - area->y1));
}
/* Free the update lists */
shell->display_areas = gimp_display_area_list_free (shell->display_areas);
/* draw the guides */
gimp_display_shell_draw_guides (shell);
/* and the cursor (if we have a software cursor) */
if (shell->have_cursor)
gimp_display_shell_draw_cursor (shell);
/* restart (and recalculate) the selection boundaries */
gimp_display_shell_selection_start (shell->select, TRUE);
/* start the currently active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
}
}
void
gimp_display_shell_update_icon (GimpDisplayShell *shell)
{
......@@ -1279,6 +1215,8 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
gimp_display_shell_color_button_changed,
shell);
}
gimp_display_shell_expose_full (shell);
}
void
......@@ -1528,15 +1466,12 @@ gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
}
}
/* private functions */
static void
gimp_display_shell_display_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
void
gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h)
{
gint sx, sy;
gint x1, y1;
......@@ -1544,6 +1479,8 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
gint dx, dy;
gint i, j;
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
sx = SCALEX (shell, shell->gdisp->gimage->width);
sy = SCALEY (shell, shell->gdisp->gimage->height);
......@@ -1634,7 +1571,7 @@ gimp_display_shell_display_area (GimpDisplayShell *shell,
}
}
static void
void
gimp_display_shell_draw_cursor (GimpDisplayShell *shell)
{
gint x, y;
......@@ -1664,6 +1601,9 @@ gimp_display_shell_draw_cursor (GimpDisplayShell *shell)
x+1, y - 7, x+1, y + 7);
}
/* private functions */
static void
gimp_display_shell_close_warning_dialog (GimpDisplayShell *shell,
GimpImage *gimage)
......
......@@ -95,8 +95,6 @@ struct _GimpDisplayShell
Selection *select; /* Selection object */
GSList *display_areas; /* display areas list */
GtkAdjustment *hsbdata; /* adjustments */
GtkAdjustment *vsbdata;
......@@ -201,7 +199,7 @@ gboolean gimp_display_shell_mask_bounds (GimpDisplayShell *shell,
gint *x2,
gint *y2);
void gimp_display_shell_add_expose_area (GimpDisplayShell *shell,
void gimp_display_shell_expose_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
......@@ -211,17 +209,24 @@ void gimp_display_shell_expose_guide (GimpDisplayShell *shell,
void gimp_display_shell_expose_full (GimpDisplayShell *shell);
void gimp_display_shell_flush (GimpDisplayShell *shell);
void gimp_display_shell_update_icon (GimpDisplayShell *shell);
void gimp_display_shell_set_padding (GimpDisplayShell *shell,
GimpDisplayPaddingMode mode,
GimpRGB *color);
void gimp_display_shell_draw_area (GimpDisplayShell *shell,
gint x,
gint y,
gint w,
gint h);
void gimp_display_shell_draw_cursor (GimpDisplayShell *shell);
void gimp_display_shell_draw_guide (GimpDisplayShell *shell,
GimpGuide *guide,
gboolean active);
void gimp_display_shell_draw_guides (GimpDisplayShell *shell);
void gimp_display_shell_update_icon (GimpDisplayShell *shell);
void gimp_display_shell_set_padding (GimpDisplayShell *shell,
GimpDisplayPaddingMode mode,
GimpRGB *color);
void gimp_display_shell_shrink_wrap (GimpDisplayShell *shell);
void gimp_display_shell_selection_visibility (GimpDisplayShell *shell,
......
......@@ -43,7 +43,6 @@
#define UPDATE_DISPLAY(cdd) G_STMT_START \
{ \
gimp_display_shell_expose_full ((cdd)->shell); \
gimp_display_shell_flush ((cdd)->shell); \
} G_STMT_END
......
......@@ -384,9 +384,6 @@ gimp_display_shell_check_notify_handler (GObject *config,
default:
break;
}
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
static void
......@@ -431,7 +428,6 @@ gimp_display_shell_monitor_res_notify_handler (GObject *config,
gimp_statusbar_resize_cursor (GIMP_STATUSBAR (shell->statusbar));
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
}
......@@ -450,9 +446,6 @@ gimp_display_shell_padding_notify_handler (GObject *config,
gimp_display_shell_set_padding (shell,
display_config->canvas_padding_mode,
&display_config->canvas_padding_color);
gimp_display_shell_expose_full (shell);
gimp_display_shell_flush (shell);
}
}
......
......@@ -43,8 +43,6 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
gint y_offset)
{
gint old_x, old_y;
gint src_x, src_y;
gint dest_x, dest_y;
GdkEvent *event;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), FALSE);
......@@ -67,65 +65,22 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
*/
gimp_display_shell_scale_setup (shell);
src_x = (x_offset < 0) ? 0 : x_offset;
src_y = (y_offset < 0) ? 0 : y_offset;
dest_x = (x_offset < 0) ? -x_offset : 0;
dest_y = (y_offset < 0) ? -y_offset : 0;
/* reset the old values so that the tool can accurately redraw */
shell->offset_x = old_x;
shell->offset_y = old_y;
/* freeze the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, PAUSE,
shell->gdisp);
gdk_window_scroll (shell->canvas->window, -x_offset, -y_offset);
/* set the offsets back to the new values */
shell->offset_x += x_offset;
shell->offset_y += y_offset;
gdk_draw_drawable (shell->canvas->window,
shell->render_gc,
shell->canvas->window,
src_x, src_y,
dest_x, dest_y,
(shell->disp_width - abs (x_offset)),
(shell->disp_height - abs (y_offset)));
/* re-enable the active tool */
tool_manager_control_active (shell->gdisp->gimage->gimp, RESUME,
shell->gdisp);
/* scale the image into the exposed regions */
if (x_offset)
{
src_x = (x_offset < 0) ? 0 : shell->disp_width - x_offset;
src_y = 0;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
abs (x_offset),
shell->disp_height);
}
if (y_offset)
{
src_x = 0;
src_y = (y_offset < 0) ? 0 : shell->disp_height - y_offset;
gimp_display_shell_add_expose_area (shell,
src_x, src_y,
shell->disp_width,
abs (y_offset));
}
if (x_offset || y_offset)
{
gimp_display_flush (shell->gdisp);
}
gimp_display_shell_scrolled (shell);
/* Make sure graphics expose events are processed before scrolling
* again
*/
......@@ -146,6 +101,8 @@ gimp_display_shell_scroll (GimpDisplayShell *shell,
gdk_window_process_updates (shell->canvas->window, FALSE);
gimp_display_shell_scrolled (shell);
return TRUE;
}
......
......@@ -311,9 +311,9 @@ gimp_display_shell_selection_invis (Selection *select)
/* Find the bounds of the selection */
if (gimp_display_shell_mask_bounds (select->shell, &x1, &y1, &x2, &y2))
{
gimp_display_shell_add_expose_area (select->shell,
x1, y1,
(x2 - x1), (y2 - y1));
gimp_display_shell_expose_area (select->shell,
x1, y1,
(x2 - x1), (y2 - y1));
}
else
{
......@@ -351,18 +351,18 @@ gimp_display_shell_selection_layer_invis (Selection *select)
y4 = select->segs_layer[3].y2 - 1;
/* expose the region */
gimp_display_shell_add_expose_area (select->shell,