Make width and height customizable

This commit is contained in:
Ksaper 2023-03-02 01:59:34 +02:00
parent 6460a4fbd5
commit 0b0609e090
5 changed files with 22 additions and 3 deletions

View File

@ -25,6 +25,8 @@ struct option long_options [] = {
{"list-properties", no_argument, nullptr, 'l'}, {"list-properties", no_argument, nullptr, 'l'},
{"set-property", required_argument, nullptr, 'o'}, {"set-property", required_argument, nullptr, 'o'},
{"class", required_argument, nullptr, 'x'}, {"class", required_argument, nullptr, 'x'},
{"width", required_argument, nullptr, 'w'},
{"height", required_argument, nullptr, 't'},
{nullptr, 0, nullptr, 0} {nullptr, 0, nullptr, 0}
}; };
@ -51,6 +53,8 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
audioEnabled (true), audioEnabled (true),
onlyListProperties (false), onlyListProperties (false),
window_class (""), window_class (""),
window_width(1280),
window_height(720)
{ {
int c; int c;
@ -116,6 +120,13 @@ CApplicationContext::CApplicationContext (int argc, char* argv[]) :
case 'x': case 'x':
this->window_class = optarg; this->window_class = optarg;
break; break;
case 'w':
this->window_width = atoi(optarg);
break;
case 't':
this->window_height = atoi(optarg);
break;
} }
} }
@ -203,4 +214,6 @@ void CApplicationContext::printHelp (const char* route)
sLog.out ("\t--list-properties\t\t\tList all the available properties and their possible values"); sLog.out ("\t--list-properties\t\t\tList all the available properties and their possible values");
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--class <class name>\t\t\tSets X11 window class"); sLog.out ("\t--class <class name>\t\t\tSets X11 window class");
sLog.out ("\t--width <width>\t\t\tSets the window width");
sLog.out ("\t--height <height>\t\t\tSets the window height");
} }

View File

@ -25,6 +25,8 @@ namespace WallpaperEngine::Application
bool onlyListProperties; bool onlyListProperties;
FREE_IMAGE_FORMAT screenshotFormat; FREE_IMAGE_FORMAT screenshotFormat;
std::string window_class; std::string window_class;
int window_width;
int window_height;
private: private:
void validatePath (); void validatePath ();

View File

@ -272,4 +272,9 @@ void CWallpaperApplication::show ()
void CWallpaperApplication::signal (int signal) void CWallpaperApplication::signal (int signal)
{ {
g_KeepRunning = false; g_KeepRunning = false;
}
const CApplicationContext& CWallpaperApplication::get_context () const
{
return this->m_context;
} }

View File

@ -22,6 +22,7 @@ namespace WallpaperEngine::Application
void show (); void show ();
void signal (int signal); void signal (int signal);
const CApplicationContext& get_context () const;
private: private:
void setupContainer (); void setupContainer ();

View File

@ -12,8 +12,6 @@
#include "CRenderContext.h" #include "CRenderContext.h"
#include "CVideo.h" #include "CVideo.h"
#define DEFAULT_WINDOW_WIDTH 1280
#define DEFAULT_WINDOW_HEIGHT 720
using namespace WallpaperEngine::Render; using namespace WallpaperEngine::Render;
@ -81,7 +79,7 @@ void CRenderContext::initialize ()
void CRenderContext::setupWindow () void CRenderContext::setupWindow ()
{ {
this->m_driver.showWindow (); this->m_driver.showWindow ();
this->m_driver.resizeWindow ({DEFAULT_WINDOW_WIDTH, DEFAULT_WINDOW_HEIGHT}); this->m_driver.resizeWindow ({this->m_app.get_context().window_width, this->m_app.get_context().window_height});
} }
void CRenderContext::setupScreens () void CRenderContext::setupScreens ()