24 #include "gmag-graphical-server.h"
30 #ifdef HAVE_COLORBLIND
31 #include <colorblind.h>
37 #ifdef USE_GDKPIXBUF_RENDER_TO_DRAWABLE
38 #include <gdk/gdkpixbuf.h>
42 #include <libbonobo.h>
45 #undef ZOOM_REGION_DEBUG
53 #define DEBUG_CLIENT_CALLS
55 #ifdef DEBUG_CLIENT_CALLS
57 #define DBG(a) if (client_debug) { (a); }
96 #ifdef DEBUG_CLIENT_CALLS
137 #ifdef HAVE_COLORBLIND
138 static COLORBLIND_RUNTIME *cbr = NULL;
139 static COLORBLIND_XCOLOR *color = NULL;
160 #define CLAMP_B_C(v) (t = (v), CLAMP (t, -1, 1));
165 const GdkRectangle rect);
167 const GdkRectangle rect);
210 #define DEBUG_RECT(a, b) _debug_announce_rect (a, b)
212 #define DEBUG_RECT(a, b)
217 fprintf (stderr,
"%s: (%d,%d - %d,%d)\n",
218 msg, rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
224 struct_bounds->
x1 = (*vector_bounds)[0];
225 struct_bounds->
y1 = (*vector_bounds)[1];
226 struct_bounds->
x2 = (*vector_bounds)[2];
227 struct_bounds->
y2 = (*vector_bounds)[3];
234 int bits_per_byte = 8;
235 guchar *pa = gdk_pixbuf_get_pixels (a);
236 guchar *pb = gdk_pixbuf_get_pixels (b);
238 long rsa = gdk_pixbuf_get_rowstride (a);
239 long rsb = gdk_pixbuf_get_rowstride (b);
240 long rowbytes = gdk_pixbuf_get_width (a) *
241 gdk_pixbuf_get_bits_per_sample (a) *
242 gdk_pixbuf_get_n_channels (a)/ bits_per_byte;
243 long n_rows = gdk_pixbuf_get_height (a);
245 if (gdk_pixbuf_get_height (b) != n_rows)
247 if (gdk_pixbuf_get_width (b) != gdk_pixbuf_get_width (a))
249 for (j = 0; j < n_rows; ++j)
253 for (i = 0; i < rowbytes; ++i)
268 #ifdef BROKEN_COALESCE_STUFF_GETS_FIXED
279 _combine_rects (GdkRectangle *a, GdkRectangle *b)
281 gboolean can_combine = FALSE;
282 if ((a->x == b->x) && (a->x + a->width == b->x + b->width))
286 else if ((a->y == b->y) && (a->y + a->height == b->y + b->height))
294 if (gdk_rectangle_intersect (a, b, &c))
296 gdk_rectangle_union (a, b, &c);
322 _refactor_rects (GdkRectangle *p, GdkRectangle *n)
324 gboolean refactored = FALSE;
328 if (p->width < n->width)
338 if (a->y == b->y + b->height)
341 a->height += b->height;
343 b->width -= a->width;
346 else if (a->y + a->height == b->y)
348 a->height += b->height;
350 b->width -= a->width;
353 if (refactored) fprintf (stderr,
"REFACTOR 1\n");
355 else if (p->y == n->y)
357 if (p->height < n->height)
367 if (a->x == b->x + b->width)
370 a->width += b->width;
372 b->height -= a->height;
375 else if (a->x + a->width == b->x)
377 a->width += b->width;
379 b->height -= a->height;
382 if (refactored) fprintf (stderr,
"REFACTOR 2\n");
384 else if (p->x + p->width == n->x + n->width)
386 if (p->width < n->width)
396 if (a->y == b->y + b->height)
399 a->height += b->height;
400 b->width -= a->width;
403 else if (a->y + a->height == b->y)
405 a->height += b->height;
406 b->width -= a->width;
409 if (refactored) fprintf (stderr,
"REFACTOR 3\n");
411 else if (p->y + p->height == n->y + n->height)
413 if (p->height < n->height)
423 if (a->x == b->x + b->width)
426 a->width += b->width;
427 b->height -= a->height;
430 else if (a->x + a->width == b->x)
432 a->width += b->width;
433 b->height -= a->height;
436 if (refactored) fprintf (stderr,
"REFACTOR 4\n");
442 _combine_update_rects (GList *q,
int lookahead_n)
445 GdkRectangle *a = q->data;
447 while (i < lookahead_n && p && p->next)
449 if (_combine_rects (a, q->next->data))
451 q = g_list_delete_link (q, p->next);
465 #define _is_horizontal_rect(r) ((r)->width > (r)->height)
466 #define _is_vertical_rect(r) ((r)->height > (r)->width)
477 GdkRectangle *v = NULL, *h = NULL;
478 GList *compact_queue = NULL;
480 if (g_list_length (q) < min_coalesce_length)
481 return g_list_copy (q);
486 if (v) gdk_rectangle_union (v, q->data, v);
489 v = g_new0 (GdkRectangle, 1);
490 *v = *(GdkRectangle *)q->data;
495 if (h) gdk_rectangle_union (h, q->data, h);
498 h = g_new0 (GdkRectangle, 1);
499 *h = *(GdkRectangle *)q->data;
503 compact_queue = g_list_prepend (compact_queue, q->data);
507 compact_queue = g_list_prepend (compact_queue, v);
509 compact_queue = g_list_prepend (compact_queue, h);
512 return compact_queue;
515 #ifdef BROKEN_COALESCE_STUFF_GETS_FIXED
517 _smartbutbroken_coalesce_update_rects (GList *q,
int lookahead_n)
520 fprintf (stderr,
"starting queue length = %d\n", g_list_length (q));
523 len = g_list_length (q);
524 q = _combine_update_rects (q, lookahead_n);
526 while (i < lookahead_n && q && q->next)
528 if (_refactor_rects (a, q->next->data))
533 q = _combine_update_rects (q, lookahead_n);
534 }
while (g_list_length (q) < len);
535 fprintf (stderr,
"ending queue length = %d\n", g_list_length (q));
545 GdkRectangle clip_rect)
547 GdkRectangle clipped;
548 clipped.x = MAX (area.x, clip_rect.x);
549 clipped.y = MAX (area.y, clip_rect.y);
550 clipped.width = MIN ((area.x + area.width), (clip_rect.x + clip_rect.width)) - clipped.x;
551 clipped.height = MIN ((area.y + area.height), (clip_rect.y + clip_rect.height)) - clipped.y;
559 area.x = MAX (area.x, clip_bounds->
x1);
560 area.x = MIN (area.x, clip_bounds->
x2);
561 area.width = MIN (area.width, clip_bounds->
x2 - area.x);
562 area.y = MAX (area.y, clip_bounds->
y1);
563 area.y = MIN (area.y, clip_bounds->
y2);
564 area.height = MIN (area.height, clip_bounds->
y2 - area.y);
573 if (zoom_region && zoom_region->
priv && zoom_region->
priv->
parent)
609 GdkRectangle pixmap_area = {0, 0, 0, 0};
612 gdk_drawable_get_size (zoom_region->
priv->
pixmap, &pixmap_area.width, &pixmap_area.height);
623 GdkRectangle window_rect;
629 if (gtk_widget_get_window (zoom_region->
priv->
w))
630 gdk_drawable_get_size (GDK_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)),
645 GdkRectangle source_rect;
650 source_rect.width = ceil ((view_bounds->
x2 - view_bounds->
x1) / zoom_region->
xscale) + 1;
651 source_rect.height = ceil ((view_bounds->
y2 - view_bounds->
y1) / zoom_region->
yscale) + 1;
657 const GdkRectangle source_rect)
659 GdkRectangle view_rect;
662 view_rect.width = source_rect.width * zoom_region->
xscale;
663 view_rect.height = source_rect.height * zoom_region->
yscale;
665 DEBUG_RECT (
"converted to view-rect", view_rect);
671 const GdkRectangle view_rect)
673 GdkRectangle source_rect;
678 source_rect.width = ceil (view_rect.width / zoom_region->
xscale) + 1;
679 source_rect.height = ceil (view_rect.height / zoom_region->
yscale) + 1;
690 rect.width = bounds->
x2 - bounds->
x1;
691 rect.height = bounds->
y2 - bounds->
y1;
700 gdouble x_old = zoom_region->
xscale;
701 gdouble y_old = zoom_region->
yscale;
717 zoom_region->
xscale = x_old;
718 zoom_region->
yscale = y_old;
741 const GdkRectangle update_rect)
744 g_new0 (GdkRectangle, 1);
747 #ifdef ZOOM_REGION_DEBUG
748 g_assert (zoom_region->alive);
752 zoom_region->
priv->
q =
753 g_list_prepend (zoom_region->
priv->
q, rect);
756 g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
765 #ifdef ZOOM_REGION_DEBUG
766 g_assert (zoom_region->alive);
768 if (zoom_region->
priv)
770 gboolean pixmap_valid = GDK_IS_DRAWABLE (zoom_region->
priv->
pixmap);
784 GdkRectangle rect = {0, 0, 0, 0};
786 GdkDrawable *cursor = NULL;
796 gdk_drawable_get_size (cursor, &rect.width, &rect.height);
803 GdkRectangle *clip_rect)
806 GdkRectangle vline_rect, hline_rect;
809 #ifdef ZOOM_REGION_DEBUG
810 g_assert (zoom_region->alive);
816 vline_rect.y = clip_rect ? clip_rect->y : 0;
818 vline_rect.height = clip_rect ? clip_rect->height : 4096;
819 hline_rect.x = clip_rect ? clip_rect->x : 0;
821 hline_rect.width = clip_rect ? clip_rect->width : 4096;
832 static GdkColormap *cmap;
833 static GdkColor last_color;
834 static gboolean last_color_init = FALSE;
838 GdkColor color = {0, 0, 0, 0};
839 int x_start = 0, y_start = 0, x_end = 4096, y_end = 4096;
840 int x_left_clip = 0, x_right_clip = 0, y_top_clip = 0, y_bottom_clip = 0;
843 #ifdef ZOOM_REGION_DEBUG
844 g_assert (zoom_region->alive);
847 gtk_widget_get_window (zoom_region->
priv->
w) &&
848 GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)) &&
855 last_color_init = FALSE;
862 color.green = 0xFFFF;
863 values.function = GDK_INVERT;
870 values.function = GDK_COPY;
873 values.foreground = color;
876 if (!last_color_init || color.red != last_color.red ||
877 color.blue != last_color.blue || color.green != last_color.green)
881 gdk_rgb_find_color (cmap, &(values.foreground));
882 gdk_gc_set_values(zoom_region->
priv->
crosswire_gc, &values, GDK_GC_FUNCTION | GDK_GC_FOREGROUND);
886 gdk_gc_set_values(zoom_region->
priv->
crosswire_gc, &values, GDK_GC_FUNCTION);
889 last_color.red = color.red;
890 last_color.blue = color.blue;
891 last_color.green = color.green;
892 last_color_init = TRUE;
900 if (clip_rect) gdk_gc_set_clip_rectangle (zoom_region->
priv->
crosswire_gc, clip_rect);
904 gdk_drawable_get_size (cursor, &csize, &csize);
931 y_bottom_clip = rect.y +
936 x_right_clip = rect.x +
943 gdk_draw_line (gtk_widget_get_window (zoom_region->
priv->
w),
945 rect.x, y_top_clip, rect.x,
947 gdk_draw_line (gtk_widget_get_window (zoom_region->
priv->
w),
949 x_left_clip, rect.y, x_right_clip,
952 gdk_draw_line (gtk_widget_get_window (zoom_region->
priv->
w),
954 rect.x, y_start, rect.x, y_end);
955 gdk_draw_line (gtk_widget_get_window (zoom_region->
priv->
w),
957 x_start, rect.y, x_end, rect.y);
962 gtk_widget_get_window (zoom_region->
priv->
w),
966 y_bottom_clip - y_top_clip);
968 gtk_widget_get_window (zoom_region->
priv->
w),
972 x_right_clip - x_left_clip,
976 gtk_widget_get_window (zoom_region->
priv->
w),
981 gtk_widget_get_window (zoom_region->
priv->
w),
991 #ifdef ZOOM_REGION_DEBUG
992 g_assert (zoom_region->alive);
1001 GdkRectangle *clip_rect)
1004 GdkRectangle rect, intersct;
1005 GdkRectangle fullscreen;
1008 #ifdef ZOOM_REGION_DEBUG
1009 g_assert (zoom_region->alive);
1014 if (clip_rect == NULL)
1018 clip_rect = &fullscreen;
1024 if (gdk_rectangle_intersect (clip_rect, &rect, &intersct))
1026 int width = 0, height = 0;
1031 else if (!GDK_IS_DRAWABLE (cursor)) g_message (
"cursor isn't DRAWABLE!");
1037 if (rect.width != width || rect.height != height)
1043 gdk_pixmap_new (gtk_widget_get_window (zoom_region->
priv->
w),
1048 if (gtk_widget_get_window (zoom_region->
priv->
w) != NULL)
1054 gtk_widget_get_window (zoom_region->
priv->
w),
1062 if (cursor && zoom_region->
priv->
w && GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
1068 values.clip_x_origin = rect.x;
1069 values.clip_y_origin = rect.y;
1072 GDK_GC_CLIP_Y_ORIGIN | GDK_GC_CLIP_MASK);
1074 gdk_draw_rectangle (gtk_widget_get_window (zoom_region->
priv->
w),
1077 rect.x, rect.y, rect.width, rect.height);
1079 gdk_draw_drawable (gtk_widget_get_window (zoom_region->
priv->
w),
1100 int lookahead_n = 4;
1103 if (zoom_region->
priv && zoom_region->
priv->
q && g_list_length (zoom_region->
priv->
q) > max_qlen)
1105 g_list_free (zoom_region->
priv->
q);
1106 zoom_region->
priv->
q = NULL;
1113 if (zoom_region->
priv && zoom_region->
priv->
q &&
1116 q = g_list_reverse (g_list_copy (zoom_region->
priv->
q));
1119 GList *coalesce_copy;
1123 coalesce_copy = (*zoom_region->
coalesce_func) (q, lookahead_n);
1124 new = g_list_reverse (coalesce_copy);
1125 g_list_free (zoom_region->
priv->
q);
1126 zoom_region->
priv->
q =
new;
1139 #ifdef ZOOM_REGION_DEBUG
1140 g_assert (zoom_region->alive);
1146 (gtk_widget_get_window (zoom_region->
priv->
border))) {
1147 color.red = (((zoom_region->
border_color & 0xFF0000) >> 16) *
1149 color.green = (((zoom_region->
border_color & 0xFF00) >> 8) *
1151 color.blue = ((zoom_region->
border_color & 0xFF) * 65535) /
1155 fprintf (stderr,
"border color triple RGB=%d|%d|%d\n",
1156 color.red, color.green, color.blue);
1159 gtk_widget_modify_bg (zoom_region->
priv->
border,
1160 GTK_STATE_NORMAL, &color);
1168 #ifdef ZOOM_REGION_DEBUG
1169 g_assert (zoom_region->alive);
1171 g_assert (zoom_region->
priv);
1172 g_assert (zoom_region->
priv->
w);
1174 if (!GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
return;
1176 zoom_region->
priv->
default_gc = gdk_gc_new (gtk_widget_get_window (zoom_region->
priv->
w));
1178 if (zoom_region->
priv->
pixmap && GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
1180 gdk_draw_drawable (gtk_widget_get_window (zoom_region->
priv->
w),
1199 GdkRectangle paint_area;
1201 #ifdef ZOOM_REGION_DEBUG
1202 g_assert (zoom_region->alive);
1214 #ifdef ZOOM_REGION_DEBUG
1215 g_assert (zoom_region->alive);
1217 if (zoom_region->
priv->
w && GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
1225 gtk_widget_get_window (zoom_region->
priv->
w),
1228 gdk_drawable_get_depth (
1229 gtk_widget_get_window (zoom_region->
priv->
w)));
1231 if (gmag_gs_error_check ()) {
1237 (zoom_region, &zoom_region->
viewport));
1249 GdkEventExpose *event,
1255 #ifdef ZOOM_REGION_DEBUG
1256 g_assert (zoom_region->alive);
1264 zoom_region->
xscale -= 1.0;
1265 zoom_region->
yscale -= 1.0;
1267 g_warning (
"Scale factor too big to fit in memory; shrinking.");
1270 g_warning (
"create-pixmap: no target drawable");
1280 GdkRectangle *clip_rect)
1282 #ifdef ZOOM_REGION_DEBUG
1283 g_assert (zoom_region->alive);
1293 if (GTK_IS_WIDGET (zoom_region->
priv->
w) &&
1294 GDK_IS_WINDOW (gtk_widget_get_window (zoom_region->
priv->
w)))
1295 gdk_display_sync (gdk_drawable_get_display (
1296 gtk_widget_get_window (zoom_region->
priv->
w)));
1302 GdkRectangle *scroll_rect,
1303 GdkRectangle *expose_rect_h,
1304 GdkRectangle *expose_rect_v)
1306 GdkWindow *window = NULL;
1307 GdkRectangle rect = {0, 0, 0, 0};
1308 gboolean retval = TRUE;
1310 #ifdef ZOOM_REGION_DEBUG
1311 g_assert (zoom_region->alive);
1315 if (zoom_region && zoom_region->
priv->
w &&
1316 gtk_widget_get_window (zoom_region->
priv->
w))
1317 window = gtk_widget_get_window (zoom_region->
priv->
w);
1324 gdk_drawable_get_size (GDK_DRAWABLE (window),
1328 if ((ABS (dx) >= rect.width) || (ABS (dy) >= rect.height)) {
1329 *scroll_rect = rect;
1330 DBG(fprintf (stderr,
"deltas too big to scroll\n"));
1334 scroll_rect->x = MAX (0, dx);
1335 scroll_rect->y = MAX (0, dy);
1336 scroll_rect->width = MIN (rect.width + dx, rect.width - dx);
1337 scroll_rect->height = MIN (rect.height + dy, rect.height - dy);
1340 expose_rect_h->x = 0;
1341 expose_rect_h->y = (scroll_rect->y == 0) ? scroll_rect->height : 0;
1342 expose_rect_h->width = rect.width;
1343 expose_rect_h->height = rect.height - scroll_rect->height;
1345 expose_rect_v->x = (scroll_rect->x == 0) ? scroll_rect->width : 0;
1346 expose_rect_v->y = scroll_rect->y;
1347 expose_rect_v->width = rect.width - scroll_rect->width;
1348 expose_rect_v->height = scroll_rect->height;
1355 GdkRectangle *scroll_rect,
1356 GdkRectangle *expose_rect_h,
1357 GdkRectangle *expose_rect_v)
1361 #ifdef ZOOM_REGION_DEBUG
1362 g_assert (zoom_region->alive);
1364 if (zoom_region->
priv->
w && gtk_widget_get_window (zoom_region->
priv->
w))
1365 window = gtk_widget_get_window (zoom_region->
priv->
w);
1372 gdk_window_scroll (window, dx, dy);
1375 gdk_window_process_updates (window, FALSE);
1379 gdk_display_sync (gdk_drawable_get_display (window));
1384 GdkRectangle *scroll_rect,
1385 GdkRectangle *expose_rect_h,
1386 GdkRectangle *expose_rect_v)
1388 GdkWindow *window = NULL;
1389 GdkRectangle window_rect;
1391 #ifdef ZOOM_REGION_DEBUG
1392 g_assert (zoom_region->alive);
1394 if (zoom_region->
priv->
w && GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
1395 window = gtk_widget_get_window (zoom_region->
priv->
w);
1400 gdk_drawable_get_size (GDK_DRAWABLE (window),
1401 &window_rect.width, &window_rect.height);
1402 gdk_window_begin_paint_rect (window, &window_rect);
1403 gdk_window_invalidate_rect (window, &window_rect, FALSE);
1404 gdk_window_process_updates (window, FALSE);
1405 gdk_window_end_paint (window);
1411 GdkRectangle scroll_rect, expose_rect_h, expose_rect_v;
1412 gboolean can_scroll;
1414 #ifdef ZOOM_REGION_DEBUG
1415 g_assert (zoom_region->alive);
1424 fprintf(stderr,
" Panning Increment (x) = %d (avg. %f) lines/frame\n",
1426 fprintf(stderr,
" Panning Increment (y) = %d (avg. %f) lines/frame\n",
1474 if (zoom_region->
priv)
1485 gint mouse_x_return, mouse_y_return;
1488 #ifdef ZOOM_REGION_DEBUG
1489 g_assert (zoom_region->alive);
1500 gdk_window_get_pointer (
1530 if (zoom_region->
priv)
1532 g_timeout_add_full (G_PRIORITY_DEFAULT,
1549 g_idle_add_full (G_PRIORITY_HIGH_IDLE,
1560 const long x,
const long y)
1564 #ifdef ZOOM_REGION_DEBUG
1565 g_assert (zoom_region->alive);
1572 if ((dx != 0) || (dy != 0)) {
1588 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
1590 int w = gdk_pixbuf_get_width (pixbuf);
1591 int h = gdk_pixbuf_get_height (pixbuf);
1592 int n_channels = gdk_pixbuf_get_n_channels (pixbuf);
1593 guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
1596 gboolean manipulate_contrast = FALSE;
1597 gboolean manipulate_brightness = FALSE;
1598 gboolean color_blind_filter = FALSE;
1602 manipulate_contrast = TRUE;
1607 manipulate_brightness = TRUE;
1610 #ifdef HAVE_COLORBLIND
1613 color_blind_filter = TRUE;
1617 if (!manipulate_contrast && !zoom_region->
invert &&
1618 !manipulate_brightness && !color_blind_filter)
1621 #define CLAMP_UCHAR(v) (t = (v), CLAMP (t, 0, 255))
1622 #define CLAMP_LOW_MID(v) (t = (v), CLAMP (t, 0, 127))
1623 #define CLAMP_MID_HIGH(v) (t = (v), CLAMP (t, 127, 255))
1625 for (j = 0; j < h; ++j) {
1626 pixels_row = pixels;
1627 for (i = 0; i < w; ++i) {
1628 if (manipulate_contrast) {
1630 if (pixels_row[0] <= 127)
1636 if (pixels_row[1] <= 127)
1642 if (pixels_row[2] <= 127)
1648 if (manipulate_brightness) {
1659 if (zoom_region->
invert) {
1660 pixels_row[0] = ~(pixels_row[0]);
1661 pixels_row[1] = ~(pixels_row[1]);
1662 pixels_row[2] = ~(pixels_row[2]);
1665 #ifdef HAVE_COLORBLIND
1666 if (color_blind_filter) {
1667 color->red = pixels_row[0];
1668 color->green = pixels_row[1];
1669 color->blue = pixels_row[2];
1670 if (colorblind_filter (cbr, color)) {
1671 pixels_row[0] = color->red;
1672 pixels_row[1] = color->green;
1673 pixels_row[2] = color->blue;
1678 pixels_row += n_channels;
1680 pixels += rowstride;
1687 GdkPixbuf *subimage,
1688 GdkPixbuf *scaled_image)
1704 const GdkRectangle bounds)
1706 int i, j, width, height;
1708 GdkPixbuf *subimage = NULL;
1710 #ifdef ZOOM_REGION_DEBUG
1711 g_assert (zoom_region->alive);
1713 width = gdk_screen_get_width (
1716 height = gdk_screen_get_height (
1720 if ((bounds.width <= 0) || (bounds.height <= 0))
1729 GdkImage *test_image = NULL;
1731 test_image = gdk_image_new (GDK_IMAGE_FASTEST,
1732 gdk_visual_get_system (),
1736 for (i = 0; i < width; ++i)
1737 for (j = 0; j < height; ++j)
1738 gdk_image_put_pixel (test_image, i, j, i*j);
1740 zoom_region->
priv->
source_drawable = gdk_pixmap_new (gtk_widget_get_window (zoom_region->
priv->
w), width, height, -1);
1763 gdk_pixbuf_new (GDK_COLORSPACE_RGB,
1769 DEBUG_RECT (
"getting subimage from ", bounds);
1772 gdk_colormap_get_system (),
1787 GdkPixbuf *cache_subpixbuf =
1789 bounds.x, bounds.y, bounds.width, bounds.height);
1791 gdk_pixbuf_copy_area (subimage, 0, 0, bounds.width, bounds.height,
1793 bounds.x, bounds.y);
1798 g_object_unref (subimage);
1801 g_object_unref (cache_subpixbuf);
1808 const GdkRectangle update_rect,
1809 GdkRectangle *p_rect)
1811 GdkPixbuf *subimage;
1812 GdkRectangle source_rect;
1814 #ifdef ZOOM_REGION_DEBUG
1815 g_assert (zoom_region->alive);
1817 DEBUG_RECT (
"unclipped update rect", update_rect);
1819 DEBUG_RECT (
"clipped to source", source_rect);
1821 DEBUG_RECT (
"update rect clipped to exposed target", source_rect);
1827 GdkRectangle paint_rect;
1832 *p_rect = paint_rect;
1843 gdk_pixbuf_scale (subimage,
1860 #ifndef USE_GDK_PIXBUF_RENDER_TO_DRAWABLE
1861 if (GDK_IS_DRAWABLE (zoom_region->
priv->
pixmap))
1871 GDK_RGB_DITHER_NONE,
1875 g_warning (
"updating non-drawable pixmap: region %p", zoom_region);
1886 GDK_RGB_DITHER_NONE,
1890 if (gmag_gs_error_check ())
1891 g_warning (
"Could not render scaled image to drawable; out of memory!\n");
1892 g_object_unref (subimage);
1907 const GdkRectangle update_rect)
1909 GdkRectangle paint_rect = {0, 0, 0, 0};
1910 if (zoom_region->
priv->
w && gtk_widget_get_window (zoom_region->
priv->
w)) {
1912 if (paint_rect.x != 0 || paint_rect.y != 0 ||
1913 paint_rect.width != 0 || paint_rect.height != 0) {
1914 gdk_window_begin_paint_rect (
1915 gtk_widget_get_window (zoom_region->
priv->
w), &paint_rect);
1917 gdk_window_end_paint (gtk_widget_get_window (zoom_region->
priv->
w));
1922 gulong microseconds;
1938 fprintf(stderr,
" Update Duration = %f (avg. %f) (max. %f) (tot. %f) seconds\n",
1941 fprintf(stderr,
" Update Pixels = %ld (avg. %ld) pixels/frame\n",
1942 (
long) source_rect.height * source_rect.width,
1944 fprintf(stderr,
" Update Rate = (avg. %f) (max. %f) updates/second\n",
1946 fprintf(stderr,
" Net Update Rate = (avg. %f) (max. %f) Mpex/second\n",
1952 fprintf (stderr,
"update on uninitialized zoom region!\n");
1960 GtkWidget *zoomer, *border;
1961 DBG(fprintf (stderr,
"window not yet created...\n"));
1962 parent = GTK_FIXED (
1964 zoomer = gtk_drawing_area_new ();
1965 border = gtk_drawing_area_new ();
1967 zoom_region->
priv->
w = zoomer;
1969 #ifdef ZOOM_REGION_DEBUG
1970 g_assert (zoom_region->alive);
1972 gtk_widget_set_size_request (GTK_WIDGET (border),
1977 gtk_widget_set_size_request (GTK_WIDGET (zoomer),
1986 gtk_fixed_put (parent, border,
1989 gtk_fixed_put (parent, zoomer,
1994 gtk_widget_show (GTK_WIDGET (border));
1995 gtk_widget_show (GTK_WIDGET (zoomer));
1996 gtk_widget_show (GTK_WIDGET (parent));
1998 g_signal_connect (G_OBJECT (zoom_region->
priv->
w),
2002 DBG(fprintf (stderr,
"New window created\n"));
2013 if (zoom_region->
priv->
q != NULL) {
2014 GList *last = g_list_last (zoom_region->
priv->
q);
2015 #ifdef ZOOM_REGION_DEBUG
2016 fprintf (stderr,
"qlen=%d\n", g_list_length (zoom_region->
priv->
q));
2019 zoom_region->
priv->
q = g_list_remove_link (zoom_region->
priv->
q,
2022 * (GdkRectangle *) last->data);
2025 fputs (
".\n", stderr);
2032 if (zoom_region->
priv)
2042 float x_scroll_incr, y_scroll_incr;
2043 int width, height, x, y;
2056 gdk_drawable_get_size (GDK_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)),
2059 fprintf(stderr,
" Frames Processed = %ld\n",
2061 fprintf(stderr,
" Width/Height/Depth = %d/%d/%d\n", x, y,
2062 gdk_drawable_get_depth (gtk_widget_get_window (zoom_region->
priv->
w)));
2063 fprintf(stderr,
" Zoom Factor (x/y) = %f/%f\n", zoom_region->
xscale,
2066 fprintf(stderr,
" Update Duration = (avg. %f) (max. %f) (tot. %f) seconds\n",
2068 fprintf(stderr,
" Update Pixels = (avg. %ld) pixels/frame\n",
2070 fprintf(stderr,
" Update Rate = (avg. %f) (max. %f) updates/second\n",
2073 fprintf(stderr,
" Net Update Rate = (avg. %f) (max. %f) Mpex/second\n",
2077 fprintf(stderr,
" Pan Latency = (avg. %f) (max. %f) seconds\n",
2079 fprintf(stderr,
" Total Frame Duration = (avg. %f) (max. %f) (tot. %f) seconds\n",
2081 fprintf(stderr,
" Frame Rate = (avg. %f) (max. %f) frames/second\n",
2083 fprintf(stderr,
" Scroll Delta (x) = (avg. %f) (tot. %d) lines\n",
2085 fprintf(stderr,
" Scroll Delta (y) = (avg. %f) (tot. %d) lines\n",
2087 fprintf(stderr,
" Scroll Rate (x) = (avg. %f) lines/second\n",
2088 x_scroll_incr / frame_avg);
2089 fprintf(stderr,
" Scroll Rate (y) = (avg. %f) lines/second\n",
2090 y_scroll_incr / frame_avg);
2092 fprintf(stderr,
" Net Render Rate = (avg. %f) (max. %f) Mpex/second\n\n",
2103 float x_scroll_incr, y_scroll_incr;
2110 gulong microseconds;
2130 fprintf(stderr,
" Total Frame Duration = %f (avg. %f) (max. %f) (tot. %f) seconds\n",
2132 fprintf(stderr,
" Frame Rate = (avg. %f) (max. %f) frames/second\n",
2134 fprintf(stderr,
" Scroll Delta (x) = (avg. %f) (tot. %d) lines\n",
2136 fprintf(stderr,
" Scroll Delta (y) = (avg. %f) (tot. %d) lines\n",
2138 fprintf(stderr,
" Scroll Rate (x) = (avg. %f) lines/second\n",
2139 x_scroll_incr / frame_avg);
2140 fprintf(stderr,
" Scroll Rate (y) = (avg. %f) lines/second\n",
2141 y_scroll_incr / frame_avg);
2143 fprintf(stderr,
" Net Render Rate = (avg. %f) (max. %f) Mpex/second\n",
2153 fprintf(stderr,
"\n### Updates summary:\n\n");
2155 fprintf(stderr,
"\n### Updates finished, starting panning test\n");
2164 while (zoom_region->
priv->
q)
2180 gulong microseconds;
2190 fprintf(stderr,
" Pan Latency = %f (avg. %f) (max. %f) seconds\n",
2211 *x = zoom_region->
roi.
x2 - width;
2214 *x = zoom_region->
roi.
x1;
2218 *x = ((zoom_region->
roi.
x1 + zoom_region->
roi.
x2) - width ) /
2224 *y = zoom_region->
roi.
y2 - height;
2227 *y = zoom_region->
roi.
y1;
2231 *y = ((zoom_region->
roi.
y1 + zoom_region->
roi.
y2) - height ) /
2251 gdk_drawable_get_size (GDK_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)),
2254 fprintf(stderr,
"\nTiming Information - ROI = (%d, %d) (%d, %d):\n",
2256 zoom_region->
roi.
y2);
2257 fprintf(stderr,
" Frame Number = %ld\n",
2259 fprintf(stderr,
" Width/Height/Depth = %d/%d/%d\n", x, y,
2260 gdk_drawable_get_depth (gtk_widget_get_window (zoom_region->
priv->
w)));
2292 g_idle_add_full (GDK_PRIORITY_REDRAW + 1,
2304 #ifdef ZOOM_REGION_DEBUG
2305 g_assert (zoom_region->alive);
2315 fprintf (stderr,
"Setting viewport %d,%d - %d,%d\n",
2316 (
int) viewport->
x1, (
int) viewport->
y1,
2317 (
int) viewport->
x2, (
int) viewport->
y2);
2320 if (!zoom_region->
priv->
w) {
2324 CORBA_Environment ev;
2327 GtkFixed *fixed = GTK_FIXED (magnifier->
priv->
canvas);
2328 gtk_fixed_move (fixed,
2332 gtk_fixed_move (fixed,
2333 zoom_region->
priv->
w,
2338 gtk_widget_set_size_request (
2342 gtk_widget_set_size_request (GTK_WIDGET (zoom_region->
priv->
w),
2351 CORBA_exception_init (&ev);
2356 if (!BONOBO_EX (&ev))
2358 properties,
"source-display-bounds", &ev);
2359 if (!BONOBO_EX (&ev))
2369 gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
2377 zoom_region, &zoom_region->
viewport));
2384 CORBA_Environment *ev,
2389 #ifdef ZOOM_REGION_DEBUG
2390 g_assert (zoom_region->alive);
2392 DBG (fprintf (stderr,
"Get zoom-region property: %s\n",
prop_names[arg_id]));
2396 BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->
is_managed);
2399 BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->
poll_mouse);
2402 BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->
draw_cursor);
2405 BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->
invert);
2414 BONOBO_ARG_SET_BOOLEAN (arg, zoom_region->
priv->
test);
2417 BONOBO_ARG_SET_STRING (arg, zoom_region->
smoothing);
2420 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
contrast_r);
2423 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
contrast_g);
2426 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
contrast_b);
2429 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
bright_r);
2432 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
bright_g);
2435 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
bright_b);
2438 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
xscale);
2441 BONOBO_ARG_SET_FLOAT (arg, zoom_region->
yscale);
2444 BONOBO_ARG_SET_LONG (
2470 BONOBO_ARG_SET_LONG (arg,
2474 BONOBO_ARG_SET_GENERAL (arg, zoom_region->
viewport,
2499 gtk_widget_set_size_request (GTK_WIDGET (zoom_region->
priv->
border),
2504 gtk_widget_set_size_request (GTK_WIDGET (zoom_region->
priv->
w),
2536 g_message (
"Adding polling timer");
2543 g_message (
"Removing polling time");
2577 zoom_region->
invert = invert;
2586 return zoom_region->
invert;
2621 zoom_region->
smoothing = g_strdup (smoothing);
2622 if (!strncmp (zoom_region->
smoothing,
"bilinear", 8)) {
2635 return g_strdup (zoom_region->
smoothing);
2674 ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
2734 bounds->
x1 = (*viewport)[0];
2735 bounds->
y1 = (*viewport)[1];
2736 bounds->
x2 = (*viewport)[2];
2737 bounds->
y2 = (*viewport)[3];
2751 ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
2753 g_array_append_val (ret, zoom_region->
viewport.
x1);
2754 g_array_append_val (ret, zoom_region->
viewport.
y1);
2755 g_array_append_val (ret, zoom_region->
viewport.
x2);
2756 g_array_append_val (ret, zoom_region->
viewport.
y2);
2823 CORBA_Environment *ev,
2830 #ifdef ZOOM_REGION_DEBUG
2831 g_assert (zoom_region->alive);
2833 DBG (fprintf (stderr,
"Set zoom-region property: %s\n",
prop_names[arg_id]));
2837 zoom_region->
is_managed = BONOBO_ARG_GET_BOOLEAN (arg);
2840 zoom_region->
poll_mouse = BONOBO_ARG_GET_BOOLEAN (arg);
2843 g_message (
"Adding polling timer");
2845 g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
2853 g_message (
"Removing polling timer");
2859 zoom_region->
draw_cursor = BONOBO_ARG_GET_BOOLEAN (arg);
2864 zoom_region->
invert = BONOBO_ARG_GET_BOOLEAN (arg);
2877 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_saturate_red);
2880 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_saturate_green);
2883 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_saturate_blue);
2886 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_dessaturate_red);
2889 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_dessaturate_green);
2892 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_dessaturate_blue);
2895 colorblind_set_filter_type (cbr, colorblind_filter_t_hue_shift_positive);
2898 colorblind_set_filter_type (cbr, colorblind_filter_t_hue_shift_negative);
2901 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_saturate);
2904 colorblind_set_filter_type (cbr, colorblind_filter_t_selective_dessaturate);
2907 colorblind_set_filter_type (cbr, colorblind_filter_t_monochrome_others);
2914 zoom_region->
smoothing = BONOBO_ARG_GET_STRING (arg);
2915 if (!strncmp (zoom_region->
smoothing,
"bilinear", 8))
2922 zoom_region->
priv->
test = BONOBO_ARG_GET_BOOLEAN (arg);
2961 BONOBO_ARG_GET_FLOAT (arg),
2967 BONOBO_ARG_GET_FLOAT (arg));
2975 BONOBO_ARG_GET_LONG (arg);
2996 BONOBO_ARG_GET_LONG (arg);
3009 bounds = BONOBO_ARG_GET_GENERAL (arg,
3039 #ifdef ZOOM_REGION_DEBUG
3040 g_assert (zoom_region->alive);
3053 CORBA_Environment ev;
3054 static int counter = 0;
3055 static gboolean finished_update = !TRUE;
3056 static float last_pixels_at_speed = -1;
3057 float pixels_at_speed;
3059 int screen_height, height;
3061 int pixel_direction;
3063 screen_height = gdk_screen_get_height (
3075 gulong microseconds;
3082 pixels_at_speed = 0.0;
3085 if ((
int)(last_pixels_at_speed) == (
int)(pixels_at_speed))
3088 pixel_position = (int)(pixels_at_speed) % (screen_height - height);
3089 counter = (int)(pixels_at_speed) / (screen_height - height);
3090 pixel_direction = counter % 2;
3092 if (!finished_update) {
3093 if ((
int)(pixels_at_speed) > (zoom_region->
roi.
y1 + height))
3094 roi.
y1 = zoom_region->
roi.
y1 + height;
3096 roi.
y1 = (
int)(pixels_at_speed);
3098 if (roi.
y1 >= screen_height - height) {
3099 roi.
y1 = screen_height - height;
3102 if (pixel_direction == 0)
3103 roi.
y1 = screen_height - height - pixel_position;
3105 roi.
y1 = pixel_position;
3108 roi.
y2 = roi.
y1 + height;
3117 BONOBO_OBJREF (magnifier), &ev);
3119 if (zoom_regions && (zoom_regions->
_length > 0)) {
3121 zoom_regions->
_buffer[0], &roi, &ev);
3124 if (!finished_update) {
3126 if (roi.
y1 == screen_height - height) {
3127 finished_update = TRUE;
3132 last_pixels_at_speed = pixels_at_speed;
3139 const CORBA_long mouse_x,
3140 const CORBA_long mouse_y,
3141 CORBA_Environment *ev)
3144 ZOOM_REGION (bonobo_object_from_servant (servant));
3145 GdkRectangle paint_area, *clip = NULL;
3147 #ifdef ZOOM_REGION_DEBUG
3148 g_assert (zoom_region->alive);
3150 DBG (fprintf (stderr,
"Set Pointer: \t%ld,%ld\n",
3151 (
long) mouse_x, (
long) mouse_y));
3153 fprintf (stderr,
"Set Pointer: \t%ld,%ld\n",
3154 (
long) mouse_x, (
long) mouse_y);
3158 if (GTK_IS_WIDGET (zoom_region->
priv->
w) &&
3159 GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
3161 gdk_drawable_get_size (
3163 gtk_widget_get_window (zoom_region->
priv->
w)),
3164 &paint_area.width, &paint_area.height);
3169 zoom_region, paint_area);
3180 const CORBA_float R,
3181 const CORBA_float G,
3182 const CORBA_float B,
3183 CORBA_Environment *ev)
3186 ZOOM_REGION (bonobo_object_from_servant (servant));
3189 #ifdef ZOOM_REGION_DEBUG
3190 g_assert (zoom_region->alive);
3192 DBG (fprintf (stderr,
"Set contrast: \t%f,%f %f\n", R, G, B));
3212 CORBA_Environment *ev)
3215 ZOOM_REGION (bonobo_object_from_servant (servant));
3217 #ifdef ZOOM_REGION_DEBUG
3218 g_assert (zoom_region->alive);
3228 const CORBA_float R,
3229 const CORBA_float G,
3230 const CORBA_float B,
3231 CORBA_Environment *ev)
3234 ZOOM_REGION (bonobo_object_from_servant (servant));
3237 #ifdef ZOOM_REGION_DEBUG
3238 g_assert (zoom_region->alive);
3240 DBG (fprintf (stderr,
"Set brightness: \t%f,%f %f\n", R, G, B));
3260 CORBA_Environment *ev)
3263 ZOOM_REGION (bonobo_object_from_servant (servant));
3265 #ifdef ZOOM_REGION_DEBUG
3266 g_assert (zoom_region->alive);
3277 CORBA_Environment *ev)
3280 ZOOM_REGION (bonobo_object_from_servant (servant));
3282 #ifdef ZOOM_REGION_DEBUG
3283 g_assert (zoom_region->alive);
3285 DBG (fprintf (stderr,
"Set ROI: \t%d,%d %d,%d\n",
3286 bounds->
x1, bounds->
y1, bounds->
x2, bounds->
y2));
3288 if ((zoom_region->
roi.
x1 == bounds->
x1) &&
3289 (zoom_region->
roi.
x2 == bounds->
x2) &&
3290 (zoom_region->
roi.
y1 == bounds->
y1) &&
3291 (zoom_region->
roi.
y2 == bounds->
y2)) {
3296 if (!bounds || (bounds->
x2 <= bounds->
x1)
3297 || (bounds->
y2 < bounds->
y1) ||
3298 ((bounds->
x1 + bounds->
x2)/2 < 0) ||
3299 ((bounds->
y1 + bounds->
y2)/2 < 0))
3301 g_warning (
"Bad bounds request (%d,%d to %d,%d), ignoring.\n",
3302 bounds->
x1, bounds->
y1, bounds->
x2, bounds->
y2);
3306 zoom_region->
roi = *bounds;
3310 g_idle_add_full (GDK_PRIORITY_REDRAW + 3,
3316 fprintf(stderr,
"\n### Timing Summary:\n\n");
3342 "\n [Last update not finished, pending - ROI=(%d, %d) (%d, %d)]\n\n",
3344 zoom_region->
roi.
y2);
3351 static CORBA_boolean
3353 const CORBA_float mag_factor_x,
3354 const CORBA_float mag_factor_y,
3355 CORBA_Environment *ev)
3358 ZOOM_REGION (bonobo_object_from_servant (servant));
3360 #ifdef ZOOM_REGION_DEBUG
3361 g_assert (zoom_region->alive);
3364 CORBA_boolean retval = CORBA_TRUE;
3366 if ((zoom_region->
xscale == mag_factor_x) &&
3367 (zoom_region->
yscale == mag_factor_y)) {
3377 properties,
"source-display-bounds", ev);
3378 if (!BONOBO_EX (ev))
3382 retval = CORBA_FALSE;
3385 mag_factor_x, mag_factor_y);
3388 bonobo_object_release_unref (properties, NULL);
3394 CORBA_float *mag_factor_x,
3395 CORBA_float *mag_factor_y,
3396 CORBA_Environment *ev)
3399 ZOOM_REGION (bonobo_object_from_servant (servant));
3401 #ifdef ZOOM_REGION_DEBUG
3402 g_assert (zoom_region->alive);
3404 *mag_factor_x = zoom_region->
xscale;
3405 *mag_factor_y = zoom_region->
yscale;
3410 CORBA_Environment *ev)
3413 ZOOM_REGION (bonobo_object_from_servant (servant));
3415 #ifdef ZOOM_REGION_DEBUG
3416 g_assert (zoom_region->alive);
3418 return bonobo_object_dup_ref (
3419 BONOBO_OBJREF (zoom_region->
properties), ev);
3424 CORBA_Environment *ev)
3427 ZOOM_REGION (bonobo_object_from_servant (servant));
3429 #ifdef ZOOM_REGION_DEBUG
3430 g_assert (zoom_region->alive);
3439 CORBA_Environment *ev)
3442 ZOOM_REGION (bonobo_object_from_servant (servant));
3444 #ifdef ZOOM_REGION_DEBUG
3445 g_assert (zoom_region->alive);
3448 zoom_region, roi_dirty) );
3459 CORBA_Environment *ev)
3462 ZOOM_REGION (bonobo_object_from_servant (servant));
3464 #ifdef ZOOM_REGION_DEBUG
3465 g_assert (zoom_region->alive);
3467 return zoom_region->
roi;
3473 CORBA_Environment *ev)
3476 ZOOM_REGION (bonobo_object_from_servant (servant));
3478 #ifdef ZOOM_REGION_DEBUG
3479 g_assert (zoom_region->alive);
3488 DBG(g_message (
"disposing region %p", zoom_region));
3490 GTK_IS_WIDGET (zoom_region->
priv->
w)) {
3491 g_signal_handler_disconnect (
3492 zoom_region->
priv->
w,
3500 g_idle_remove_by_data (zoom_region);
3502 #ifdef ZOOM_REGION_DEBUG
3503 zoom_region->alive = FALSE;
3509 CORBA_Environment *ev)
3512 ZOOM_REGION (bonobo_object_from_servant (servant));
3527 #ifdef ZOOM_REGION_DEBUG
3528 g_assert (zoom_region->alive);
3530 CORBA_Environment ev;
3531 CORBA_exception_init (&ev);
3533 gboolean retval = TRUE;
3535 if ((zoom_region->
xscale == mag_factor_x) &&
3536 (zoom_region->
yscale == mag_factor_y)) {
3546 properties,
"source-display-bounds", &ev);
3547 if (!BONOBO_EX (&ev))
3566 ret = g_array_new (FALSE, FALSE,
sizeof (gdouble));
3568 g_array_append_val (ret, zoom_region->
xscale);
3569 g_array_append_val (ret, zoom_region->
yscale);
3580 #ifdef ZOOM_REGION_DEBUG
3581 g_assert (zoom_region->alive);
3583 DBG (fprintf (stderr,
"Set ROI: \t%d,%d %d,%d\n",
3584 bounds->
x1, bounds->
y1, bounds->
x2, bounds->
y2));
3586 if ((zoom_region->
roi.
x1 == bounds->
x1) &&
3587 (zoom_region->
roi.
x2 == bounds->
x2) &&
3588 (zoom_region->
roi.
y1 == bounds->
y1) &&
3589 (zoom_region->
roi.
y2 == bounds->
y2)) {
3594 if (!bounds || (bounds->
x2 <= bounds->
x1)
3595 || (bounds->
y2 < bounds->
y1) ||
3596 ((bounds->
x1 + bounds->
x2)/2 < 0) ||
3597 ((bounds->
y1 + bounds->
y2)/2 < 0))
3599 g_warning (
"Bad bounds request (%d,%d to %d,%d), ignoring.\n",
3600 bounds->
x1, bounds->
y1, bounds->
x2, bounds->
y2);
3604 zoom_region->
roi.
x1 = bounds->
x1;
3605 zoom_region->
roi.
y1 = bounds->
y1;
3606 zoom_region->
roi.
x2 = bounds->
x2;
3607 zoom_region->
roi.
y2 = bounds->
y2;
3611 g_idle_add_full (GDK_PRIORITY_REDRAW + 3,
3617 fprintf(stderr,
"\n### Timing Summary:\n\n");
3643 "\n [Last update not finished, pending - ROI=(%d, %d) (%d, %d)]\n\n",
3645 zoom_region->
roi.
y2);
3658 #ifdef ZOOM_REGION_DEBUG
3659 g_assert (zoom_region->alive);
3671 roi_dirty->
x1 = (*bounds)[0];
3672 roi_dirty->
y1 = (*bounds)[1];
3673 roi_dirty->
x2 = (*bounds)[2];
3674 roi_dirty->
y2 = (*bounds)[3];
3676 #ifdef ZOOM_REGION_DEBUG
3677 g_assert (zoom_region->alive);
3680 zoom_region, roi_dirty) );
3696 ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
3698 g_array_append_val (ret, zoom_region->
roi.
x1);
3699 g_array_append_val (ret, zoom_region->
roi.
y1);
3700 g_array_append_val (ret, zoom_region->
roi.
x2);
3701 g_array_append_val (ret, zoom_region->
roi.
y2);
3709 #ifdef ZOOM_REGION_DEBUG
3710 g_assert (zoom_region->alive);
3713 viewport_bounds->
x1 = (*viewport)[0];
3714 viewport_bounds->
y1 = (*viewport)[1];
3715 viewport_bounds->
x2 = (*viewport)[2];
3716 viewport_bounds->
y2 = (*viewport)[3];
3726 GdkRectangle paint_area, *clip = NULL;
3728 #ifdef ZOOM_REGION_DEBUG
3729 g_assert (zoom_region->alive);
3731 DBG (fprintf (stderr,
"Set Pointer: \t%ld,%ld\n",
3732 (
long) mouse_x, (
long) mouse_y));
3734 fprintf (stderr,
"Set Pointer: \t%ld,%ld\n",
3735 (
long) mouse_x, (
long) mouse_y);
3739 if (GTK_IS_WIDGET (zoom_region->
priv->
w) &&
3740 GDK_IS_DRAWABLE (gtk_widget_get_window (zoom_region->
priv->
w)))
3742 gdk_drawable_get_size (
3744 gtk_widget_get_window (zoom_region->
priv->
w)),
3745 &paint_area.width, &paint_area.height);
3750 zoom_region, paint_area);
3766 #ifdef ZOOM_REGION_DEBUG
3767 g_assert (zoom_region->alive);
3769 DBG (fprintf (stderr,
"Set contrast: \t%f,%f %f\n", R, G, B));
3791 ret = g_array_new (FALSE, FALSE,
sizeof (gdouble));
3793 g_array_append_val (ret, zoom_region->
contrast_r);
3794 g_array_append_val (ret, zoom_region->
contrast_g);
3795 g_array_append_val (ret, zoom_region->
contrast_b);
3805 #ifdef ZOOM_REGION_DEBUG
3806 g_assert (zoom_region->alive);
3808 DBG (fprintf (stderr,
"Set brightness: \t%f,%f %f\n", R, G, B));
3830 ret = g_array_new (FALSE, FALSE,
sizeof (gdouble));
3832 g_array_append_val (ret, zoom_region->
bright_r);
3833 g_array_append_val (ret, zoom_region->
bright_g);
3834 g_array_append_val (ret, zoom_region->
bright_b);
3847 BONOBO_CALL_PARENT (G_OBJECT_CLASS, dispose, (
object));
3853 GObjectClass * object_class = (GObjectClass *) klass;
3876 #ifdef DEBUG_CLIENT_CALLS
3877 client_debug = (g_getenv (
"MAG_CLIENT_DEBUG") != NULL);
3887 bonobo_property_bag_new_closure (
3888 g_cclosure_new_object (
3890 G_OBJECT (zoom_region)),
3891 g_cclosure_new_object (
3893 G_OBJECT (zoom_region)));
3895 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
3896 BONOBO_ARG_SET_BOOLEAN (def, TRUE);
3898 bonobo_property_bag_add (zoom_region->
properties,
3903 "If false, zoom region does not auto-update, but is drawn into directly by the client",
3907 bonobo_arg_release (def);
3908 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
3909 BONOBO_ARG_SET_BOOLEAN (def, TRUE);
3911 bonobo_property_bag_add (zoom_region->
properties,
3916 "If false, zoom region does not poll for pointer location, but is (exclusively) given it by the client",
3920 bonobo_arg_release (def);
3921 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
3922 BONOBO_ARG_SET_BOOLEAN (def, TRUE);
3924 bonobo_property_bag_add (zoom_region->
properties,
3929 "If false, zoom region does not draw the cursor.",
3933 bonobo_arg_release (def);
3934 def = bonobo_arg_new (BONOBO_ARG_SHORT);
3937 bonobo_property_bag_add (zoom_region->
properties,
3938 "smooth-scroll-policy",
3942 "scrolling policy, slower versus faster",
3946 bonobo_arg_release (def);
3947 def = bonobo_arg_new (BONOBO_ARG_SHORT);
3948 BONOBO_ARG_SET_SHORT (
3952 bonobo_property_bag_add (zoom_region->
properties,
3953 "color-blind-filter",
3957 "color blind filter to apply in an image",
3961 bonobo_arg_release (def);
3962 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
3963 BONOBO_ARG_SET_BOOLEAN (def, FALSE);
3965 bonobo_property_bag_add (zoom_region->
properties,
3970 "use test pattern for source",
3974 bonobo_arg_release (def);
3975 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
3976 BONOBO_ARG_SET_BOOLEAN (def, TRUE);
3978 bonobo_property_bag_add (zoom_region->
properties,
3983 "inverse video display",
3987 bonobo_arg_release (def);
3989 bonobo_property_bag_add (zoom_region->
properties,
3994 "image smoothing algorithm used",
3998 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
3999 BONOBO_ARG_SET_FLOAT (def, 0.0);
4001 bonobo_property_bag_add (zoom_region->
properties,
4006 "red image contrast ratio",
4009 bonobo_arg_release (def);
4011 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4012 BONOBO_ARG_SET_FLOAT (def, 0.0);
4014 bonobo_property_bag_add (zoom_region->
properties,
4019 "green image contrast ratio",
4022 bonobo_arg_release (def);
4024 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4025 BONOBO_ARG_SET_FLOAT (def, 0.0);
4027 bonobo_property_bag_add (zoom_region->
properties,
4032 "blue image contrast ratio",
4035 bonobo_arg_release (def);
4037 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4038 BONOBO_ARG_SET_FLOAT (def, 0.0);
4040 bonobo_property_bag_add (zoom_region->
properties,
4045 "red image brightness ratio",
4048 bonobo_arg_release (def);
4050 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4051 BONOBO_ARG_SET_FLOAT (def, 0.0);
4053 bonobo_property_bag_add (zoom_region->
properties,
4058 "green image brightness ratio",
4061 bonobo_arg_release (def);
4063 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4064 BONOBO_ARG_SET_FLOAT (def, 0.0);
4066 bonobo_property_bag_add (zoom_region->
properties,
4071 "blue image brightness ratio",
4074 bonobo_arg_release (def);
4076 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4077 BONOBO_ARG_SET_FLOAT (def, 2.0);
4079 bonobo_property_bag_add (zoom_region->
properties,
4088 bonobo_arg_release (def);
4089 def = bonobo_arg_new (BONOBO_ARG_FLOAT);
4090 BONOBO_ARG_SET_FLOAT (def, 2.0);
4092 bonobo_property_bag_add (zoom_region->
properties,
4101 bonobo_arg_release (def);
4102 def = bonobo_arg_new (BONOBO_ARG_LONG);
4103 BONOBO_ARG_SET_LONG (def, 0);
4105 bonobo_property_bag_add (zoom_region->
properties,
4110 "size of zoom-region borders, in pixels",
4114 bonobo_arg_release (def);
4115 def = bonobo_arg_new (BONOBO_ARG_LONG);
4116 BONOBO_ARG_SET_LONG (def, 0);
4118 bonobo_property_bag_add (zoom_region->
properties,
4123 "size of left zoom-region border, in pixels",
4127 bonobo_arg_release (def);
4128 def = bonobo_arg_new (BONOBO_ARG_LONG);
4129 BONOBO_ARG_SET_LONG (def, 0);
4131 bonobo_property_bag_add (zoom_region->
properties,
4136 "size of top zoom-region border, in pixels",
4140 bonobo_arg_release (def);
4141 def = bonobo_arg_new (BONOBO_ARG_LONG);
4142 BONOBO_ARG_SET_LONG (def, 0);
4144 bonobo_property_bag_add (zoom_region->
properties,
4145 "border-size-right",
4149 "size of right zoom-region border, in pixels",
4153 bonobo_arg_release (def);
4154 def = bonobo_arg_new (BONOBO_ARG_LONG);
4155 BONOBO_ARG_SET_LONG (def, 0);
4157 bonobo_property_bag_add (zoom_region->
properties,
4158 "border-size-bottom",
4162 "size of bottom zoom-region border, in "
4167 bonobo_arg_release (def);
4168 def = bonobo_arg_new (BONOBO_ARG_LONG);
4169 BONOBO_ARG_SET_LONG (def, 0x00000000);
4171 bonobo_property_bag_add (zoom_region->
properties,
4176 "border color, as RGBA32",
4180 bonobo_arg_release (def);
4181 def = bonobo_arg_new (BONOBO_ARG_INT);
4182 BONOBO_ARG_SET_INT (def, 0);
4184 bonobo_property_bag_add (zoom_region->
properties,
4189 "x-alignment policy for this region",
4193 bonobo_arg_release (def);
4194 def = bonobo_arg_new (BONOBO_ARG_INT);
4195 BONOBO_ARG_SET_INT (def, 0);
4197 bonobo_property_bag_add (zoom_region->
properties,
4202 "y-alignment policy for this region",
4205 bonobo_arg_release (def);
4207 bonobo_property_bag_add (zoom_region->
properties,
4212 "viewport bounding box",
4216 def = bonobo_arg_new (BONOBO_ARG_INT);
4217 BONOBO_ARG_SET_INT (def, 0);
4219 bonobo_property_bag_add (zoom_region->
properties,
4220 "timing-iterations",
4224 "timing iterations",
4227 bonobo_arg_release (def);
4229 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
4230 BONOBO_ARG_SET_BOOLEAN (def, FALSE);
4232 bonobo_property_bag_add (zoom_region->
properties,
4241 bonobo_arg_release (def);
4243 def = bonobo_arg_new (BONOBO_ARG_INT);
4244 BONOBO_ARG_SET_INT (def, 0);
4246 bonobo_property_bag_add (zoom_region->
properties,
4254 bonobo_arg_release (def);
4256 def = bonobo_arg_new (BONOBO_ARG_BOOLEAN);
4257 BONOBO_ARG_SET_BOOLEAN (def, FALSE);
4259 bonobo_property_bag_add (zoom_region->
properties,
4268 bonobo_arg_release (def);
4275 GdkRectangle rect = {0, 0, 0, 0};
4307 DBG(g_message (
"initializing region %p", zoom_region));
4309 #ifdef HAVE_COLORBLIND
4310 cbr = colorblind_create();
4311 color = malloc (
sizeof (COLORBLIND_XCOLOR));
4326 zoom_region->
invert = FALSE;
4333 zoom_region->
roi.
x1 = 0;
4334 zoom_region->
roi.
x1 = 0;
4335 zoom_region->
roi.
x2 = 1;
4336 zoom_region->
roi.
x2 = 1;
4343 bonobo_object_add_interface (BONOBO_OBJECT (zoom_region),
4346 #ifdef ZOOM_REGION_DEBUG
4347 zoom_region->alive = TRUE;
4350 g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
4361 GError *error = NULL;
4367 klass->
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
4369 g_warning (
"Unable to connect to dbus: %s", error->message);
4370 g_error_free (error);
4377 G_OBJECT (_this_zoom_region));
4381 return _this_zoom_region;
4390 DBG(g_message (
"finalizing region %p", zoom_region));
4392 if (zoom_region->
priv && zoom_region->
priv->
q)
4394 g_list_free (zoom_region->
priv->
q);
4395 zoom_region->
priv->
q = NULL;
4397 if (GTK_IS_WIDGET (zoom_region->
priv->
w))
4398 gtk_container_remove (GTK_CONTAINER (((
Magnifier *) zoom_region->
priv->
parent)->priv->canvas), GTK_WIDGET (zoom_region->
priv->
w));
4399 if (GTK_IS_WIDGET (zoom_region->
priv->
border))
4411 g_free (zoom_region->
priv);
4412 zoom_region->
priv = NULL;
4414 #ifdef HAVE_COLORBLIND
4419 #ifdef ZOOM_REGION_DEBUG
4420 zoom_region->alive = FALSE;
4422 BONOBO_CALL_PARENT (G_OBJECT_CLASS, finalize, (region));