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