6 ms·
> This is super hard to get right. Not _really_. The issue is that games are trying to do god-knows-what when they lose focus. In reality, they just need to ig
by WhyNotHugo 6y ago
> This is super hard to get right.
Not _really_. The issue is that games are trying to do god-knows-what when they lose focus. In reality, they just need to ignore this happening.
Regular applications handle losing focus just fine, and games would too -- unless you try to do magic funky stuff when you lose focus (my guess is that they do this to work around funky WM issues on window that don't exist on Linux).
- coldpie 6y agoFirst, sure, if games didn't do complex things, it would be easier to support. But they do. So it is hard. Also, it's much more complicated than that. When running in exclusive fullscreen mode (which almost all fullscreen games did before about 5 years ago), they have to do stuff like restore the original display resolution, tear down their graphics stack, and restore all of that when bringing the window back up. Many games depend on a very particular sequence of window messages during that process, including D3D handling some of those messages on their behalf in certain ways. In the case of non-exclusive or windowed mode games, they may choose to stop reading controller input, stop rendering, stop sending audio, etc. All of that requires correct window notifications in the correct order, and support in Wine for correctly tearing down and restoring all of those things. And all that is just on the Windows side of the equation, you also need to tear down the Linux graphics stack and manage how X thinks about the windows in a way that the window manager will do the right thing for the user, without doing the /wrong/ thing for the app from the Windows perspective. For example if the WM chooses to resize the window when it requests fullscreen mode, at a time when Windows does not, then we have to ignore those messages, or the game will suddenly be rendering at the wrong size (or worse, infinite loop as the WM and the game fight over the window sizes... yeah, that happened[1]). It's a nightmare. I've spent months and months on this stuff, and other devs have spent even more. If it was easy to fix, it would be fixed, I promise you :) [1] https://github.com/ValveSoftware/wine/commit/4f590327ab2028aadc6ac5b7c0ac10bd363e3c80 https://github.com/ValveSoftware/wine/commit/4f590327ab2028a...
- davedx 6y agoThank you for doing this kind of work. That commit is funny -- I've read that there's similar stuff in graphics card drivers too :)
- rasz 6y agoSince its all emulated why even tell the game its alt tabbed in the first place? Just keep it thinking nothing changed, its not like games do special stuff when in the background.
- coldpie 6y agoWe investigated that briefly. It's not as easy as it sounds, and even if it was, some games do useful things when they lose focus (e.g. auto pause the game, stop sending audio). We decided it wasn't worth pursuing.
- xenadu02 6y agoFrom one engineer to another: I'm sorry you keep having to deal with people who haven't spent a single minute working on this problem second-guessing your work. I get the same thing regularly and it can be very frustrating. As you noted: if the solution were so trivial it would have been done and shipped already.
- coldpie 6y agoHahaha! Nah, it's fine. Their suggestion was a good one; like I said, we did consider doing it. It's fun to talk about this stuff here on HN because the discussion is usually sensible. You should see the dumb crap they say on Reddit.
- account42 6y agoYou can work on something forever and still have others provide new insights. Feedback is not an attack, even if you have already considered that option (and even then there might be crucial details that could change things).
- supercheetah 6y agoWould it be worth it to make that as an option, perhaps a command line option like PROTON_ALWAYS_FOCUSED=1?
- WhyNotHugo 6y ago> they have to do stuff like restore the original display resolution This is something that I find incredibly annoying: games handling their own resolution and having their own resolution configuration. It's like their reinventing something that the OS already provides. Just use the resolution that's configured: if I wanted to change it I'd change it. Non-native resolutions look awful on LCDs anyway, so apps really shouldn't change it. Actually though, the easier way to support linux is just to run on windows mode with no chrome -- I can just fullscreen the window myself and that's it. Games that try to detect screen resolution themselves very often screw up picking the right resolution when you have multiple screens: but again, the problem is they're trying to do too much.
- graynk 6y ago> Just use the resolution that's configured: if I wanted to change it I'd change it. So you're saying you'd want to change desktop resolution each time you want to play a performance heavy game? > Non-native resolutions look awful on LCDs anyway, so apps really shouldn't change it. So you're saying developers should take away the options that people actively use because you subjectively don't like how it looks on your specific monitor?
- account42 6y ago> So you're saying you'd want to change desktop resolution each time you want to play a performance heavy game? Yes, for the Window definitely. If you need to drop the render resolution for perf then the game should upscale at the end (and for fucks sake, handle arbitrary aspect ratios correctly!!!). Personally though, I'd rather wait until I have hardware that can run the game at full resolution.
- graynk 6y agoI agree about upscaling the end result, some games do that and I really appreciate it. Lately DLSS took it to the whole other level though
- WhyNotHugo 6y ago
- account42 6y agoI think the point was that for some games it might be better (perfect even) to not tell the game that it has lost focus since on X11 there is no such thing as exclusive fullscreen anyway. Of course that won't work for everything (game won't auto pause, might continue polling for mouse input, ...). AFAICT Proton already lies to games about the fullscreen resolution and silently upscales the result instead changing the monitor resolution (which I think might be the single most awesome thing Proton adds) so this isn't unprecedented.
- sumtechguy 6y agoThe thing is (as a mostly windows gamer here) it is not consistent in windows really either. Then on top of that many of the companies that made these games went basically defunct years ago and some publisher is just selling them and cutting a check to some other company that is a shell corp for something else. You are correct on what should happen to the game. But some programs do need to react to lose focus. So for it to 'ignore' it there would need to be a setting for it (and per program). Which could even cause side effects in that game because they just plain got it wrong. I have had in the past month seen black screen on return. No controls after return. Does not tab out at all. There are other variations. Most games do work. But some dont. My wife plays dont starve quite a bit and that game is kind of flakey in its external behavior (once in game you are fine). One bug she is dealing with is in some cases it takes 30+ mins to get in game with new settings on a fairly beefy new computer.