ValveSoftware / csgo-osx-linux

Counter-Strike: Global Offensive
http://counter-strike.net
771 stars 68 forks source link

[Linux] CS:GO sometimes launches on the wrong monitor #60

Open Locat opened 9 years ago

Locat commented 9 years ago

I have 2 monitors. My main monitor is correctly configured and when launching Dota 2, I have no problem with this whatsoever. So it seems like a CS:GO related problem. When rebooting the problem goes away but after playing for a bit quitting the game and launching it back it reappears.

https://gist.github.com/Locat/17842717e965193629f6

Thermionix commented 9 years ago

would really like tips on fixing this too

speedfreak01 commented 9 years ago

I had the same issue as well. To get the game on the correct screen i just disabled the other monitor temporarily whilst i played.

Im not sure if this is specifically related to CS:GO though, given i have had the same issues with some other steam games. Would be cool if the steam client allowed you to specify which screen you want a game to run on.

Locat commented 9 years ago

Yeah might be dependant on games. Dota 2 works fine though. It's a really frustrating bug, the worst is that sometimes it works and sometimes not and I have not a single clue as to why.

Edit: The only way I found of fixing it atm is going into either fullscreen windowed or windowed mode, dragging the window the right monitor and then going back to fullscreen.

CommanderAlchemy commented 9 years ago

Not sure if this is the cause but see what monitor is primary in both Xorg and in VM.

Locat commented 9 years ago

It is already the case.

qshane commented 9 years ago

CS:GO opens up on my primary monitor as expected.

Also, are you all using the same resolution on both monitors?

Locat commented 9 years ago

One is a 5:4 monitor and one a 16:9 so not the same resolution. As I said it is strange because it works at first and then it stops working, even when the focus is on the right monitor

audkar commented 9 years ago

I have similar problem: My 2nd monitor is set as primary in linux system but CS start fullscreen on 1st one.

2 monitors setup

Slydder commented 9 years ago

same problem here.

devhen commented 9 years ago

Same. It usually opens on my primary display but sometimes opens on the secondary. I was hoping there might be a way to force which monitor it uses.

devhen commented 9 years ago

FYI, I've been able to get around it by disabling my secondary monitor in GNOME3, start the game, then alt-tab out and re-enable the secondary monitor.

gulafaran commented 9 years ago

same problem here too. however i just set the second monitor as "primary" and it opens on the right one but that means i need to change it back when im opening any other game.

jocelynthode commented 9 years ago

@devhen @gulafaran : You can simply hit the "Super" key and drag the csgo window on the right monitor :)

gulafaran commented 9 years ago

so funny, no matter what sdl env var i change nor xorg conf, the game will ALWAYS open on the non primary one.

mariodonofrio commented 9 years ago

Can you let me know what "sdl_displayindex" is set to in your config.cfg (in the game/csgo/cfg folder). This is not a public convar, but the value is written to/read from this file, and if changing it (if you have two monitors, the range of values is just 0 and 1) makes any difference to how the game boots up - the multi-monitor startup configuration should be handled the same way as Dota2. Thanks.

audkar commented 9 years ago

@mariodonofrio changing "sdl_displayindex" variable value fix'ed this issue for me

mariodonofrio commented 9 years ago

Thanks @audkar - sdl_displayindex should get written with whichever monitor you last played CS:GO on (i.e. if you move it to another monitor it will change). There are some issues with SDL not enumerating the displays correctly on all boxes, but if you moved it to a display it should put it back up on that same display regardless of enumeration. It might be worth trying to do that, and enforcing the change by modifying the video settings (change resolution, go full-screen or windowed, etc) and saving them - this should force the sdl_displayindex update in that config file.

Be interested in hearing what other users that have had issues might experience too.

gulafaran commented 9 years ago

yeah changing displayindex to 1 , makes it open on my middle monitor. i run three and the mid one is set as primary and most things works with this even something as basic as https://wiki.libsdl.org/SDL_GetCurrentDisplayMode orders it correctly, however steam and its games seems to open the games on the most left one at all times.

bsuttonq commented 9 years ago

Confirmed that changing the config.cfg sdl_displayindex solved this issue for me.

bm956 commented 8 years ago

Any push to get this fixed? Is it backlogged?

Dotile commented 8 years ago

I have no config.cfg file in my folder only to other files named config containing the keyboard and 360 controller configuration.

Can I create my own config.cfg file and add sdl_displayindex?

Tele42 commented 8 years ago

@Dotile, your config.cfg should be located at ~/.local/share/Steam/userdata/<steamid>/730/local/cfg/config.cfg or similar, depending on where your distro put the steam folder.

Note for dev: I suspect all affected users have a primary monitor to the right, sdl_displayindex 0 is the primary monitor, and CS:GO is not enumerating the monitors in the correct order. The physical connections going to the displays are most likely not enumerated from the leftmost to the rightmost.

Mercotui commented 7 years ago

still an issue, combined with #608 #4566 and #528 for me

AntouanK commented 7 years ago

Dota 2 does launch in the secondary monitor for me. I do use xrandr to set the primary monitor, and tried nvidia-setting as well. Still it keeps launching in the secondary one. Big picture mode does the same.

Any idea how to fix it?

birgersp commented 7 years ago

+1

Would love to see this fixed!

kaskii commented 7 years ago

Had same problem on Linux Mint (18.1, dual monitor, nvidia-375) with CS:GO after alt+tabbing out of the game. I fixed it by changing to windowed mode, dragging window to correct display and changing full screen mode back. Haven't tested changing sdl_displayindex as now the game opens on correct display every time.

kisak-valve commented 7 years ago

For everyone currently affected, please switch the game to windowed, dragging it to the preferred monitor, then switching it back to the previous display mode (fullscreen or fullscreen windowed) and close CS:GO to make sure the setting is saved.

If this does not resolve the issue, please describe your monitor layout with emphasis on the primary monitor and the order the monitors are enumerated. Also include your distro version.

Mercotui commented 7 years ago

screenshot from 2017-05-23 17-33-00 I tried the method described by @kisak-valve , but with minimal succes.

Expected behavior:

Game starts on the primary monitor, with the correct primary monitors resolution.

Actual behavior:

The game now starts on my primary monitor, but in the secondary resolution, leaving undrawn areas of the window. See picture, The chrome browser running on the secondary monitor, and the game running on the primary monitor, with incorrect resolution. Note that if I forcibly move the game away and back to the primary monitor, the resolution adapts correctly.

Setup:

CSGO buildID: 1831910 Distro: Fedora 24 Monitor enumerated as 1: VGA display, labeled secondary monitor in gnomeshell resolution 1280x1024 Monitor enumerated as 2: HDMI display, labeled primary monitor in gnomeshell; resolution 1920x1080 Monitor 1 (secondary monitor), is positioned left of Monitor 2 (primary monitor).

kisak-valve commented 7 years ago

The resolution mismatch is being tracked at #1322.

Mercotui commented 7 years ago

actually, testing it more (testing is very slow because of #608 ) it seems the following happens:

I set the correct monitor by the method described by @kisak-valve . First time starting the game afterwards: it launches on the primary monitor, but in the secondary's resolution. Any additional attempt afterwards: the games launches in the secondary monitor, in the secondary's resolution.

kisak-valve commented 7 years ago

Sdl_displayindex is getting reset to 0 if the game is minimized / alt-tabbed at any point. While the window is restored to the correct monitor, this change is commited to the config when the game is closed and then launches on the wrong monitor on the next start of the game.

maksymovi commented 6 years ago

I am continuing to have the issue, the sdl_displayindex workaround of course works but generally gets reset every time the game is launched with no success so far to change this through normal means. I have found that using "sudo chatter +i config.cfg" will not allow one to reset it (for those unaware, this applies the immutable tag to the file, making it impossible to change for even the superuser, unless the tag is first removed with chattr -i config.cfg). I believe this will also not allow you to change any csgo settings however so it is not ideal.

Currently my biggest problem however remains to be #1322

FailedCode commented 5 years ago

Happens to me too after the update from Ubuntu 16.04 to 18.04

FailedCode commented 5 years ago

Well. I had some trouble with Devil Daggers not starting and tried a steam --reset All games where marked as uninstalled and for some reason the steam executable is now located in /usr/games/steam (I think it was /usr/bin/steam before). BUT after reinstalling csgo will now start on my main monitor as it used to. Weird. Oh, Devil Daggers also starts up fine again, but for that I had installed libcurl3 which might or might not have helped. If you try the reset option, remember to save your config first. Edit: now the problem is #1322 ...

BloodyIron commented 5 years ago

For some reason my config.cfg had "sdl_displayindex 1" set. I have 3x1920x1080 monitors, and this resulted in the game launching on my left monitor, yet my middle one is set as Primary/Default in my environment.

Setting it to "0" in the in-game console (then gracefully quitting) "resolved" this, however I think having in-game settings support for this facet really is the best long-term way to do this. Since this issue really isn't self-evident of the cause.

szmarczak commented 3 years ago

Welp, it's still here! 6yrs and counting :man_facepalming:

jeppenodgaard commented 3 years ago

actually, testing it more (testing is very slow because of #608 ) it seems the following happens:

I set the correct monitor by the method described by @kisak-valve . First time starting the game afterwards: it launches on the primary monitor, but in the secondary's resolution. Any additional attempt afterwards: the games launches in the secondary monitor, in the secondary's resolution.

The same happens on Pop!_OS 20.04

kisak-valve commented 3 years ago

Ubuntu two monitor setup and fullscreen modus: Game always starts on secondary monitor

Issue transferred from https://github.com/ValveSoftware/csgo-osx-linux/issues/2542. @ptck posted on 2020-10-23T12:28:24:

Your system information

Please describe your issue in as much detail as possible:

I have two monitors. One with 1920x1080 resolution (primary) and an old 4:3 monitor (secondary) on the left side on my desk. I had this problem under Ubuntu 16.04 and also now on 20.04 (I set my computer completely new up for this). When I start the game it always starts on my 4:3 monitor. Dragging it over to the primary screen doesn't help as when I hover over a button with my mouse the game register it as a hover somewhere else. Probably because the game is still in the 4:3 modus. Adding "-fullscreen" to launch options doesn't help. The only solution is to disconnect my 4:3 monitor from my PC so that I have only one monitor.

Also as a side note: If I start the game I get for a couple for seconds a black screen and a "csgo_linux64 not responding" warning before the CS:GO starting screen appears. All in all the game needs 15-20 seconds to start up.

Steps for reproducing this issue:

  1. Having 2 screens with different resolutions
  2. Have Ubuntu
  3. Have the secondary screen on the left, the primary screen on the right

    @kisak-valve commented on 2020-10-23T12:47:44:

Hello @ptck, this issue is already being tracked at #60 with a possible workaround at https://github.com/ValveSoftware/csgo-osx-linux/issues/60#issuecomment-303432736.

Also, your side note is being tracked at #665.

Closing as a duplicate.


@ptck commented on 2020-10-23T14:25:47:

@kisak-valve Thanks for #60. Unfortunately none of the suggestions there helped.


@kisak-valve commented on 2020-10-23T14:30:29:

Just to check, did you remove the -fullscreen launch option while testing?

philippkant commented 3 years ago

@kisak-valve

screenshot from 2017-05-23 17-33-00 I tried the method described by @kisak-valve , but with minimal succes.

Expected behavior:

Game starts on the primary monitor, with the correct primary monitors resolution.

Actual behavior:

The game now starts on my primary monitor, but in the secondary resolution, leaving undrawn areas of the window. See picture, The chrome browser running on the secondary monitor, and the game running on the primary monitor, with incorrect resolution. Note that if I forcibly move the game away and back to the primary monitor, the resolution adapts correctly.

Setup:

CSGO buildID: 1831910 Distro: Fedora 24 Monitor enumerated as 1: VGA display, labeled secondary monitor in gnomeshell resolution 1280x1024 Monitor enumerated as 2: HDMI display, labeled primary monitor in gnomeshell; resolution 1920x1080 Monitor 1 (secondary monitor), is positioned left of Monitor 2 (primary monitor).

I have the exact same issue. My monitors are enumerated exactly like this in the Ubuntu display settings (1 and 2) and I have the same resolutions for both monitors. My secondary monitor is also positioned left of my primary monitor. The only difference is that I have Ubuntu 20.04 and my primary monitor is connected via DVI, not HDMI. To expand on this: sdl_displayindex is always resetted to 1. I did not set any launch options.

actually, testing it more (testing is very slow because of #608 ) it seems the following happens:

I set the correct monitor by the method described by @kisak-valve . First time starting the game afterwards: it launches on the primary monitor, but in the secondary's resolution. Any additional attempt afterwards: the games launches in the secondary monitor, in the secondary's resolution.

Also this is the same for me. But I don't have a long startup time (15-20 seconds).

ericek111 commented 3 years ago

Another workaround for X11:

wpid=$(xprop -id `xdotool getwindowfocus` | grep '_NET_WM_PID' | grep -oE '[[:digit:]]*$')
win=$(xdotool search --pid $wpid | head -n1)
wmctrl -i -r $win -e 0,1920,0,-1,-1

Put this into a script, bind it to a keyboard shortcut or add it to ~/.steam/steam/steamapps/common/Counter-Strike Global Offensive/csgo.sh with some sleep before it. Works for any game (I had problems with GTA V launching on the wrong monitor.

EDIT: Oh, works only until the game is minimized, then it jumps back to the left-most monitor.

pschichtel commented 3 years ago

I had success using gamescope.