mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-21 15:20:00 +01:00
New Headless execution mode (DRAFT)
This commit is contained in:
@@ -1398,6 +1398,7 @@ void Control::keyboardCalback(GLFWwindow* w, int key, int, int action, int mods)
|
||||
{
|
||||
if (UserInterface::manager().keyboardAvailable())
|
||||
{
|
||||
// keys without modifiers in any windows
|
||||
if (!mods) {
|
||||
int _key = layoutKey(key);
|
||||
Control::manager().input_access_.lock();
|
||||
@@ -1411,15 +1412,32 @@ void Control::keyboardCalback(GLFWwindow* w, int key, int, int action, int mods)
|
||||
}
|
||||
Control::manager().input_access_.unlock();
|
||||
}
|
||||
// keys with modifiers in non-main window
|
||||
else if ( w != Rendering::manager().mainWindow().window() )
|
||||
{
|
||||
#if defined(APPLE)
|
||||
else if ( w != Rendering::manager().mainWindow().window() &&
|
||||
key == GLFW_KEY_F && action == GLFW_PRESS && mods == GLFW_MOD_SUPER )
|
||||
if ( key == GLFW_KEY_F && action == GLFW_PRESS && mods == GLFW_MOD_SUPER )
|
||||
#else
|
||||
else if ( key == GLFW_KEY_F && action == GLFW_PRESS && mods == GLFW_MOD_CONTROL )
|
||||
if ( key == GLFW_KEY_F && action == GLFW_PRESS && mods == GLFW_MOD_CONTROL )
|
||||
#endif
|
||||
{
|
||||
// toggle fullscreen on CTRL+F
|
||||
Rendering::manager().window(w)->toggleFullscreen();
|
||||
}
|
||||
#if defined(APPLE)
|
||||
else if ( key == GLFW_KEY_Q && action == GLFW_PRESS && mods == GLFW_MOD_SUPER )
|
||||
#else
|
||||
else if ( key == GLFW_KEY_Q && action == GLFW_PRESS && mods == GLFW_MOD_CONTROL )
|
||||
#endif
|
||||
{
|
||||
// Quit on CTRL+Q (if no main window)
|
||||
if (glfwGetWindowAttrib(Rendering::manager().mainWindow().window(), GLFW_VISIBLE)
|
||||
== GL_FALSE) {
|
||||
// close rendering manager = quit
|
||||
Rendering::manager().close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,15 +201,26 @@ static void OutputWindowEvent( GLFWwindow *w, int button, int action, int)
|
||||
|
||||
static void WindowCloseCallback( GLFWwindow* w )
|
||||
{
|
||||
// close main window
|
||||
if (Rendering::manager().mainWindow().window() == w) {
|
||||
if (!UserInterface::manager().TryClose())
|
||||
glfwSetWindowShouldClose(w, GLFW_FALSE);
|
||||
}
|
||||
else if (!glfwWindowShouldClose(w)) {
|
||||
// not main window
|
||||
else {
|
||||
// if headless (main window not visile)
|
||||
if (glfwGetWindowAttrib(Rendering::manager().mainWindow().window(), GLFW_VISIBLE)
|
||||
== GL_FALSE) {
|
||||
// close rendering manager = quit
|
||||
Rendering::manager().close();
|
||||
}
|
||||
// attempt to close shows display view
|
||||
else {
|
||||
Mixer::manager().setView(View::DISPLAYS);
|
||||
Rendering::manager().mainWindow().show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Rendering::MonitorConnect(GLFWmonitor* monitor, int event)
|
||||
{
|
||||
@@ -397,7 +408,7 @@ bool Rendering::init()
|
||||
unsigned int err = 0;
|
||||
|
||||
while((err = glGetError()) != GL_NO_ERROR){
|
||||
fprintf(stderr, "394 error %d \n", err );
|
||||
fprintf(stderr, "GLFW error %d \n", err );
|
||||
}
|
||||
|
||||
//
|
||||
@@ -444,13 +455,14 @@ RenderingWindow* Rendering::window(int index)
|
||||
}
|
||||
|
||||
|
||||
void Rendering::show()
|
||||
void Rendering::show(bool show_main_window)
|
||||
{
|
||||
// show output windows
|
||||
for (auto it = outputs_.begin(); it != outputs_.end(); ++it)
|
||||
it->show();
|
||||
|
||||
// show main window
|
||||
if (show_main_window || Settings::application.num_output_windows < 1 )
|
||||
main_.show();
|
||||
|
||||
// show menu on first show
|
||||
|
||||
@@ -116,7 +116,7 @@ public:
|
||||
// Initialization OpenGL and GLFW window creation
|
||||
bool init();
|
||||
// show windows and reset views
|
||||
void show();
|
||||
void show(bool show_main_window = true);
|
||||
// true if active rendering window
|
||||
bool isActive();
|
||||
// draw one frame
|
||||
|
||||
@@ -68,6 +68,7 @@ int main(int argc, char *argv[])
|
||||
int versionRequested = 0;
|
||||
int testRequested = 0;
|
||||
int cleanRequested = 0;
|
||||
int headlessRequested = 0;
|
||||
int helpRequested = 0;
|
||||
int fontsizeRequested = 0;
|
||||
int ret = -1;
|
||||
@@ -79,6 +80,8 @@ int main(int argc, char *argv[])
|
||||
testRequested = 1;
|
||||
} else if (strcmp(argv[i], "--clean") == 0 || strcmp(argv[i], "-C") == 0) {
|
||||
cleanRequested = 1;
|
||||
} else if (strcmp(argv[i], "--headless") == 0 || strcmp(argv[i], "-L") == 0) {
|
||||
headlessRequested = 1;
|
||||
} else if (strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-H") == 0) {
|
||||
helpRequested = 1;
|
||||
} else if (strcmp(argv[i], "--fontsize") == 0 || strcmp(argv[i], "-F") == 0) {
|
||||
@@ -132,12 +135,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (helpRequested) {
|
||||
printf("Usage: %s [-H, --help] [-V, --version] [-F N, --fontsize N] [-T, --test] [-C, --clean] [filename]\n",
|
||||
printf("Usage: %s [-H, --help] [-V, --version] [-F N, --fontsize N] [-L, --headless] [-T, --test] [-C, --clean] [filename]\n",
|
||||
argv[0]);
|
||||
printf("Options:\n");
|
||||
printf(" --help : Display usage information\n");
|
||||
printf(" --version : Display version information\n");
|
||||
printf(" --fontsize N : Force rendering font size to specified value N\n");
|
||||
printf(" --headless : Run without GUI\n");
|
||||
printf(" --test : Run rendering test\n");
|
||||
printf(" --clean : Reset user settings\n");
|
||||
ret = 0;ret = 0;
|
||||
@@ -211,7 +215,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
// show all windows
|
||||
Rendering::manager().draw();
|
||||
Rendering::manager().show();
|
||||
Rendering::manager().show(!headlessRequested);
|
||||
|
||||
// try to load file given in argument
|
||||
Mixer::manager().load(_openfile);
|
||||
|
||||
Reference in New Issue
Block a user