Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix fullscreen in GLMakie #4032

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix fullscreen in GLMakie #4032

wants to merge 2 commits into from

Conversation

marcsgil
Copy link

Description

I was trying to display a GLMakie window in fullscreen, as described in discourse. The problem was that the fullscreen keyword in the GLMakie.activate!() function appeard to have no effect. As suggested there, the keyword wasn't actually used in the source code.

I then read the GFLW documentation, to see how would one make a fullscreen window. It appears that a call to the function glfwSetWindowMonitor does the job, so I tried to find where it is called in the GLMakie source code. To my surprise, it is called with a wrong signature! I then attempted to fix it, and with this new version, the following code produces the result that I desire: a fullscreen image.

using GLMakie, GLMakie.GLFW
monitor = GLFW.GetPrimaryMonitor()
GLMakie.activate!(; decorated=false, monitor)

video_mode = GLFW.GetVideoMode(monitor)
w, h = video_mode.width, video_mode.height
img = rand(UInt8, w, h)

fig = Figure(size=(w, h), figure_padding=0)
ax = Axis(fig[1, 1], aspect=DataAspect())
hidedecorations!(ax)
heatmap!(ax, img, colormap=:greys)
fig

In the master branch, this will error do to the incorrect call to GLFW.SetWindowMonitor.

I'm not really familiar with the repository, so I don't know if this change might have effects elsewhere. If this is the right fix for the fullscreen problem, then the keyword could be removed, as it is not being used, and we should also update the docs.

@jkrumbiegel
Copy link
Member

I don't quite understand, where in your code above do you actually request fullscreen? At least on Mac there's a difference between a window that is fullscreened and a window that has the same size as the monitor set

@marcsgil
Copy link
Author

marcsgil commented Jul 15, 2024

According to the GLFW docs: "Windowed mode windows can be made full screen by setting a monitor with glfwSetWindowMonitor, and full screen ones can be made windowed by unsetting it with the same function."

In particular, in my code, the window is turned into fullscreen once I specify the monitor keyword. Then, a corrected call to GLFW.SetWindowMonitor is made.

@SimonDanisch
Copy link
Member

Works for me... It's not perfect, but maybe we could merge it like this for now.
Could you maybe add this to the GLMakie backend docs?

@SimonDanisch
Copy link
Member

To be honest, I lost track what we did for fullscreen at what point and it's also not a priority for me right now to improve it.
So removing fullscreen=true and documenting your solution for now seems like a fair compromise.

I guess we should also add to the docs how to exit fullscreen, which doesn't seem trivial (had to tab out and call GLMakie.closeall()).
If someone has time, we should register a callback for pressing the esc key which should den exit fullscreen.

@SimonDanisch SimonDanisch marked this pull request as ready for review August 7, 2024 15:36
@SimonDanisch
Copy link
Member

@marcsgil would you have time to update the docs? :)

@marcsgil
Copy link
Author

marcsgil commented Aug 7, 2024

This month I'll be very busy, so unfortunately I cannot do this right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Work in progress
Development

Successfully merging this pull request may close these issues.

3 participants