magnifier-main.c

Go to the documentation of this file.
00001 /*
00002  * AT-SPI - Assistive Technology Service Provider Interface
00003  * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
00004  *
00005  * Copyright 2001 Sun Microsystems Inc.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the
00019  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA 02111-1307, USA.
00021  */
00022 
00023 #include "config.h"
00024 #include <string.h>
00025 #include <stdlib.h>
00026 #include <sys/time.h>
00027 #include <gdk/gdkwindow.h>
00028 #include <gdk/gdkx.h>
00029 #include <gtk/gtk.h>
00030 #include <libbonobo.h>
00031 #include "magnifier.h"
00032 #include "magnifier-private.h"
00033 #include "zoom-region.h"
00034 #include "gmag-events.h"
00035 #include "GNOME_Magnifier.h"
00036 
00037 #define ENV_STRING_MAX_SIZE 128
00038 
00039 GNOME_Magnifier_ZoomRegion zoom_region;
00040 
00041 typedef struct {
00042         gchar    *target_display;
00043         gchar    *source_display;
00044         gchar    *cursor_set;
00045         gchar    *smoothing_type;
00046         gdouble   zoom_factor;
00047         gdouble   zoom_factor_x;
00048         gdouble   zoom_factor_y;
00049         gint      refresh_time;
00050         gint      mouse_poll_time;
00051         gint      cursor_size;
00052         gdouble   cursor_scale_factor;
00053         gint64    cursor_color;
00054         gboolean  vertical_split;
00055         gboolean  horizontal_split;
00056         gboolean  fullscreen;
00057         gboolean  mouse_follow;
00058         gboolean  invert_image;
00059         gboolean  no_initial_region;
00060         gint      timing_iterations;
00061         gboolean  timing_output;
00062         gint      timing_delta_x;
00063         gint      timing_delta_y;
00064         gint      timing_pan_rate;
00065         gboolean  smooth_scroll;
00066         gint      border_width;
00067         gint64    border_color;
00068         gboolean  test_pattern;
00069         gboolean  is_override_redirect;
00070         gboolean  ignore_damage;
00071 #ifdef HAVE_COMPOSITE
00072         gboolean   ignore_composite;
00073 #endif /* HAVE_COMPOSITE */
00074         gboolean  print_version;
00075 } MagnifierOptions;
00076 
00077 static MagnifierOptions global_options = { NULL,      /* target_display */
00078                                            NULL,      /* source_display */
00079                                            "default", /* cursor_set */
00080                                            "none",    /* smoothing_type */
00081                                            2.0,       /* zoom_factor */
00082                                            0.0,       /* zoom_factor_x */
00083                                            0.0,       /* zoom_factor_y */
00084                                            500,       /* refresh_time */
00085                                            50,        /* mouse_poll_time */
00086                                            0,         /* cursor_size */
00087                                            0.0F,      /* cursor_scale_factor */
00088                                            0xFF000000,/* cursor_color */
00089                                            0,         /* vertical_split */
00090                                            0,         /* horizontal_split */
00091                                            0,         /* fullscreen */
00092                                            0,         /* mouse_follow */
00093                                            0,         /* invert_image */
00094                                            0,         /* no_initial_region */
00095                                            0,         /* timing_iterations */
00096                                            0,         /* timing_output */
00097                                            10,        /* timing_delta_x */
00098                                            10,        /* timing_delat_y */
00099                                            0,         /* timing_pan_rate */
00100                                            1,         /* smooth_scroll */
00101                                            0,         /* border_width */
00102                                            0,         /* border_color */
00103                                            0,         /* test_pattern */
00104                                            0,         /* is_override_redirect*/
00105                                            0          /* ignore_damage */
00106 #ifdef HAVE_COMPOSITE
00107                                            ,0         /* ignore_composite */
00108 #endif /* HAVE_COMPOSITE */
00109                                            ,0         /* print_version */
00110                                          };
00111 
00112 static GOptionEntry magnifier_options [] = {
00113         {"target-display", 't', 0, G_OPTION_ARG_STRING, &global_options.target_display, "specify display on which to show magnified view", NULL},
00114         {"source-display", 's', 0, G_OPTION_ARG_STRING, &global_options.source_display, "specify display to magnify", NULL},
00115         {"cursor-set", 0, 0, G_OPTION_ARG_STRING, &global_options.cursor_set, "cursor set to use in target display", NULL},
00116         {"cursor-size", 0, 0, G_OPTION_ARG_INT, &global_options.cursor_size, "cursor size to use (overrides cursor-scale-factor)", NULL},
00117         {"cursor-scale-factor", 0, 0, G_OPTION_ARG_DOUBLE, &global_options.cursor_scale_factor, "cursor scale factor", NULL},
00118         {"cursor-color", 0, 0, G_OPTION_ARG_INT64, &global_options.cursor_color, "cursor color (applied to \'black\' pixels)", NULL},
00119         {"vertical", 'v', 0, G_OPTION_ARG_NONE, &global_options.vertical_split, "split screen vertically (if target display = source display)", NULL},
00120         {"horizontal", 'h', 0, G_OPTION_ARG_NONE, &global_options.horizontal_split, "split screen horizontally (if target display = source display)", NULL},
00121         {"mouse-follow", 'm', 0, G_OPTION_ARG_NONE, &global_options.mouse_follow, "track mouse movements", NULL},
00122         {"refresh-time", 'r', 0, G_OPTION_ARG_INT, &global_options.refresh_time, "minimum refresh time for idle, in ms", NULL},
00123         {"mouse-latency", 0, 0, G_OPTION_ARG_INT, &global_options.mouse_poll_time, "maximum mouse latency time, in ms", NULL},
00124         {"zoom-factor", 'z', 0, G_OPTION_ARG_DOUBLE, &global_options.zoom_factor, "zoom (scale) factor used to magnify source display", NULL}, 
00125         {"invert-image", 'i', 0, G_OPTION_ARG_NONE, &global_options.invert_image, "invert the image colormap", NULL}, 
00126         {"no-initial-region", 0, 0, G_OPTION_ARG_NONE, &global_options.no_initial_region, "don't create an initial zoom region", NULL},
00127         {"timing-iterations", 0, 0, G_OPTION_ARG_INT, &global_options.timing_iterations, "iterations to run timing benchmark test (0=continuous)", NULL},
00128         {"timing-output", 0, 0, G_OPTION_ARG_NONE, &global_options.timing_output, "display performance ouput", NULL},
00129         {"timing-pan-rate", 0, 0, G_OPTION_ARG_INT, &global_options.timing_pan_rate, "timing pan rate in lines per frame", NULL},
00130         {"timing-delta-x", 0, 0, G_OPTION_ARG_INT, &global_options.timing_delta_x, "pixels to pan in x-dimension each frame in timing update test", NULL},
00131         {"timing-delta-y", 0, 0, G_OPTION_ARG_INT, &global_options.timing_delta_y, "pixels to pan in y-dimension each frame in timing update test", NULL},
00132         {"smoothing-type", 0, 0, G_OPTION_ARG_STRING, &global_options.smoothing_type, "image smoothing algorithm to apply (bilinear-interpolation | none)", NULL},
00133         {"fullscreen", 'f', 0, G_OPTION_ARG_NONE, &global_options.fullscreen, "fullscreen magnification, covers entire target display [REQUIRES --source-display and --target-display]", NULL},
00134         {"smooth-scrolling", 0, 0, G_OPTION_ARG_NONE, &global_options.smooth_scroll, "use smooth scrolling", NULL},
00135         {"border-size", 'b', 0, G_OPTION_ARG_INT, &global_options.border_width, "width of border", NULL},
00136         {"border-color", 'c', 0, G_OPTION_ARG_INT64, &global_options.border_color, "border color specified as (A)RGB 23-bit value, Alpha-MSB", NULL},
00137         {"use-test-pattern", 0, 0, G_OPTION_ARG_NONE, &global_options.test_pattern, "use test pattern as source", NULL},
00138         {"override-redirect", 0, 0, G_OPTION_ARG_NONE, &global_options.is_override_redirect, "make the magnifier window totally unmanaged by the window manager", NULL},
00139         {"ignore-damage", 0, 0, G_OPTION_ARG_NONE, &global_options.ignore_damage, "ignore the X server DAMAGE extension, if present", NULL},
00140 #ifdef HAVE_COMPOSITE
00141         {"ignore-composite", 0, 0, G_OPTION_ARG_NONE, &global_options.ignore_composite, "ignore the X server COMPOSITE extension, if present", NULL},
00142 #endif /* HAVE_COMPOSITE */
00143         {"version", 0, 0, G_OPTION_ARG_NONE, &global_options.print_version, "print version", NULL},
00144         {NULL}
00145 };
00146 
00147 static void
00148 init_rect_bounds (GNOME_Magnifier_RectBounds *bounds,
00149                   long x1, long y1, long x2, long y2)
00150 {
00151         bounds->x1 = x1;
00152         bounds->y1 = y1;
00153         bounds->x2 = x2;
00154         bounds->y2 = y2;
00155 }
00156 
00157 static int screen_width, screen_height;
00158 
00159 static int
00160 magnifier_main_test_image (gpointer data)
00161 {
00162         static long timing_counter = 0;
00163         static int timing_x_pos = 0;
00164         static int timing_y_pos = 0;
00165         static int x_direction = 1;
00166         static int y_direction = 1;
00167         Magnifier *magnifier = (Magnifier *) data;
00168         GNOME_Magnifier_ZoomRegionList *zoom_regions;
00169         Bonobo_PropertyBag properties;
00170         CORBA_Environment ev;
00171         GNOME_Magnifier_RectBounds roi;
00172         int x_roi, y_roi;
00173 
00174         /* Only iterate the number of times specified */
00175         if (global_options.timing_iterations > 0) {
00176                 if (timing_counter > global_options.timing_iterations) {
00177                         CORBA_exception_init (&ev);
00178                         properties = GNOME_Magnifier_ZoomRegion_getProperties (zoom_region, &ev);
00179                         if (BONOBO_EX (&ev))
00180                                 fprintf (stderr, "EXCEPTION\n");
00181 
00182                         bonobo_pbclient_set_boolean (properties, "exit-magnifier",
00183                                        TRUE, &ev);
00184                 }
00185         }
00186 
00187         CORBA_exception_init (&ev);
00188 
00189         x_roi  = global_options.timing_delta_x * timing_x_pos;
00190         roi.x1 = x_roi;
00191         roi.x2 = (screen_width / global_options.zoom_factor) + roi.x1;
00192         x_roi  = global_options.timing_delta_x * (timing_x_pos + x_direction);
00193 
00194         /* Determine if magnifier hit an edge and should reverse direction */
00195         if (x_roi + (screen_width / global_options.zoom_factor) > screen_width)
00196                 x_direction = -1;
00197         else if (x_roi < 0)
00198                 x_direction = 1;
00199 
00200         timing_x_pos += x_direction;
00201 
00202         y_roi = global_options.timing_delta_y * timing_y_pos;
00203 
00204         /* Calculate size of screen not covered by magnifier */
00205         if (global_options.horizontal_split)
00206                 roi.y1 = y_roi + screen_height;
00207         else
00208                 roi.y1 = y_roi;
00209         roi.y2 = (screen_height / global_options.zoom_factor) + roi.y1;
00210 
00211         y_roi = global_options.timing_delta_y * (timing_y_pos + y_direction);
00212 
00213         /* The counter is increased each time the y-direction changes */
00214         if (y_roi + (screen_height / global_options.zoom_factor) > screen_height) {
00215                 timing_counter++;
00216                 y_direction = -1;
00217         }
00218         else if (y_roi < 0) {
00219                 timing_counter++;
00220                 y_direction = 1;
00221         }
00222 
00223         timing_y_pos += y_direction;
00224 
00225         if (!IS_MAGNIFIER (magnifier))
00226                 return FALSE;
00227 
00228         magnifier->priv->cursor_x = (roi.x2 + roi.x1) / 2;
00229         magnifier->priv->cursor_y = (roi.y2 + roi.y1) / 2;
00230 
00231         zoom_regions =
00232                 GNOME_Magnifier_Magnifier_getZoomRegions (
00233                         BONOBO_OBJREF (magnifier),
00234                         &ev);
00235 
00236         if (zoom_regions && (zoom_regions->_length > 0)) {
00237 
00238                 GNOME_Magnifier_ZoomRegion_setROI (
00239                         zoom_regions->_buffer[0], &roi, &ev);
00240         }
00241 
00242         return TRUE;
00243 }
00244 
00245 static int last_x = 0, last_y = 0;
00246 
00247 static int
00248 magnifier_main_pan_image (gpointer data)
00249 {
00250   Magnifier *magnifier = (Magnifier *) data;
00251   GNOME_Magnifier_ZoomRegionList *zoom_regions;
00252   GNOME_Magnifier_ZoomRegion zoom_region;
00253   CORBA_Environment ev;
00254   GNOME_Magnifier_RectBounds roi;
00255   int mouse_x_return, mouse_y_return;
00256   int w, h;
00257   GdkModifierType mask_return;
00258 
00259   CORBA_exception_init (&ev);
00260 
00261   if (global_options.mouse_follow && IS_MAGNIFIER (magnifier))
00262   {
00263           gdk_window_get_pointer (
00264                   magnifier_get_root (magnifier),
00265                   &mouse_x_return,
00266                   &mouse_y_return,
00267                   &mask_return);
00268           
00269           if (last_x != mouse_x_return || last_y != mouse_y_return)
00270           {
00271                   last_x = mouse_x_return;
00272                   last_y = mouse_y_return;
00273                   w = (magnifier->target_bounds.x2 - magnifier->target_bounds.x1);
00274                   h = (magnifier->target_bounds.y2 - magnifier->target_bounds.y1);
00275                   roi.x1 = mouse_x_return;
00276                   roi.y1 = mouse_y_return;
00277                   roi.x2 = roi.x1 + 1;
00278                   roi.y2 = roi.y1 + 1;
00279                   
00280                   zoom_regions =
00281                           GNOME_Magnifier_Magnifier_getZoomRegions (
00282                                   BONOBO_OBJREF (magnifier),
00283                                   &ev);
00284                   if (zoom_regions && (zoom_regions->_length > 0))
00285                   {
00286                           int i;
00287                           for (i = 0; i < zoom_regions->_length; ++i)
00288                           {
00289                                   /* fprintf (stderr, "panning region %d\n", i);*/
00290                                   zoom_region =
00291                                           CORBA_Object_duplicate (
00292                                                   ( (CORBA_Object *)
00293                                                     (zoom_regions->_buffer))[i], &ev);
00294                                   if (zoom_region != CORBA_OBJECT_NIL) {
00295                                           GNOME_Magnifier_ZoomRegion_setROI (zoom_region,
00296                                                                              &roi,
00297                                                                              &ev);
00298                                   } else fprintf (stderr, "nil region!\n");
00299                           }
00300                   }
00301           }
00302           return TRUE;
00303   }
00304   
00305   return FALSE;
00306 }
00307 
00308 static int
00309 magnifier_main_refresh_all (gpointer data)
00310 {
00311         int i;
00312         Magnifier *magnifier = data;
00313         CORBA_any *dirty_bounds_any;
00314         CORBA_Environment ev;
00315         Bonobo_PropertyBag properties;
00316         GNOME_Magnifier_RectBounds *dirty_bounds;
00317         GNOME_Magnifier_ZoomRegionList *regions;
00318         
00319         CORBA_exception_init (&ev);
00320 
00321         if (!IS_MAGNIFIER (magnifier))
00322                 return FALSE;
00323         
00324         regions = GNOME_Magnifier_Magnifier_getZoomRegions (
00325                 BONOBO_OBJREF (magnifier),
00326                 &ev);
00327 
00328 #ifdef DEBUG_REFRESH
00329         fprintf (stderr, "refreshing %d regions\n", regions->_length);
00330 #endif
00331 
00332         properties = GNOME_Magnifier_Magnifier_getProperties (BONOBO_OBJREF (magnifier), &ev);
00333 
00334         dirty_bounds_any = Bonobo_PropertyBag_getValue (properties, "source-display-bounds", &ev);
00335         if (BONOBO_EX (&ev)) {
00336                 g_warning ("Error getting source-display-bounds");
00337                 bonobo_main_quit ();
00338                 return FALSE;
00339         }
00340 
00341         dirty_bounds = (GNOME_Magnifier_RectBounds *) dirty_bounds_any->_value;
00342 
00343           fprintf (stderr, "region to update: %d %d %d %d\n",
00344                  dirty_bounds->x1, dirty_bounds->y1, dirty_bounds->x2, dirty_bounds->y2);
00345 
00346         for (i = 0; i < regions->_length; ++i)
00347                 GNOME_Magnifier_ZoomRegion_markDirty (
00348                         regions->_buffer [i], dirty_bounds, &ev);
00349 
00350         bonobo_object_release_unref (properties, NULL);
00351 
00352         return TRUE;
00353 }
00354 
00355 int
00356 main (int argc, char** argv)
00357 {
00358   GOptionContext *context;
00359   GNOME_Magnifier_RectBounds *roi = GNOME_Magnifier_RectBounds__alloc();
00360   GNOME_Magnifier_RectBounds *viewport = GNOME_Magnifier_RectBounds__alloc();
00361   CORBA_any *viewport_any;
00362   int x = 0, y = 0, fullwidth, fullheight;
00363   guint pan_handle = 0, refresh_handle = 0;
00364   CORBA_Environment ev;
00365   Bonobo_PropertyBag properties;
00366 
00367   Magnifier *magnifier;
00368   
00369   if (!bonobo_init (&argc, argv)) {
00370     g_error ("Could not initialize Bonobo");
00371   }
00372   CORBA_exception_init (&ev);
00373   
00374   context = g_option_context_new ("- a screen magnifier for Gnome");
00375   g_option_context_set_description (context, "Report bugs to http://bugzilla.gnome.org\n");
00376   g_option_context_add_main_entries (context, magnifier_options, "main options");
00377   g_option_context_set_ignore_unknown_options (context, TRUE);
00378   g_option_context_parse(context, &argc, &argv, NULL);
00379   g_option_context_free(context);
00380 
00381   if (global_options.print_version) {
00382           g_print ("%s\n", VERSION);
00383           return 0;
00384   }
00385 
00391   if (global_options.target_display) {
00392           gchar *string;
00393           string = g_strconcat ("DISPLAY=", global_options.target_display, NULL);
00394           putenv (string);
00395   } else {
00396                   global_options.target_display = getenv ("DISPLAY");
00397                   if (!global_options.target_display) {
00398                           fprintf (stderr, _("Can't open display, DISPLAY is not set"));
00399                           exit (1);
00400                   }
00401   }  
00402 
00403   if (!global_options.source_display) {
00404                   global_options.source_display = global_options.target_display;
00405   }
00406 
00407   if (global_options.timing_pan_rate && global_options.timing_iterations == 0)
00408   {
00409     g_error ("Must specify timing_iterations when running pan test");
00410   }
00411 
00412   /* FIXME */
00413   gtk_init (&argc, &argv);
00414 
00415   if (global_options.ignore_damage)
00416   {
00417       g_setenv ("MAGNIFIER_IGNORE_DAMAGE", "1", TRUE);
00418   }
00419 #ifdef HAVE_COMPOSITE
00420   if (global_options.ignore_composite) {
00421           g_setenv ("MAGNIFIER_IGNORE_COMPOSITE", "1", TRUE);
00422   }
00423 #endif /* HAVE_COMPOSITE */
00424 
00425   magnifier = magnifier_new (global_options.is_override_redirect);
00426   
00427   properties = GNOME_Magnifier_Magnifier_getProperties (
00428           BONOBO_OBJREF (magnifier), &ev);
00429   if (ev._major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION\n");
00430 
00431   if (global_options.source_display)
00432           bonobo_pbclient_set_string (properties, "source-display-screen",
00433                                       global_options.source_display, NULL);
00434 
00435   if (global_options.target_display)
00436           bonobo_pbclient_set_string (properties, "target-display-screen",
00437                                       global_options.target_display, NULL);
00438 
00439   if (global_options.cursor_set)
00440           bonobo_pbclient_set_string (properties, "cursor-set",
00441                                       global_options.cursor_set, NULL);
00442 
00443   if (global_options.cursor_size)
00444           bonobo_pbclient_set_long (properties, "cursor-size",
00445                                     global_options.cursor_size, NULL);
00446 
00447   else if (global_options.cursor_scale_factor != 0.0F)
00448           bonobo_pbclient_set_float (properties, "cursor-scale-factor",
00449                                      global_options.cursor_scale_factor, NULL);
00450   else 
00451           bonobo_pbclient_set_float (properties, "cursor-scale-factor",
00452                                      global_options.zoom_factor, NULL);
00453 
00454   if (global_options.cursor_color)
00455           bonobo_pbclient_set_ulong (properties, "cursor-color",
00456                                      global_options.cursor_color, 
00457                                      NULL);
00458 
00459   fullwidth = screen_width = gdk_screen_get_width (
00460           gdk_display_get_screen (magnifier->target_display,
00461                                   magnifier->target_screen_num));
00462   fullheight = screen_height = gdk_screen_get_height (
00463           gdk_display_get_screen (magnifier->target_display,
00464                                   magnifier->target_screen_num));
00465 
00466   if (global_options.vertical_split) {
00467           screen_width /= 2;
00468           x = screen_width;
00469   }
00470   if (global_options.horizontal_split) {
00471           screen_height /= 2;
00472           y = screen_height;
00473   }
00474 
00475   fprintf (stderr, "initial viewport %d %d\n", (int) screen_width,
00476            (int) screen_height);
00477 
00478   init_rect_bounds (viewport, x, y, x + screen_width, y + screen_height);
00479   viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds, viewport);
00480   
00481   bonobo_pbclient_set_value (properties, "target-display-bounds",
00482                              viewport_any,
00483                              &ev);
00484   bonobo_arg_release (viewport_any);
00485 
00486   if (global_options.vertical_split || global_options.horizontal_split) 
00487   {
00488 #ifdef HAVE_COMPOSITE
00489           if (!g_getenv ("MAGNIFIER_IGNORE_COMPOSITE"))
00490                   init_rect_bounds (viewport, 0, 0, fullwidth, fullheight);
00491           else
00492 #endif /* HAVE_COMPOSITE */
00493                   init_rect_bounds (viewport, 0, 0, fullwidth-x, fullheight-y);
00494       viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds, viewport);
00495       bonobo_pbclient_set_value (properties, "source-display-bounds",
00496                                  viewport_any,
00497                                  &ev);
00498 
00499       bonobo_arg_release (viewport_any);
00500   } else if (global_options.fullscreen) {
00501           init_rect_bounds (viewport, 0, 0, fullwidth, fullheight);
00502           viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds,
00503                                               viewport);
00504           bonobo_pbclient_set_value (properties, "source-display-bounds",
00505                                      viewport_any,
00506                                      &ev);
00507           bonobo_arg_release (viewport_any);
00508   }
00509 
00510   bonobo_object_release_unref (properties, NULL);
00511   properties = NULL;
00512 
00513   if (global_options.vertical_split ||
00514       global_options.horizontal_split ||
00515       global_options.fullscreen)
00516   {
00517           int scroll_policy;
00518           
00519           init_rect_bounds (roi, 0, 0, 100, 100);
00520           init_rect_bounds (viewport, 0, 0, screen_width, screen_height);
00521           zoom_region =
00522                   GNOME_Magnifier_Magnifier_createZoomRegion (
00523                           BONOBO_OBJREF (magnifier),
00524                           global_options.zoom_factor,
00525                           global_options.zoom_factor,
00526                           roi,
00527                           viewport,
00528                           &ev);
00529           
00530           properties = GNOME_Magnifier_ZoomRegion_getProperties (zoom_region, &ev);
00531           if (BONOBO_EX (&ev))
00532                   fprintf (stderr, "EXCEPTION\n");
00533 
00534           scroll_policy = global_options.smooth_scroll ?
00535                   GNOME_Magnifier_ZoomRegion_SCROLL_SMOOTHEST :
00536                   GNOME_Magnifier_ZoomRegion_SCROLL_FASTEST;
00537 
00538           bonobo_pbclient_set_long (properties, "timing-iterations",
00539                                        global_options.timing_iterations, &ev);
00540           bonobo_pbclient_set_boolean (properties, "timing-output",
00541                                        global_options.timing_output, &ev);
00542           bonobo_pbclient_set_long (properties, "timing-pan-rate",
00543                                        global_options.timing_pan_rate, &ev);
00544           bonobo_pbclient_set_long    (properties, "border-size",
00545                                        global_options.border_width, &ev);
00546           bonobo_pbclient_set_long    (properties, "border-color",
00547                                        global_options.border_color, &ev);
00548           bonobo_pbclient_set_short   (properties, "smooth-scroll-policy",
00549                                        (short) scroll_policy, &ev);
00550           bonobo_pbclient_set_boolean (properties, "use-test-pattern",
00551                                        global_options.test_pattern, &ev);
00552 
00553           if (strcmp (global_options.smoothing_type, "none"))
00554                   bonobo_pbclient_set_string (properties, "smoothing-type",
00555                                               global_options.smoothing_type, &ev);
00556 
00557           if (global_options.invert_image)
00558                   bonobo_pbclient_set_boolean (properties, "inverse-video",
00559                                                global_options.invert_image, NULL);
00560 
00561           GNOME_Magnifier_Magnifier_addZoomRegion (
00562                   BONOBO_OBJREF (magnifier),
00563                   zoom_region,
00564                   &ev);
00565 
00566           bonobo_object_release_unref (properties, &ev);
00567           properties = NULL;
00568   }
00569 
00570   if (global_options.timing_pan_rate)
00571   {
00572           GNOME_Magnifier_ZoomRegionList *zoom_regions;
00573           GNOME_Magnifier_RectBounds roi;
00574           roi.x1 = 100;
00575           roi.x2 = 100 + (screen_width / global_options.zoom_factor);
00576           roi.y1 = 0;
00577           roi.y2 = screen_height / global_options.zoom_factor;
00578           
00579           zoom_regions = GNOME_Magnifier_Magnifier_getZoomRegions (
00580                   BONOBO_OBJREF (magnifier), &ev);
00581           
00582           if (zoom_regions && (zoom_regions->_length > 0))
00583           {
00584                   GNOME_Magnifier_ZoomRegion_setROI (
00585                           zoom_regions->_buffer[0], &roi, &ev);
00586           }
00587   }
00588   else if (global_options.timing_iterations)
00589   {
00590           refresh_handle = g_timeout_add (global_options.refresh_time,
00591                                           magnifier_main_test_image,
00592                                           magnifier);
00593   }
00594   else
00595   {
00596           if (global_options.ignore_damage ||
00597               !gmag_events_source_has_damage_extension (magnifier)) 
00598           {
00599                   refresh_handle = g_timeout_add (
00600                           global_options.refresh_time,
00601                           magnifier_main_refresh_all, magnifier);
00602           }
00603           
00604           pan_handle = g_timeout_add (
00605                   global_options.mouse_poll_time,
00606                   magnifier_main_pan_image, magnifier);
00607   }
00608   
00609   bonobo_main ();
00610   
00611   if (refresh_handle)
00612           g_source_remove (refresh_handle);
00613   
00614   if (pan_handle)
00615           g_source_remove (pan_handle);
00616 
00617   return 0;
00618 }

Generated on Fri Mar 9 14:08:09 2007 for gnome-mag by  doxygen 1.4.7