26

Sometimes when using Wine, specially with Games, doing ALT+TAB will make the system loose either keyboard or mouse focus over the current active window.

With this I mean that for example, if I do ALT+TAB from the Wine game to Nautilus, Empathy or another App and then try to go back to the game (May need to do this several times, about 3 to 4 should be enough), it will stay in Nautilus (The active window) or any other app, but the keyboard and mouse will be on the game.

If I try to ALT+TAB my way back, the ALT+TAB functionality is lost (Can not use it until I forcibly close the Wine game using for example wineserver -k on a terminal. So I will be left with a system that is showing me in foreground the nautilus app but the keyboard and mouse focus are on a minimized, background app (Wine Game for example).

So how can I either get the ALT+TAB back or be able to get focus on the current active window and be able to switch back and forth again. This can also happen to only one input, for example, the wine game might have the keyboard focused on it, but the mouse is not (Sometimes even lost and not usable until Wine is closed).

amc
  • 7,322
Luis Alvarado
  • 217,203
  • It looks like a bug. – edwin Aug 02 '13 at 04:25
  • What configuration you use for wine? Do you emulate a virtual desktop? Also the version of wine? – Braiam Aug 03 '13 at 22:28
  • Does not matter which version of Wine. All versions since 1.4 up to and including 1.6. For the focus part it also does not matter if I am emulating an specific resolution or not. Being testing this for 2 years at least. This is also not applicable to all apps, but some will take hold of the focus for one or both of the input devices. Give me a couple of days and I will add some more information since it happens most often with Unity. – Luis Alvarado Aug 04 '13 at 00:40
  • Have you tried the rawinput patches? I'm not sure if they made it in to main or not, but some games used to have problems with input devices that got solved by the same. It seems like I read comments in the patch code about it being a kludgy work-around, but it seemed to work for some things I tried it to solve. – RobotHumans Aug 07 '13 at 20:59
  • I found a solution for my problem in this thread. I had to add a string value in the registry as the last answer in this thread suggested – Modamod May 20 '19 at 21:13
  • Bug report: https://bugs.winehq.org/show_bug.cgi?id=57438 – Alberto Salvia Novella Nov 20 '24 at 23:23

5 Answers5

34

I was able to solve this for my setup --- I'm using Wine play Hearthstone through Lutris. The trick is to edit the registry using regedit in Wine for this particular game, following this user's suggestion:

  • Open Regedit, e.g. with wine regedit.exe
  • Go to HKEY_CURRENT_USER\Software\Wine\X11 Driver, creating it if it does not exist
  • Create a new entry named UseTakeFocus with value N

Alternatively you can achieve the same by running this on the command-line:

wine reg add 'HKEY_CURRENT_USER\Software\Wine\X11 Driver' /t REG_SZ /v UseTakeFocus /d N /f 

This not only fixed my alt-tabbing issues, I was able to modify the window size and change between fullscreen and windowed mode in-game with only the expected behavior!

Specifically in Lutris, I selected the game (Hearthstone), clicked "Wine registry", and added the value in Regedit as suggested (when creating the new entry, it's right click, add key, String value; then right click modify it to make the value "N"). Then close out; the registry should be saved (but you can edit it again to double check that the new value is there). Then launch the game and the new behavior is in place.

I expect this doesn't work across games, because it depends the game having proper support for Desktop keyboard shortcuts and window management modifications.

joeytwiddle
  • 2,009
Caleb Stanford
  • 450
  • 7
  • 11
8

Switching desktops did the trick for me.

I use Openbox, and have hit this snag in FlStudio 10, it seems to me that the wineserver will allow you to alt-tab out, and back in, however sometime after doing it once it stops the alt-tab window from showing. Like I said I use Openbox, so my experience might be different, all I have to do is hold the alt button press tab once then proceed to switch desktops (mouse-wheel). since I don't use unity, I'm not certain that that is the default binding there, but it does seem to be a common binding. Do be careful some games/programs don't like this, for instance Command and Conquer 3 will almost certainly crash, be sure to save first!!!

3

My solution is simple. before running the game turn on emulate virtual desktop in wine configuration>graphics

nkvnkv
  • 803
0

One possible reason a game might not appear in the Alt-Tab list is the winecfg settings:

  1. Run winecfg
  2. Go to the Graphics tab
  3. Check the options to allow the window manager to decorate and control the window.
  4. Hit Ok or Apply.
  5. Then quit and re-run the game if it's already running.

After this the game appeared in the Alt-Tab list for me as expected.

rakslice
  • 199
0

I noticed that some older version of wine have this bug of doing Alt+Tab loses mouse focus in windows applications running in wine, while newest version of wine don't have this problem.
For example when I was using wine of this version wine-10.0 then I had this Alt+Tab problem.
On the other hand when I installed this "Staging" branch version of wine then this problem got fixed alongside with other problems - wine-10.13 (Staging)
The wine-staging branch version of wine contains some new, experimental patches which haven't yet been integrated into mainstream wine-stable branch of wine. So mainstream, stable version of wine available in default repository of Linux might be a bit outdated and can still contain many bugs unfixed.

Below are the instructions to install wine-staging branch version, which I recommend

# purge former installation of wine
sudo apt remove winehq* wine-stable* wine-devel* wine*
sudo apt purge winehq* wine-stable* wine-devel* wine*
sudo apt autoremove
# install wine staging branch version
sudo dpkg --add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
# below line is for Linux Ubuntu 24.04 noble numbat, you can adjust it for other versions
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/noble/winehq-noble.sources
sudo apt update
sudo apt install --install-recommends winehq-staging
wine --version
# wine-10.13 (Staging)

Then this problem of Alt+Tab should disappear.
For games you can also try using heroic launcher with proton-ge based on wine but customized for gaming, instead of default wine version.
I recommend installing wine prefixes on ext4 partitions, instead of ntfs, fat partitions, because otherwise there can be crashes caused by lack of symbolic links in ntfs, fat partitions.

If above doesn't work then You can also check these other 2 solutions for this problem:

Method 1:
Run winecfg -> Graphics tab -> check all 4 checkboxes especially these 2:

  • "Automatically capture the mouse in full-screen windows"
  • "Emulate a virtual desktop"
    Here it might be advisable to set Desktop size resolution equal to the monitor resolution that is used in Your Linux OS, like 1366x768 both in monitor screen settings and inside this winecfg option.
    When both screen resolutions are identical then Window application running in game should fit entire monitor screen just like full screen. If both resolutions aren't identical then there can be undesired results like wine window not filling entire screen - windowed mode.

Method 2:
Another potential workaround to these problems with Alt+Tab is to use 2 different desktop workspaces, 1st for non-wine applications and 2nd for wine applications.
Switch to another desktop workspace and launch wine applications in a separate workspace and then you can switch workspaces with key combinations like these:
Ctrl+Alt+Left / Right
Super key+Page Down / Page Up