27 #include "gmag-graphical-server.h"
40 #include <libbonobo.h>
42 #define ENV_STRING_MAX_SIZE 128
77 gboolean ignore_composite;
113 #ifdef HAVE_COMPOSITE
122 {
"target-display",
't', 0, G_OPTION_ARG_STRING, &global_options.
target_display,
"specify display on which to show magnified view", NULL},
123 {
"source-display",
's', 0, G_OPTION_ARG_STRING, &global_options.
source_display,
"specify display to magnify", NULL},
124 {
"cursor-set", 0, 0, G_OPTION_ARG_STRING, &global_options.
cursor_set,
"cursor set to use in target display", NULL},
125 {
"cursor-size", 0, 0, G_OPTION_ARG_INT, &global_options.
cursor_size,
"cursor size to use (overrides cursor-scale-factor)", NULL},
126 {
"cursor-scale-factor", 0, 0, G_OPTION_ARG_DOUBLE, &global_options.
cursor_scale_factor,
"cursor scale factor", NULL},
127 {
"cursor-color", 0, 0, G_OPTION_ARG_INT64, &global_options.
cursor_color,
"cursor color (applied to \'black\' pixels)", NULL},
128 {
"vertical",
'v', 0, G_OPTION_ARG_NONE, &global_options.
vertical_split,
"split screen vertically (if target display = source display)", NULL},
129 {
"horizontal",
'h', 0, G_OPTION_ARG_NONE, &global_options.
horizontal_split,
"split screen horizontally (if target display = source display)", NULL},
130 {
"mouse-follow",
'm', 0, G_OPTION_ARG_NONE, &global_options.
mouse_follow,
"track mouse movements", NULL},
131 {
"refresh-time",
'r', 0, G_OPTION_ARG_INT, &global_options.
refresh_time,
"minimum refresh time for idle, in ms", NULL},
132 {
"mouse-latency", 0, 0, G_OPTION_ARG_INT, &global_options.
mouse_poll_time,
"maximum mouse latency time, in ms", NULL},
133 {
"zoom-factor",
'z', 0, G_OPTION_ARG_DOUBLE, &global_options.
zoom_factor,
"zoom (scale) factor used to magnify source display", NULL},
134 {
"invert-image",
'i', 0, G_OPTION_ARG_NONE, &global_options.
invert_image,
"invert the image colormap", NULL},
135 {
"no-initial-region", 0, 0, G_OPTION_ARG_NONE, &global_options.
no_initial_region,
"don't create an initial zoom region", NULL},
136 {
"timing-iterations", 0, 0, G_OPTION_ARG_INT, &global_options.
timing_iterations,
"iterations to run timing benchmark test (0=continuous)", NULL},
137 {
"timing-output", 0, 0, G_OPTION_ARG_NONE, &global_options.
timing_output,
"display performance ouput", NULL},
138 {
"timing-pan-rate", 0, 0, G_OPTION_ARG_INT, &global_options.
timing_pan_rate,
"timing pan rate in lines per frame", NULL},
139 {
"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},
140 {
"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},
141 {
"smoothing-type", 0, 0, G_OPTION_ARG_STRING, &global_options.
smoothing_type,
"image smoothing algorithm to apply (bilinear-interpolation | none)", NULL},
142 {
"fullscreen",
'f', 0, G_OPTION_ARG_NONE, &global_options.
fullscreen,
"fullscreen magnification, covers entire target display [REQUIRES --source-display and --target-display]", NULL},
143 {
"smooth-scrolling", 0, 0, G_OPTION_ARG_NONE, &global_options.
smooth_scroll,
"use smooth scrolling", NULL},
144 {
"border-size",
'b', 0, G_OPTION_ARG_INT, &global_options.
border_width,
"width of border", NULL},
145 {
"border-color",
'c', 0, G_OPTION_ARG_INT64, &global_options.
border_color,
"border color specified as (A)RGB 23-bit value, Alpha-MSB", NULL},
146 {
"hide-pointer", 0, 0, G_OPTION_ARG_NONE, &global_options.
hide_pointer,
"hide magnifier pointer when passed", NULL},
147 {
"show-crosswires", 0, 0, G_OPTION_ARG_NONE, &global_options.
show_crosswires,
"show crosswires when passed", NULL},
148 {
"use-test-pattern", 0, 0, G_OPTION_ARG_NONE, &global_options.
test_pattern,
"use test pattern as source", NULL},
149 {
"override-redirect", 0, 0, G_OPTION_ARG_NONE, &global_options.
is_override_redirect,
"make the magnifier window totally unmanaged by the window manager", NULL},
150 {
"ignore-damage", 0, 0, G_OPTION_ARG_NONE, &global_options.
ignore_damage,
"ignore the X server DAMAGE extension, if present", NULL},
151 #ifdef HAVE_COMPOSITE
152 {
"ignore-composite", 0, 0, G_OPTION_ARG_NONE, &global_options.ignore_composite,
"ignore the X server COMPOSITE extension, if present", NULL},
154 {
"version", 0, 0, G_OPTION_ARG_NONE, &global_options.
print_version,
"print version", NULL},
160 long x1,
long y1,
long x2,
long y2)
173 static long timing_counter = 0;
174 static int timing_x_pos = 0;
175 static int timing_y_pos = 0;
176 static int x_direction = 1;
177 static int y_direction = 1;
181 CORBA_Environment ev;
188 CORBA_exception_init (&ev);
191 fprintf (stderr,
"EXCEPTION\n");
193 bonobo_pbclient_set_boolean (properties,
"exit-magnifier",
198 CORBA_exception_init (&ev);
203 x_roi = global_options.
timing_delta_x * (timing_x_pos + x_direction);
211 timing_x_pos += x_direction;
222 y_roi = global_options.
timing_delta_y * (timing_y_pos + y_direction);
225 if (y_roi + (target_height / global_options.
zoom_factor) >
230 else if (y_roi < 0) {
235 timing_y_pos += y_direction;
245 BONOBO_OBJREF (magnifier),
248 if (zoom_regions && (zoom_regions->
_length > 0)) {
251 zoom_regions->
_buffer[0], &roi, &ev);
265 CORBA_Environment ev;
267 int mouse_x_return, mouse_y_return;
269 GdkModifierType mask_return;
271 CORBA_exception_init (&ev);
275 gdk_window_get_pointer (
281 if (
last_x != mouse_x_return ||
last_y != mouse_y_return)
287 roi.
x1 = mouse_x_return;
288 roi.
y1 = mouse_y_return;
294 BONOBO_OBJREF (magnifier),
296 if (zoom_regions && (zoom_regions->
_length > 0))
299 for (i = 0; i < zoom_regions->
_length; ++i)
303 CORBA_Object_duplicate (
305 (zoom_regions->
_buffer))[i], &ev);
306 if (zoom_region != CORBA_OBJECT_NIL) {
310 }
else fprintf (stderr,
"nil region!\n");
325 CORBA_any *dirty_bounds_any;
326 CORBA_Environment ev;
331 CORBA_exception_init (&ev);
337 BONOBO_OBJREF (magnifier),
341 fprintf (stderr,
"refreshing %d regions\n", regions->
_length);
347 if (BONOBO_EX (&ev)) {
348 g_warning (
"Error getting source-display-bounds");
355 fprintf (stderr,
"region to update: %d %d %d %d\n",
356 dirty_bounds->
x1, dirty_bounds->
y1, dirty_bounds->
x2, dirty_bounds->
y2);
358 for (i = 0; i < regions->
_length; ++i)
360 regions->
_buffer [i], dirty_bounds, &ev);
362 bonobo_object_release_unref (properties, NULL);
370 GOptionContext *context;
373 CORBA_any *viewport_any;
374 int x = 0, y = 0, src_width, src_height;
375 guint pan_handle = 0, refresh_handle = 0;
376 CORBA_Environment ev;
381 if (!bonobo_init (&argc, argv)) {
382 g_error (
"Could not initialize Bonobo");
384 CORBA_exception_init (&ev);
386 context = g_option_context_new (
"- a screen magnifier for Gnome");
387 g_option_context_set_description (context,
"Report bugs to http://bugzilla.gnome.org\n");
389 g_option_context_set_ignore_unknown_options (context, TRUE);
390 g_option_context_parse(context, &argc, &argv, NULL);
391 g_option_context_free(context);
394 g_print (
"%s\n", VERSION);
405 string = g_strconcat (
"DISPLAY=", global_options.
target_display, NULL);
410 fprintf (stderr, _(
"Can't open display: DISPLAY is not set"));
421 g_error (
"Must specify timing_iterations when running pan test");
425 gtk_init (&argc, &argv);
429 g_setenv (
"MAGNIFIER_IGNORE_DAMAGE",
"1", TRUE);
431 #ifdef HAVE_COMPOSITE
432 if (global_options.ignore_composite)
433 g_setenv (
"MAGNIFIER_IGNORE_COMPOSITE",
"1", TRUE);
439 BONOBO_OBJREF (magnifier), &ev);
440 if (ev._major != CORBA_NO_EXCEPTION) fprintf (stderr,
"EXCEPTION\n");
443 bonobo_pbclient_set_string (properties,
"target-display-screen",
447 bonobo_pbclient_set_string (properties,
"source-display-screen",
451 bonobo_pbclient_set_string (properties,
"cursor-set",
455 bonobo_pbclient_set_long (properties,
"cursor-size",
459 bonobo_pbclient_set_float (properties,
"cursor-scale-factor",
462 bonobo_pbclient_set_float (properties,
"cursor-scale-factor",
466 bonobo_pbclient_set_ulong (properties,
"cursor-color",
471 bonobo_pbclient_set_long (properties,
"crosswire-size", 0, NULL);
473 src_width = gdk_screen_get_width (gdk_display_get_screen (
476 src_height = gdk_screen_get_height (gdk_display_get_screen (
480 target_width = gdk_screen_get_width (gdk_display_get_screen (
496 fprintf (stderr,
"initial viewport %d %d\n", (
int)
target_width,
507 bonobo_pbclient_set_value (properties,
"target-display-bounds",
509 bonobo_arg_release (viewport_any);
514 #ifdef HAVE_COMPOSITE
515 if (!g_getenv (
"MAGNIFIER_IGNORE_COMPOSITE"))
517 src_width, src_height);
521 src_width-x, src_height-y);
524 bonobo_pbclient_set_value (properties,
"source-display-bounds",
528 bonobo_arg_release (viewport_any);
533 bonobo_pbclient_set_value (properties,
"source-display-bounds",
536 bonobo_arg_release (viewport_any);
539 bonobo_object_release_unref (properties, NULL);
554 BONOBO_OBJREF (magnifier),
563 fprintf (stderr,
"EXCEPTION\n");
569 bonobo_pbclient_set_long (properties,
"timing-iterations",
571 bonobo_pbclient_set_boolean (properties,
"timing-output",
573 bonobo_pbclient_set_long (properties,
"timing-pan-rate",
575 bonobo_pbclient_set_long (properties,
"border-size",
577 bonobo_pbclient_set_long (properties,
"border-color",
579 bonobo_pbclient_set_short (properties,
"smooth-scroll-policy",
580 (
short) scroll_policy, &ev);
581 bonobo_pbclient_set_boolean (properties,
"use-test-pattern",
583 bonobo_pbclient_set_boolean (properties,
"draw-cursor",
587 bonobo_pbclient_set_string (properties,
"smoothing-type",
591 bonobo_pbclient_set_boolean (properties,
"inverse-video",
595 BONOBO_OBJREF (magnifier),
599 bonobo_object_release_unref (properties, &ev);
613 BONOBO_OBJREF (magnifier), &ev);
615 if (zoom_regions && (zoom_regions->
_length > 0))
618 zoom_regions->
_buffer[0], &roi, &ev);
623 refresh_handle = g_timeout_add (global_options.
refresh_time,
630 !gmag_gs_source_has_damage_extension (magnifier))
632 refresh_handle = g_timeout_add (
637 pan_handle = g_timeout_add (
645 g_source_remove (refresh_handle);
648 g_source_remove (pan_handle);