diff --git a/src/she/win/window.cpp b/src/she/win/window.cpp index f8984ad5f..17cacd8d4 100644 --- a/src/she/win/window.cpp +++ b/src/she/win/window.cpp @@ -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", diff --git a/src/ui/manager.cpp b/src/ui/manager.cpp index da957deb1..2e492adbe 100644 --- a/src/ui/manager.cpp +++ b/src/ui/manager.cpp @@ -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; diff --git a/src/ui/widget.cpp b/src/ui/widget.cpp index 2808f06bb..abd43a369 100644 --- a/src/ui/widget.cpp +++ b/src/ui/widget.cpp @@ -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);