AC_SUBST(GOBJ_LIBS)
AC_SUBST(GOBJ_CFLAGS)
-PKG_CHECK_MODULES(GDK, [gdk-2.0 >= 2.0.0])
-AC_SUBST(GDK_LIBS)
-AC_SUBST(GDK_CFLAGS)
-
AC_PATH_XTRA
if test x$no_x = xyes ; then
at_spi2_registryd_CFLAGS = $(DBUS_GLIB_CFLAGS) \
$(GOBJ_CFLAGS) \
$(ATK_CFLAGS) \
- $(GDK_CFLAGS) \
-I$(top_srcdir) \
-DATSPI_INTROSPECTION_PATH=\"$(pkgdatadir)/$(DEFAULT_ATSPI_INTROSPECTION_PATH)\"
at_spi2_registryd_LDADD = $(DBUS_GLIB_LIBS) \
$(GOBJ_CFLAGS) \
$(ATK_LIBS) \
- $(GDK_LIBS) \
$(X_LIBS) \
$(SM_LIBS) \
$(XTST_LIBS) \
de-marshaller.h \
de-marshaller.c \
de-types.h \
+ display.h \
+ display.c \
+ event-source.h \
+ event-source.c \
keymasks.h \
paths.h \
registry-main.c \
#endif /* HAVE_XEVIE */
#include <glib.h>
-#include <gdk/gdk.h>
-#include <gdk/gdkx.h> /* TODO: hide dependency (wrap in single porting file) */
-#include <gdk/gdkkeysyms.h>
#include <dbus/dbus.h>
#include "keymasks.h"
#include "de-types.h"
#include "de-marshaller.h"
+#include "display.h"
#include "deviceeventcontroller.h"
#include "reentrant-list.h"
/* A pointer to our parent object class */
static int spi_error_code = 0;
-static GdkPoint last_mouse_pos_static = {0, 0};
-static GdkPoint *last_mouse_pos = &last_mouse_pos_static;
+struct _SpiPoint {
+ gint x;
+ gint y;
+};
+typedef struct _SpiPoint SpiPoint;
+static SpiPoint last_mouse_pos_static = {0, 0};
+static SpiPoint *last_mouse_pos = &last_mouse_pos_static;
static unsigned int mouse_mask_state = 0;
static unsigned int mouse_button_mask =
Button1Mask | Button2Mask | Button3Mask | Button4Mask | Button5Mask;
static gboolean spi_dec_poll_mouse_moving (gpointer data);
static gboolean spi_dec_poll_mouse_idle (gpointer data);
-#define spi_get_display() GDK_DISPLAY()
-
G_DEFINE_TYPE(SpiDEController, spi_device_event_controller, G_TYPE_OBJECT)
DBusMessage *
if (display)
{
if (XGrabButton (display, AnyButton, AnyModifier,
- gdk_x11_get_default_root_xwindow (),
+ spi_get_root_window (),
True, ButtonPressMask | ButtonReleaseMask,
GrabModeSync, GrabModeAsync, None, None) != Success) {
#ifdef SPI_DEBUG
CurrentTime);
}
-static GdkFilterReturn
-global_filter_fn (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)
+static void
+global_filter_fn (XEvent *xevent, void *data)
{
- XEvent *xevent = gdk_xevent;
SpiDEController *controller;
DEControllerPrivateData *priv;
Display *display = spi_get_display ();
}
}
- return GDK_FILTER_CONTINUE;
+ return;
}
if (xevent->type == ButtonPress || xevent->type == ButtonRelease)
{
XSynchronize (display, FALSE);
}
- return GDK_FILTER_CONTINUE;
+ return;
}
static int
if (XKeycodeToKeysym (spi_get_display (), i, 0) != 0)
{
/* don't use this one if there's a grab client! */
- gdk_error_trap_push ();
+
+ /* Runtime errors are generated from these functions,
+ * that are then quashed. Equivalent to:
+ * try
+ * {Blah}
+ * except
+ * {;}
+ */
+
+ spi_x_error_trap ();
XGrabKey (spi_get_display (), i, 0,
- gdk_x11_get_default_root_xwindow (),
+ spi_get_root_window (),
TRUE,
GrabModeSync, GrabModeSync);
XSync (spi_get_display (), TRUE);
XUngrabKey (spi_get_display (), i, 0,
- gdk_x11_get_default_root_xwindow ());
- if (!gdk_error_trap_pop ())
+ spi_get_root_window ());
+ if (!spi_x_error_release ())
{
reserved = i;
break;
#endif
}
- gdk_window_add_filter (NULL, global_filter_fn, controller);
-
- gdk_window_set_events (gdk_get_default_root_window (),
- GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
+ spi_set_filter (global_filter_fn, controller);
+ spi_set_events (KeyPressMask | KeyReleaseMask);
x_default_error_handler = XSetErrorHandler (_spi_controller_device_error_handler);
}
XUngrabKey (spi_get_display (),
grab_mask->key_val,
grab_mask->mod_mask,
- gdk_x11_get_default_root_xwindow ());
+ spi_get_root_window ());
do_remove = TRUE;
}
XGrabKey (spi_get_display (),
grab_mask->key_val,
grab_mask->mod_mask,
- gdk_x11_get_default_root_xwindow (),
+ spi_get_root_window (),
True,
GrabModeSync,
GrabModeSync);
* and fall back to XSendEvent() if XTest is not available.
*/
- gdk_error_trap_push ();
+ spi_x_error_trap ();
priv = (DEControllerPrivateData *)
g_object_get_qdata (G_OBJECT (controller), spi_dec_private_quark);
static void
spi_device_event_controller_init (SpiDEController *device_event_controller)
{
+ spi_events_init (spi_get_display());
#ifdef HAVE_XEVIE
GIOChannel *ioc;
int fd;
#define SPI_DEVICE_EVENT_CONTROLLER_H_
#include <X11/Xlib.h>
-#include <gdk/gdk.h>
#include <dbus/dbus.h>
typedef struct _SpiDEController SpiDEController;
--- /dev/null
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2009 Nokia.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "display.h"
+
+static Display *default_display = NULL;
+
+Display *spi_set_display (const char *display_name)
+{
+ /*
+ * TODO - Should we ever do anything different might need to
+ * close previous display.
+ */
+ default_display = XOpenDisplay (display_name);
+ if (!default_display)
+ {
+ g_error ("AT-SPI: Cannot open default display");
+ return NULL;
+ }
+}
+
+Display *spi_get_display ()
+{
+ if (!default_display)
+ spi_set_display (NULL);
+
+ return default_display;
+}
+
+Window spi_get_root_window ()
+{
+ if (!default_display)
+ spi_set_display (NULL);
+
+ return DefaultRootWindow (default_display);
+}
+
+static int (*old_x_error_handler) (Display *, XErrorEvent *);
+static int x_error_code;
+
+static int spi_x_error_handler (Display *display, XErrorEvent *error)
+{
+ if (error->error_code)
+ x_error_code = error->error_code;
+ else
+ x_error_code = 0;
+
+ return 0;
+}
+
+void spi_x_error_trap (void)
+{
+ old_x_error_handler = XSetErrorHandler (spi_x_error_handler);
+}
+
+int spi_x_error_release (void)
+{
+ XSetErrorHandler (old_x_error_handler);
+ return x_error_code;
+}
--- /dev/null
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2009 Nokia.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SPI_DISPLAY_H_
+#define SPI_DISPLAY_H_
+
+#include <X11/Xlib.h>
+
+Display *spi_set_display (const char *display_name);
+Display *spi_get_display ();
+
+Window spi_get_root_window ();
+
+void spi_x_error_trap (void);
+int spi_x_error_release (void);
+
+#endif /* SPI_DISPLAY_H_ */
--- /dev/null
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2009 Nokia.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <glib.h>
+
+#include "event-source.h"
+
+typedef struct _DisplaySource
+{
+ GSource source;
+
+ Display *display;
+ GPollFD event_poll_fd;
+} DisplaySource;
+
+/*---------------------------------------------------------------------------*/
+
+static void (*_spi_default_filter) (XEvent*, void*) = NULL;
+static void* _spi_default_filter_data = NULL;
+
+/*---------------------------------------------------------------------------*/
+
+static gboolean
+event_prepare (GSource *source, gint *timeout)
+{
+ Display *display = ((DisplaySource *)source)->display;
+ gboolean retval;
+
+ *timeout = -1;
+ retval = XPending (display);
+
+ return retval;
+}
+
+static gboolean
+event_check (GSource *source)
+{
+ DisplaySource *display_source = (DisplaySource*)source;
+ gboolean retval;
+
+ if (display_source->event_poll_fd.revents & G_IO_IN)
+ retval = XPending (display_source->display);
+ else
+ retval = FALSE;
+
+ return retval;
+}
+
+static gboolean
+event_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
+{
+ Display *display = ((DisplaySource*)source)->display;
+ XEvent xevent;
+
+ /* TODO - Should this be "if (XPending (display))"?
+ * The effect of this might be to run other main loop functions
+ * before dispatching the next XEvent.
+ */
+ while (XPending (display))
+ {
+ XNextEvent (display, &xevent);
+
+ switch (xevent.type)
+ {
+ case KeyPress:
+ case KeyRelease:
+ break;
+ default:
+ if (XFilterEvent (&xevent, None))
+ continue;
+ }
+
+ if (_spi_default_filter)
+ {
+ _spi_default_filter (&xevent, _spi_default_filter_data);
+ }
+ }
+
+ return TRUE;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static GSourceFuncs event_funcs = {
+ event_prepare,
+ event_check,
+ event_dispatch,
+ NULL
+};
+
+static GSource *
+display_source_new (Display *display)
+{
+ GSource *source = g_source_new (&event_funcs, sizeof (DisplaySource));
+ DisplaySource *display_source = (DisplaySource *) source;
+
+ display_source->display = display;
+
+ return source;
+}
+
+/*---------------------------------------------------------------------------*/
+
+static DisplaySource *spi_display_source = NULL;
+
+void
+spi_events_init (Display *display)
+{
+ GSource *source;
+
+ int connection_number = ConnectionNumber (display);
+
+ source = display_source_new (display);
+ spi_display_source = (DisplaySource*) source;
+
+ g_source_set_priority (source, G_PRIORITY_DEFAULT);
+
+ spi_display_source->event_poll_fd.fd = connection_number;
+ spi_display_source->event_poll_fd.events = G_IO_IN;
+
+ g_source_add_poll (source, &spi_display_source->event_poll_fd);
+ g_source_set_can_recurse (source, TRUE);
+ g_source_attach (source, NULL);
+}
+
+void
+spi_events_uninit ()
+{
+ if (spi_display_source)
+ {
+ g_source_destroy ((GSource *) spi_display_source);
+ g_source_unref ((GSource *) spi_display_source);
+ spi_display_source = NULL;
+ }
+}
+
+void
+spi_set_events (long event_mask)
+{
+ long xevent_mask = StructureNotifyMask | PropertyChangeMask;
+ xevent_mask |= event_mask;
+
+ XSelectInput (spi_display_source->display,
+ DefaultRootWindow (spi_display_source->display),
+ xevent_mask);
+}
+
+void
+spi_set_filter (void (*filter) (XEvent*, void*), void* data)
+{
+ _spi_default_filter = filter;
+ _spi_default_filter_data = data;
+}
+
+/*END------------------------------------------------------------------------*/
--- /dev/null
+/*
+ * AT-SPI - Assistive Technology Service Provider Interface
+ * (Gnome Accessibility Project; http://developer.gnome.org/projects/gap)
+ *
+ * Copyright 2009 Nokia.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef SPI_EVENT_SOURCE_H_
+#define SPI_EVENT_SOURCE_H_
+
+#include <X11/Xlib.h>
+
+void spi_events_init (Display *display);
+void spi_events_uninit ();
+void spi_set_events (long event_mask);
+void spi_set_filter (void (*filter) (XEvent*, void*), void* data);
+
+#endif /* SPI_EVENT_SOURCE_H_ */
#include <config.h>
#include <string.h>
#include <glib.h>
+#include <stdio.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
g_type_init();
- /* We depend on GDK as well as XLib for device event processing */
- gdk_init(&argc, &argv);
-
/*Parse command options*/
opt = g_option_context_new(NULL);
g_option_context_add_main_entries(opt, optentries, NULL);