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

Multiple monitors: Position a space on a specific monitor #554

Open
tinchodias opened this issue Jul 9, 2024 · 4 comments
Open

Multiple monitors: Position a space on a specific monitor #554

tinchodias opened this issue Jul 9, 2024 · 4 comments

Comments

@tinchodias
Copy link
Collaborator

tinchodias commented Jul 9, 2024

I looked at how it would be to support multiple monitors with SDL2 host. I did this "research" from a question of @labordep in #507

This is a tutorial about this:
https://lazyfoo.net/tutorials/SDL/37_multiple_displays/index.php

Apparently it's as simple as knowing the number of monitors with:
https://wiki.libsdl.org/SDL2/SDL_GetNumVideoDisplays ,
and then you ask for each monitors bound (a rectangle):
https://wiki.libsdl.org/SDL2/SDL_GetDisplayBounds
and finally, you set the window position at e.g. (monitorBounds at: 2) origin + aSpace positionInMonitor

@tinchodias
Copy link
Collaborator Author

Possible implementation:

  • add BlSpace>>numberOfVideoDisplays method and
  • add videoDisplayIndex instvar and accessors in BlSpace and, IF POSSIBLE, the host takes into account the display index to do what is needed

Let's think on scenarios.

  1. Simple case: open a space in 50@100 of the last of the monitors (I guess 1 is the default, and that's the OS main monitor)
s := BlSpace new.
s position: 50@100.
s videoDisplayIndex: s numberOfVideoDisplays. 
s show
  1. Move that space to 50@100 position but in first (main) display: s videoDisplayIndex: 1

In the case the default Bloc host is Morphic, not SDL, then 2. has no effect.

@labordep
Copy link
Contributor

labordep commented Jul 10, 2024

Hi!
Cool! This is important to determine on what screen to display, for example on starting an application I can display a first window on screen 1 and a second window on screen 2. Each windows can be in fullscreen or not.
But before that it is necessary to known the hardware configuration, what is the way to known:

  • number of screens
  • definition of each screens (can be different)
  • resolution of each screens (can be different)
  • position of screens regarding each ones
    ?

This question also concern window placement and moving after starting the application.

@tinchodias
Copy link
Collaborator Author

Okay, for extra info, I see:

https://wiki.libsdl.org/SDL2/SDL_GetDisplayName, to get a String

https://wiki.libsdl.org/SDL2/SDL_GetDisplayDPI, to get:

int displayIndex the index of the display from which DPI information should be queried.
float * ddpi a pointer filled in with the diagonal DPI of the display; may be NULL.
float * hdpi a pointer filled in with the horizontal DPI of the display; may be NULL.
float * vdpi a pointer filled in with the vertical DPI of the display; may be NULL.

https://wiki.libsdl.org/SDL2/SDL_GetNumDisplayModes and https://wiki.libsdl.org/SDL2/SDL_GetDisplayMode, to get a list of:

    Uint32 format;              /**< pixel format */
    int w;                      /**< width, in screen coordinates */
    int h;                      /**< height, in screen coordinates */
    int refresh_rate;           /**< refresh rate (or zero for unspecified) */
    void *driverdata;           /**< driver-specific data, initialize to 0 */

https://wiki.libsdl.org/SDL2/SDL_DisplayOrientation, to get one of:

    SDL_ORIENTATION_UNKNOWN,            /**< The display orientation can't be determined */
    SDL_ORIENTATION_LANDSCAPE,          /**< The display is in landscape mode, with the right side up, relative to portrait mode */
    SDL_ORIENTATION_LANDSCAPE_FLIPPED,  /**< The display is in landscape mode, with the left side up, relative to portrait mode */
    SDL_ORIENTATION_PORTRAIT,           /**< The display is in portrait mode */
    SDL_ORIENTATION_PORTRAIT_FLIPPED    /**< The display is in portrait mode, upside down */

@labordep
Copy link
Contributor

Wow awesome!

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

No branches or pull requests

2 participants