win-capture: Allow window capturing of current process
Allows window capture to capture windows of the current process, and adds windows of the current process to the end of the window list.master
parent
a140d749f2
commit
8d520b970d
|
@ -1579,7 +1579,7 @@ static obs_properties_t *game_capture_properties(void *data)
|
|||
p = obs_properties_add_list(ppts, SETTING_CAPTURE_WINDOW, TEXT_WINDOW,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
obs_property_list_add_string(p, "", "");
|
||||
fill_window_list(p, INCLUDE_MINIMIZED);
|
||||
fill_window_list(p, INCLUDE_MINIMIZED, false);
|
||||
|
||||
obs_property_set_modified_callback(p, window_changed_callback);
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ static obs_properties_t *wc_properties(void *unused)
|
|||
|
||||
p = obs_properties_add_list(ppts, "window", TEXT_WINDOW,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_STRING);
|
||||
fill_window_list(p, EXCLUDE_MINIMIZED);
|
||||
fill_window_list(p, EXCLUDE_MINIMIZED, true);
|
||||
|
||||
p = obs_properties_add_list(ppts, "priority", TEXT_MATCH_PRIORITY,
|
||||
OBS_COMBO_TYPE_LIST, OBS_COMBO_FORMAT_INT);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#define PSAPI_VERSION 1
|
||||
#include <obs.h>
|
||||
#include <util/dstr.h>
|
||||
#include <util/darray.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <psapi.h>
|
||||
|
@ -67,6 +68,13 @@ static inline HANDLE open_process(DWORD desired_access, bool inherit_handle,
|
|||
return open_process_proc(desired_access, inherit_handle, process_id);
|
||||
}
|
||||
|
||||
static inline bool is_self(HWND window)
|
||||
{
|
||||
DWORD id;
|
||||
GetWindowThreadProcessId(window, &id);
|
||||
return id == GetCurrentProcessId();
|
||||
}
|
||||
|
||||
bool get_window_exe(struct dstr *name, HWND window)
|
||||
{
|
||||
wchar_t wname[MAX_PATH];
|
||||
|
@ -77,8 +85,6 @@ bool get_window_exe(struct dstr *name, HWND window)
|
|||
DWORD id;
|
||||
|
||||
GetWindowThreadProcessId(window, &id);
|
||||
if (id == GetCurrentProcessId())
|
||||
return false;
|
||||
|
||||
process = open_process(PROCESS_QUERY_LIMITED_INFORMATION, false, id);
|
||||
if (!process)
|
||||
|
@ -204,14 +210,29 @@ static inline HWND first_window(enum window_search_mode mode)
|
|||
return window;
|
||||
}
|
||||
|
||||
void fill_window_list(obs_property_t *p, enum window_search_mode mode)
|
||||
void fill_window_list(obs_property_t *p, enum window_search_mode mode,
|
||||
bool allow_self)
|
||||
{
|
||||
HWND window = first_window(mode);
|
||||
DARRAY(HWND) process_windows;
|
||||
|
||||
da_init(process_windows);
|
||||
|
||||
while (window) {
|
||||
add_window(p, window);
|
||||
if (is_self(window))
|
||||
da_push_back(process_windows, &window);
|
||||
else
|
||||
add_window(p, window);
|
||||
|
||||
window = next_window(window, mode);
|
||||
}
|
||||
|
||||
if (allow_self) {
|
||||
for (size_t i = 0; i < process_windows.num; i++)
|
||||
add_window(p, process_windows.array[i]);
|
||||
}
|
||||
|
||||
da_free(process_windows);
|
||||
}
|
||||
|
||||
static int window_rating(HWND window,
|
||||
|
|
|
@ -15,7 +15,8 @@ enum window_search_mode {
|
|||
|
||||
extern bool get_window_exe(struct dstr *name, HWND window);
|
||||
|
||||
extern void fill_window_list(obs_property_t *p, enum window_search_mode mode);
|
||||
extern void fill_window_list(obs_property_t *p, enum window_search_mode mode,
|
||||
bool allow_self);
|
||||
|
||||
extern void build_window_strings(const char *str,
|
||||
char **class,
|
||||
|
|
Loading…
Reference in New Issue