win8: Add support to double tap with pen

Discussion:
https://community.aseprite.org/t/surface-pro-3-file-navigation/696
This commit is contained in:
David Capello 2017-11-23 17:03:24 -03:00
parent e1232516ee
commit 848ce5972d
3 changed files with 34 additions and 17 deletions

View File

@ -775,7 +775,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
m_ignoreMouseMessages = true;
#endif
if (pi.pointerType == PT_TOUCH) {
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.AddPointerInteractionContext)
winApi.AddPointerInteractionContext(m_ictx, pi.pointerId);
@ -804,7 +804,7 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
m_ignoreMouseMessages = false;
#endif
if (pi.pointerType == PT_TOUCH) {
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.RemovePointerInteractionContext)
winApi.RemovePointerInteractionContext(m_ictx, pi.pointerId);
@ -832,11 +832,12 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
if (!pointerEvent(wparam, ev, pi))
break;
if (pi.pointerType == PT_TOUCH) {
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.ProcessPointerFramesInteractionContext) {
winApi.ProcessPointerFramesInteractionContext(m_ictx, 1, 1, &pi);
return 0;
if (pi.pointerType == PT_TOUCH)
return 0;
}
}
@ -862,11 +863,12 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
if (!pointerEvent(wparam, ev, pi))
break;
if (pi.pointerType == PT_TOUCH) {
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.ProcessPointerFramesInteractionContext) {
winApi.ProcessPointerFramesInteractionContext(m_ictx, 1, 1, &pi);
return 0;
if (pi.pointerType == PT_TOUCH)
return 0;
}
}
@ -892,11 +894,12 @@ LRESULT WinWindow::wndProc(UINT msg, WPARAM wparam, LPARAM lparam)
if (!pointerEvent(wparam, ev, pi))
break;
if (pi.pointerType == PT_TOUCH) {
if (pi.pointerType == PT_TOUCH || pi.pointerType == PT_PEN) {
auto& winApi = system()->winApi();
if (m_ictx && winApi.ProcessPointerFramesInteractionContext) {
winApi.ProcessPointerFramesInteractionContext(m_ictx, 1, 1, &pi);
return 0;
if (pi.pointerType == PT_TOUCH)
return 0;
}
}
@ -1201,8 +1204,11 @@ void WinWindow::handleInteractionContextOutput(
output->interactionFlags,
output->inputType);
// We use the InteractionContext to interpret touch gestures only.
if (output->inputType == PT_TOUCH) {
// We use the InteractionContext to interpret touch gestures only and double tap with pen.
if ((output->inputType == PT_TOUCH) ||
(output->inputType == PT_PEN &&
output->interactionId == INTERACTION_ID_TAP &&
output->arguments.tap.count == 2)) {
ABS_CLIENT_RC(rc);
gfx::Point pos(int((output->x - rc.left) / m_scale),
@ -1212,6 +1218,13 @@ void WinWindow::handleInteractionContextOutput(
ev.setModifiers(get_modifiers_from_last_win32_message());
ev.setPosition(pos);
bool hadMouse = m_hasMouse;
if (!m_hasMouse) {
m_hasMouse = true;
ev.setType(Event::MouseEnter);
queueEvent(ev);
}
switch (output->interactionId) {
case INTERACTION_ID_MANIPULATION: {
MOUSE_TRACE(" - delta xy=%.16g %.16g scale=%.16g expansion=%.16g rotation=%.16g\n",

View File

@ -1444,7 +1444,8 @@ bool Manager::sendMessageToWidget(Message* msg, Widget* widget)
"Unknown";
std::cout << "Event " << msg->type() << " (" << string << ") "
<< "for " << typeid(*widget).name();
<< "for " << ((void*)widget) << std::flush;
std::cout << " (" << typeid(*widget).name() << ")";
if (!widget->id().empty())
std::cout << " (" << widget->id() << ")";
std::cout << std::endl;

View File

@ -81,7 +81,15 @@ Widget::Widget(WidgetType type)
Widget::~Widget()
{
// Break relationship with the manager.
// First, we remove children (so children's ~Widget() can access to
// the manager()).
while (!m_children.empty())
delete m_children.front();
// Break relationship with the manager. This cannot be before
// deleting children, if we delete children after releasing the
// parent, a children deletion could generate a kMouseLeaveMessage
// for the parent that will be deleted too.
Manager* manager = this->manager();
ASSERT(manager);
if (manager) {
@ -90,11 +98,6 @@ Widget::~Widget()
manager->removeMessageFilterFor(this);
}
// Remove first children (so children's ~Widget() can access to the
// manager()).
while (!m_children.empty())
delete m_children.front();
// Remove this widget from parent.
if (m_parent)
m_parent->removeChild(this);