mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-06-12 09:44:44 -04:00
Frontend plugins should not require being placed in the frontend directory to be built successfully. Indeed they should only depend on libobs and the obs-frontend-api and thus their source tree should be able to exist anywhere (even standalone) and the plugin should still compile successfully (just like any 3rd party plugin). Thus moving those plugins into the main plugin directory ensures that they don't require on any "special sauce" within the source tree to compile.
72 lines
1.5 KiB
C++
72 lines
1.5 KiB
C++
#include <windows.h>
|
|
#include <util/platform.h>
|
|
#include "auto-scene-switcher.hpp"
|
|
|
|
using namespace std;
|
|
|
|
static bool GetWindowTitle(HWND window, string &title)
|
|
{
|
|
size_t len = (size_t)GetWindowTextLengthW(window);
|
|
wstring wtitle;
|
|
|
|
wtitle.resize(len);
|
|
if (!GetWindowTextW(window, &wtitle[0], (int)len + 1))
|
|
return false;
|
|
|
|
len = os_wcs_to_utf8(wtitle.c_str(), 0, nullptr, 0);
|
|
title.resize(len);
|
|
os_wcs_to_utf8(wtitle.c_str(), 0, &title[0], len + 1);
|
|
return true;
|
|
}
|
|
|
|
static bool WindowValid(HWND window)
|
|
{
|
|
LONG_PTR styles, ex_styles;
|
|
RECT rect;
|
|
DWORD id;
|
|
|
|
if (!IsWindowVisible(window))
|
|
return false;
|
|
GetWindowThreadProcessId(window, &id);
|
|
if (id == GetCurrentProcessId())
|
|
return false;
|
|
|
|
GetClientRect(window, &rect);
|
|
styles = GetWindowLongPtr(window, GWL_STYLE);
|
|
ex_styles = GetWindowLongPtr(window, GWL_EXSTYLE);
|
|
|
|
if (ex_styles & WS_EX_TOOLWINDOW)
|
|
return false;
|
|
if (styles & WS_CHILD)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void GetWindowList(vector<string> &windows)
|
|
{
|
|
HWND window = GetWindow(GetDesktopWindow(), GW_CHILD);
|
|
|
|
while (window) {
|
|
string title;
|
|
if (WindowValid(window) && GetWindowTitle(window, title))
|
|
windows.emplace_back(title);
|
|
window = GetNextWindow(window, GW_HWNDNEXT);
|
|
}
|
|
}
|
|
|
|
void GetCurrentWindowTitle(string &title)
|
|
{
|
|
HWND window = GetForegroundWindow();
|
|
DWORD id;
|
|
|
|
GetWindowThreadProcessId(window, &id);
|
|
if (id == GetCurrentProcessId()) {
|
|
title = "";
|
|
return;
|
|
}
|
|
GetWindowTitle(window, title);
|
|
}
|
|
|
|
void CleanupSceneSwitcher() {}
|