View Issue Details

IDProjectCategoryView StatusLast Update
0004430The Dark ModCodingpublic01.04.2024 22:32
Reporterduzenko Assigned Toduzenko  
PrioritynormalSeveritynormalReproducibilityhave not tried
Status assignedResolutionopen 
Product VersionSVN 
Summary0004430: Allow TDM to run on non-primary monitors
DescriptionCurrently TDM will always run on a primary Windows monitor.
Owners of multi-monitor systems get used to be able to choose what program runs on what monitor.
Tagsgraphics, settings, usability

Relationships

has duplicate 0006471 closed Feature Request: Add ability to launch TDM on chosen monitor/display 
related to 0004402 resolvedduzenko Dpi Awareness 

Activities

duzenko

duzenko

01.12.2016 12:45

developer   ~0008577

Done (partially) for r_useFbo 1.
Instructions:
 - TDM starts fullscreen on primary monitor
 - alt-enter and ` to open console
 - drag window to another monitor
 - alt-enter and ` to close console

As for r_useFbo 0 I am confused by this code

  x = y = w = h = 0;
...
  SetWindowPos(win32.hWnd, parms.fullScreen ? HWND_TOPMOST : HWND_NOTOPMOST, x, y, w, h, parms.fullScreen ? SWP_NOSIZE | SWP_NOMOVE : SWP_SHOWWINDOW);

Anyone who has a clue feel free to fix.
nbohr1more

nbohr1more

19.09.2017 21:53

developer   ~0009307

The line you have trouble with can be decoded by:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx

That said, this is the most widely referred to solution:


https://www.gamedev.net/forums/topic/455737-c-winapi-how-to-start-a-program-in-secondary-display-device/?PageSpeed=noscript

The only method I found was to create the window and then move it to a location on the secondary screen before showing it.

To do this you need to enumerate the display devices and get their 'virtual coordinates' so that you know where to move the window to.

For example on my setup the virtual coordinates for my primary monitor would be (0,0) with a width of 1920 and height of 1200. My secondard monitor however, as it is to the left of my primary has the virtual coordinates of (-1920,0) and the same width and height.

https://msdn.microsoft.com/en-us/library/windows/desktop/dd162610(v=vs.85).aspx
nbohr1more

nbohr1more

11.12.2018 05:11

developer   ~0010870

Too close to 2.07 beta. Moving to 2.08
nbohr1more

nbohr1more

28.01.2024 02:24

developer   ~0016448

Duplicate new issue 0006471
Frost_Salamander

Frost_Salamander

28.01.2024 09:23

reporter   ~0016454

Commenting because my duplicate issue was closed (sorry about that).

DarkRadiant supports this feature - is it worth looking at how it's done there?
stgatilov

stgatilov

28.01.2024 09:41

administrator   ~0016455

As far as I understand, we should query monitors and get rectangle of each of them.
Then we can set X,Y-position of the created window on the respective monitor.
  https://stackoverflow.com/questions/1834771/how-do-you-get-createwindowex-to-create-the-window-on-a-specific-monitor

I suppose this should NOT apply in Windowed mode.
duzenko

duzenko

28.01.2024 12:55

developer   ~0016458

Last edited: 28.01.2024 12:56

Windows side is easy, but Linux has to match this function
When I played with it originally I stopped on a workaround and not adding a regular GUI option because I couldn't test there
stgatilov

stgatilov

28.01.2024 16:48

administrator   ~0016459

It should be even easier on Linux because it uses GLFW:
  https://gamedev.stackexchange.com/questions/146810/how-can-i-execute-glfw-fullsceen-in-a-secondary-monitor-xorg
The main question is: once someone implements this, who is ready to test and debug on each OS.
Frost_Salamander

Frost_Salamander

28.01.2024 18:10

reporter   ~0016462

I can test/debug for WIndows - I have 3 monitors in my setup.
nbohr1more

nbohr1more

28.03.2024 05:30

developer   ~0016595

Hmm.

There is a cvar r_custommonitor that lets you choose the monitor number ( defaults to 0 AKA primary )
duzenko

duzenko

30.03.2024 06:39

developer   ~0016597

In which file? I can see r_customWidth/height, but not r_custommonitor anywhere
nbohr1more

nbohr1more

30.03.2024 20:21

developer   ~0016599

Do you have 2.12 or SVN installed?

Darkmod.cfg has seta r_customMonitor "0"
Frost_Salamander

Frost_Salamander

30.03.2024 20:41

reporter   ~0016600

setting r_customMonitor in Darkmod.cfg does nothing. The game starts in the same monitor every time and the line gets removed from Darkmod.cfg after the game starts.

Or am I doing it wrong? I just added this to the file:

seta r_customMonitor "0" (or "1" or "2", etc)
nbohr1more

nbohr1more

31.03.2024 00:24

developer   ~0016601

I wonder if it only works on Linux...
duzenko

duzenko

31.03.2024 08:03

developer   ~0016603

@nbohr1more
Is Darkmod.cfg in source control though? I think it's your local file, no?
nbohr1more

nbohr1more

31.03.2024 12:14

developer   ~0016604

Last edited: 31.03.2024 12:16

I discovered the cvar by examining console results for r_ + tab.

Yes it's Linux only:

https://github.com/stgatilov/darkmod_src/blob/c1894aea31035904b3b32b0602b6d24d1ba75c4d/sys/linux/glimp.cpp#L23

static GLFWmonitor *GLimp_GetMonitor() {
    int count;
    GLFWmonitor **monitors = glfwGetMonitors( &count );
    int requestedMonitor = r_customMonitor.GetInteger();
    if ( requestedMonitor < 0 || requestedMonitor >= count ) {
        common->Printf( "Requested monitor %d not found, using primary monitor\n", requestedMonitor );
        r_customMonitor.SetInteger( 0 );
        return glfwGetPrimaryMonitor();
    }
    return monitors[requestedMonitor];
}
duzenko

duzenko

01.04.2024 05:54

developer   ~0016609

Oh, I get it now
So this ticket will resolve when the Windows part moves to GLFW too

Issue History

Date Modified Username Field Change
30.11.2016 20:36 duzenko New Issue
30.11.2016 20:36 duzenko Status new => assigned
30.11.2016 20:36 duzenko Assigned To => duzenko
01.12.2016 12:45 duzenko Note Added: 0008577
01.12.2016 12:49 duzenko Relationship added related to 0004402
19.09.2017 21:53 nbohr1more Note Added: 0009307
06.10.2017 02:33 nbohr1more Target Version TDM 2.06 => TDM 2.07
11.12.2018 05:11 nbohr1more Note Added: 0010870
11.12.2018 05:12 nbohr1more Target Version TDM 2.07 => TDM 2.08
22.03.2020 18:15 duzenko Target Version TDM 2.08 => TDM 2.09
05.12.2020 12:41 stgatilov Product Version SVN => TDM 2.06
05.12.2020 12:41 stgatilov Target Version TDM 2.09 =>
28.01.2024 02:22 nbohr1more Relationship added has duplicate 0006471
28.01.2024 02:24 nbohr1more Note Added: 0016448
28.01.2024 02:24 nbohr1more Product Version TDM 2.06 => SVN
28.01.2024 09:23 Frost_Salamander Note Added: 0016454
28.01.2024 09:41 stgatilov Note Added: 0016455
28.01.2024 12:55 duzenko Note Added: 0016458
28.01.2024 12:56 duzenko Note Edited: 0016458
28.01.2024 16:48 stgatilov Note Added: 0016459
28.01.2024 18:10 Frost_Salamander Note Added: 0016462
28.03.2024 05:30 nbohr1more Note Added: 0016595
30.03.2024 06:39 duzenko Note Added: 0016597
30.03.2024 20:21 nbohr1more Note Added: 0016599
30.03.2024 20:41 Frost_Salamander Note Added: 0016600
31.03.2024 00:24 nbohr1more Note Added: 0016601
31.03.2024 08:03 duzenko Note Added: 0016603
31.03.2024 12:14 nbohr1more Note Added: 0016604
31.03.2024 12:16 nbohr1more Note Edited: 0016604
01.04.2024 05:54 duzenko Note Added: 0016609
01.04.2024 22:32 Fiver Tag Attached: usability
01.04.2024 22:32 Fiver Tag Attached: settings
01.04.2024 22:32 Fiver Tag Attached: graphics