Defer wxAccessible::NotifyEvent() to idle time

Change NotifyEvent() implementation so that it doesn't call
::NotifyWinEvent() immediately, but only in the next iteration of the
event loop. This makes it easier to write code that uses, because it
must be called after the changes it notifies about were fully made and
are visible in the corresponding window's accessible interface.
This commit is contained in:
Václav Slavík 2016-12-11 16:53:33 +01:00 committed by Václav Slavík
parent f7514467ae
commit d720155910

View File

@ -28,6 +28,7 @@
#include "wx/access.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/msw/wrapwin.h"
#include "wx/window.h"
#include "wx/log.h"
@ -1823,12 +1824,36 @@ IAccessible *wxAccessible::GetIAccessibleStd()
return NULL;
}
namespace
{
struct SendNotification
{
SendNotification(DWORD eventType_, HWND hwnd_, LONG idObject_, LONG idChild_)
: eventType(eventType_), hwnd(hwnd_), idObject(idObject_), idChild(idChild_)
{}
void operator()(void)
{
::NotifyWinEvent(eventType, hwnd, idObject, idChild);
}
DWORD eventType;
HWND hwnd;
LONG idObject, idChild;
};
} // anonymous namespace
// Sends an event when something changes in an accessible object.
void wxAccessible::NotifyEvent(int eventType, wxWindow* window, wxAccObject objectType,
int objectId)
{
::NotifyWinEvent((DWORD) eventType, (HWND) window->GetHWND(),
(LONG) objectType, (LONG) objectId);
// send the notification in idle time to be sure it is sent after the change
// was fully done in wx code
const HWND hwnd = (HWND)window->GetHWND();
SendNotification delayed((DWORD)eventType, hwnd, (LONG)objectType, (LONG)objectId);
wxTheApp->CallAfter(delayed);
}
// Utilities