mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-05 23:40:02 +01:00
Fix OSX fullscreen crash
This commit is contained in:
@@ -128,7 +128,7 @@ std::string FrameBuffer::info() const
|
||||
}
|
||||
}
|
||||
|
||||
s += std::to_string(height()) + " px";
|
||||
s += std::to_string(width()) + "x" + std::to_string(height()) + " px";
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ static void WindowEscapeFullscreen( GLFWwindow *w, int key, int scancode, int ac
|
||||
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
|
||||
{
|
||||
// escape fullscreen
|
||||
GLFW_window_[w]->setFullscreen(nullptr);
|
||||
GLFW_window_[w]->exitFullscreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -505,7 +505,7 @@ GLFWmonitor *RenderingWindow::monitor()
|
||||
return monitorAt(x, y);
|
||||
}
|
||||
|
||||
void RenderingWindow::setFullscreen(GLFWmonitor *mo)
|
||||
void RenderingWindow::setFullscreen_(GLFWmonitor *mo)
|
||||
{
|
||||
// if in fullscreen mode
|
||||
if (mo == nullptr) {
|
||||
@@ -529,18 +529,34 @@ void RenderingWindow::setFullscreen(GLFWmonitor *mo)
|
||||
}
|
||||
}
|
||||
|
||||
void RenderingWindow::toggleFullscreen()
|
||||
void RenderingWindow::exitFullscreen()
|
||||
{
|
||||
// if in fullscreen mode
|
||||
if (isFullscreen()) {
|
||||
// exit fullscreen
|
||||
setFullscreen(nullptr);
|
||||
request_toggle_fullscreen_ = true;
|
||||
}
|
||||
// not in fullscreen mode
|
||||
else {
|
||||
// enter fullscreen in monitor where the window is
|
||||
setFullscreen(monitor());
|
||||
}
|
||||
|
||||
void RenderingWindow::toggleFullscreen()
|
||||
{
|
||||
request_toggle_fullscreen_ = true;
|
||||
}
|
||||
|
||||
void RenderingWindow::toggleFullscreen_()
|
||||
{
|
||||
if (request_toggle_fullscreen_) {
|
||||
// if in fullscreen mode
|
||||
if (isFullscreen()) {
|
||||
// exit fullscreen
|
||||
setFullscreen_(nullptr);
|
||||
}
|
||||
// not in fullscreen mode
|
||||
else {
|
||||
// enter fullscreen in monitor where the window is
|
||||
setFullscreen_(monitor());
|
||||
}
|
||||
}
|
||||
request_toggle_fullscreen_ = false;
|
||||
}
|
||||
|
||||
int RenderingWindow::width()
|
||||
@@ -665,7 +681,7 @@ void RenderingWindow::show()
|
||||
|
||||
if ( Settings::application.windows[index_].fullscreen ) {
|
||||
GLFWmonitor *mo = monitorNamed(Settings::application.windows[index_].monitor);
|
||||
setFullscreen(mo);
|
||||
setFullscreen_(mo);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -673,6 +689,8 @@ void RenderingWindow::show()
|
||||
|
||||
void RenderingWindow::makeCurrent()
|
||||
{
|
||||
toggleFullscreen_();
|
||||
|
||||
// handle window resize
|
||||
glfwGetFramebufferSize(window_, &(window_attributes_.viewport.x), &(window_attributes_.viewport.y));
|
||||
|
||||
@@ -693,6 +711,8 @@ void RenderingWindow::draw(FrameBuffer *fb)
|
||||
if (!window_ || !fb)
|
||||
return;
|
||||
|
||||
toggleFullscreen_();
|
||||
|
||||
// only draw if window is not iconified
|
||||
if( !glfwGetWindowAttrib(window_, GLFW_ICONIFIED ) ) {
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ class RenderingWindow
|
||||
uint fbo_;
|
||||
class WindowSurface *surface_;
|
||||
|
||||
bool request_toggle_fullscreen_;
|
||||
void toggleFullscreen_ ();
|
||||
void setFullscreen_(GLFWmonitor *mo);
|
||||
|
||||
public:
|
||||
RenderingWindow();
|
||||
@@ -58,7 +61,7 @@ public:
|
||||
|
||||
// fullscreen
|
||||
bool isFullscreen ();
|
||||
void setFullscreen(GLFWmonitor *mo);
|
||||
void exitFullscreen();
|
||||
void toggleFullscreen ();
|
||||
|
||||
// get width of rendering area
|
||||
@@ -122,7 +125,7 @@ public:
|
||||
void popAttrib();
|
||||
RenderingAttrib currentAttrib();
|
||||
|
||||
// get hold on the main window
|
||||
// get hold on the windows
|
||||
inline RenderingWindow& mainWindow() { return main_; }
|
||||
inline RenderingWindow& outputWindow() { return output_; }
|
||||
|
||||
|
||||
@@ -361,7 +361,7 @@ void UserInterface::handleKeyboard()
|
||||
// button esc to toggle fullscreen
|
||||
else if (ImGui::IsKeyPressed( GLFW_KEY_ESCAPE )) {
|
||||
if (Rendering::manager().mainWindow().isFullscreen())
|
||||
Rendering::manager().mainWindow().setFullscreen(nullptr);
|
||||
Rendering::manager().mainWindow().exitFullscreen();
|
||||
else if (navigator.pannelVisible())
|
||||
navigator.hidePannel();
|
||||
else if (!Mixer::selection().empty()) {
|
||||
@@ -2362,17 +2362,12 @@ void Navigator::RenderMainPannel()
|
||||
ImGui::Text(APP_NAME);
|
||||
ImGui::PopFont();
|
||||
|
||||
// TODO fix fullscreen for OSX :(
|
||||
// Icon to switch fullscreen
|
||||
ImGui::SetCursorPos(ImVec2(pannel_width_ - 35.f, 15.f));
|
||||
const char *tooltip[2] = {"Enter Fullscreen", "Exit Fullscreen"};
|
||||
bool fs = Rendering::manager().mainWindow().isFullscreen();
|
||||
if ( ImGuiToolkit::IconToggle(3,15,2,15, &fs, tooltip ) ) {
|
||||
Rendering::manager().mainWindow().toggleFullscreen();
|
||||
#ifndef APPLE
|
||||
ImGui::End();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
// Session menu
|
||||
ImGui::SetCursorPosY(width_);
|
||||
|
||||
Reference in New Issue
Block a user