gnome-mag: magnifier-main.c Source File

# 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           g_setenv ("MAGNIFIER_IGNORE_COMPOSITE", "1", TRUE);
    00432 #endif /* HAVE_COMPOSITE */
    00433
    00434   magnifier = magnifier_new (global_options.is_override_redirect);
    00435
    00436   properties = GNOME_Magnifier_Magnifier_getProperties (
    00437           BONOBO_OBJREF (magnifier), &ev);
    00438   if (ev._major != CORBA_NO_EXCEPTION) fprintf (stderr, "EXCEPTION\n");
    00439
    00440   if (global_options.source_display)
    00441           bonobo_pbclient_set_string (properties, "source-display-screen",
    00442                                       global_options.source_display, NULL);
    00443
    00444   if (global_options.target_display)
    00445           bonobo_pbclient_set_string (properties, "target-display-screen",
    00446                                       global_options.target_display, NULL);
    00447
    00448   if (global_options.cursor_set)
    00449           bonobo_pbclient_set_string (properties, "cursor-set",
    00450                                       global_options.cursor_set, NULL);
    00451
    00452   if (global_options.cursor_size)
    00453           bonobo_pbclient_set_long (properties, "cursor-size",
    00454                                     global_options.cursor_size, NULL);
    00455
    00456   else if (global_options.cursor_scale_factor != 0.0F)
    00457           bonobo_pbclient_set_float (properties, "cursor-scale-factor",
    00458                                      global_options.cursor_scale_factor, NULL);
    00459   else
    00460           bonobo_pbclient_set_float (properties, "cursor-scale-factor",
    00461                                      global_options.zoom_factor, NULL);
    00462
    00463   if (global_options.cursor_color)
    00464           bonobo_pbclient_set_ulong (properties, "cursor-color",
    00465                                      global_options.cursor_color,
    00466                                      NULL);
    00467
    00468   if (!global_options.show_crosswires)
    00469           bonobo_pbclient_set_long (properties, "crosswire-size", 0, NULL);
    00470
    00471   src_width = gdk_screen_get_width (gdk_display_get_screen (
    00472                                             magnifier->source_display,
    00473                                             magnifier->source_screen_num));
    00474   src_height = gdk_screen_get_height (gdk_display_get_screen (
    00475                                               magnifier->source_display,
    00476                                               magnifier->source_screen_num));
    00477
    00478   target_width = gdk_screen_get_width (gdk_display_get_screen (
    00479                                                magnifier->target_display,
    00480                                                magnifier->target_screen_num));
    00481   target_height = gdk_screen_get_height (
    00482           gdk_display_get_screen (magnifier->target_display,
    00483                                   magnifier->target_screen_num));
    00484
    00485   if (global_options.vertical_split) {
    00486           target_width /= 2;
    00487           x = target_width;
    00488   }
    00489   if (global_options.horizontal_split) {
    00490           target_height /= 2;
    00491           y = target_height;
    00492   }
    00493
    00494   fprintf (stderr, "initial viewport %d %d\n", (int) target_width,
    00495            (int) target_height);
    00496
    00497
    00498   if (global_options.vertical_split || global_options.horizontal_split ||
    00499       global_options.fullscreen) {
    00500           init_rect_bounds (viewport, x, y, x + target_width,
    00501                             y + target_height);
    00502           viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds,
    00503                                               viewport);
    00504
    00505           bonobo_pbclient_set_value (properties, "target-display-bounds",
    00506                                      viewport_any, &ev);
    00507           bonobo_arg_release (viewport_any);
    00508   }
    00509
    00510   if (global_options.vertical_split || global_options.horizontal_split)
    00511   {
    00512 #ifdef HAVE_COMPOSITE
    00513           if (!g_getenv ("MAGNIFIER_IGNORE_COMPOSITE"))
    00514                   init_rect_bounds (viewport, 0, 0,
    00515                                     src_width, src_height);
    00516           else
    00517 #endif /* HAVE_COMPOSITE */
    00518                   init_rect_bounds (viewport, 0, 0,
    00519                                     src_width-x, src_height-y);
    00520       viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds,
    00521                                           viewport);
    00522       bonobo_pbclient_set_value (properties, "source-display-bounds",
    00523                                  viewport_any,
    00524                                  &ev);
    00525
    00526       bonobo_arg_release (viewport_any);
    00527   } else if (global_options.fullscreen) {
    00528           init_rect_bounds (viewport, 0, 0, src_width, src_height);
    00529           viewport_any = bonobo_arg_new_from (TC_GNOME_Magnifier_RectBounds,
    00530                                               viewport);
    00531           bonobo_pbclient_set_value (properties, "source-display-bounds",
    00532                                      viewport_any,
    00533                                      &ev);
    00534           bonobo_arg_release (viewport_any);
    00535   }
    00536
    00537   bonobo_object_release_unref (properties, NULL);
    00538   properties = NULL;
    00539
    00540   if (global_options.vertical_split ||
    00541       global_options.horizontal_split ||
    00542       global_options.fullscreen)
    00543   {
    00544           int scroll_policy;
    00545
    00546           init_rect_bounds (roi, 0, 0,
    00547                             target_width / global_options.zoom_factor,
    00548                             target_height / global_options.zoom_factor);
    00549           init_rect_bounds (viewport, 0, 0, target_width, target_height);
    00550           zoom_region =
    00551                   GNOME_Magnifier_Magnifier_createZoomRegion (
    00552                           BONOBO_OBJREF (magnifier),
    00553                           global_options.zoom_factor,
    00554                           global_options.zoom_factor,
    00555                           roi,
    00556                           viewport,
    00557                           &ev);
    00558
    00559           properties = GNOME_Magnifier_ZoomRegion_getProperties (zoom_region, &ev);
    00560           if (BONOBO_EX (&ev))
    00561                   fprintf (stderr, "EXCEPTION\n");
    00562
    00563           scroll_policy = global_options.smooth_scroll ?
    00564                   GNOME_Magnifier_ZoomRegion_SCROLL_SMOOTHEST :
    00565                   GNOME_Magnifier_ZoomRegion_SCROLL_FASTEST;
    00566
    00567           bonobo_pbclient_set_long (properties, "timing-iterations",
    00568                                        global_options.timing_iterations, &ev);
    00569           bonobo_pbclient_set_boolean (properties, "timing-output",
    00570                                        global_options.timing_output, &ev);
    00571           bonobo_pbclient_set_long (properties, "timing-pan-rate",
    00572                                        global_options.timing_pan_rate, &ev);
    00573           bonobo_pbclient_set_long    (properties, "border-size",
    00574                                        global_options.border_width, &ev);
    00575           bonobo_pbclient_set_long    (properties, "border-color",
    00576                                        global_options.border_color, &ev);
    00577           bonobo_pbclient_set_short   (properties, "smooth-scroll-policy",
    00578                                        (short) scroll_policy, &ev);
    00579           bonobo_pbclient_set_boolean (properties, "use-test-pattern",
    00580                                        global_options.test_pattern, &ev);
    00581           bonobo_pbclient_set_boolean (properties, "draw-cursor",
    00582                                        !global_options.hide_pointer, &ev);
    00583
    00584           if (strcmp (global_options.smoothing_type, "none"))
    00585                   bonobo_pbclient_set_string (properties, "smoothing-type",
    00586                                               global_options.smoothing_type, &ev);
    00587
    00588           if (global_options.invert_image)
    00589                   bonobo_pbclient_set_boolean (properties, "inverse-video",
    00590                                                global_options.invert_image, NULL);
    00591
    00592           GNOME_Magnifier_Magnifier_addZoomRegion (
    00593                   BONOBO_OBJREF (magnifier),
    00594                   zoom_region,
    00595                   &ev);
    00596
    00597           bonobo_object_release_unref (properties, &ev);
    00598           properties = NULL;
    00599   }
    00600
    00601   if (global_options.timing_pan_rate)
    00602   {
    00603           GNOME_Magnifier_ZoomRegionList *zoom_regions;
    00604           GNOME_Magnifier_RectBounds roi;
    00605           roi.x1 = 100;
    00606           roi.x2 = 100 + (target_width / global_options.zoom_factor);
    00607           roi.y1 = 0;
    00608           roi.y2 = target_height / global_options.zoom_factor;
    00609
    00610           zoom_regions = GNOME_Magnifier_Magnifier_getZoomRegions (
    00611                   BONOBO_OBJREF (magnifier), &ev);
    00612
    00613           if (zoom_regions && (zoom_regions->_length > 0))
    00614           {
    00615                   GNOME_Magnifier_ZoomRegion_setROI (
    00616                           zoom_regions->_buffer[0], &roi, &ev);
    00617           }
    00618   }
    00619   else if (global_options.timing_iterations)
    00620   {
    00621           refresh_handle = g_timeout_add (global_options.refresh_time,
    00622                                           magnifier_main_test_image,
    00623                                           magnifier);
    00624   }
    00625   else
    00626   {
    00627           if (global_options.ignore_damage ||
    00628               !gmag_gs_source_has_damage_extension (magnifier))
    00629           {
    00630                   refresh_handle = g_timeout_add (
    00631                           global_options.refresh_time,
    00632                           magnifier_main_refresh_all, magnifier);
    00633           }
    00634
    00635           pan_handle = g_timeout_add (
    00636                   global_options.mouse_poll_time,
    00637                   magnifier_main_pan_image, magnifier);
    00638   }
    00639
    00640   bonobo_main ();
    00641
    00642   if (refresh_handle)
    00643           g_source_remove (refresh_handle);
    00644
    00645   if (pan_handle)
    00646           g_source_remove (pan_handle);
    00647
    00648   return 0;
    00649 }