cyfdecyf/cow

Bug in cow-taskbar.exe

Opened this issue · 0 comments

rexdf commented

TL;DR
We should call SetForegroundWindow and then call TrackPopupMenu

https://stackoverflow.com/questions/15494591/hide-close-menu-when-mouse-is-clicked-outside-its-focus

https://msdn.microsoft.com/en-us/library/windows/desktop/ms648002(v=vs.85).aspx

The version in cow-taskbar.exe, sub_4011E3() is ShowPopupMenu

  if ( Msg != 275 )
  {
    if ( Msg != 1044 )
      return DefWindowProcW(hWnd, Msg, wParam, lParam);
    if ( lParam != 514 )
    {
      if ( lParam == 517 )
        sub_4011E3();
      return 0;
    }
    v5 = IsWindowVisible(dword_4033E0) == 0;
    ShowWindow(dword_4033E0, v5);
    goto LABEL_13;
  }

The version from goproxy, sub_401D30() is ShowPopupMenu

    if ( a2 == 1044 )
    {
      if ( a4 != 514 )
      {
        if ( a4 == 517 )
        {
          SetForegroundWindow(hWnd);
          sub_401D30();
        }
        return 0;
      }
      nCmdShow = IsWindowVisible(dword_40C4C8) == 0;
      ShowWindow(dword_40C4C8, nCmdShow);
LABEL_25:
      SetForegroundWindow(dword_40C4C8);
      return 0;
    }

https://github.com/phuslu/taskbar/blob/80e4a0b97e8ed9427d9054138891828bf30aad35/windows/taskbar.c#L509-L510

		case WM_TASKBARNOTIFY:
			if (lParam == WM_LBUTTONUP)
			{
				ShowWindow(hConsole, !IsWindowVisible(hConsole));
				SetForegroundWindow(hConsole);
			}
			else if (lParam == WM_RBUTTONUP)
			{
				SetForegroundWindow(hWnd);
				ShowPopupMenu();
			}
			break;
		case WM_COMMAND: