Added -w option
This commit is contained in:
parent
022edf74e1
commit
9ada3dd260
17
main.cpp
17
main.cpp
@ -31,10 +31,11 @@ std::unique_ptr<cairo_t, void(*)(cairo_t*)> main_context {nullptr, cairo_destroy
|
|||||||
std::unique_ptr<cairo_surface_t, void(*)(cairo_surface_t*)> main_surface {nullptr, cairo_surface_destroy};
|
std::unique_ptr<cairo_surface_t, void(*)(cairo_surface_t*)> main_surface {nullptr, cairo_surface_destroy};
|
||||||
|
|
||||||
void print_help() {
|
void print_help() {
|
||||||
std::cout << "usage: screensaver [-h|-l|--version]\n";
|
std::cout << "usage: screensaver [-h|-l|--version][-r][-w]\n";
|
||||||
std::cout << " -h, --help show this help text and exit\n";
|
std::cout << " -h, --help show this help text and exit\n";
|
||||||
std::cout << " -l, --list show available screensaver modules and exit\n";
|
std::cout << " -l, --list show available screensaver modules and exit\n";
|
||||||
std::cout << " -r, --random choose random module from available ones\n";
|
std::cout << " -r, --random choose random module from available ones\n";
|
||||||
|
std::cout << " -w, --window show in resizable window instead of fullscreen\n";
|
||||||
std::cout << " --version show version number and exit\n";
|
std::cout << " --version show version number and exit\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,15 +91,17 @@ int main(int argc, const char * argv[]) {
|
|||||||
sc::plugin<ScreensaverPlugin>::scan_plugins(plugin_dir, "saver");
|
sc::plugin<ScreensaverPlugin>::scan_plugins(plugin_dir, "saver");
|
||||||
std::string saver_name;
|
std::string saver_name;
|
||||||
bool random_saver {false};
|
bool random_saver {false};
|
||||||
|
bool small_window {false};
|
||||||
int opt_char, opt_val;
|
int opt_char, opt_val;
|
||||||
struct option long_options[] = {
|
struct option long_options[] = {
|
||||||
{"help", no_argument, nullptr, 'h'},
|
{"help", no_argument, nullptr, 'h'},
|
||||||
{"list", no_argument, nullptr, 'l'},
|
{"list", no_argument, nullptr, 'l'},
|
||||||
{"random", no_argument, nullptr, 'r'},
|
{"random", no_argument, nullptr, 'r'},
|
||||||
|
{"window", no_argument, nullptr, 'w'},
|
||||||
{"version", no_argument, &opt_val, 1},
|
{"version", no_argument, &opt_val, 1},
|
||||||
{nullptr, 0, nullptr, 0}
|
{nullptr, 0, nullptr, 0}
|
||||||
};
|
};
|
||||||
while ((opt_char = getopt_long(argc, const_cast<char* const *>(argv), "hlr", long_options, nullptr)) != -1) {
|
while ((opt_char = getopt_long(argc, const_cast<char* const *>(argv), "hlrw", long_options, nullptr)) != -1) {
|
||||||
std::string arg {optarg ? optarg : ""};
|
std::string arg {optarg ? optarg : ""};
|
||||||
switch (opt_char) {
|
switch (opt_char) {
|
||||||
case 0: {
|
case 0: {
|
||||||
@ -119,6 +122,9 @@ int main(int argc, const char * argv[]) {
|
|||||||
case 'r':
|
case 'r':
|
||||||
random_saver = true;
|
random_saver = true;
|
||||||
break;
|
break;
|
||||||
|
case 'w':
|
||||||
|
small_window = true;
|
||||||
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
throw std::runtime_error("unrecognized option");
|
throw std::runtime_error("unrecognized option");
|
||||||
}
|
}
|
||||||
@ -157,11 +163,8 @@ int main(int argc, const char * argv[]) {
|
|||||||
sc::gui::SDLImageWrapper sdl_image;
|
sc::gui::SDLImageWrapper sdl_image;
|
||||||
|
|
||||||
// main window
|
// main window
|
||||||
#if DEBUG
|
Uint32 flags {small_window ? SDL_WINDOW_RESIZABLE : SDL_WINDOW_FULLSCREEN_DESKTOP};
|
||||||
sc::gui::Window& window {sc::gui::Window::new_window("Living Art")};
|
sc::gui::Window& window {sc::gui::Window::new_window("Living Art", flags)};
|
||||||
#else
|
|
||||||
sc::gui::Window& window {sc::gui::Window::new_window("Living Art", SDL_WINDOW_FULLSCREEN_DESKTOP)};
|
|
||||||
#endif
|
|
||||||
main_window = &window;
|
main_window = &window;
|
||||||
window.add_event_handler(handle_window_resize, SDL_WINDOWEVENT_RESIZED);
|
window.add_event_handler(handle_window_resize, SDL_WINDOWEVENT_RESIZED);
|
||||||
window.add_event_handler(handle_window_resize, SDL_WINDOWEVENT_SIZE_CHANGED);
|
window.add_event_handler(handle_window_resize, SDL_WINDOWEVENT_SIZE_CHANGED);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user