X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=cspi%2Fbonobo%2Fcspi-bonobo.c;h=797f3612bfa46ecab629e83a41d1a5c823cca9e4;hb=5d01be6ec7d2cb2e662c695bd4c28c50ac3f2dab;hp=252306b70c78e6002fc6cfd9625f541cba1e05e2;hpb=15f09a5c7d956efee77d36c2a92eb98608da783b;p=platform%2Fcore%2Fuifw%2Fat-spi2-atk.git diff --git a/cspi/bonobo/cspi-bonobo.c b/cspi/bonobo/cspi-bonobo.c index 252306b..797f361 100644 --- a/cspi/bonobo/cspi-bonobo.c +++ b/cspi/bonobo/cspi-bonobo.c @@ -25,6 +25,8 @@ #include #include #include "../cspi-lowlevel.h" +#include +#include CORBA_Object cspi_dup_ref (CORBA_Object object) @@ -49,7 +51,7 @@ cspi_check_ev (const char *error_string) err = bonobo_exception_get_text (ev); - if (!_cspi_exception_throw (ev, (char *) error_string)) { + if (!cspi_exception_throw (ev, (char *) error_string)) { fprintf (stderr, "Warning: AT-SPI error: %s: %s\n", error_string, err); } @@ -78,24 +80,88 @@ cspi_exception_get_text (void) return ret; } +/* + * Returns a 'canonicalized' value for DISPLAY, + * with the screen number stripped off if present. + */ +static const gchar* +cspi_display_name (void) +{ + static const char *canonical_display_name = NULL; + if (!canonical_display_name) + { + const gchar *display_env = g_getenv ("AT_SPI_DISPLAY"); + if (!display_env) + { + display_env = g_getenv ("DISPLAY"); + if (!display_env || !display_env[0]) + canonical_display_name = ":0"; + else + { + gchar *display_p, *screen_p; + canonical_display_name = g_strdup (display_env); + display_p = strrchr (canonical_display_name, ':'); + screen_p = strrchr (canonical_display_name, '.'); + if (screen_p && display_p && (screen_p > display_p)) + { + *screen_p = '\0'; + } + } + } + else + { + canonical_display_name = display_env; + } + } + return canonical_display_name; +} + +static gchar * +cspi_get_registry_ior (void) +{ + Atom AT_SPI_IOR; + Atom actual_type; + int actual_format; + unsigned char *data = NULL; + unsigned long nitems; + unsigned long leftover; + static Display *display = NULL; + if (!display) + display = XOpenDisplay (cspi_display_name ()); + + AT_SPI_IOR = XInternAtom (display, "AT_SPI_IOR", False); + XGetWindowProperty(display, + XDefaultRootWindow (display), + AT_SPI_IOR, 0L, + (long)BUFSIZ, False, + (Atom) 31, &actual_type, &actual_format, + &nitems, &leftover, &data); + if (data == NULL) + g_warning ("AT_SPI_REGISTRY was not started at session startup."); + + return (gchar *) data; +} + CORBA_Object cspi_init (void) { - char *obj_id; - CORBA_Object registry; + CORBA_Object registry = NULL; CORBA_Environment ev; + char *ior = NULL; - if (!bonobo_init (0, NULL)) + if (!bonobo_init (NULL, NULL)) { g_error ("Could not initialize Bonobo"); } - obj_id = "OAFIID:Accessibility_Registry:1.0"; - CORBA_exception_init (&ev); - registry = bonobo_activation_activate_from_id ( - obj_id, 0, NULL, &ev); + ior = (char *) cspi_get_registry_ior (); + if (ior != NULL) + { + registry = CORBA_ORB_string_to_object (bonobo_activation_orb_get (), + ior, &ev); + } if (ev._major != CORBA_NO_EXCEPTION) { @@ -105,7 +171,7 @@ cspi_init (void) if (registry == CORBA_OBJECT_NIL) { - g_error ("Could not locate registry"); + g_warning ("Could not locate registry"); } bonobo_activate ();