Skip to content

Commit

Permalink
Add SHE_USE_POINTER_API_FOR_MOUSE
Browse files Browse the repository at this point in the history
  • Loading branch information
dacap committed Mar 19, 2018
1 parent 4ce5e0b commit a576a7d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/she/win/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,13 @@ WinWindow::WinWindow(int width, int height, int scale)
, m_usePointerApi(false)
, m_lastPointerId(0)
, m_ictx(nullptr)
#if SHE_USE_POINTER_API_FOR_MOUSE
, m_emulateDoubleClick(false)
, m_doubleClickMsecs(GetDoubleClickTime())
, m_lastPointerDownTime(0)
, m_lastPointerDownButton(Event::NoneButton)
, m_pointerDownCount(0)
#endif
, m_hpenctx(nullptr)
, m_pointerType(PointerType::Unknown)
, m_pressure(0.0)
Expand All @@ -94,7 +96,7 @@ WinWindow::WinWindow(int width, int height, int scale)
// - We have to emulate the double-click for the regular mouse
// (search for m_emulateDoubleClick).
// - Double click with Wacom stylus doesn't work.
#if 0
#if SHE_USE_POINTER_API_FOR_MOUSE
if (!winApi.IsMouseInPointerEnabled()) {
// Prefer pointer messages (WM_POINTER*) since Windows 8 instead
// of mouse messages (WM_MOUSE*)
Expand Down Expand Up @@ -1194,9 +1196,11 @@ bool WinWindow::pointerEvent(WPARAM wparam, Event& ev, POINTER_INFO& pi)
void WinWindow::handlePointerButtonChange(Event& ev, POINTER_INFO& pi)
{
if (pi.ButtonChangeType == POINTER_CHANGE_NONE) {
#if SHE_USE_POINTER_API_FOR_MOUSE
// Reset the counter of pointer down for the emulated double-click
if (m_emulateDoubleClick)
m_pointerDownCount = 0;
#endif
return;
}

Expand Down Expand Up @@ -1237,6 +1241,7 @@ void WinWindow::handlePointerButtonChange(Event& ev, POINTER_INFO& pi)
ev.setType(down ? Event::MouseDown: Event::MouseUp);
ev.setButton(button);

#if SHE_USE_POINTER_API_FOR_MOUSE
if (down && m_emulateDoubleClick) {
if (button != m_lastPointerDownButton)
m_pointerDownCount = 0;
Expand All @@ -1253,6 +1258,7 @@ void WinWindow::handlePointerButtonChange(Event& ev, POINTER_INFO& pi)
m_lastPointerDownTime = curTime;
m_lastPointerDownButton = button;
}
#endif

queueEvent(ev);
}
Expand Down
4 changes: 4 additions & 0 deletions src/she/win/window.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include <windows.h>
#include <interactioncontext.h>

#define SHE_USE_POINTER_API_FOR_MOUSE 0

namespace she {
class Surface;
class WindowSystem;
Expand Down Expand Up @@ -93,6 +95,7 @@ namespace she {
UINT32 m_capturePointerId;
HINTERACTIONCONTEXT m_ictx;

#if SHE_USE_POINTER_API_FOR_MOUSE
// Emulate double-click with pointer API. I guess that this should
// be done by the Interaction Context API but it looks like
// messages with pointerType != PT_TOUCH or PT_PEN are just
Expand All @@ -104,6 +107,7 @@ namespace she {
base::tick_t m_lastPointerDownTime;
Event::MouseButton m_lastPointerDownButton;
int m_pointerDownCount;
#endif

// Wintab API data
HCTX m_hpenctx;
Expand Down

0 comments on commit a576a7d

Please sign in to comment.