[dasher] Only listen to accessibility bus while in direct mode.
- From: Patrick Welche <pwelche src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dasher] Only listen to accessibility bus while in direct mode.
- Date: Thu, 24 Jan 2013 15:58:15 +0000 (UTC)
commit 8857b4e8c602b42bb696f1f106f276bd5ea9156a
Author: Patrick Welche <prlw1 cam ac uk>
Date: Thu Jan 24 15:56:17 2013 +0000
Only listen to accessibility bus while in direct mode.
Src/Gtk2/dasher_editor.cpp | 9 ++++++++
Src/Gtk2/dasher_editor.h | 1 +
Src/Gtk2/dasher_editor_external.h | 1 +
Src/Gtk2/dasher_editor_external_atspi.cpp | 29 ++++++++++++++++++++++---
Src/Gtk2/dasher_editor_external_cspi.cpp | 33 +++++++++++++++++++++++-----
Src/Gtk2/dasher_editor_external_xtest.cpp | 4 +++
Src/Gtk2/dasher_main.cpp | 2 +
7 files changed, 69 insertions(+), 10 deletions(-)
---
diff --git a/Src/Gtk2/dasher_editor.cpp b/Src/Gtk2/dasher_editor.cpp
index 9ecf590..13ce830 100644
--- a/Src/Gtk2/dasher_editor.cpp
+++ b/Src/Gtk2/dasher_editor.cpp
@@ -276,6 +276,15 @@ dasher_editor_handle_start(DasherEditor *pSelf) {
// set_mark();
}
+void
+dasher_editor_toggle_direct_mode(DasherEditor *pSelf) {
+ // Should be able to play function pointer games here to avoid
+ // isdirect() calls in dasher_editor_output() and friends.
+
+ DasherEditorPrivate *pPrivate = DASHER_EDITOR_GET_PRIVATE(pSelf);
+
+ dasher_editor_external_toggle_direct_mode(pSelf, isdirect(pPrivate->pAppSettings));
+}
void
dasher_editor_clear(DasherEditor *pSelf) {
diff --git a/Src/Gtk2/dasher_editor.h b/Src/Gtk2/dasher_editor.h
index b740d0f..bf87b68 100644
--- a/Src/Gtk2/dasher_editor.h
+++ b/Src/Gtk2/dasher_editor.h
@@ -88,6 +88,7 @@ void dasher_editor_edit_protect(DasherEditor *pSelf);
void dasher_editor_handle_parameter_change(DasherEditor *pSelf, gint iParameter);
void dasher_editor_handle_stop(DasherEditor *pSelf);
void dasher_editor_handle_start(DasherEditor *pSelf);
+void dasher_editor_toggle_direct_mode(DasherEditor *);
/* Functions needed to maintain application UI */
void dasher_editor_grab_focus(DasherEditor *pSelf);
diff --git a/Src/Gtk2/dasher_editor_external.h b/Src/Gtk2/dasher_editor_external.h
index 719faf8..1067743 100644
--- a/Src/Gtk2/dasher_editor_external.h
+++ b/Src/Gtk2/dasher_editor_external.h
@@ -9,5 +9,6 @@ void dasher_editor_external_output(DasherEditor *pSelf, const char *szText, int
void dasher_editor_external_delete(DasherEditor *pSelf, int iLength, int iOffset);
const char * dasher_editor_external_get_context(DasherEditor *pSelf, int iOffset, int iLength);
int dasher_editor_external_get_offset(DasherEditor *pSelf);
+void dasher_editor_external_toggle_direct_mode(DasherEditor *, bool);
#endif
diff --git a/Src/Gtk2/dasher_editor_external_atspi.cpp b/Src/Gtk2/dasher_editor_external_atspi.cpp
index fbdd15b..e930f51 100644
--- a/Src/Gtk2/dasher_editor_external_atspi.cpp
+++ b/Src/Gtk2/dasher_editor_external_atspi.cpp
@@ -19,6 +19,9 @@ void dasher_editor_external_handle_caret(DasherEditor *pSelf, const AtspiEvent *
void focus_listener(const AtspiEvent *pEvent, void *pUserData);
void caret_listener(const AtspiEvent *pEvent, void *pUserData);
+static void listen_to_bus(DasherEditor *);
+static void unlisten_to_bus(DasherEditor *);
+
bool
initSPI() {
#ifdef DEBUG_ATSPI
@@ -39,8 +42,7 @@ dasher_editor_external_finalize(GObject *pSelf) {
printf("dasher_editor_external_finalize()\n");
#endif
- atspi_event_listener_deregister(p->pFocusListener, "focus:", NULL);
- atspi_event_listener_deregister(p->pCaretListener, "object:text-caret-moved", NULL);
+ unlisten_to_bus(DASHER_EDITOR(pSelf));
g_object_unref(p->pFocusListener);
g_object_unref(p->pCaretListener);
@@ -70,9 +72,28 @@ dasher_editor_external_create_buffer(DasherEditor *pSelf) {
#ifdef DEBUG_ATSPI
printf("dasher_editor_external_create_buffer: pPrivate=%p, pExtPrivate=%p\n", pPrivate, p);
#endif
+}
+
+static void
+listen_to_bus(DasherEditor *pSelf) {
+ DasherEditorPrivate *p = DASHER_EDITOR_GET_PRIVATE(pSelf);
+ atspi_event_listener_register(p->pExtPrivate->pFocusListener, "focus:", NULL);
+ atspi_event_listener_register(p->pExtPrivate->pCaretListener, "object:text-caret-moved", NULL);
+}
- atspi_event_listener_register(p->pFocusListener, "focus:", NULL);
- atspi_event_listener_register(p->pCaretListener, "object:text-caret-moved", NULL);
+static void
+unlisten_to_bus(DasherEditor *pSelf) {
+ DasherEditorPrivate *p = DASHER_EDITOR_GET_PRIVATE(pSelf);
+ atspi_event_listener_deregister(p->pExtPrivate->pFocusListener, "focus:", NULL);
+ atspi_event_listener_deregister(p->pExtPrivate->pCaretListener, "object:text-caret-moved", NULL);
+}
+
+void
+dasher_editor_external_toggle_direct_mode(DasherEditor *pSelf, bool direct) {
+ if (direct)
+ listen_to_bus(pSelf);
+ else
+ unlisten_to_bus(pSelf);
}
void
diff --git a/Src/Gtk2/dasher_editor_external_cspi.cpp b/Src/Gtk2/dasher_editor_external_cspi.cpp
index 6074c98..8b8c72b 100644
--- a/Src/Gtk2/dasher_editor_external_cspi.cpp
+++ b/Src/Gtk2/dasher_editor_external_cspi.cpp
@@ -26,6 +26,9 @@ void dasher_editor_external_handle_caret(DasherEditor *pSelf, const AccessibleEv
void focus_listener(const AccessibleEvent *pEvent, void *pUserData);
void caret_listener(const AccessibleEvent *pEvent, void *pUserData);
+static void listen_to_bus(DasherEditor *);
+static void unlisten_to_bus(DasherEditor *);
+
enum {
NOT_INIT,
INIT_SUCCESS,
@@ -43,8 +46,7 @@ void
dasher_editor_external_finalize(GObject *pSelf) {
DasherEditorPrivate *pPrivate = DASHER_EDITOR_GET_PRIVATE(pSelf);
- SPI_deregisterGlobalEventListener(pPrivate->pExtPrivate->pFocusListener, "focus:");
- SPI_deregisterGlobalEventListener(pPrivate->pExtPrivate->pCaretListener, "object:text-caret-moved");
+ unlisten_to_bus(DASHER_EDITOR(pSelf));
AccessibleEventListener_unref(pPrivate->pExtPrivate->pFocusListener);
AccessibleEventListener_unref(pPrivate->pExtPrivate->pCaretListener);
delete pPrivate->pExtPrivate;
@@ -63,15 +65,34 @@ dasher_editor_external_create_buffer(DasherEditor *pSelf) {
pPrivate->pExtPrivate->pCaretListener = SPI_createAccessibleEventListener(caret_listener, pSelf);
pPrivate->pExtPrivate->pAccessibleText = NULL;
- if(pPrivate->pExtPrivate->pFocusListener && pPrivate->pExtPrivate->pCaretListener) {
- SPI_registerGlobalEventListener(pPrivate->pExtPrivate->pFocusListener, "focus:");
- SPI_registerGlobalEventListener(pPrivate->pExtPrivate->pCaretListener, "object:text-caret-moved");
- } else {
+ if(!(pPrivate->pExtPrivate->pFocusListener && pPrivate->pExtPrivate->pCaretListener)) {
g_message("Could not obtain an SPI listener");
}
}
}
+static void
+listen_to_bus(DasherEditor *pSelf) {
+ DasherEditorPrivate *p = DASHER_EDITOR_GET_PRIVATE(pSelf);
+ SPI_registerGlobalEventListener(p->pExtPrivate->pFocusListener, "focus:");
+ SPI_registerGlobalEventListener(p->pExtPrivate->pCaretListener, "object:text-caret-moved");
+}
+
+static void
+unlisten_to_bus(DasherEditor *pSelf) {
+ DasherEditorPrivate *p = DASHER_EDITOR_GET_PRIVATE(pSelf);
+ SPI_deregisterGlobalEventListener(p->pExtPrivate->pFocusListener, "focus:");
+ SPI_deregisterGlobalEventListener(p->pExtPrivate->pCaretListener, "object:text-caret-moved");
+}
+
+void
+dasher_editor_external_toggle_direct_mode(DasherEditor *pSelf, bool direct) {
+ if (direct)
+ listen_to_bus(pSelf);
+ else
+ unlisten_to_bus(pSelf);
+}
+
void
dasher_editor_external_output(DasherEditor *pSelf, const gchar *szText, int iOffset /* unused */) {
if(!initSPI())
diff --git a/Src/Gtk2/dasher_editor_external_xtest.cpp b/Src/Gtk2/dasher_editor_external_xtest.cpp
index b5fcf30..efb7a77 100644
--- a/Src/Gtk2/dasher_editor_external_xtest.cpp
+++ b/Src/Gtk2/dasher_editor_external_xtest.cpp
@@ -24,6 +24,10 @@ dasher_editor_external_create_buffer(DasherEditor *pSelf) {
}
void
+dasher_editor_external_toggle_direct_mode(DasherEditor *pSelf, bool direct) {
+}
+
+void
dasher_editor_external_output(DasherEditor *pSelf, const gchar *szText, int iOffset /* unused */) {
glong numoutput;
int numcodes;
diff --git a/Src/Gtk2/dasher_main.cpp b/Src/Gtk2/dasher_main.cpp
index 82c79b0..e2d822e 100644
--- a/Src/Gtk2/dasher_main.cpp
+++ b/Src/Gtk2/dasher_main.cpp
@@ -606,6 +606,8 @@ void dasher_main_command_toggle_direct_mode(DasherMain *pSelf) {
gtk_window_stick(GTK_WINDOW(pPrivate->pMainWindow));
dasher_app_settings_set_long(pPrivate->pAppSettings, APP_LP_STYLE, APP_STYLE_DIRECT);
}
+
+ dasher_editor_toggle_direct_mode(pPrivate->pEditor);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]