Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have two screens hooked together with twinview. Some applications treat it as one big 3840*1200 panel but that's pretty undesirable in first person shooters as your sights end up in the gap between the two screens.

So I usually run Wine games in a 1920*1200px window. The window manager makes it full-screen on one screen and that works great for some games. However some games lag and that allows the mouse to fly out the side of the Wine window, causing my player to spin like a fox on drugs.

And then there are a whole load of native games (X3, OpenArena, Quake4, QuakeWars, etc) that don't have a good windowed mode. Using windowed mode on X3 results in the mouse becoming uber-sensitive.

Wouldn't it be nice if I could launch some games in a new X session that just used one screen?!

It would. I've got as far as this for Steam:

#!/bin/sh

X :3 -ac & nvidia-settings --load-config-only
sleep 10 # wait for X to catch up

cd ~/.wine/drive_c/Program\ Files/Steam/
DISPLAY=:3 WINEDEBUG=-all wine "Steam.exe"

Now this technically uses two screens but when games launch in fullscreen mode once they've already been set to 1920*1200, they seem to adapt and use one of my xorg.conf metamodes. It would be better if I could explicitly state the mode in this executable. Is there a way to do that?

There's also no sound. I've got the WinePulse patch so I just need to get PulseAudio hooked into this session (or vice versa) and I'm good to go for now, I think.

Edit: Ralf picked up on a few things but missed (or misconstrued) some others. This is probably down to my over-verbose question. Despite the length of the post, I only have two problems.

Here are my problems in a succinct setting:

  • How can I start a new X session with a specified resolution? I would preferably like to specify an existing metamode or the exact resolution when I call X.

  • How can I get applications on the new X session talking with the right PulseAudio server? At the moment, they don't seem to line up. I've tested this with totem, not just Wine apps.

share|improve this question
    
No, I understand what you were trying to do and why. --- I was given an alternative path. And tried to provide a sort of mini tutorial to deal with common issues concerning twinview/wine/games. Using a separate X session, albeit possible, isn't something I would ever recommend as a solution to a mousewarp problem which you can simply workaround using WINEFORCEMOUSEWARP=yes wine yourapp.exe –  Ralf Sep 10 '10 at 15:55
    
That doesn't work in this case because my problem comes when Modern Warfare 2 is lagging from turning (semi-known bug). While lagging it allows the mouse to leave the screen. Pure metamodes would work but I've wasted too much time putting panels back in the right place in the past to trust it alone. –  Oli Sep 10 '10 at 16:11
    
Doesn't the WINEFORCEMOUSEWARP work on Modern Warfare 2? –  Ralf Sep 10 '10 at 18:14
    
Not for me. I don't think it's related to games like Bioshock where it does work. The mouse just feels like it's stuck in mud for most of the time and then WEEEEE it's on the next screen. Sure it's something that'll get fixed the more I whinge about it ;) –  Oli Sep 10 '10 at 20:26

3 Answers 3

up vote 2 down vote accepted

To answer your question more specifically. You can use nvidia-settings to change the meta-mode. A fragment from nvidia-settings --help:

-a, --assign=[ASSIGN]
  The ASSIGN argument to the '--assign' commandline option is of the form:

    {DISPLAY}/{attribute name}[{display devices}]={value}

  This assigns the attribute {attribute name} to the value {value} on the X
  Display {DISPLAY}.  {DISPLAY} follows the usual {host}:{display}.{screen}
  syntax of the DISPLAY environment variable and is optional; when it is
  not specified, then it is implied following the same rule as the
  --ctrl-display option.  If the X screen is not specified, then the
  assignment is made to all X screens.  Note that the '/' is only required
  when {DISPLAY} is present.

  {DISPLAY} can additionally include a target specification to direct an
  assignment to something other than an X screen.  A target specification
  is contained within brackets and consists of a target type name, a colon,
  and the target id.  The target type name can be one of "screen", "gpu",
  "framelock", "vcs", "gvi", or "fan"; the target id is the index into the
  list of targets (for that target type).  The target specification can be
  used in {DISPLAY} wherever an X screen can be used, following the syntax
  {host}:{display}[{target_type}:{target_id}].  See the output of
  `nvidia-settings -q all` for information on which target types can be
  used with which attributes.  See the output of `nvidia-settings -q
  screens -q gpus -q framelocks -q vcs -q gvis -q fans` for lists of
  targets for each target type.

  The [{display devices}] portion is also optional; if it is not specified,
  then the attribute is assigned to all display devices.

  Some examples:

    -a FSAA=5
    -a localhost:0.0/DigitalVibrance[CRT-0]=0
    --assign="SyncToVBlank=1"
    -a [gpu:0]/DigitalVibrance[DFP-1]=63
share|improve this answer

For sound, all you have to do is run ck-launch-session in the script:

#!/bin/sh

X :3 -ac & nvidia-settings --load-config-only
sleep 10 # wait for X to catch up

cd ~/.wine/drive_c/Program\ Files/Steam/
DISPLAY=:3 ck-launch-session
DISPLAY=:3 WINEDEBUG=-all wine "Steam.exe"

Sound from both X displays get merged.

share|improve this answer
    
It worked initially, but I cant find a way to put it on a script that after it I call jwm and xscreensaver (both are ignored or dont run at all...). Also, for test I run ck-launch-session before X and now I get this: xterm: Xt error: Can't open display: :1 guess I need to reboot?; anyway, any tip on what to look for where you put sleep 10? 10 is too much..., if we could track something thru qdbus, it would help a lot! –  Aquarius Power Apr 25 '13 at 6:42
    
ok, I fixed it this way xterm -display :1 -e "ck-launch-session"& so it wont interfere with the other terminals and will still let sound work! Also there is little documentation on ck-launch-session, I dont quite understand what I did, I just know it worked :) –  Aquarius Power Apr 25 '13 at 6:53
    
about this error xterm: Xt error: Can't open display: :1, you just need to exit the terminal and it cleans up; try ck-list-sessions before and after that. –  Aquarius Power Apr 25 '13 at 6:58

Running more than one X session

I think this is exactly what you want. And running more than X session is possible, that doesn't mean all video-drivers allow you to use the same video-card. So running more than Xsession, means you are going to need more than one video card.

Metamodes

Games can change the resolution of your desktop and the setup of your screen using meta-modes. Say you have a large 1680x1050 monitor on the left, and an older, smaller monitor on the right which has 1025x768 as the highest resolution.

Section "Screen"
Identifier  "Default Screen"
DefaultDepth    24
    Option         "TwinView" "1"
    Option         "TwinViewXineramaInfoOrder" "CRT-0"
    Option         "metamodes" "CRT-0: 1680x1050 +0+0, CRT-1: 1024x768 +1680 +0; CRT-0: 1680x1050 +0+0, CRT-1: NULL; CRT-0: 1400x900 +0+0, CRT-1: NULL;"
EndSection

When you can select the resolution in a game you'll have these options:

2704x1050      this refers to the total viewport size of using two monitors
1680x1050      this means the second monitor is off, and you will use a high resolution
1400x900       this also only used the first monitor, but it will run a bit quicker 

You could add a lot of meta-modes. Just make sure that the 'resulting' viewport has a unique resolution. Otherwise the games won't understand it.

Interestingly, when you alt-tab out of a game, your system will switch back to the original meta-mode, and when alt-tab back into a game, it will go to back to configured meta-mode for the game.

Wine/Steam

The meta-mode trick will work with wine as well. However, there are games that don't support changing the resolution.

A nice workaround:

- turn on emulate virtual desktop, in wine-config, and set it to your desktop size
- compiz will automatically turn it into 'fullscreen' mode and hide panels
- the mouse will be captured properly. Your other monitor is still on, and displays whatever is there. You will need to alt=tab to reach it though. Perhaps its a good idea to associate a shortcut to minimize window. 

If you still have issue with mouse capturing with certain games, you can use mousewarp mode:

WINEFORCEMOUSEWARP=yes wine yourapp.exe

Pulseaudio & Wine

You can use this PPA, to get a wine that has the pulse-audio driver enabled. Make sure to also select it using wine-config.

 https://launchpad.net/~neil-aldur/+archive/ppa
share|improve this answer
    
Multiple X: you can have more than one on one card. It works. Getting it launched isn't a problem. Metamodes: Again not a problem for me, these are already defined well. I don't like using metamodes on my real display (:0) because it gumps up the desktop and running applications. That's why I want this on :2 Wine+PA: As I said in the post, I'm already running the WinePulse patches. My issue is between the new X session and PA. –  Oli Sep 10 '10 at 15:51
    
(Not trying to be mean. I really appreciate the effort. I'm just explaining that this doesn't actually answer the problems I have so I can't accept it as an answer. But leave it here as other people might find it useful.) –  Oli Sep 10 '10 at 15:53
    
Cool to hear that multiple X actually works. You are however a bit on a rougher grounds there. -- I've never had an issue where metamodes gumps up my desktop. Except when a game crashes on shutdown and doesn't restore the resolution. In that case, wrapping the game in a script that restores the resolution should fix your issues. –  Ralf Sep 10 '10 at 16:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.