Hello,

i am trying to design a options setting where the user can choose on wich monitor/screen/display the game should be displayed at.

I found out that you can get the current screen used with DisplayServer.window_get_current_screen() as an int and set it with DisplayServer.window_set_current_screen(i).
With DisplayServer.get_screen_count() you can get the amount of monitors/screens/displays.
But what i could not find was a how i would get the name of the monitors/screens/displays.

So how do i approach this problem? How do i find the monitor/screen/display names if that is even possible?

    Fruitdude get the name of the monitors/screens/displays.

    No such screen_get_name/screen_get_product_name/screen_get_manufacturer_name function far as I can see exists. You can open a proposal/feature request on the proposals tracker tho. In the meanwhile, on OS's(windows) that provide a default/standard set of applications to poll device info including monitors for their EDID you can call external programs via the OS class (provides an execute() method).

    On windows I guess you would poll something like DevCon or PnPUtil.

    On linux there is no exact equivalent, though a myriad of solutions to get the info if you are able to install them. Which you won't since this would be the end-user system. Since linux is so very fragmented and every distribution different you can't count on them all featuring the same bundled software for this. Well, X11 provides xrandr but that limits you to X11 systems leaving Wayland users to hang dry. So, being unix like system you might be able to look around in the /sys directory, probably somewhere in /sys/devices perhaps? Honestly probably just easier to make that feature request and leave this on the backburner for now tho. Unix is a mess.

    Even display drivers such as nvidias or amd's often fail to get a clear name tho since many, especially the cheaper monitors do not provide a clear product name in their EDID however.

    I'm on linux now but it was the same under windows 7(since the info is stored on and provided by the monitor via EDID), I have 3 monitors right now:

    • Wacom Tech Cintiq 12WX (product provides a clear manufacturer and product names)
    • LG Electronics LG IPS FULLHD (LG is not doing as good of a job, there's probably many different LG displays reporting themselves as 'LG IPS FULLHD', but at least the manufacturer name metadata is filled properly)
    • Fujitsu Siemens Computers GmbH P23T-6 LED (again, both Manufacturer and product name are filled with clearly specific identifiers.)

    Looking at this anecdotal sample size of 3 I think it's probably better to focus on getting the manufacturer ID since it's the more reliable one of the 2.

      Megalomaniak On linux there is no exact equivalent, though a myriad of solutions to get the info if you are able to install them. Which you won't since this would be the end-user system. Since linux is so very fragmented and every distribution different you can't count on them all featuring the same bundled software for this. Well, X11 provides xrandr but that limits you to X11 systems leaving Wayland users to hang dry. So, being unix like system you might be able to look around in the /sys directory, probably somewhere in /sys/devices perhaps? Honestly probably just easier to make that feature request and leave this on the backburner for now tho. Unix is a mess.

      After quickly trying it out I can report that in my wayland session I do get xrandr access, so the above quoted text isn't as accurate as I expected. Good news then. You can try calling xrandr both in X11 and Wayland sessions.

      Sadly the best I get out of it is:

      xrandr --listmonitors
      Monitors: 3
       0: +*XWAYLAND2 1920/480x1080/270+1280+0  XWAYLAND2
       1: +XWAYLAND0 1280/270x800/170+0+0  XWAYLAND0
       2: +XWAYLAND1 1080/290x1920/510+3200+0  XWAYLAND1

      Better than nothing tho.

      Thank you very much for your answers.

      I think that is to much effort for this feature. My skill is not high enough for that haha. I have literally no experience with linux. I think i will just name them something like "Display 1".

      Just grep'ed /var/log/Xorg.0.log and lo and behold there's a display name "LG Ultragear". So somehow the driver does know about the thing.

      Vulkan has the

      VkDisplayPropertiesKHR 

      structure that is filled by the

      vkGetPhysicalDeviceDisplayPropertiesKHR() 

      API. That structure has a field

      const char* displayName

      that I reckon holds the display name the driver knows about.

      Know that the structures are Vulkan-typically chained together, so that in case of multiple monitors I'd expect there'd be all the info one needs to present a list of connected monitors. But there'd be much more to do and check to let the user choose one monitor of several from the application side.

      tl, dr: yeah, the info is there and can be displayed independently from the OS. One could ask the devs if they'd be so kind ...

        Pixophir Just grep'ed /var/log/Xorg.0.log and lo and behold there's a display name "LG Ultragear"

        Likely applicable to X11 only.

        Pixophir So somehow the driver does know about the thing.

        Via EDID.

        Pixophir Vulkan has the
        VkDisplayPropertiesKHR
        structure that is filled by the
        vkGetPhysicalDeviceDisplayPropertiesKHR()
        API. That structure has a field
        const char* displayName
        that I reckon holds the display name the driver knows about.

        This could be useful for the vulkan renderer/build if a feature request was submitted to the proposals repo. I suspect however that the interest would be to also support this for the GL renderer.

        Not OpenGL ES directly, but the context-providing system. Not sure if that makes sense, OpenGL ES is outdated today, deprecated on newer Apple devices, and generally falling behind.

        But there's a cross platform functionality in Vulkan.

        Anyway users can always drag their programs from one monitor to another without any ado.

        I believe you can get the screen resolution given the screen number. This may be enough of a help without doing custom code. So it could look like this:

        Display 0 : 3840 x 2160
        Display 1 : 2560 x 1440
        Display 2 : 1920 x 1080
        for i in OS.get_screen_count():
            var res = OS.get_screen_size(i)
            print("Display ", i, " : ", res.x, " x ", res.y)

          Well yes, I'm saying as a simple compromise.

          The alternative would be writing native C++ code, for each supported OS, which is not hard, but it's something else to maintain.

          2 years later

          Create a new Scene, choose other and type Window.
          Create a script for your window scene:

          extends Window
          
          func _ready():
          	always_on_top = true
          	borderless = true
          	mode = Mode.MODE_FULLSCREEN
          
          func Start(screenNo : int):
          	current_screen = screenNo

          From your main/startup scene instanciate and set the monitor to show your window:

          	var d = window.instantiate()
          	add_child(d)
          	d.Start(1) # 0 is monitor, 1 is monitor 2 etc.

          You have to move your code into the window instead of the main scene. and you can hide the main scene window, but this way you can start your game on any screen/monitor and even make it multi monitor by instantiating multiple windows.