Suggestion Mac fullscreen can't get to dock or menu on top of screen

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Hi, it'd be nice if when setting the game to fullscreen it would let the user drag there mouse on the edge of the screen to get the dock and top menu to appear. When you start the game in windowed mode (#GLFW_WINDOW_FULLSCREEN=False) and use #GLFW_WINDOW_RESIZABLE=True the user is able to press the green enlarge button on the window to make it fullscreen and then they are able to access the dock and menu. If the game starts in full-screen or the developer sets it to fullscreen in code, the user can't access the dock or menu.

Code:
Local myDisplaySize:DisplayMode
myDisplaySize = DesktopMode()
SetDeviceWindow(myDisplaySize.Width,myDisplaySize.Height,4|2|1)

If the developer passes in the "4" flag (Decorated Window), it would be nice to have the dock/menu accessible.
 

Phil7

Administrator
CX Code Contributor
3rd Party Tool Dev
Joined
Jun 26, 2017
Messages
643
If you want to investigate on this, I would look into glfw, if this is possible there. Maybe I can find some time next week.
 

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Thanks, I will have to get some experience with glfw. I just wanted to have some of these things reported and try to help with Android and HTML related stuff for now.
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
I'm not sure if this helps as It is not exactly that but this gives you a fullscreen with visible dock and titlebar on desktop platform (it's only tested on macOS right now but it should work on Windows as well).

fullscreenwindow.cxs
Code:
' Set your native fullscreen resolution here (0 crashses mojo2)
#GLFW_WINDOW_WIDTH = 1440
#GLFW_WINDOW_HEIGHT = 900

Strict
Public

Import mojo2
Import "commands.cpp"

Extern ' bindings
    Function SetWindowPosition:Void(X:Int, Y:Int)="windowtest::setWindowPosition"
    Function GetMonitorCanvas:Void(Output:Int[], MinimumHeight:Bool=False)="windowtest::getMonitorCanvas"
    Function GetMonitorCanvas:Int[](MinimumHeight:Bool=False)="windowtest::getMonitorCanvas"
Public

Function Main:Int()
    New Application()
    Return 0
End

Class Application Extends App Final
  
    Field Color:Float
    Field canvas:Canvas
    Field fullscreen:Bool = true
  
    Method OnCreate:Int()
        canvas = New Canvas()
        SetUpdateRate 0
        Local Desktop := GetMonitorCanvas()
        SetDeviceWindow(Desktop[2],Desktop[3],0)     
        .SetWindowPosition(Desktop[0],Desktop[1])
        Return 0
    End
  
    Method OnUpdate:Int()
        If KeyHit(KEY_ESCAPE) Then OnClose() ; Return 0     
        Color = Sin(Float(Millisecs()/10)) * 255.0
        Return 0
    End
  
    Method OnRender:Int()
        canvas.Clear Color/255.0,0.0,0.0
        canvas.Flush
        Return 0
    End
  
End

commands.cpp
Code:
namespace windowtest
{
    void setWindowPosition(int X, int Y)
    {
        glfwSetWindowPos(BBGlfwGame::GlfwGame()->GetGLFWwindow(), X, Y);
        return;
    }
    void getMonitorCanvas(Array<int> output, bool minimumHeight=false)
    {
        int count;
        GLFWmonitor** monitors = glfwGetMonitors(&count);
        int minx = 0;
        int miny = 0;
        int width = 0;
        int height = 0;
        for (int i = 0; i < count; i++) // NULL
        {
            GLFWmonitor* monitor = monitors[i];
            int xpos, ypos;
            const GLFWvidmode* video = glfwGetVideoMode(monitor);
            width += video->width;
            if (!minimumHeight)
            {
                height += video->height;
            }
            else
            {
                // Not using 'min' due to some odd compatibility issues.
                if ((i == 0) || video->height < height)
                {
                    height = video->height;
                }
            }
        glfwGetMonitorPos(monitor, &xpos, &ypos);
            if (xpos < minx)
            {
                minx = xpos;
            }
            if (ypos < miny)
            {
                miny = ypos;
            }
        }
        output[0] = minx;
        output[1] = miny;
        output[2] = width;
        output[3] = height;
        return;
    }
    Array<int> getMonitorCanvas(bool minimumHeight=false)
    {
        Array<int> output = Array<int>(4);
        getMonitorCanvas(output, minimumHeight);     
        return output;
    }
}
 

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Thanks Jimmy, but I really want the dock/menu hide automatically since that is standard behavior on Mac.

I messed around with it today and got it working, but it is all buggy and I'll try to finish this weekend. It's not possible with the GLFW APIs it seems, so it has to go through the cocoa window code itself.
 
Last edited:

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
Well I give up. It seems like it's just a couple of lines to make it full screen using Mac's built in functions, but GLFW does a bunch of other stuff when SetDeviceWindow is used and they clash with each other.

I tried putting these lines in this file/method.
/Applications/Cerberus/targets/glfw3/template/glfw3/src/cocoa_window.m
createNativeWindow()
Code:
[window setCollectionBehavior:(NSWindowCollectionBehaviorFullScreenPrimary)];
[window->ns.object toggleFullScreen:nil];
 
Last edited:

grant

Member
CX Code Contributor
3rd Party Module Dev
Joined
Nov 19, 2019
Messages
81
If GLFW is not supporting it, certainly we won't modify it.
I can understand you don't want to modify any outside libraries/frameworks. Good thing for me it's all open source. :D
 

MikeHart

Administrator
Joined
Jun 19, 2017
Messages
3,165
Let's wait and see what GLFW finally brings to the table. Do you happen to know if SDL supports it?
 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
SDL2 seem to solve it by introducing an extra flag so it has extra control over native fullscreen.
GLWF had this unresolved for a long time.

"Based on this information I'd like to toggle fullscreen mode of my window using glfwSetWindowMonitor. This works great except when using native fullscreen mode introduced in macOS 10.7. When inside native fullscreen mode glfwGetWindowMonitor always returns NULL."

"Here's some rough info I quickly gathered on how SDL provides access to native fullscreen mode on macOS:
SDL introduced a second fullscreen window flag: SDL_WINDOW_FULLSCREEN_DESKTOP. Whereas the old SDL_WINDOW_FULLSCREEN flag provides access to fullscreen video modes with defined resolutions exactly as glfw does right now, SDL_WINDOW_FULLSCREEN_DESKTOP simply uses the display mode of the desktop. On macOS this manifests itself as native fullscreen mode (with transition animation and workspace creation)."

 

Jimmy

Active member
3rd Party Module Dev
Tutorial Author
Joined
Jan 2, 2020
Messages
912
I'm not sure about this idea but if Cerberus-X is allowed to send keystrokes to macOS you could send the key combo Command-Control-F at the start to make a fullscreen with autohidden menu and dock.
 
Top Bottom