28 #include "gmag-cursor.h"
29 #include "gmag-graphical-server.h"
37 #include <libbonobo.h>
38 #include <login-helper/login-helper.h>
40 #include <dbus/dbus-glib-bindings.h>
42 #include <gdk-pixbuf/gdk-pixbuf.h>
48 #define DEBUG_CLIENT_CALLS
50 #ifdef DEBUG_CLIENT_CALLS
52 #define DBG(a) if (client_debug) { (a); }
106 #ifdef DEBUG_CLIENT_CALLS
117 "CURSOR_DEFAULT_SIZE",
140 Window *mainwin = NULL;
144 if (magnifier && magnifier->
priv && magnifier->
priv->
w)
146 mainwin = g_new0 (Window, 2);
147 mainwin[0] = GDK_WINDOW_XWINDOW (gtk_widget_get_window (magnifier->
priv->
w));
153 static LoginHelperDeviceReqFlags
158 return LOGIN_HELPER_GUI_EVENTS |
159 LOGIN_HELPER_POST_WINDOWS |
160 LOGIN_HELPER_CORE_POINTER;
172 LoginHelperClass *login_helper_class = LOGIN_HELPER_CLASS(klass);
196 can_open_display (gchar *display_name)
199 if ((d = XOpenDisplay (display_name)))
210 int x, y, unused_x, unused_y;
212 Window root_return, child_return;
216 if (!XQueryPointer (GDK_DISPLAY_XDISPLAY (magnifier->
source_display),
217 GDK_WINDOW_XWINDOW (magnifier->
priv->
root),
221 &unused_x, &unused_y,
226 GDK_WINDOW_XWINDOW (magnifier->
priv->
root),
239 g_assert (magnifier);
245 CORBA_Environment ev;
246 zoom_region = list->data;
247 CORBA_exception_init (&ev);
250 CORBA_Object_duplicate (zoom_region, &ev), &ev);
251 list = g_list_next (list);
260 g_assert (magnifier);
267 CORBA_Environment ev;
268 zoom_region = list->data;
269 CORBA_exception_init (&ev);
274 list = g_list_next (list);
280 GdkPixbuf *cursor_pixbuf)
282 GdkPixmap *pixmap, *mask;
285 GdkDrawable *drawable = gtk_widget_get_window (magnifier->
priv->
w);
291 if (drawable && cursor_pixbuf) {
292 const gchar *xhot_string = NULL, *yhot_string = NULL;
293 width = gdk_pixbuf_get_width (cursor_pixbuf);
294 height = gdk_pixbuf_get_height (cursor_pixbuf);
295 pixmap = gdk_pixmap_new (drawable, width, height, -1);
296 gc = gdk_gc_new (pixmap);
297 if (GDK_IS_DRAWABLE (pixmap))
298 gdk_draw_pixbuf (pixmap, gc, cursor_pixbuf, 0, 0, 0, 0,
299 width, height, GDK_RGB_DITHER_NONE,
302 DBG (g_warning (
"empty cursor pixmap created."));
303 mask = gdk_pixmap_new (drawable, width, height, 1);
304 gdk_pixbuf_render_threshold_alpha (cursor_pixbuf, mask,
312 xhot_string = g_object_get_data (G_OBJECT(cursor_pixbuf),
"x_hot");
313 yhot_string = g_object_get_data (G_OBJECT(cursor_pixbuf),
"y_hot");
320 gdk_drawable_get_size (
336 GdkPixbuf *retval = NULL;
338 retval = g_hash_table_lookup (magnifier->
priv->
cursorlist, cursor_name);
340 g_object_ref (retval);
346 const gchar *cursor_name,
347 gboolean source_fallback)
352 if (source_fallback == TRUE)
354 pixbuf = gmag_cursor_get_source_pixbuf (magnifier);
362 if (pixbuf) g_object_unref (pixbuf);
369 rect_bounds.
x1 = rect->x;
370 rect_bounds.
y1 = rect->y;
371 rect_bounds.
x2 = rect->x + rect->width;
372 rect_bounds.
y2 = rect->y + rect->height;
375 g_message (
"damage");
376 g_message (
"dirty %d, %d to %d, %d", rect_bounds.
x1, rect_bounds.
y1,
377 rect_bounds.
x2, rect_bounds.
y2);
385 gmag_gs_client_init (magnifier);
392 gmag_gs_check_set_struts (_this_magnifier);
398 gmag_gs_magnifier_realize (widget);
405 magnifier->
priv->
root = gdk_screen_get_root_window (
414 gchar **display_name)
419 if (display_name != NULL) {
420 strings = g_strsplit (full_display_string,
":", 2);
421 *display_name = strings [0];
422 if (strings [1] != NULL)
423 g_free (strings [1]);
426 screen_ptr = rindex (full_display_string,
'.');
427 if (screen_ptr != NULL) {
428 return (gint) strtol (++screen_ptr, NULL, 10);
439 rect_bounds->
x2 = gdk_screen_get_width (
443 rect_bounds->
y2 = gdk_screen_get_height (
451 rect_bounds->
x2 = gdk_screen_get_width (
455 rect_bounds->
y2 = gdk_screen_get_height (
467 gmag_gs_use_compositor (magnifier))
477 gdouble vfract_top, vfract_bottom, hfract_left, hfract_right;
482 (double) rect_bounds.
x2;
484 (
double) rect_bounds.
y2;
485 hfract_right = (double) (rect_bounds.
x2 -
487 (double) rect_bounds.
x2;
488 vfract_bottom = (
double) (rect_bounds.
y2 -
490 (
double) rect_bounds.
y2;
495 }
else if (MAX (hfract_left, hfract_right) >
496 MAX (vfract_top, vfract_bottom)) {
498 if (hfract_right > hfract_left) {
510 if (vfract_bottom > vfract_top) {
522 g_message (
"set source bounds to %d,%d; %d,%d",
531 CORBA_Environment ev;
533 CORBA_exception_init (&ev);
535 DBG(g_message (
"unreffing zoom region"));
538 if (!BONOBO_EX (&ev))
539 Bonobo_Unknown_unref (zoom_region, &ev);
548 DBG(g_message (
"unreffing zoom region"));
557 GSList *save_props = NULL;
559 g_assert (magnifier);
562 DBG(g_message (
"saving %d regions", g_list_length (list)));
567 CORBA_Environment ev;
568 zoom_region = list->data;
569 CORBA_exception_init (&ev);
581 zoomer_props->
is_managed = bonobo_pbclient_get_boolean (properties,
"is-managed", NULL);
582 zoomer_props->
scroll_policy = bonobo_pbclient_get_short (properties,
"smooth-scroll-policy", NULL);
583 zoomer_props->
contrast = bonobo_pbclient_get_float (properties,
"contrast", NULL);
584 zoomer_props->
zx = bonobo_pbclient_get_float (properties,
"mag-factor-x", NULL);
585 zoomer_props->
zy = bonobo_pbclient_get_float (properties,
"mag-factor-y", NULL);
586 zoomer_props->
xalign = bonobo_pbclient_get_long (properties,
"x-alignment", NULL);
587 zoomer_props->
yalign = bonobo_pbclient_get_long (properties,
"y-alignment", NULL);
588 zoomer_props->
border_color = bonobo_pbclient_get_long (properties,
"border-color", NULL);
589 zoomer_props->
border_size = bonobo_pbclient_get_long (properties,
"border-size", NULL);
590 zoomer_props->
smoothing_type = bonobo_pbclient_get_string (properties,
"smoothing-type", NULL);
591 zoomer_props->
inverse = bonobo_pbclient_get_boolean (properties,
"inverse-video", NULL);
593 bonobo_object_release_unref (properties, &ev);
595 save_props = g_slist_append (save_props, zoomer_props);
597 list = g_list_next (list);
609 GSList *list = region_params;
613 CORBA_Environment ev;
618 CORBA_exception_init (&ev);
621 bonobo_pbclient_set_boolean (new_properties,
"is-managed",
623 bonobo_pbclient_set_short (new_properties,
"smooth-scroll-policy",
625 bonobo_pbclient_set_float (new_properties,
"contrast",
633 bonobo_pbclient_set_long (new_properties,
"border-color",
635 bonobo_pbclient_set_long (new_properties,
"border-size",
637 bonobo_pbclient_set_string (new_properties,
"smoothing-type",
639 bonobo_pbclient_set_boolean (new_properties,
"inverse-video",
643 g_free (zoomer_props);
644 bonobo_object_release_unref (new_properties, &ev);
645 list = g_slist_next (list);
647 g_slist_free (region_params);
653 if (!can_open_display (display_name))
663 gdk_display_open (display_name);
667 gdk_screen_get_root_window (
668 gdk_display_get_screen (
679 gdk_display_open (display_name);
685 gdk_screen_get_root_window (
686 gdk_display_get_screen (
700 #define GET_PIXEL(a,i,j,s,b) \
701 (*(guint32 *)(memcpy (b,(a) + ((j) * s + (i) * pixel_size_t), pixel_size_t)))
703 #define PUT_PIXEL(a,i,j,s,b) \
704 (memcpy (a + ((j) * s + (i) * pixel_size_t), &(b), pixel_size_t))
709 int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
711 int w = gdk_pixbuf_get_width (pixbuf);
712 int h = gdk_pixbuf_get_height (pixbuf);
713 guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
714 guint32 pixval = 0, cursor_color = 0;
715 size_t pixel_size_t = 3;
717 cursor_color = ((magnifier->
cursor_color & 0xFF0000) >> 16) +
720 for (j = 0; j < h; ++j) {
721 for (i = 0; i < w; ++i) {
722 pixval =
GET_PIXEL (pixels, i, j, rowstride, &pixval);
723 if ((pixval & 0x808080) == 0)
725 pixval = cursor_color;
740 GdkPixbuf *scaled_cursor_pixbuf;
741 GdkPixbuf *scaled_mask_pixbuf;
742 GdkPixbuf *scaled_mask_pixbuf_alpha;
743 GdkPixbuf *cursor_pixbuf;
744 GdkPixbuf *mask_pixbuf;
745 GdkPixmap *cursor_pixmap = magnifier->
priv->
cursor;
762 gdk_drawable_get_size (magnifier->
priv->
cursor, &width, &height);
763 if ((size_x == width) && (size_y == height)
767 cgc = gdk_gc_new (cursor_pixmap);
768 mgc = gdk_gc_new (mask_pixmap);
769 cursor_pixbuf = gdk_pixbuf_get_from_drawable (NULL, cursor_pixmap,
774 mask_pixbuf = gdk_pixbuf_get_from_drawable (NULL,
778 scaled_cursor_pixbuf = gdk_pixbuf_scale_simple (
779 cursor_pixbuf, size_x, size_y, GDK_INTERP_NEAREST);
786 scaled_mask_pixbuf = gdk_pixbuf_scale_simple (
787 mask_pixbuf, size_x, size_y, GDK_INTERP_NEAREST);
788 g_object_unref (cursor_pixbuf);
789 g_object_unref (mask_pixbuf);
790 g_object_unref (cursor_pixmap);
791 g_object_unref (mask_pixmap);
793 gtk_widget_get_window (magnifier->
priv->
w),
796 if (!GDK_IS_DRAWABLE (magnifier->
priv->
cursor))
798 DBG (g_warning (
"NULL magnifier cursor pixmap."));
802 gtk_widget_get_window (magnifier->
priv->
w),
805 if (GDK_IS_DRAWABLE (magnifier->
priv->
cursor)) {
808 scaled_cursor_pixbuf,
809 0, 0, 0, 0, size_x, size_y,
810 GDK_RGB_DITHER_NONE, 0, 0 );
813 DBG (g_warning (
"cursor pixmap is non-drawable."));
814 scaled_mask_pixbuf_alpha = gdk_pixbuf_add_alpha (
815 scaled_mask_pixbuf, True, 0, 0, 0);
816 gdk_pixbuf_render_threshold_alpha (scaled_mask_pixbuf_alpha,
818 0, 0, 0, 0, size_x, size_y,
820 g_object_unref (scaled_mask_pixbuf_alpha);
821 g_object_unref (scaled_cursor_pixbuf);
822 g_object_unref (scaled_mask_pixbuf);
823 g_object_unref (mgc);
824 g_object_unref (cgc);
837 (!strcmp (cursor_set,
"default") &&
841 if (!strcmp (magnifier->
cursor_set,
"none")) {
848 const gchar *filename;
849 gchar *cursor_dirname;
855 magnifier->
priv->
cursorlist = g_hash_table_new_full (g_str_hash, g_str_equal,
856 g_free, g_object_unref);
858 cursor_dirname = g_strconcat (CURSORSDIR,
"/", magnifier->
cursor_set, NULL);
859 cursor_dir = g_dir_open (cursor_dirname, 0, NULL);
861 while (cursor_dir && (filename = g_dir_read_name (cursor_dir)) != NULL)
865 gchar *path = g_strconcat (cursor_dirname,
"/", filename, NULL);
866 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
871 cname = g_path_get_basename (filename);
872 sv = g_strsplit (cname,
".", 2);
882 g_free (cursor_dirname);
883 if (cursor_dir) g_dir_close (cursor_dir);
896 #if GTK_CHECK_VERSION (2,19,5)
897 if (magnifier->
priv &&
898 gtk_widget_get_realized (magnifier->
priv->
w) &&
899 gmag_gs_check_set_struts (magnifier)) {
903 if (magnifier->
priv &&
904 GTK_WIDGET_REALIZED (magnifier->
priv->
w) &&
905 gmag_gs_check_set_struts (magnifier)) {
917 CORBA_Environment *ev,
938 BONOBO_ARG_SET_STRING (arg, magnifier->
cursor_set);
949 TC_CORBA_unsigned_long,
950 CORBA_unsigned_long, NULL);
960 gdk_drawable_get_size (magnifier->
priv->
cursor,
962 BONOBO_ARG_SET_INT (arg, csize);
990 gchar *full_display_string = source_display;
991 if (can_open_display (full_display_string))
993 GSList *zoom_region_params = NULL;
999 gdk_display_open (full_display_string);
1003 gdk_screen_get_root_window (
1004 gdk_display_get_screen (
1027 gmag_gs_check_set_struts (magnifier);
1028 gmag_gs_reset_overlay_at_idle (magnifier);
1030 DBG(fprintf (stderr,
"Set source display: \t%s\n", full_display_string));
1044 gchar *full_display_string = target_display;
1045 if (can_open_display (full_display_string))
1049 full_display_string,
1052 gdk_display_open (full_display_string);
1054 if (GTK_IS_WINDOW (magnifier->
priv->
w))
1056 #ifdef REPARENT_GTK_WINDOW_WORKS
1057 gtk_window_set_screen (GTK_WINDOW (magnifier->
priv->
w),
1058 gdk_display_get_screen (
1062 GSList *zoom_region_params = NULL;
1064 g_object_disconnect (magnifier->
priv->
w,
1072 gtk_widget_destroy (magnifier->
priv->
w);
1088 gtk_window_move (GTK_WINDOW (magnifier->
priv->
w),
1102 gtk_window_resize (GTK_WINDOW (magnifier->
priv->
w),
1105 DBG(fprintf (stderr,
"Set target size: \t%d,%d to %d,%d\n",
1111 gmag_gs_check_set_struts (magnifier);
1113 DBG(fprintf (stderr,
"Set target display: \t%s (screen %d)\n",
1132 DBG (fprintf (stderr,
"Set source size: \t%d,%d to %d,%d\n",
1141 GArray *ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
1168 gtk_window_move (GTK_WINDOW (magnifier->
priv->
w),
1172 gtk_window_resize (GTK_WINDOW (magnifier->
priv->
w),
1175 gmag_gs_check_set_struts (magnifier);
1176 DBG(fprintf (stderr,
"Set target size: \t%d,%d to %d,%d\n",
1188 GArray *ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
1202 DBG (fprintf (stderr,
"Setting cursor set: \t%s\n", cursor_set));
1219 DBG (fprintf (stderr,
"Setting cursor size: \t%d\n", magnifier->
cursor_size_x));
1227 GArray *ret = g_array_new (FALSE, FALSE,
sizeof (gint));
1256 DBG (fprintf (stderr,
"Setting cursor color: \t%u\n", (
unsigned) magnifier->
cursor_color));
1280 GArray *ret = g_array_new (FALSE, FALSE,
sizeof (gint32));
1294 gdk_drawable_get_size (magnifier->
priv->
cursor, &csize, &csize);
1304 DBG (fprintf (stderr,
"Setting crosswire size: \t%d\n", magnifier->
crosswire_size));
1322 rect_bounds.
x2 = 4096;
1323 rect_bounds.
y2 = 4096;
1336 DBG (fprintf (stderr,
"Setting crosswire clip: \t%s\n", magnifier->
crosswire_clip ?
"true" :
"false"));
1357 DBG (fprintf (stderr,
"Setting crosswire color: \t%ld\n", (
long) magnifier->
crosswire_color));
1372 CORBA_Environment *ev,
1376 gchar *full_display_string;
1381 rect_bounds.
x2 = 4096;
1382 rect_bounds.
y2 = 4096;
1386 full_display_string = BONOBO_ARG_GET_STRING (arg);
1387 if (can_open_display (full_display_string))
1389 GSList *zoom_region_params = NULL;
1392 full_display_string,
1395 gdk_display_open (full_display_string);
1399 gdk_screen_get_root_window (
1400 gdk_display_get_screen (
1423 gmag_gs_check_set_struts (magnifier);
1424 gmag_gs_reset_overlay_at_idle (magnifier);
1426 DBG(fprintf (stderr,
"Set source display: \t%s\n", full_display_string));
1429 full_display_string = BONOBO_ARG_GET_STRING (arg);
1430 if (can_open_display (full_display_string))
1434 full_display_string,
1437 gdk_display_open (full_display_string);
1439 if (GTK_IS_WINDOW (magnifier->
priv->
w))
1441 #ifdef REPARENT_GTK_WINDOW_WORKS
1442 gtk_window_set_screen (GTK_WINDOW (magnifier->
priv->
w),
1443 gdk_display_get_screen (
1447 GSList *zoom_region_params = NULL;
1449 g_object_disconnect (magnifier->
priv->
w,
1457 gtk_widget_destroy (magnifier->
priv->
w);
1473 gtk_window_move (GTK_WINDOW (magnifier->
priv->
w),
1487 gtk_window_resize (GTK_WINDOW (magnifier->
priv->
w),
1490 DBG(fprintf (stderr,
"Set target size: \t%d,%d to %d,%d\n",
1496 gmag_gs_check_set_struts (magnifier);
1498 DBG(fprintf (stderr,
"Set target display: \t%s (screen %d)\n",
1506 DBG (fprintf (stderr,
"Set source size: \t%d,%d to %d,%d\n",
1524 gtk_window_move (GTK_WINDOW (magnifier->
priv->
w),
1528 gtk_window_resize (GTK_WINDOW (magnifier->
priv->
w),
1531 gmag_gs_check_set_struts (magnifier);
1532 DBG(fprintf (stderr,
"Set target size: \t%d,%d to %d,%d\n",
1540 DBG (fprintf (stderr,
"Setting cursor set: \t%s\n", BONOBO_ARG_GET_STRING (arg)));
1546 DBG (fprintf (stderr,
"Setting cursor size: \t%d\n", magnifier->
cursor_size_x));
1555 TC_CORBA_unsigned_long,
1556 CORBA_unsigned_long,
1559 DBG (fprintf (stderr,
"Setting cursor color: \t%u\n", (
unsigned) magnifier->
cursor_color));
1575 DBG (fprintf (stderr,
"Setting crosswire size: \t%d\n", magnifier->
crosswire_size));
1588 DBG (fprintf (stderr,
"Setting crosswire clip: \t%s\n", magnifier->
crosswire_clip ?
"true" :
"false"));
1593 DBG (fprintf (stderr,
"Setting crosswire size: \t%ld\n", (
long) magnifier->
crosswire_color));
1605 bonobo_activation_active_server_unregister (
1615 bonobo_main_quit ();
1623 BONOBO_CALL_PARENT (G_OBJECT_CLASS, dispose, (
object));
1629 CORBA_Environment *ev G_GNUC_UNUSED)
1631 #ifdef HAVE_COLORBLIND
1640 CORBA_Environment *ev)
1644 gmag_gs_hide_cursor (magnifier);
1649 CORBA_Environment *ev)
1653 gmag_gs_show_cursor (magnifier);
1659 CORBA_Environment * ev)
1665 gmag_gs_use_compositor (magnifier))
1676 gmag_gs_use_compositor (magnifier)) {
1686 gmag_gs_hide_cursor (magnifier);
1694 gmag_gs_show_cursor (magnifier);
1702 #ifdef HAVE_COLORBLIND
1714 const gint32 **viewport)
1718 DBG (fprintf (stderr,
"Create zoom region: \tzoom %f,%f, viewport %d,%d to %d,%d\n", (
float) zx, (
float) zy, (*viewport)[0], (*viewport)[1], (*viewport)[2], (*viewport)[3]));
1724 DBG(g_message (
"creating zoom region with parent %p", magnifier));
1733 gtk_widget_set_size_request (magnifier->
priv->
canvas,
1734 (*viewport)[2] - (*viewport)[0],
1735 (*viewport)[3] - (*viewport)[1]);
1737 gtk_widget_show (magnifier->
priv->
w);
1752 list = g_malloc0 (
sizeof (gchar *) * len);
1753 for (i = 0; i < len; ++i) {
1758 DBG (fprintf (stderr,
"Get zoom regions: \t%d\n", len));
1775 g_hash_table_remove (
zoom_hash, zoom_region_path);
1776 gmag_gs_check_set_struts (magnifier);
1806 const CORBA_char *display,
1807 CORBA_Environment *ev)
1810 BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
1811 gchar *full_display_string;
1813 full_display_string = g_strdup (display);
1814 if (strcmp (full_display_string,
"") == 0)
1815 full_display_string = (gchar *) g_getenv (
"DISPLAY");
1817 BONOBO_ARG_SET_STRING (arg, full_display_string);
1819 DBG (fprintf (stderr,
"Set source display: \t%s\n",
1820 full_display_string));
1831 DBG (fprintf (stderr,
"Attempt to set source to same value as previous: %s\n",
1832 full_display_string));
1834 bonobo_arg_release (arg);
1839 const CORBA_char *display,
1840 CORBA_Environment *ev)
1843 BonoboArg *arg = bonobo_arg_new (BONOBO_ARG_STRING);
1844 gchar *full_display_string;
1846 full_display_string = g_strdup (display);
1847 if (strcmp (full_display_string,
"") == 0)
1848 full_display_string = (gchar *) g_getenv (
"DISPLAY");
1850 BONOBO_ARG_SET_STRING (arg, full_display_string);
1852 DBG (fprintf (stderr,
"Set target display: \t%s\n",
1853 full_display_string));
1865 DBG (fprintf (stderr,
"Attempt to set target to same value as previous: %s\n",
1866 full_display_string));
1868 bonobo_arg_release (arg);
1874 CORBA_Environment *ev)
1885 CORBA_Environment *ev)
1888 DBG (fprintf (stderr,
"Get target display: \t%s\n",
1896 const CORBA_float zx,
1897 const CORBA_float zy,
1900 CORBA_Environment *ev)
1903 CORBA_any viewport_any;
1908 DBG (fprintf (stderr,
"Create zoom region: \tzoom %f,%f, viewport %d,%d to %d,%d\n", (
float) zx, (
float) zy, viewport->
x1, viewport->
y1, viewport->
x2, viewport->
y2));
1914 DBG(g_message (
"creating zoom region with parent %p", magnifier));
1917 retval = BONOBO_OBJREF (zoom_region);
1920 CORBA_exception_init (ev);
1923 if (ev->_major != CORBA_NO_EXCEPTION)
1924 fprintf (stderr,
"EXCEPTION setMagFactor\n");
1926 CORBA_exception_init (ev);
1928 if (ev->_major != CORBA_NO_EXCEPTION)
1929 fprintf (stderr,
"EXCEPTION getProperties\n");
1932 viewport_any._value = (gpointer) viewport;
1934 properties,
"viewport", &viewport_any, ev);
1937 if (ev->_major != CORBA_NO_EXCEPTION)
1938 fprintf (stderr,
"EXCEPTION setROI\n");
1940 CORBA_exception_init (ev);
1942 gtk_widget_set_size_request (magnifier->
priv->
canvas,
1943 viewport->
x2 - viewport->
x1,
1944 viewport->
y2 - viewport->
y1);
1946 gtk_widget_show (magnifier->
priv->
w);
1948 bonobo_object_release_unref (properties, ev);
1950 return CORBA_Object_duplicate (retval, ev);
1957 CORBA_Environment * ev)
1968 gmag_gs_check_set_struts (magnifier);
1975 CORBA_Environment *ev)
1978 return bonobo_object_dup_ref (
1984 CORBA_Environment * ev)
1987 MAGNIFIER (bonobo_object_from_servant (servant));
1990 CORBA_Object objref;
1998 for (i = 0; i < len; ++i) {
2001 CORBA_Object_duplicate (objref, ev);
2003 CORBA_sequence_set_release (list, CORBA_TRUE);
2005 DBG (fprintf (stderr,
"Get zoom regions: \t%d\n", len));
2012 CORBA_Environment * ev)
2015 fprintf (stderr,
"Clear all zoom regions.\n");
2026 CORBA_Environment *ev)
2029 MAGNIFIER (bonobo_object_from_servant (servant)));
2035 GObjectClass * object_class = (GObjectClass *) klass;
2065 bonobo_property_bag_new_closure (
2066 g_cclosure_new_object (
2068 G_OBJECT (magnifier)),
2069 g_cclosure_new_object (
2071 G_OBJECT (magnifier)));
2073 bonobo_object_add_interface (BONOBO_OBJECT (magnifier),
2076 def = bonobo_arg_new (BONOBO_ARG_STRING);
2077 display_env = getenv (
"DISPLAY");
2078 BONOBO_ARG_SET_STRING (def, display_env);
2081 "source-display-screen",
2085 "source display screen",
2089 "target-display-screen",
2093 "target display screen",
2096 bonobo_arg_release (def);
2105 "source-display-bounds",
2109 "source display bounds/size",
2112 bonobo_arg_release (def);
2118 "target-display-bounds",
2122 "target display bounds/size",
2125 bonobo_arg_release (def);
2132 "name of cursor set",
2136 def = bonobo_arg_new (BONOBO_ARG_INT);
2137 BONOBO_ARG_SET_INT (def, 64);
2144 "cursor size, in pixels",
2147 bonobo_arg_release (def);
2150 "cursor-scale-factor",
2154 "scale factor for cursors (overrides size)",
2161 TC_CORBA_unsigned_long,
2163 "foreground color for 1-bit cursors, as ARGB",
2172 "hotspot relative to cursor's upper-left-corner, at default resolition",
2177 "cursor-default-size",
2181 "default size of current cursor set",
2189 "thickness of crosswire cursor, in target pixels",
2198 "length of crosswire cursor, in target pixels",
2207 "color of crosswire, as A-RGB; note that alpha is required. (use 0 for XOR wire)",
2216 "whether to inset the cursor over the crosswire or not",
2224 GtkWindowType mag_win_type = GTK_WINDOW_TOPLEVEL;
2226 mag_win_type = GTK_WINDOW_POPUP;
2228 magnifier->
priv->
w =
2229 g_object_connect (gtk_widget_new (gtk_window_get_type (),
2232 "type", mag_win_type,
2233 "title",
"magnifier",
2235 "allow_shrink", TRUE,
2242 gtk_window_set_screen (GTK_WINDOW (magnifier->
priv->
w), screen);
2244 gtk_container_add (GTK_CONTAINER (magnifier->
priv->
w),
2275 magnifier->
priv->
w = NULL;
2289 #ifdef DEBUG_CLIENT_CALLS
2290 client_debug = (g_getenv (
"MAG_CLIENT_DEBUG") != NULL);
2293 zoom_hash = g_hash_table_new (g_str_hash, g_str_equal);
2304 gchar *default_cursor_filename =
2305 g_strconcat (CURSORSDIR,
"/",
"default-cursor.xpm", NULL);
2306 pixbuf = gdk_pixbuf_new_from_file (default_cursor_filename, NULL);
2310 g_object_unref (pixbuf);
2313 g_free (default_cursor_filename);
2315 GdkPixbuf *cursor_pixbuf = gmag_cursor_get_source_pixbuf (
2318 if (cursor_pixbuf) g_object_unref (cursor_pixbuf);
2330 GError *error = NULL;
2332 DBusGProxy *driver_proxy;
2340 _this_magnifier = mag;
2342 helper = g_object_new (mag_login_helper_get_type (), NULL);
2345 bonobo_object_add_interface (bonobo_object (mag),
2346 BONOBO_OBJECT (helper));
2348 ret = bonobo_activation_active_server_register (
2350 if (ret != Bonobo_ACTIVATION_REG_SUCCESS) {
2351 if ( ret == Bonobo_ACTIVATION_REG_ALREADY_ACTIVE)
2353 printf(
"An instance of magnifier is already active. Exiting Program.\n");
2356 g_error (
"Error registering magnifier server.\n");
2361 klass->
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
2363 g_warning (
"Unable to connect to dbus: %s", error->message);
2364 g_error_free (error);
2370 dbus_g_connection_register_g_object (klass->
connection,
"/org/freedesktop/gnome/Magnifier",
2371 G_OBJECT (_this_magnifier));
2373 driver_proxy = dbus_g_proxy_new_for_name (klass->
connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS,
2374 DBUS_INTERFACE_DBUS);
2376 if (!org_freedesktop_DBus_request_name (driver_proxy,
"org.freedesktop.gnome.Magnifier", 0, &request_req,
2378 g_warning (
"Unable to register service: %s", error->message);
2379 g_error_free (error);
2383 g_timeout_add (500, gmag_gs_reset_overlay_at_idle, mag);