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

Generated on Tue Apr 24 15:39:22 2007 for gnome-mag by  doxygen 1.5.1