Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/ProjectMSDLApplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ void ProjectMSDLApplication::defineOptions(Poco::Util::OptionSet& options)
options.addOption(Option("beatSensitivity", "", "Beat sensitivity. Between 0.0 and 2.0. Default 1.0.",
false, "<number>", true)
.binding("projectM.beatSensitivity", _commandLineOverrides));
#ifdef __linux__
options.addOption(Option("window_id", "wid", "Existing X11 window id to draw in.",
false, "<number>", true)
.binding("window.wid", _commandLineOverrides));
#endif
}

int ProjectMSDLApplication::main(POCO_UNUSED const std::vector<std::string>& args)
Expand Down
18 changes: 16 additions & 2 deletions src/SDLRenderingWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ void SDLRenderingWindow::CreateSDLWindow()
int top{_config->getInt("top", 0)};
bool positionOverridden = _config->getBool("overridePosition", false);

#ifdef __linux__
uint64_t wid{_config->getUInt64("wid", 0)};
#endif

if (!positionOverridden)
{
left = SDL_WINDOWPOS_UNDEFINED;
Expand Down Expand Up @@ -249,8 +253,18 @@ void SDLRenderingWindow::CreateSDLWindow()
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
#endif

_renderingWindow = SDL_CreateWindow("projectM", left, top, width, height,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
#ifdef __linux__
if (wid) {
SDL_SetHint(SDL_HINT_VIDEO_FOREIGN_WINDOW_OPENGL, "1");
_renderingWindow = SDL_CreateWindowFrom((void*)wid);
}
else
#endif
{
_renderingWindow = SDL_CreateWindow("projectM", left, top, width, height,
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI);
}

if (!_renderingWindow)
{
auto errorMessage = "Could not create SDL rendering window. Error: " + std::string(SDL_GetError());
Expand Down