Skip to content

Commit

Permalink
优化鼠标手势
Browse files Browse the repository at this point in the history
  • Loading branch information
shuax committed Apr 6, 2016
1 parent ef644f1 commit 4b1a6a6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
16 changes: 12 additions & 4 deletions src/TabBookmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,19 @@ IAccessible* FindChildElement(IAccessible *parent, long role)
IAccessible* element = NULL;
if (parent)
{
int i = 1;
TraversalAccessible(parent, [&element, &i, &role]
TraversalAccessible(parent, [&element, &role]
(IAccessible* child) {
if (CheckAccessibleRole(child, role))
{
element = child;
}
i++;
return element != NULL;
});
}
if (parent && !element)
{
DebugLog(L"FindChildElement %X failed", role);
}
return element;
}

Expand All @@ -259,11 +261,12 @@ IAccessible* FindTopContainerView(IAccessible *top)
{
if(GetAccessibleRole(BookMark)==ROLE_SYSTEM_TOOLBAR)
{
top = GetChildElement(top, true, 3);
BookMark->Release();
top = GetChildElement(top, true, 3);
}
else
{
top->Release();
top = BookMark;
}

Expand All @@ -288,6 +291,10 @@ IAccessible* GetTopContainerView(HWND hwnd)
if ( S_OK == AccessibleObjectFromWindow(hwnd, OBJID_WINDOW, IID_IAccessible, (void**)&paccMainWindow) )
{
TopContainerView = FindTopContainerView(paccMainWindow);
if (!TopContainerView)
{
DebugLog(L"FindTopContainerView failed");
}
}
}
return TopContainerView;
Expand Down Expand Up @@ -545,6 +552,7 @@ LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
if(wParam==WM_RBUTTONUP && wheel_tab_ing)
{
wheel_tab_ing = false;
gesture_mgr.OnRButtonUp(pmouse);
return 1;
}

Expand Down
14 changes: 10 additions & 4 deletions src/gesture/GestureWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GestureWindow :
if(!image_up) return;

RECT rect;
::GetWindowRect(GetTopWnd(main_hwnd), &rect);
::GetWindowRect(main_hwnd, &rect);

int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
Expand Down Expand Up @@ -126,14 +126,14 @@ class GestureWindow :

LRESULT OnUserHwnd(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
main_hwnd = (HWND)wParam;
main_hwnd = GetTopWnd((HWND)wParam);
return 0;
}

LRESULT OnUserShow(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
{
RECT rect;
::GetWindowRect(GetTopWnd(main_hwnd), &rect);
::GetWindowRect(main_hwnd, &rect);
::SetWindowPos(m_hWnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOACTIVATE | SWP_NOZORDER);

DoUpdateWindow();
Expand All @@ -157,11 +157,17 @@ class GestureWindow :
std::wstring action = GetAction(command);
if (action.empty()) return 0;

SendKey(action);
std::thread th(DelaySendkeys, action);
th.detach();
return 0;
}

private:
static void DelaySendkeys(std::wstring action)
{
Sleep(50);
SendKey(action);
}
HWND GetTopWnd(HWND hwnd)
{
while (::GetParent(hwnd) && ::IsWindowVisible(::GetParent(hwnd)))
Expand Down

0 comments on commit 4b1a6a6

Please sign in to comment.