From: padraigo Date: Mon, 27 Jan 2003 14:00:28 +0000 (+0000) Subject: 2003-01-27 Padraig O'Briain diff --git a/registryd/desktop.c b/registryd/desktop.c index fe52c70..4d278dc 100644 --- a/registryd/desktop.c +++ b/registryd/desktop.c @@ -27,6 +27,9 @@ #include #include #include "desktop.h" +#include +#include +#include /* SpiDesktop signals */ enum { @@ -48,15 +51,104 @@ typedef struct { /* A pointer to our parent object class */ static SpiAccessibleClass *parent_class; +#define SPI_TYPE_ATK_DESKTOP (spi_atk_desktop_get_type ()) +#define SPI_ATK_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SPI_TYPE_ATK_DESKTOP, SpiAtkDesktop)) +#define SPI_IS_ATK_DESKTOP(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), SPI_TYPE_ATK_DESKTOP)) + +typedef struct { + AtkObject parent; + + GdkScreen *screen; +} SpiAtkDesktop; + +typedef struct { + AtkObjectClass parent; +} SpiAtkDesktopClass; + +static void spi_atk_desktop_init (SpiAtkDesktop *desktop); +static void atk_component_interface_init (AtkComponentIface *iface); +static void spi_atk_desktop_get_extents (AtkComponent *component, + gint *x, + gint *y, + gint *width, + gint *height, + AtkCoordType coord_type); + +static GType +spi_atk_desktop_get_type () +{ + static GType type = 0; + + if (!type) + { + static const GTypeInfo typeInfo = + { + sizeof (SpiAtkDesktopClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) NULL, + (GClassFinalizeFunc) NULL, + NULL, + sizeof (SpiAtkDesktop), + 0, + (GInstanceInitFunc) spi_atk_desktop_init, + } ; + static const GInterfaceInfo atk_component_info = + { + (GInterfaceInitFunc) atk_component_interface_init, + (GInterfaceFinalizeFunc) NULL, + NULL + }; + + type = g_type_register_static (ATK_TYPE_OBJECT, + "SpiAtkDesktop", &typeInfo, 0); + g_type_add_interface_static (type, ATK_TYPE_COMPONENT, + &atk_component_info); + } + return type; +} + +static void +spi_atk_desktop_init (SpiAtkDesktop *desktop) +{ + GdkDisplay *display; + + atk_object_set_name (ATK_OBJECT (desktop), "main"); + display = gdk_x11_lookup_xdisplay (GDK_DISPLAY ()); + desktop->screen = gdk_display_get_default_screen (display); +} + static void -spi_desktop_init (SpiDesktop *desktop) +atk_component_interface_init (AtkComponentIface *iface) { - spi_base_construct (SPI_BASE (desktop), g_object_new (ATK_TYPE_OBJECT, NULL)); + g_return_if_fail (iface != NULL); + iface->get_extents = spi_atk_desktop_get_extents; +} + +static void +spi_atk_desktop_get_extents (AtkComponent *component, + gint *x, + gint *y, + gint *width, + gint *height, + AtkCoordType coord_type) +{ + SpiAtkDesktop *desktop; + + g_return_if_fail (SPI_IS_ATK_DESKTOP (component)); + desktop = SPI_ATK_DESKTOP (component); + *x = 0; + *y = 0; + *width = gdk_screen_get_width (desktop->screen); + *height = gdk_screen_get_height (desktop->screen); +} + +static void +spi_desktop_init (SpiDesktop *desktop) +{ desktop->applications = NULL; bonobo_object_set_immortal (BONOBO_OBJECT (desktop), TRUE); - - atk_object_set_name (ATK_OBJECT (SPI_BASE (desktop)->gobj), "main"); } static void @@ -158,9 +250,14 @@ BONOBO_TYPE_FUNC_FULL (SpiDesktop, SpiDesktop * spi_desktop_new (void) { - SpiDesktop *retval = g_object_new (SPI_DESKTOP_TYPE, NULL); + SpiDesktop *desktop; + SpiAccessible *accessible; + + accessible = spi_accessible_construct (SPI_DESKTOP_TYPE, g_object_new (SPI_TYPE_ATK_DESKTOP, NULL)); + g_assert (SPI_IS_DESKTOP (accessible)); + desktop = SPI_DESKTOP (accessible); - return retval; + return desktop; } static void diff --git a/registryd/deviceeventcontroller.c b/registryd/deviceeventcontroller.c index 469616c..9171c5b 100644 --- a/registryd/deviceeventcontroller.c +++ b/registryd/deviceeventcontroller.c @@ -1961,13 +1961,6 @@ spi_device_event_controller_init (SpiDEController *device_event_controller) device_event_controller->mouse_listeners = NULL; device_event_controller->keygrabs_list = NULL; - /* - * TODO: fixme, this module makes the foolish assumptions that - * registryd uses the same display as the apps, and that the - * DISPLAY environment variable is set. - */ - gdk_init (NULL, NULL); - private = g_new0 (DEControllerPrivateData, 1); gettimeofday (&private->last_press_time, NULL); gettimeofday (&private->last_release_time, NULL); diff --git a/registryd/registry.c b/registryd/registry.c index 6ae9ed2..68380dc 100644 --- a/registryd/registry.c +++ b/registryd/registry.c @@ -676,6 +676,13 @@ static void spi_registry_init (SpiRegistry *registry) { spi_registry_set_debug (g_getenv ("AT_SPI_DEBUG")); + /* + * TODO: fixme, this module makes the foolish assumptions that + * registryd uses the same display as the apps, and that the + * DISPLAY environment variable is set. + */ + gdk_init (NULL, NULL); + registry->object_listeners = NULL; registry->window_listeners = NULL; registry->toolkit_listeners = NULL;