Started actually writing the accessibility code. Does not work yet.

This commit is contained in:
Pietro Gagliardi 2014-12-24 20:15:45 -05:00
parent 9aff3fd792
commit 6720fa7bc2
2 changed files with 84 additions and 0 deletions

View File

@ -0,0 +1,75 @@
// 24 december 2014
struct tableAcc {
IAccessibleVtbl *vtbl;
ULONG refcount;
struct table *t;
};
static HRESULT STDMETHODCALLTYPE tableAccQueryInterface(IUnknown *this, REFIID riid, void **ppvObject)
{
if (ppvObject == NULL)
return E_POINTER;
if (IsEqualIID(riid, IID_IUnknown) ||
0)// IsEqualIID(riid, IID_IDispatch)
{// IsEqualIID(riid, IID_IAccessible) {
*ppvObject = (void *) this;
return S_OK;
}
*ppvObject = NULL;
return E_NOINTERFACE;
}
#define TA ((struct tableAcc *) this)
// TODO use InterlockedIncrement()/InterlockedDecrement() for these?
static ULONG STDMETHODCALLTYPE tableAccAddRef(IUnknown *this)
{
TA->refcount++;
return TA->refcount;
}
static ULONG STDMETHODCALLTYPE tableAccRelease(IUnknown *this)
{
TA->refcount--;
if (TA->refcount == 0) {
tableFree(TA, "error freeing Table accessibility object");
return 0;
}
return TA->refcount;
}
static const IAccessibleVtbl tableAccVtbl = {
.QueryInterface = tableAccQueryInterface,
.AddRef = tableAccAddRef,
.Release = tableAccRelease,
};
static struct tableAcc *newTableAcc(struct table *t)
{
struct tableAcc *ta;
ta = (struct tableAcc *) tableAlloc(sizeof (struct tableAcc), "error creating Table accessibility object");
ta->vtbl = &tableAccVtbl;
ta->vtbl->AddRef(vtbl);
ta->t = t;
return ta;
}
static void freeTableAcc(struct tableAcc *ta)
{
ta->t = NULL;
ta->vtbl->Release(ta);
}
HANDLER(accessibilityHandler)
{
if (uMsg != WM_GETOBJECT)
return FALSE;
if (wParam != OBJID_CLIENT)
return FALSE;
*lResult = LresultFromObject(IID_IUnknown, wParam, t->ta);
// TODO check *lResult
return TRUE;
}

View File

@ -58,6 +58,9 @@ static void (*tablePanic)(const char *, DWORD) = NULL;
static BOOL (*WINAPI tableTrackMouseEvent)(LPTRACKMOUSEEVENT); static BOOL (*WINAPI tableTrackMouseEvent)(LPTRACKMOUSEEVENT);
// forward declaration
struct tableAcc;
struct table { struct table {
HWND hwnd; HWND hwnd;
HWND header; HWND header;
@ -83,6 +86,7 @@ struct table {
BOOL checkboxMouseDown; BOOL checkboxMouseDown;
intptr_t checkboxMouseDownRow; intptr_t checkboxMouseDownRow;
intptr_t checkboxMouseDownColumn; intptr_t checkboxMouseDownColumn;
struct tableAcc *ta;
}; };
#include "util.h" #include "util.h"
@ -98,6 +102,7 @@ struct table {
#include "resize.h" #include "resize.h"
#include "draw.h" #include "draw.h"
#include "api.h" #include "api.h"
#include "accessibility.h"
static const handlerfunc handlers[] = { static const handlerfunc handlers[] = {
eventHandlers, eventHandlers,
@ -107,6 +112,7 @@ static const handlerfunc handlers[] = {
apiHandlers, apiHandlers,
hscrollHandler, hscrollHandler,
vscrollHandler, vscrollHandler,
accessibilityHandler,
NULL, NULL,
}; };
@ -136,6 +142,7 @@ static LRESULT CALLBACK tableWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
t->selectedRow = -1; t->selectedRow = -1;
t->selectedColumn = -1; t->selectedColumn = -1;
loadCheckboxThemeData(t); loadCheckboxThemeData(t);
t->ta = newTableAcc(t);
initDummyTableStuff(t); initDummyTableStuff(t);
SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t); SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) t);
} }
@ -146,6 +153,8 @@ initDummyTableStuff(t);
printf("destroy\n"); printf("destroy\n");
// TODO free appropriate (after figuring this part out) components of t // TODO free appropriate (after figuring this part out) components of t
// TODO send EVENT_OBJECT_DESTROY events to accessibility listeners (when appropriate); see the note on proxy objects as well // TODO send EVENT_OBJECT_DESTROY events to accessibility listeners (when appropriate); see the note on proxy objects as well
freeTableAcc(t->ta);
t->ta = NULL;
freeCheckboxThemeData(t); freeCheckboxThemeData(t);
destroyHeader(t); destroyHeader(t);
tableFree(t, "error allocating internal Table data structure"); tableFree(t, "error allocating internal Table data structure");