mirror of
https://github.com/Almamu/linux-wallpaperengine.git
synced 2025-07-14 13:22:23 +08:00
allow specifying outputs with a flag
This commit is contained in:
parent
5b1ea68164
commit
b505db103c
@ -12,22 +12,23 @@
|
|||||||
using namespace WallpaperEngine::Application;
|
using namespace WallpaperEngine::Application;
|
||||||
|
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{ "screen-root", required_argument, nullptr, 'r' },
|
{ "screen-root", required_argument, nullptr, 'r' },
|
||||||
{ "bg", required_argument, nullptr, 'b' },
|
{ "wayland-display", required_argument, nullptr, 'i' },
|
||||||
{ "window", required_argument, nullptr, 'w' },
|
{ "bg", required_argument, nullptr, 'b' },
|
||||||
{ "pkg", required_argument, nullptr, 'p' },
|
{ "window", required_argument, nullptr, 'w' },
|
||||||
{ "dir", required_argument, nullptr, 'd' },
|
{ "pkg", required_argument, nullptr, 'p' },
|
||||||
{ "silent", no_argument, nullptr, 's' },
|
{ "dir", required_argument, nullptr, 'd' },
|
||||||
{ "volume", required_argument, nullptr, 'v' },
|
{ "silent", no_argument, nullptr, 's' },
|
||||||
{ "help", no_argument, nullptr, 'h' },
|
{ "volume", required_argument, nullptr, 'v' },
|
||||||
{ "fps", required_argument, nullptr, 'f' },
|
{ "help", no_argument, nullptr, 'h' },
|
||||||
{ "assets-dir", required_argument, nullptr, 'a' },
|
{ "fps", required_argument, nullptr, 'f' },
|
||||||
{ "screenshot", required_argument, nullptr, 'c' },
|
{ "assets-dir", required_argument, nullptr, 'a' },
|
||||||
{ "list-properties", no_argument, nullptr, 'l' },
|
{ "screenshot", required_argument, nullptr, 'c' },
|
||||||
{ "set-property", required_argument, nullptr, 'o' },
|
{ "list-properties", no_argument, nullptr, 'l' },
|
||||||
{ "noautomute", no_argument, nullptr, 'm' },
|
{ "set-property", required_argument, nullptr, 'o' },
|
||||||
{ "no-fullscreen-pause", no_argument,nullptr, 'n' },
|
{ "noautomute", no_argument, nullptr, 'm' },
|
||||||
{ nullptr, 0, nullptr, 0 }
|
{ "no-fullscreen-pause", no_argument, nullptr, 'n' },
|
||||||
|
{ nullptr, 0, nullptr, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
std::string stringPathFixes (const std::string& s)
|
std::string stringPathFixes (const std::string& s)
|
||||||
@ -84,7 +85,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|||||||
|
|
||||||
std::string lastScreen;
|
std::string lastScreen;
|
||||||
|
|
||||||
while ((c = getopt_long (argc, argv, "b:r:p:d:shf:a:w:mn", long_options, nullptr)) != -1)
|
while ((c = getopt_long (argc, argv, "b:ri:p:d:shf:a:w:mn", long_options, nullptr)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -129,6 +130,18 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|||||||
this->settings.general.screenBackgrounds[lastScreen] = "";
|
this->settings.general.screenBackgrounds[lastScreen] = "";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'i':
|
||||||
|
if (this->settings.general.screenBackgrounds.find (optarg) != this->settings.general.screenBackgrounds.end ())
|
||||||
|
sLog.exception ("Cannot specify the same screen more than once: ", optarg);
|
||||||
|
if (this->settings.render.mode == EXPLICIT_WINDOW)
|
||||||
|
sLog.exception ("Cannot run in both background and window mode");
|
||||||
|
|
||||||
|
this->settings.render.mode = WAYLAND_LAYER_SHELL;
|
||||||
|
lastScreen = optarg;
|
||||||
|
this->settings.general.screenBackgrounds[lastScreen] = "";
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case 'w':
|
case 'w':
|
||||||
if (this->settings.render.mode == X11_BACKGROUND)
|
if (this->settings.render.mode == X11_BACKGROUND)
|
||||||
sLog.exception ("Cannot run in both background and window mode");
|
sLog.exception ("Cannot run in both background and window mode");
|
||||||
|
@ -263,11 +263,10 @@ namespace WallpaperEngine::Application
|
|||||||
void CWallpaperApplication::show ()
|
void CWallpaperApplication::show ()
|
||||||
{
|
{
|
||||||
// initialize OpenGL driver
|
// initialize OpenGL driver
|
||||||
const bool WAYLAND = getenv("WAYLAND_DISPLAY");
|
const bool WAYLAND = getenv("WAYLAND_DISPLAY") && this->m_context.settings.render.mode == CApplicationContext::WAYLAND_LAYER_SHELL;
|
||||||
if (WAYLAND) {
|
if (WAYLAND) {
|
||||||
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver>("wallpaperengine", this->m_context, this);
|
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver>("wallpaperengine", this->m_context, this);
|
||||||
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get());
|
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CWaylandOpenGLDriver*)videoDriver.get());
|
||||||
this->m_context.settings.render.mode = CApplicationContext::WAYLAND_LAYER_SHELL;
|
|
||||||
} else {
|
} else {
|
||||||
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CX11OpenGLDriver>("wallpaperengine", this->m_context);
|
videoDriver = std::make_unique<WallpaperEngine::Render::Drivers::CX11OpenGLDriver>("wallpaperengine", this->m_context);
|
||||||
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CX11OpenGLDriver*)videoDriver.get());
|
inputContext = std::make_unique<WallpaperEngine::Input::CInputContext>(*(WallpaperEngine::Render::Drivers::CX11OpenGLDriver*)videoDriver.get());
|
||||||
|
@ -229,6 +229,19 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver(const char* windowTitle, CApplication
|
|||||||
if (!waylandContext.compositor || !waylandContext.shm || !waylandContext.layerShell || m_outputs.empty())
|
if (!waylandContext.compositor || !waylandContext.shm || !waylandContext.layerShell || m_outputs.empty())
|
||||||
sLog.exception("Failed to bind to required interfaces");
|
sLog.exception("Failed to bind to required interfaces");
|
||||||
|
|
||||||
|
SWaylandOutput* outputToUse = nullptr;
|
||||||
|
for (auto& o : m_outputs) {
|
||||||
|
if (std::find_if(context.settings.general.screenBackgrounds.begin(), context.settings.general.screenBackgrounds.end(), [&] (const auto& e) { return e.first == o->name; }) != context.settings.general.screenBackgrounds.end()) {
|
||||||
|
outputToUse = o.get();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!outputToUse) {
|
||||||
|
sLog.debug("Failed to find any output, using first");
|
||||||
|
outputToUse = m_outputs[0].get();
|
||||||
|
}
|
||||||
|
|
||||||
const auto XCURSORSIZE = getenv("XCURSOR_SIZE") ? std::stoi(getenv("XCURSOR_SIZE")) : 24;
|
const auto XCURSORSIZE = getenv("XCURSOR_SIZE") ? std::stoi(getenv("XCURSOR_SIZE")) : 24;
|
||||||
const auto PRCURSORTHEME = wl_cursor_theme_load(NULL, XCURSORSIZE, waylandContext.shm);
|
const auto PRCURSORTHEME = wl_cursor_theme_load(NULL, XCURSORSIZE, waylandContext.shm);
|
||||||
|
|
||||||
@ -244,7 +257,7 @@ CWaylandOpenGLDriver::CWaylandOpenGLDriver(const char* windowTitle, CApplication
|
|||||||
initEGL();
|
initEGL();
|
||||||
|
|
||||||
waylandContext.layerSurface.surface = wl_compositor_create_surface(waylandContext.compositor);
|
waylandContext.layerSurface.surface = wl_compositor_create_surface(waylandContext.compositor);
|
||||||
waylandContext.layerSurface.layerSurface = zwlr_layer_shell_v1_get_layer_surface(waylandContext.layerShell, waylandContext.layerSurface.surface, m_outputs[0]->output, ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, "linux-wallpaperengine");
|
waylandContext.layerSurface.layerSurface = zwlr_layer_shell_v1_get_layer_surface(waylandContext.layerShell, waylandContext.layerSurface.surface, outputToUse->output, ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND, "linux-wallpaperengine");
|
||||||
|
|
||||||
if (!waylandContext.layerSurface.layerSurface) {
|
if (!waylandContext.layerSurface.layerSurface) {
|
||||||
finishEGL();
|
finishEGL();
|
||||||
|
Loading…
Reference in New Issue
Block a user