elvissteinjr / DesktopPlus

Advanced desktop access for OpenVR
GNU General Public License v3.0
467 stars 29 forks source link

Non-strict title matching doesn't match titles at all unless they include " - AppName" #59

Closed Identifier closed 1 year ago

Identifier commented 1 year ago

I'm using the NewUI branch. With the new code inWindowInfo::FindClosestWindowForTitle, if we are not using strict title matching, then the title will only be considered if it includes " - ApplicationName". If it doesn't include " - AppName", then the title will not be considered at all when looking for the best match window.

In other words, please change this:

    //Just straight look for a complete match when strict matching is enabled
    if (ConfigManager::GetValue(configid_bool_windows_winrt_window_matching_strict))
    {
        auto it = std::find_if(window_list.begin(), window_list.end(), 
                               [&](const auto& info){ return ( (info.GetWindowClassName() == class_wstr) && (info.GetExeName() == exe_str) && (info.GetTitle() == title_wstr) ); });

        return (it != window_list.end()) ? it->GetWindowHandle() : nullptr;
    }

to this:

    auto it = std::find_if(window_list.begin(), window_list.end(), 
                               [&](const auto& info){ return ( (info.GetWindowClassName() == class_wstr) && (info.GetExeName() == exe_str) && (info.GetTitle() == title_wstr) ); });

    if (it != window_list.end())
    {
        return it->GetWindowHandle();
    }

    //Just straight look for a complete match when strict matching is enabled
    if (ConfigManager::GetValue(configid_bool_windows_winrt_window_matching_strict))
    {
        return nullptr;
    }
elvissteinjr commented 1 year ago

Hi, I've kind of left this hanging for quite a bit. Saw this, thought I'd just respond once I applied the change after I'm done with my current thing... and got sidetracked. Sorry about that.

What you're saying here is totally right though. I've gone ahead and applied those changes to both branches (master/stable doesn't have strict matching but didn't do a complete match either) and had them be part of the new builds that needed to be made anyways. Thanks!