magnifier.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 "zoom-region-private.h"
00028 #include "gmag-cursor.h"
00029 #include "gmag-graphical-server.h"
00030 #include "GNOME_Magnifier.h"
00031 #include "magnifier-server.h"
00032 
00033 #include <stdlib.h>
00034 #include <string.h>
00035 #include <strings.h>
00036 
00037 #include <libbonobo.h>
00038 #include <login-helper/login-helper.h>
00039 
00040 #include <dbus/dbus-glib-bindings.h>
00041 
00042 #include <gdk-pixbuf/gdk-pixbuf.h>
00043 #include <gdk/gdkx.h>
00044 #include <gdk/gdk.h>
00045 #include <gtk/gtk.h>
00046 
00047 /* if you #define this, don't forget to set MAG_CLIENT_DEBUG env variable */
00048 #define DEBUG_CLIENT_CALLS
00049 
00050 #ifdef DEBUG_CLIENT_CALLS
00051 static gboolean client_debug = FALSE;
00052 #define DBG(a) if (client_debug) { (a); }
00053 #else
00054 #define DBG(a)
00055 #endif
00056 
00057 typedef struct
00058 {
00059     LoginHelper parent;
00060     Magnifier *mag;
00061 } MagLoginHelper;
00062 
00063 typedef struct 
00064 {
00065     LoginHelperClass parent_class;
00066 } MagLoginHelperClass;
00067 
00068 static GObjectClass *parent_class = NULL;
00069 
00070 enum {
00071         MAGNIFIER_SOURCE_DISPLAY_PROP,
00072         MAGNIFIER_TARGET_DISPLAY_PROP,
00073         MAGNIFIER_SOURCE_SIZE_PROP,
00074         MAGNIFIER_TARGET_SIZE_PROP,
00075         MAGNIFIER_CURSOR_SET_PROP,
00076         MAGNIFIER_CURSOR_SIZE_PROP,
00077         MAGNIFIER_CURSOR_ZOOM_PROP,
00078         MAGNIFIER_CURSOR_COLOR_PROP,
00079         MAGNIFIER_CURSOR_HOTSPOT_PROP,
00080         MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP,
00081         MAGNIFIER_CROSSWIRE_SIZE_PROP,
00082         MAGNIFIER_CROSSWIRE_LENGTH_PROP,
00083         MAGNIFIER_CROSSWIRE_CLIP_PROP,
00084         MAGNIFIER_CROSSWIRE_COLOR_PROP
00085 } PropIdx;
00086 
00087 typedef struct
00088 {
00089         GNOME_Magnifier_RectBounds rectbounds;
00090         RectBounds dbus_rectbounds;
00091         GNOME_Magnifier_RectBounds viewport;
00092         RectBounds dbus_viewport;
00093         gboolean   is_managed;
00094         gint       scroll_policy;
00095         gfloat     contrast;
00096         gfloat     zx;
00097         gfloat     zy;
00098         gint32     xalign;
00099         gint32     yalign;
00100         guint32    border_color;
00101         gint32     border_size;
00102         gchar     *smoothing_type;
00103         gboolean   inverse;
00104 } MagnifierZoomRegionSaveProps;
00105 
00106 #ifdef DEBUG_CLIENT_CALLS
00107 gchar* mag_prop_names[MAGNIFIER_CROSSWIRE_COLOR_PROP + 1] = {
00108     "SOURCE_DISPLAY",
00109     "TARGET_DISPLAY",
00110     "SOURCE_SIZE",
00111     "TARGET_SIZE",
00112     "CURSOR_SET",
00113     "CURSOR_SIZE",
00114     "CURSOR_ZOOM",
00115     "CURSOR_COLOR",
00116     "CURSOR_HOTSPOT",
00117     "CURSOR_DEFAULT_SIZE",
00118     "CROSSWIRE_SIZE",
00119     "CROSSWIRE_LENGTH",
00120     "CROSSWIRE_CLIP",
00121     "CROSSWIRE_COLOR"
00122 };
00123 #endif
00124 
00125 static Magnifier *_this_magnifier = NULL;
00126 extern gint       fixes_event_base;
00127 
00128 static void magnifier_init_cursor_set (Magnifier *magnifier, gchar *cursor_set);
00129 static void magnifier_init_window (Magnifier *magnifier, GdkScreen *screen);
00130 static gboolean magnifier_reset_struts_at_idle (gpointer data);
00131 static void magnifier_init_window (Magnifier *magnifier, GdkScreen *screen);
00132 static void magnifier_adjust_source_size (Magnifier *magnifier);
00133 static gboolean _is_override_redirect = FALSE;
00134 
00135 static GHashTable *zoom_hash = NULL;
00136 
00137 static Window*
00138 mag_login_helper_get_raise_windows (LoginHelper *helper)
00139 {
00140     Window *mainwin = NULL;
00141     MagLoginHelper *mag_helper = (MagLoginHelper *) helper;
00142     Magnifier *magnifier = MAGNIFIER (mag_helper->mag);
00143 
00144     if (magnifier && magnifier->priv && magnifier->priv->w)
00145     {
00146         mainwin = g_new0 (Window, 2);
00147         mainwin[0] = GDK_WINDOW_XWINDOW (magnifier->priv->w->window);
00148         mainwin[1] = None;
00149     }
00150     return mainwin;
00151 }
00152 
00153 static LoginHelperDeviceReqFlags
00154 mag_login_helper_get_device_reqs (LoginHelper *helper)
00155 {
00156     /* means "don't grab the xserver or core pointer", 
00157        and "we need to raise windows" */
00158     return LOGIN_HELPER_GUI_EVENTS | 
00159         LOGIN_HELPER_POST_WINDOWS | 
00160         LOGIN_HELPER_CORE_POINTER;
00161 }
00162 
00163 static gboolean
00164 mag_login_helper_set_safe (LoginHelper *helper, gboolean ignored)
00165 {
00166     return TRUE;
00167 }
00168 
00169 static void
00170 mag_login_helper_class_init (MagLoginHelperClass *klass)
00171 {
00172         LoginHelperClass *login_helper_class = LOGIN_HELPER_CLASS(klass);
00173         login_helper_class->get_raise_windows = mag_login_helper_get_raise_windows;
00174         login_helper_class->get_device_reqs = mag_login_helper_get_device_reqs;
00175         login_helper_class->set_safe = mag_login_helper_set_safe;
00176 }
00177 
00178 static void
00179 mag_login_helper_init (MagLoginHelper *helper)
00180 {
00181     helper->mag = NULL; /* we set this with mag_login_helper_set_magnifier */
00182 }
00183 
00184 static void
00185 mag_login_helper_set_magnifier (MagLoginHelper *helper, Magnifier *mag)
00186 {
00187     if (helper) 
00188         helper->mag = mag;
00189 }
00190 
00191 BONOBO_TYPE_FUNC (MagLoginHelper, 
00192                   LOGIN_HELPER_TYPE,
00193                   mag_login_helper)
00194 
00195 static gboolean
00196 can_open_display (gchar *display_name)
00197 {
00198     Display *d;
00199     if ((d = XOpenDisplay (display_name)))
00200     {
00201         XCloseDisplay (d);
00202         return TRUE;
00203     }
00204     return FALSE;
00205 }
00206 
00207 static void
00208 magnifier_warp_cursor_to_screen (Magnifier *magnifier)
00209 {
00210         int x, y, unused_x, unused_y;
00211         unsigned int mask;
00212         Window root_return, child_return;
00213 
00214         if (magnifier->source_display)
00215         {
00216             if (!XQueryPointer (GDK_DISPLAY_XDISPLAY (magnifier->source_display), 
00217                                 GDK_WINDOW_XWINDOW (magnifier->priv->root), 
00218                                 &root_return,
00219                                 &child_return,
00220                                 &x, &y,
00221                                 &unused_x, &unused_y,
00222                                 &mask))
00223             {
00224                 XWarpPointer (GDK_DISPLAY_XDISPLAY (magnifier->source_display),
00225                               None,
00226                               GDK_WINDOW_XWINDOW (magnifier->priv->root),
00227                               0, 0, 0, 0,
00228                               x, y);
00229                 XSync (GDK_DISPLAY_XDISPLAY (magnifier->source_display), FALSE);
00230             }
00231         }
00232 }
00233 
00234 void
00235 magnifier_zoom_regions_update_pointer (Magnifier *magnifier)
00236 {
00237         GList *list;
00238 
00239         g_assert (magnifier);
00240 
00241         list = magnifier->zoom_regions;
00242         while (list) {
00243                 /* propagate the expose events to the zoom regions */
00244                 GNOME_Magnifier_ZoomRegion zoom_region;
00245                 CORBA_Environment ev;
00246                 zoom_region = list->data;
00247                 CORBA_exception_init (&ev);
00248                 if (zoom_region)
00249                         GNOME_Magnifier_ZoomRegion_updatePointer (
00250                                 CORBA_Object_duplicate (zoom_region, &ev), &ev);
00251                 list = g_list_next (list);
00252         }
00253 }
00254 
00255 static void
00256 magnifier_zoom_regions_mark_dirty (Magnifier *magnifier, GNOME_Magnifier_RectBounds rect_bounds)
00257 {
00258         GList *list;
00259 
00260         g_assert (magnifier);
00261 
00262         list = magnifier->zoom_regions;
00263         while (list) 
00264         {
00265                 /* propagate the expose events to the zoom regions */
00266                 GNOME_Magnifier_ZoomRegion zoom_region;
00267                 CORBA_Environment ev;
00268                 zoom_region = list->data;
00269                 CORBA_exception_init (&ev);
00270                 if (zoom_region)
00271                         GNOME_Magnifier_ZoomRegion_markDirty (CORBA_Object_duplicate (zoom_region, &ev),
00272                                                               &rect_bounds,
00273                                                               &ev);
00274                 list = g_list_next (list);
00275         }
00276 }
00277 
00278 void
00279 magnifier_set_cursor_from_pixbuf (Magnifier *magnifier,
00280                                   GdkPixbuf *cursor_pixbuf)
00281 {
00282         GdkPixmap *pixmap, *mask;
00283         gint width, height;
00284         GdkGC *gc;
00285         GdkDrawable *drawable = magnifier->priv->w->window;
00286 
00287         if (magnifier->priv->cursor) {
00288                 g_object_unref (magnifier->priv->cursor);
00289                 magnifier->priv->cursor = NULL;
00290         }
00291         if (drawable && cursor_pixbuf) {
00292                 const gchar *xhot_string = NULL, *yhot_string = NULL;
00293                 width = gdk_pixbuf_get_width (cursor_pixbuf);
00294                 height = gdk_pixbuf_get_height (cursor_pixbuf);
00295                 pixmap = gdk_pixmap_new (drawable, width, height, -1);
00296                 gc = gdk_gc_new (pixmap);
00297                 if (GDK_IS_DRAWABLE (pixmap))
00298                         gdk_draw_pixbuf (pixmap, gc, cursor_pixbuf, 0, 0, 0, 0,
00299                                          width, height, GDK_RGB_DITHER_NONE,
00300                                          0, 0);
00301                 else
00302                         DBG (g_warning ("empty cursor pixmap created."));
00303                 mask = gdk_pixmap_new (drawable, width, height, 1);
00304                 gdk_pixbuf_render_threshold_alpha (cursor_pixbuf, mask,
00305                                                    0, 0, 0, 0, 
00306                                                    width, height,
00307                                                    200);
00308                 g_object_unref (gc);
00309                 magnifier->priv->cursor = pixmap;
00310                 magnifier->priv->cursor_mask = mask;
00311 
00312                 xhot_string = g_object_get_data (cursor_pixbuf, "x_hot");
00313                 yhot_string = g_object_get_data (cursor_pixbuf, "y_hot");
00314 
00315                 if (xhot_string)
00316                         magnifier->cursor_hotspot.x = atoi (xhot_string);
00317                 if (yhot_string)
00318                         magnifier->cursor_hotspot.y = atoi (yhot_string);
00319                 if (pixmap) {
00320                         gdk_drawable_get_size (
00321                                 pixmap,
00322                                 &magnifier->priv->cursor_default_size_x,
00323                                 &magnifier->priv->cursor_default_size_y);
00324                         magnifier->priv->cursor_hotspot_x =
00325                                 magnifier->cursor_hotspot.x;
00326                         magnifier->priv->cursor_hotspot_y =
00327                                 magnifier->cursor_hotspot.y;
00328                 }
00329         }
00330 }
00331 
00332 
00333 GdkPixbuf *
00334 magnifier_get_pixbuf_for_name (Magnifier *magnifier, const gchar *cursor_name)
00335 {
00336     GdkPixbuf *retval = NULL;
00337     if (magnifier->priv->cursorlist) 
00338             retval = g_hash_table_lookup (magnifier->priv->cursorlist, cursor_name);
00339     if (retval) 
00340             g_object_ref (retval);
00341     return retval;
00342 }
00343 
00344 void
00345 magnifier_set_cursor_pixmap_by_name (Magnifier *magnifier,
00346                                      const gchar *cursor_name, 
00347                                      gboolean source_fallback)
00348 {
00349         GdkPixbuf *pixbuf;
00350         /* search local table; if not found, use source screen's cursor if source_fallback is TRUE */
00351         if ((pixbuf = magnifier_get_pixbuf_for_name (magnifier, cursor_name)) == NULL) {
00352                 if (source_fallback == TRUE)
00353                 {
00354                         pixbuf = gmag_cursor_get_source_pixbuf (magnifier);
00355                 }
00356                 else
00357                 {
00358                         pixbuf = magnifier_get_pixbuf_for_name (magnifier, "default");
00359                 }
00360         }
00361         magnifier_set_cursor_from_pixbuf (magnifier, pixbuf);
00362         if (pixbuf) g_object_unref (pixbuf);
00363 }
00364 
00365 void
00366 magnifier_notify_damage (Magnifier *magnifier, GdkRectangle *rect)
00367 {
00368         GNOME_Magnifier_RectBounds rect_bounds;
00369         rect_bounds.x1 = rect->x;
00370         rect_bounds.y1 = rect->y;
00371         rect_bounds.x2 = rect->x + rect->width;
00372         rect_bounds.y2 = rect->y + rect->height;
00373 #undef DEBUG_DAMAGE
00374 #ifdef DEBUG_DAMAGE
00375         g_message ("damage");
00376         g_message ("dirty %d, %d to %d, %d", rect_bounds.x1, rect_bounds.y1,
00377                    rect_bounds.x2, rect_bounds.y2);
00378 #endif
00379         magnifier_zoom_regions_mark_dirty (magnifier, rect_bounds);
00380 }
00381 
00382 static void
00383 magnifier_set_extension_listeners (Magnifier *magnifier, GdkWindow *root)
00384 {
00385         gmag_gs_client_init (magnifier);
00386         magnifier->source_initialized = TRUE;
00387 }
00388 
00389 static void
00390 magnifier_size_allocate (GtkWidget *widget)
00391 {
00392         gmag_gs_check_set_struts (_this_magnifier);
00393 }
00394 
00395 static void
00396 magnifier_realize (GtkWidget *widget)
00397 {
00398         gmag_gs_magnifier_realize (widget);
00399 }
00400 
00401 GdkWindow*
00402 magnifier_get_root (Magnifier *magnifier)
00403 {
00404     if (!magnifier->priv->root && magnifier->source_display) {
00405         magnifier->priv->root = gdk_screen_get_root_window (
00406             gdk_display_get_screen (magnifier->source_display,
00407                                     magnifier->source_screen_num));
00408     }
00409     return magnifier->priv->root;
00410 }
00411 
00412 static gint
00413 magnifier_parse_display_name (Magnifier *magnifier, gchar *full_display_string,
00414                               gchar **display_name)
00415 {
00416         gchar *screen_ptr;
00417         gchar **strings;
00418         
00419         if (display_name != NULL) {
00420                 strings = g_strsplit (full_display_string, ":", 2);
00421                 *display_name = strings [0];
00422                 if (strings [1] != NULL)
00423                         g_free (strings [1]);
00424         }
00425 
00426         screen_ptr = rindex (full_display_string, '.');
00427         if (screen_ptr != NULL) {
00428                 return (gint) strtol (++screen_ptr, NULL, 10);
00429         }
00430         return 0;
00431 }
00432 
00433 static void
00434 magnifier_get_display_rect_bounds (Magnifier *magnifier, GNOME_Magnifier_RectBounds *rect_bounds, gboolean is_target)
00435 {
00436     if (is_target)
00437     {
00438         rect_bounds->x1 = 0;
00439         rect_bounds->x2 = gdk_screen_get_width (
00440             gdk_display_get_screen (magnifier->target_display,
00441                                     magnifier->target_screen_num));
00442         rect_bounds->y1 = 0;
00443         rect_bounds->y2 = gdk_screen_get_height (
00444             gdk_display_get_screen (magnifier->target_display,
00445                                     magnifier->target_screen_num));
00446 
00447     }
00448     else 
00449     {
00450         rect_bounds->x1 = 0;
00451         rect_bounds->x2 = gdk_screen_get_width (
00452             gdk_display_get_screen (magnifier->source_display,
00453                                     magnifier->source_screen_num));
00454         rect_bounds->y1 = 0;
00455         rect_bounds->y2 = gdk_screen_get_height (
00456             gdk_display_get_screen (magnifier->source_display,
00457                                     magnifier->source_screen_num));
00458 
00459     }
00460 }
00461 
00462 gboolean
00463 magnifier_full_screen_capable (Magnifier *magnifier)
00464 {
00465         if ((strcmp (magnifier->source_display_name,
00466                      magnifier->target_display_name) != 0) ||
00467                 gmag_gs_use_compositor (magnifier))
00468                 return TRUE;
00469 
00470         return FALSE;
00471 }
00472 
00473 static void
00474 magnifier_adjust_source_size (Magnifier *magnifier)
00475 {
00476         GNOME_Magnifier_RectBounds rect_bounds; 
00477         gdouble vfract_top, vfract_bottom, hfract_left, hfract_right;
00478 
00479         magnifier_get_display_rect_bounds (magnifier, &rect_bounds, FALSE);
00480 
00481         hfract_left = (double) (magnifier->target_bounds.x1) /
00482                 (double) rect_bounds.x2;
00483         vfract_top = (double) (magnifier->target_bounds.y1) /
00484                 (double) rect_bounds.y2;
00485         hfract_right = (double) (rect_bounds.x2 -
00486                                  magnifier->target_bounds.x2) /
00487                 (double) rect_bounds.x2;
00488         vfract_bottom = (double) (rect_bounds.y2 -
00489                                   magnifier->target_bounds.y2) /
00490                 (double) rect_bounds.y2;
00491 
00492         if (magnifier_full_screen_capable (magnifier)) {
00493         /* we make our 'source' rectangle the largest available subsection which we aren't occupying */
00494                 magnifier->source_bounds = rect_bounds;
00495         } else if (MAX (hfract_left, hfract_right) >
00496                    MAX (vfract_top, vfract_bottom)) {  /* vertical split,
00497                                                         * approximately */
00498                 if (hfract_right > hfract_left) {
00499                         magnifier->source_bounds.x1 =
00500                                 magnifier->target_bounds.x2;
00501                         magnifier->source_bounds.x2 = rect_bounds.x2;
00502                 } else  {
00503                         magnifier->source_bounds.x1 = rect_bounds.x1;
00504                         magnifier->source_bounds.x2 =
00505                                 magnifier->target_bounds.x1;
00506                 }
00507                 magnifier->source_bounds.y1 = rect_bounds.y1;
00508                 magnifier->source_bounds.y2 = rect_bounds.y2;
00509         } else { /* more-or-less horizontally split */
00510                 if (vfract_bottom > vfract_top) {
00511                         magnifier->source_bounds.y1 =
00512                                 magnifier->target_bounds.y2;
00513                         magnifier->source_bounds.y2 = rect_bounds.y2;
00514                 } else {
00515                         magnifier->source_bounds.y1 = rect_bounds.y1;
00516                         magnifier->source_bounds.y2 =
00517                                 magnifier->target_bounds.y1;
00518                 }
00519                 magnifier->source_bounds.x1 = rect_bounds.x1;
00520                 magnifier->source_bounds.x2 = rect_bounds.x2;
00521         }
00522         g_message ("set source bounds to %d,%d; %d,%d", 
00523                    magnifier->source_bounds.x1, magnifier->source_bounds.y1,
00524                    magnifier->source_bounds.x2, magnifier->source_bounds.y2);
00525 }
00526 
00527 static void
00528 magnifier_unref_zoom_region (gpointer data, gpointer user_data)
00529 {
00530 /*      Magnifier *magnifier = user_data; NOT USED */
00531         CORBA_Environment ev;
00532         GNOME_Magnifier_ZoomRegion zoom_region = data;
00533         CORBA_exception_init (&ev);
00534         
00535         DBG(g_message ("unreffing zoom region"));
00536 
00537         GNOME_Magnifier_ZoomRegion_dispose (zoom_region, &ev);
00538         if (!BONOBO_EX (&ev))
00539             Bonobo_Unknown_unref (zoom_region, &ev);
00540 }
00541 
00542 static void
00543 magnifier_dbus_unref_zoom_region (gpointer data, gpointer user_data)
00544 {
00545 /*      Magnifier *magnifier = user_data; NOT USED */
00546         ZoomRegion *zoom_region = data;
00547         
00548         DBG(g_message ("unreffing zoom region"));
00549 
00550         impl_dbus_zoom_region_dispose (zoom_region);
00551 }
00552 
00553 static GSList*
00554 magnifier_zoom_regions_save (Magnifier *magnifier)
00555 {
00556     GList *list;
00557     GSList *save_props = NULL;
00558     
00559     g_assert (magnifier);
00560     list = magnifier->zoom_regions;
00561 
00562     DBG(g_message ("saving %d regions", g_list_length (list)));
00563 
00564     while (list) 
00565     {
00566         GNOME_Magnifier_ZoomRegion zoom_region;
00567         CORBA_Environment ev;
00568         zoom_region = list->data;
00569         CORBA_exception_init (&ev);
00570         if (zoom_region)
00571         {
00572             Bonobo_PropertyBag properties;
00573             CORBA_any *value;
00574             MagnifierZoomRegionSaveProps *zoomer_props = g_new0 (MagnifierZoomRegionSaveProps, 1);
00575 
00576             zoomer_props->rectbounds = GNOME_Magnifier_ZoomRegion_getROI (zoom_region, &ev);
00577             properties = GNOME_Magnifier_ZoomRegion_getProperties (zoom_region, &ev);
00578             value = bonobo_pbclient_get_value (properties, "viewport", TC_GNOME_Magnifier_RectBounds, &ev);
00579             memcpy (&zoomer_props->viewport, value->_value, sizeof (GNOME_Magnifier_RectBounds));
00580             CORBA_free (value);
00581             zoomer_props->is_managed = bonobo_pbclient_get_boolean (properties, "is-managed", NULL);
00582             zoomer_props->scroll_policy = bonobo_pbclient_get_short (properties, "smooth-scroll-policy", NULL);
00583             zoomer_props->contrast = bonobo_pbclient_get_float (properties, "contrast", NULL);
00584             zoomer_props->zx = bonobo_pbclient_get_float (properties, "mag-factor-x", NULL);
00585             zoomer_props->zy = bonobo_pbclient_get_float (properties, "mag-factor-y", NULL);
00586             zoomer_props->xalign = bonobo_pbclient_get_long (properties, "x-alignment", NULL);
00587             zoomer_props->yalign = bonobo_pbclient_get_long (properties, "y-alignment", NULL);
00588             zoomer_props->border_color = bonobo_pbclient_get_long (properties, "border-color", NULL); 
00589             zoomer_props->border_size = bonobo_pbclient_get_long (properties, "border-size", NULL);
00590             zoomer_props->smoothing_type = bonobo_pbclient_get_string (properties, "smoothing-type", NULL); 
00591             zoomer_props->inverse = bonobo_pbclient_get_boolean (properties, "inverse-video", NULL); 
00592 
00593             bonobo_object_release_unref (properties, &ev);
00594             magnifier_unref_zoom_region ((gpointer) zoom_region, NULL);
00595             save_props = g_slist_append (save_props, zoomer_props);
00596         }
00597         list = g_list_next (list);
00598     }   
00599 
00600     magnifier->zoom_regions = NULL;
00601     magnifier->zoom_regions_dbus = NULL;
00602 
00603     return save_props;
00604 }
00605 
00606 static void
00607 magnifier_zoom_regions_restore (Magnifier *magnifier, GSList *region_params)
00608 {
00609         GSList *list = region_params;
00610 
00611         while (list)
00612         {
00613                 CORBA_Environment ev;
00614                 MagnifierZoomRegionSaveProps *zoomer_props = list->data;
00615                 GNOME_Magnifier_ZoomRegion new_region;
00616                 Bonobo_PropertyBag new_properties;
00617 
00618                 CORBA_exception_init (&ev);
00619                 new_region = GNOME_Magnifier_Magnifier_createZoomRegion (BONOBO_OBJREF (magnifier), zoomer_props->zx, zoomer_props->zy, &zoomer_props->rectbounds, &zoomer_props->viewport, &ev);
00620                 new_properties = GNOME_Magnifier_ZoomRegion_getProperties (new_region, &ev);
00621                 bonobo_pbclient_set_boolean (new_properties, "is-managed", 
00622                                              zoomer_props->is_managed, NULL);
00623                 bonobo_pbclient_set_short (new_properties, "smooth-scroll-policy", 
00624                                            zoomer_props->scroll_policy, NULL);
00625                 bonobo_pbclient_set_float (new_properties, "contrast", 
00626                                            zoomer_props->contrast, NULL);
00627 /* NOT YET USED
00628                 bonobo_pbclient_set_long (new_properties, "x-alignment", 
00629                                              zoomer_props->xalign, NULL);
00630                 bonobo_pbclient_set_long (new_properties, "y-alignment", 
00631                                              zoomer_props->yalign, NULL);
00632 */
00633                 bonobo_pbclient_set_long (new_properties, "border-color", 
00634                                              zoomer_props->border_color, NULL);
00635                 bonobo_pbclient_set_long (new_properties, "border-size", 
00636                                              zoomer_props->border_size, NULL);
00637                 bonobo_pbclient_set_string (new_properties, "smoothing-type", 
00638                                              zoomer_props->smoothing_type, NULL);
00639                 bonobo_pbclient_set_boolean (new_properties, "inverse-video", 
00640                                              zoomer_props->inverse, NULL);
00641                 GNOME_Magnifier_Magnifier_addZoomRegion (BONOBO_OBJREF (magnifier), new_region, &ev);
00642                 g_free (zoomer_props->smoothing_type);
00643                 g_free (zoomer_props);
00644                 bonobo_object_release_unref (new_properties, &ev);
00645                 list = g_slist_next (list);
00646         }
00647         g_slist_free (region_params);
00648 }
00649 
00650 static void
00651 magnifier_init_display (Magnifier *magnifier, gchar *display_name, gboolean is_target)
00652 {
00653     if (!can_open_display (display_name))
00654         return;
00655 
00656     if (is_target)
00657     {
00658         magnifier->target_screen_num =
00659             magnifier_parse_display_name (magnifier,
00660                                           display_name,
00661                                           NULL);
00662         magnifier->target_display =
00663             gdk_display_open (display_name);
00664         if (magnifier->target_display_name) g_free (magnifier->target_display_name);
00665         magnifier->target_display_name = g_strdup (display_name);
00666         magnifier->priv->root =
00667             gdk_screen_get_root_window (
00668                 gdk_display_get_screen (
00669                     magnifier->target_display,
00670                     magnifier->target_screen_num));
00671     }
00672     else 
00673     {
00674         magnifier->source_screen_num =
00675             magnifier_parse_display_name (magnifier,
00676                                           display_name,
00677                                           NULL);
00678         magnifier->source_display =
00679             gdk_display_open (display_name);
00680         if (magnifier->source_display)
00681         {
00682             if (magnifier->source_display_name) g_free (magnifier->source_display_name);
00683             magnifier->source_display_name = g_strdup (display_name);
00684             magnifier->priv->root =
00685                 gdk_screen_get_root_window (
00686                     gdk_display_get_screen (
00687                         magnifier->source_display,
00688                         magnifier->source_screen_num));
00689         }
00690     }
00691 }
00692 
00693 static void
00694 magnifier_exit (GtkObject *object)
00695 {
00696         gtk_main_quit ();
00697         exit (0);
00698 }
00699 
00700 #define GET_PIXEL(a,i,j,s,b) \
00701 (*(guint32 *)(memcpy (b,(a) + ((j) * s + (i) * pixel_size_t), pixel_size_t)))
00702 
00703 #define PUT_PIXEL(a,i,j,s,b) \
00704 (memcpy (a + ((j) * s + (i) * pixel_size_t), &(b), pixel_size_t))
00705 
00706 static void
00707 magnifier_recolor_pixbuf (Magnifier *magnifier, GdkPixbuf *pixbuf)
00708 {
00709         int rowstride = gdk_pixbuf_get_rowstride (pixbuf);
00710         int i, j;
00711         int w = gdk_pixbuf_get_width (pixbuf);
00712         int h = gdk_pixbuf_get_height (pixbuf);
00713         guchar *pixels = gdk_pixbuf_get_pixels (pixbuf);
00714         guint32 pixval = 0, cursor_color = 0;
00715         size_t pixel_size_t = 3; /* FIXME: invalid assumption ? */
00716 
00717         cursor_color = ((magnifier->cursor_color & 0xFF0000) >> 16) +
00718                 (magnifier->cursor_color & 0x00FF00) +
00719                 ((magnifier->cursor_color & 0x0000FF) << 16);
00720         for (j = 0; j < h; ++j) {
00721                 for (i = 0; i < w; ++i) {
00722                         pixval = GET_PIXEL (pixels, i, j, rowstride, &pixval);
00723                         if ((pixval & 0x808080) == 0)
00724                         {
00725                                 pixval = cursor_color;
00726                                 PUT_PIXEL (pixels, i, j, rowstride,
00727                                            pixval);
00728                         }
00729                 }
00730         }
00731 }
00732 
00733 void
00734 magnifier_transform_cursor (Magnifier *magnifier)
00735 {
00736         if (magnifier->priv->cursor) /* don't do this if cursor isn't intialized yet */
00737         {
00738                 int width, height;
00739                 int size_x, size_y;
00740                 GdkPixbuf *scaled_cursor_pixbuf;
00741                 GdkPixbuf *scaled_mask_pixbuf;
00742                 GdkPixbuf *scaled_mask_pixbuf_alpha;
00743                 GdkPixbuf *cursor_pixbuf;
00744                 GdkPixbuf *mask_pixbuf;
00745                 GdkPixmap *cursor_pixmap = magnifier->priv->cursor;
00746                 GdkPixmap *mask_pixmap = magnifier->priv->cursor_mask;
00747                 GdkGC *cgc;
00748                 GdkGC *mgc;
00749 
00750                 if (magnifier->cursor_size_x)
00751                 {
00752                         size_x = magnifier->cursor_size_x;
00753                         size_y = magnifier->cursor_size_y;
00754                 }
00755                 else
00756                 {
00757                         size_x = magnifier->priv->cursor_default_size_x * 
00758                                magnifier->cursor_scale_factor;
00759                         size_y = magnifier->priv->cursor_default_size_y * 
00760                                magnifier->cursor_scale_factor;
00761                 }
00762                 gdk_drawable_get_size (magnifier->priv->cursor, &width, &height);
00763                 if ((size_x == width) && (size_y == height) 
00764                     && (magnifier->cursor_color == 0xFF000000)) {
00765                         return; /* nothing changes */
00766                 }
00767                 cgc = gdk_gc_new (cursor_pixmap);
00768                 mgc = gdk_gc_new (mask_pixmap);
00769                 cursor_pixbuf = gdk_pixbuf_get_from_drawable (NULL, cursor_pixmap,
00770                                                               NULL, 0, 0, 0, 0,
00771                                                               width, height);
00772                 if (magnifier->cursor_color != 0xFF000000)
00773                         magnifier_recolor_pixbuf (magnifier, cursor_pixbuf);
00774                 mask_pixbuf = gdk_pixbuf_get_from_drawable (NULL,
00775                                                             mask_pixmap,
00776                                                             NULL, 0, 0, 0, 0,
00777                                                             width, height);
00778                 scaled_cursor_pixbuf = gdk_pixbuf_scale_simple (
00779                         cursor_pixbuf, size_x, size_y, GDK_INTERP_NEAREST);
00780                 
00781                 magnifier->cursor_hotspot.x = magnifier->priv->cursor_hotspot_x * size_x 
00782                                             / magnifier->priv->cursor_default_size_x;
00783                 magnifier->cursor_hotspot.y = magnifier->priv->cursor_hotspot_y * size_y 
00784                                             / magnifier->priv->cursor_default_size_y;
00785                                             
00786                 scaled_mask_pixbuf = gdk_pixbuf_scale_simple (
00787                         mask_pixbuf, size_x, size_y, GDK_INTERP_NEAREST);
00788                 g_object_unref (cursor_pixbuf);
00789                 g_object_unref (mask_pixbuf);
00790                 g_object_unref (cursor_pixmap);
00791                 g_object_unref (mask_pixmap);
00792                 magnifier->priv->cursor = gdk_pixmap_new (
00793                         magnifier->priv->w->window,
00794                         size_x, size_y,
00795                         -1);
00796                 if (!GDK_IS_DRAWABLE (magnifier->priv->cursor)) 
00797                 {
00798                     DBG (g_warning ("NULL magnifier cursor pixmap."));
00799                     return;
00800                 }
00801                 magnifier->priv->cursor_mask = gdk_pixmap_new (
00802                         magnifier->priv->w->window,
00803                         size_x, size_y,
00804                         1);
00805                 if (GDK_IS_DRAWABLE (magnifier->priv->cursor)) {
00806                     gdk_draw_pixbuf (magnifier->priv->cursor,
00807                                      cgc,
00808                                      scaled_cursor_pixbuf,
00809                                      0, 0, 0, 0, size_x, size_y,
00810                                      GDK_RGB_DITHER_NONE, 0, 0 );
00811                 }
00812                 else
00813                     DBG (g_warning ("cursor pixmap is non-drawable."));
00814                 scaled_mask_pixbuf_alpha = gdk_pixbuf_add_alpha (
00815                         scaled_mask_pixbuf, True, 0, 0, 0);
00816                 gdk_pixbuf_render_threshold_alpha (scaled_mask_pixbuf_alpha,
00817                                                    magnifier->priv->cursor_mask,
00818                                                    0, 0, 0, 0, size_x, size_y,
00819                                                    0x80);
00820                 g_object_unref (scaled_mask_pixbuf_alpha);
00821                 g_object_unref (scaled_cursor_pixbuf);
00822                 g_object_unref (scaled_mask_pixbuf);
00823                 g_object_unref (mgc);
00824                 g_object_unref (cgc);
00825         }       
00826 }
00827 
00828 static void
00829 magnifier_init_cursor_set (Magnifier *magnifier, gchar *cursor_set)
00830 {
00831         /*
00832          * we check the cursor-set property string here,
00833          * and create/apply the appropriate cursor settings
00834          */
00835         magnifier->cursor_set = cursor_set;
00836         magnifier->priv->use_source_cursor = 
00837             (!strcmp (cursor_set, "default") && 
00838              (fixes_event_base != 0));
00839         if (magnifier->priv->use_source_cursor) return;
00840 
00841         if (!strcmp (magnifier->cursor_set, "none")) {
00842                 magnifier->priv->cursor = NULL;
00843                 return;
00844         }
00845         else 
00846         {
00847                 GDir *cursor_dir;
00848                 const gchar *filename;
00849                 gchar *cursor_dirname;
00850 
00851                 if (magnifier->priv->cursorlist)
00852                 {
00853                         g_hash_table_destroy (magnifier->priv->cursorlist);
00854                 }
00855                 magnifier->priv->cursorlist = g_hash_table_new_full (g_str_hash, g_str_equal,
00856                                                                      g_free, g_object_unref);
00857 
00858                 cursor_dirname = g_strconcat (CURSORSDIR, "/", magnifier->cursor_set, NULL);
00859                 cursor_dir = g_dir_open (cursor_dirname, 0, NULL);
00860                 /* assignment, not comparison, is intentional */
00861                 while (cursor_dir && (filename = g_dir_read_name (cursor_dir)) != NULL) 
00862                 {
00863                         if (filename) 
00864                         {
00865                                 gchar *path = g_strconcat (cursor_dirname, "/", filename, NULL);
00866                                 GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (path, NULL);
00867                                 if (pixbuf)
00868                                 {
00869                                         /* add this pixbuf and its name to our list */
00870                                         gchar **sv, *cname;
00871                                         cname = g_path_get_basename (filename);
00872                                         sv = g_strsplit (cname, ".", 2);
00873                                         g_hash_table_insert (magnifier->priv->cursorlist, 
00874                                                              g_strdup (sv[0]),
00875                                                              pixbuf);
00876                                         g_free (cname);
00877                                         g_strfreev (sv);
00878                                 }
00879                                 g_free (path);
00880                         }
00881                 } 
00882                 g_free (cursor_dirname);
00883                 if (cursor_dir) g_dir_close (cursor_dir);
00884         }
00885         /* don't fallover to source cursor here, we haven't initialized X yet */
00886         magnifier_set_cursor_pixmap_by_name (magnifier, "default", FALSE);
00887         magnifier_transform_cursor (magnifier);
00888 }
00889 
00890 static gboolean 
00891 magnifier_reset_struts_at_idle (gpointer data)
00892 {
00893         if (data)
00894         {
00895                 Magnifier *magnifier = MAGNIFIER (data);
00896 #if GTK_CHECK_VERSION (2,19,5)
00897                 if (magnifier->priv &&
00898                     gtk_widget_get_realized (magnifier->priv->w) &&
00899                     gmag_gs_check_set_struts (magnifier)) {
00900                         return FALSE;
00901                 }
00902 #else
00903                 if (magnifier->priv &&
00904                     GTK_WIDGET_REALIZED (magnifier->priv->w) && 
00905                     gmag_gs_check_set_struts (magnifier)) {
00906                         return FALSE;
00907                 }
00908 #endif
00909         }
00910         return TRUE;
00911 }
00912 
00913 static void
00914 magnifier_get_property (BonoboPropertyBag *bag,
00915                         BonoboArg *arg,
00916                         guint arg_id,
00917                         CORBA_Environment *ev,
00918                         gpointer user_data)
00919 {
00920         Magnifier *magnifier = user_data;
00921         int csize = 0;
00922 
00923         DBG (fprintf (stderr, "Get property: \t%s\n", mag_prop_names[arg_id]));
00924         
00925         switch (arg_id) {
00926         case MAGNIFIER_SOURCE_SIZE_PROP:
00927                 BONOBO_ARG_SET_GENERAL (arg, magnifier->source_bounds,
00928                                         TC_GNOME_Magnifier_RectBounds,
00929                                         GNOME_Magnifier_RectBounds, NULL);
00930                 break;
00931         case MAGNIFIER_TARGET_SIZE_PROP:
00932                 BONOBO_ARG_SET_GENERAL (arg, magnifier->target_bounds,
00933                                         TC_GNOME_Magnifier_RectBounds,
00934                                         GNOME_Magnifier_RectBounds, NULL);
00935 
00936                 break;
00937         case MAGNIFIER_CURSOR_SET_PROP:
00938                 BONOBO_ARG_SET_STRING (arg, magnifier->cursor_set);
00939                 break;
00940         case MAGNIFIER_CURSOR_SIZE_PROP:
00941                 BONOBO_ARG_SET_INT (arg, magnifier->cursor_size_x);
00942                 BONOBO_ARG_SET_INT (arg, magnifier->cursor_size_y);
00943                 break;
00944         case MAGNIFIER_CURSOR_ZOOM_PROP:
00945                 BONOBO_ARG_SET_FLOAT (arg, magnifier->cursor_scale_factor);
00946                 break;
00947         case MAGNIFIER_CURSOR_COLOR_PROP:
00948                 BONOBO_ARG_SET_GENERAL (arg, magnifier->cursor_color,
00949                                         TC_CORBA_unsigned_long,
00950                                         CORBA_unsigned_long, NULL);
00951                 break;
00952         case MAGNIFIER_CURSOR_HOTSPOT_PROP:
00953                 BONOBO_ARG_SET_GENERAL (arg, magnifier->cursor_hotspot,
00954                                         TC_GNOME_Magnifier_Point,
00955                                         GNOME_Magnifier_Point, NULL);
00956 
00957                 break;
00958         case MAGNIFIER_CURSOR_DEFAULT_SIZE_PROP:
00959                 if (magnifier->priv->cursor)
00960                         gdk_drawable_get_size (magnifier->priv->cursor,
00961                                                &csize, &csize);
00962                 BONOBO_ARG_SET_INT (arg, csize);
00963                 break;
00964         case MAGNIFIER_CROSSWIRE_SIZE_PROP:
00965                 BONOBO_ARG_SET_INT (arg, magnifier->crosswire_size);
00966                 break;
00967         case MAGNIFIER_CROSSWIRE_LENGTH_PROP:
00968                 BONOBO_ARG_SET_INT (arg, magnifier->crosswire_length);
00969                 break;
00970         case MAGNIFIER_CROSSWIRE_CLIP_PROP:
00971                 BONOBO_ARG_SET_BOOLEAN (arg, magnifier->crosswire_clip);
00972                 break;
00973         case MAGNIFIER_CROSSWIRE_COLOR_PROP:
00974                 BONOBO_ARG_SET_LONG (arg, magnifier->crosswire_color);
00975                 break;
00976         case MAGNIFIER_SOURCE_DISPLAY_PROP:
00977                 BONOBO_ARG_SET_STRING (arg, magnifier->source_display_name);
00978                 break;
00979         case MAGNIFIER_TARGET_DISPLAY_PROP:
00980                 BONOBO_ARG_SET_STRING (arg, magnifier->target_display_name);
00981                 break;
00982         default:
00983                 bonobo_exception_set (ev, ex_Bonobo_PropertyBag_NotFound);
00984         };
00985 }
00986 
00987 gboolean
00988 impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->source_screen_num =
00995                 magnifier_parse_display_name (magnifier,
00996                                               full_display_string,
00997                                               NULL);
00998             magnifier->source_display =
00999                 gdk_display_open (full_display_string);
01000             magnifier->source_display_name = g_strdup (full_display_string);
01001             zoom_region_params = magnifier_zoom_regions_save (magnifier);
01002             magnifier->priv->root =
01003                 gdk_screen_get_root_window (
01004                     gdk_display_get_screen (
01005                         magnifier->source_display,
01006                         magnifier->source_screen_num));
01007 
01008             /* remove the source_drawable, since in the new display the
01009              * composite can be unavailable and the source_drawable is
01010              * where the desktop screen is composed. If this is not
01011              * freed it will be used even if the display doesn't use
01012              * composite what will lead to wrong behavior and crashes.
01013              * If composite is used in the new display this variable is
01014              * re-created */
01015             if (magnifier->priv->source_drawable) {
01016                     g_object_unref (magnifier->priv->source_drawable);
01017                     magnifier->priv->source_drawable = NULL;
01018             }
01019 
01020             /* attach listeners for DAMAGE, "dirty region", XFIXES
01021              * cursor changes */
01022             magnifier_set_extension_listeners (magnifier, magnifier_get_root (magnifier));
01023             magnifier_get_display_rect_bounds (magnifier, &magnifier->source_bounds, FALSE);
01024             magnifier_adjust_source_size (magnifier);
01025             magnifier_zoom_regions_restore (magnifier, zoom_region_params);
01026             magnifier_warp_cursor_to_screen (magnifier);
01027             gmag_gs_check_set_struts (magnifier);
01028             gmag_gs_reset_overlay_at_idle (magnifier);
01029         }
01030         DBG(fprintf (stderr, "Set source display: \t%s\n", full_display_string));
01031         
01032         return TRUE;
01033 }
01034 
01035 gchar*
01036 impl_dbus_magnifier_get_source_display (Magnifier *magnifier)
01037 {
01038         return g_strdup (magnifier->source_display_name);
01039 }
01040 
01041 gboolean
01042 impl_dbus_magnifier_set_target_display (Magnifier *magnifier, gchar *target_display)
01043 {
01044         gchar *full_display_string = target_display;
01045         if (can_open_display (full_display_string))
01046         {
01047             magnifier->target_screen_num =
01048                 magnifier_parse_display_name (magnifier,
01049                                               full_display_string,
01050                                               NULL);
01051             magnifier->target_display =
01052                 gdk_display_open (full_display_string);
01053             magnifier->target_display_name = g_strdup (full_display_string);
010b3f715e639bde2eagnifier_8c.html#a61f6ae8184cb62549bce5cb93d00507e">impl_dbus_magnifier_set_source_display (Magnifier *magnifier, gchar *source_display)
00989 {
00990         gchar *full_display_string = source_display;
00991         if (can_open_display (full_display_string))
00992         {
00993             GSList *zoom_region_params = NULL;
00994             magnifier->