|
@@ -28,10 +28,29 @@ struct option long_options[] = {
|
|
|
{ "noautomute", no_argument, nullptr, 'm' },
|
|
{ "noautomute", no_argument, nullptr, 'm' },
|
|
|
{ "no-fullscreen-pause", no_argument, nullptr, 'n' },
|
|
{ "no-fullscreen-pause", no_argument, nullptr, 'n' },
|
|
|
{ "disable-mouse", no_argument, nullptr, 'e' },
|
|
{ "disable-mouse", no_argument, nullptr, 'e' },
|
|
|
- { "clamp-strategy", required_argument, nullptr, 't' },
|
|
|
|
|
|
|
+ { "scaling", required_argument, nullptr, 't' },
|
|
|
|
|
+ { "clamping", required_argument, nullptr, 't' },
|
|
|
{ nullptr, 0, nullptr, 0 }
|
|
{ nullptr, 0, nullptr, 0 }
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+/* std::hash::operator() isn't constexpr, so it can't be used to get hash values as compile-time constants
|
|
|
|
|
+ * So here is customHash. It skips all spaces, so hashes for " find " and "fi nd" are the same
|
|
|
|
|
+ * Basicly got it from here: https://stackoverflow.com/questions/8317508/hash-function-for-a-string
|
|
|
|
|
+*/
|
|
|
|
|
+constexpr size_t customHash(const char* str) {
|
|
|
|
|
+ constexpr size_t A = 54059; /* a prime */
|
|
|
|
|
+ constexpr size_t B = 76963; /* another prime */
|
|
|
|
|
+ constexpr size_t C = 86969; /* yet another prime */
|
|
|
|
|
+ constexpr size_t FIRSTH = 37; /* also prime */
|
|
|
|
|
+ size_t hash = FIRSTH;
|
|
|
|
|
+ while (*str) {
|
|
|
|
|
+ if(*str != ' ') // Skip spaces
|
|
|
|
|
+ hash = (hash * A) ^ (*str * B);
|
|
|
|
|
+ ++str;
|
|
|
|
|
+ }
|
|
|
|
|
+ return hash % C;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
std::string stringPathFixes (const std::string& s)
|
|
std::string stringPathFixes (const std::string& s)
|
|
|
{
|
|
{
|
|
|
if (s.empty ())
|
|
if (s.empty ())
|
|
@@ -66,7 +85,8 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|
|
.mode = NORMAL_WINDOW,
|
|
.mode = NORMAL_WINDOW,
|
|
|
.maximumFPS = 30,
|
|
.maximumFPS = 30,
|
|
|
.pauseOnFullscreen = true,
|
|
.pauseOnFullscreen = true,
|
|
|
- .window = { .geometry = {}, .clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs, .scaleToFit=false },
|
|
|
|
|
|
|
+ .window = { .geometry = {}, .clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs,
|
|
|
|
|
+ .scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs, },
|
|
|
},
|
|
},
|
|
|
.audio =
|
|
.audio =
|
|
|
{
|
|
{
|
|
@@ -105,6 +125,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|
|
// no need to check for previous screen being in the list, as it's the only way for this variable
|
|
// no need to check for previous screen being in the list, as it's the only way for this variable
|
|
|
// to have any value
|
|
// to have any value
|
|
|
this->settings.general.screenBackgrounds[lastScreen] = translateBackground (optarg);
|
|
this->settings.general.screenBackgrounds[lastScreen] = translateBackground (optarg);
|
|
|
|
|
+ this->settings.general.screenScalings[lastScreen] = this->settings.render.window.scalingMode;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case 'o':
|
|
case 'o':
|
|
@@ -133,6 +154,7 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|
|
this->settings.render.mode = DESKTOP_BACKGROUND;
|
|
this->settings.render.mode = DESKTOP_BACKGROUND;
|
|
|
lastScreen = optarg;
|
|
lastScreen = optarg;
|
|
|
this->settings.general.screenBackgrounds[lastScreen] = "";
|
|
this->settings.general.screenBackgrounds[lastScreen] = "";
|
|
|
|
|
+ this->settings.general.screenScalings[lastScreen] = this->settings.render.window.scalingMode;
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case 'w':
|
|
case 'w':
|
|
@@ -196,25 +218,38 @@ CApplicationContext::CApplicationContext (int argc, char* argv[])
|
|
|
break;
|
|
break;
|
|
|
|
|
|
|
|
case 't':
|
|
case 't':
|
|
|
- {
|
|
|
|
|
- char opt = optarg[0];
|
|
|
|
|
- switch (opt)
|
|
|
|
|
- {
|
|
|
|
|
- case 's':/* stretch*/
|
|
|
|
|
- this->settings.render.window.scaleToFit=true;
|
|
|
|
|
- break;
|
|
|
|
|
- case 'b':/* clamp border (crop black)*/
|
|
|
|
|
- this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVsBorder;//clampStrategy(optarg);
|
|
|
|
|
- break;
|
|
|
|
|
- case 'c':/* clamp*/
|
|
|
|
|
- this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs;
|
|
|
|
|
- break;
|
|
|
|
|
- case 'r':
|
|
|
|
|
- this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::NoFlags;
|
|
|
|
|
- break;
|
|
|
|
|
- default:
|
|
|
|
|
- sLog.error("Wrong argument provided for clamp-strategy");
|
|
|
|
|
- break;
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ size_t hash = customHash(optarg);
|
|
|
|
|
+ // Use a switch statement with the hash
|
|
|
|
|
+ switch (hash) {
|
|
|
|
|
+ // --scale options
|
|
|
|
|
+ case customHash("stretch"):
|
|
|
|
|
+ this->settings.render.window.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::StretchUVs;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case customHash("fit"):
|
|
|
|
|
+ this->settings.render.window.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::ZoomFitUVs;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case customHash("fill"):
|
|
|
|
|
+ this->settings.render.window.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::ZoomFillUVs;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case customHash("default"):
|
|
|
|
|
+ this->settings.render.window.scalingMode = WallpaperEngine::Render::CWallpaperState::TextureUVsScaling::DefaultUVs;
|
|
|
|
|
+ break;
|
|
|
|
|
+ // --clamp options
|
|
|
|
|
+ case customHash("clamp"):
|
|
|
|
|
+ this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVs;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case customHash("border"):
|
|
|
|
|
+ this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::ClampUVsBorder;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case customHash("repeat"):
|
|
|
|
|
+ this->settings.render.window.clamp = WallpaperEngine::Assets::ITexture::TextureFlags::NoFlags;
|
|
|
|
|
+ break;
|
|
|
|
|
+ default:
|
|
|
|
|
+ sLog.error("Wrong argument:");
|
|
|
|
|
+ sLog.error(optarg);
|
|
|
|
|
+ sLog.exception("Wrong argument provided for --scale or --clamp option.");
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
break;
|
|
break;
|
|
@@ -314,5 +349,8 @@ void CApplicationContext::printHelp (const char* route)
|
|
|
sLog.out ("\t--set-property <name=value>\tOverrides the default value of the given property");
|
|
sLog.out ("\t--set-property <name=value>\tOverrides the default value of the given property");
|
|
|
sLog.out ("\t--no-fullscreen-pause\tPrevents the background pausing when an app is fullscreen");
|
|
sLog.out ("\t--no-fullscreen-pause\tPrevents the background pausing when an app is fullscreen");
|
|
|
sLog.out ("\t--disable-mouse\tDisables mouse interactions");
|
|
sLog.out ("\t--disable-mouse\tDisables mouse interactions");
|
|
|
- sLog.out ("\t--clamp-strategy <strategy>\t Clamp strategy if wallpaper doesn't fit screen. Can be stretch, border, repeat, clamp. Can be shortend to s, b, r, c. Default is clamp");
|
|
|
|
|
|
|
+ sLog.out ("\t--scaling <mode>\t Scaling mode for wallpaper. Can be stretch, fit, fill, default. Must be used before wallpaper provided.\n\
|
|
|
|
|
+ \t\t For default wallpaper last specified value will be used.\n\
|
|
|
|
|
+ \t\t Example: ./wallengine --scaling stretch --screen-root eDP-1 --bg 2667198601 --scaling fill --screen-root eDP-2 2667198602");
|
|
|
|
|
+ sLog.out ("\t--clamping <mode>\t Clamping mode for all wallpapers. Can be clamp, border, repeat. Enables GL_CLAMP_TO_EDGE, GL_CLAMP_TO_BORDER, GL_REPEAT accordingly. Default is clamp.");
|
|
|
}
|
|
}
|