Merge pull request #3121 from jpark37/chrome-window-priority
win-capture: Don't use Chrome classes for prioritymaster
commit
97ecf23df0
|
@ -363,7 +363,7 @@ void fill_window_list(obs_property_t *p, enum window_search_mode mode,
|
|||
|
||||
static int window_rating(HWND window, enum window_priority priority,
|
||||
const char *class, const char *title, const char *exe,
|
||||
bool uwp_window)
|
||||
bool generic_class)
|
||||
{
|
||||
struct dstr cur_class = {0};
|
||||
struct dstr cur_title = {0};
|
||||
|
@ -379,8 +379,8 @@ static int window_rating(HWND window, enum window_priority priority,
|
|||
bool exe_matches = dstr_cmpi(&cur_exe, exe) == 0;
|
||||
int title_val = abs(dstr_cmpi(&cur_title, title));
|
||||
|
||||
/* always match by name with UWP windows */
|
||||
if (uwp_window) {
|
||||
/* always match by name if class is generic */
|
||||
if (generic_class) {
|
||||
if (priority == WINDOW_PRIORITY_EXE && !exe_matches)
|
||||
val = 0x7FFFFFFF;
|
||||
else
|
||||
|
@ -405,6 +405,37 @@ static int window_rating(HWND window, enum window_priority priority,
|
|||
return val;
|
||||
}
|
||||
|
||||
static const char *generic_class_substrings[] = {
|
||||
"Chrome",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const char *generic_classes[] = {
|
||||
"Windows.UI.Core.CoreWindow",
|
||||
NULL,
|
||||
};
|
||||
|
||||
static bool is_generic_class(const char *current_class)
|
||||
{
|
||||
const char **class = generic_class_substrings;
|
||||
while (*class) {
|
||||
if (astrstri(current_class, *class) != NULL) {
|
||||
return true;
|
||||
}
|
||||
class ++;
|
||||
}
|
||||
|
||||
class = generic_classes;
|
||||
while (*class) {
|
||||
if (astrcmpi(current_class, *class) == 0) {
|
||||
return true;
|
||||
}
|
||||
class ++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
HWND find_window(enum window_search_mode mode, enum window_priority priority,
|
||||
const char *class, const char *title, const char *exe)
|
||||
{
|
||||
|
@ -418,11 +449,11 @@ HWND find_window(enum window_search_mode mode, enum window_priority priority,
|
|||
if (!class)
|
||||
return NULL;
|
||||
|
||||
bool uwp_window = strcmp(class, "Windows.UI.Core.CoreWindow") == 0;
|
||||
bool generic_class = is_generic_class(class);
|
||||
|
||||
while (window) {
|
||||
int rating = window_rating(window, priority, class, title, exe,
|
||||
uwp_window);
|
||||
generic_class);
|
||||
if (rating < best_rating) {
|
||||
best_rating = rating;
|
||||
best_window = window;
|
||||
|
@ -442,7 +473,7 @@ struct top_level_enum_data {
|
|||
const char *class;
|
||||
const char *title;
|
||||
const char *exe;
|
||||
bool uwp_window;
|
||||
bool generic_class;
|
||||
HWND best_window;
|
||||
int best_rating;
|
||||
};
|
||||
|
@ -462,7 +493,7 @@ BOOL CALLBACK enum_windows_proc(HWND window, LPARAM lParam)
|
|||
|
||||
const int rating = window_rating(window, data->priority, data->class,
|
||||
data->title, data->exe,
|
||||
data->uwp_window);
|
||||
data->generic_class);
|
||||
if (rating < data->best_rating) {
|
||||
data->best_rating = rating;
|
||||
data->best_window = window;
|
||||
|
@ -484,7 +515,7 @@ HWND find_window_top_level(enum window_search_mode mode,
|
|||
data.class = class;
|
||||
data.title = title;
|
||||
data.exe = exe;
|
||||
data.uwp_window = strcmp(class, "Windows.UI.Core.CoreWindow") == 0;
|
||||
data.generic_class = is_generic_class(class);
|
||||
data.best_window = NULL;
|
||||
data.best_rating = 0x7FFFFFFF;
|
||||
EnumWindows(enum_windows_proc, (LPARAM)&data);
|
||||
|
|
Loading…
Reference in New Issue