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

Generated on Sat Jan 12 14:30:51 2008 for gnome-mag by  doxygen 1.5.2