You are not logged in.

#1 2014-04-18 22:01:49

bagheera
Member
Registered: 2009-06-13
Posts: 84

Change screen size (virtual resolution) on new display

Hi to all,
I'm using following script to run wine games on separate display:

#!/bin/bash

# calculate first available VT
LVT=`fgconsole --next-available`

# calculate first usable display
XNUM="-1"
SOCK="something"
while [ ! -z "$SOCK" ]
do
XNUM=$(( $XNUM + 1 ))
SOCK=$(ls -A -1 /tmp/.X11-unix | grep "X$XNUM" )
done
NEWDISP=":$XNUM"

if [ ! -z "$*" ]
# generate exec line if arguments are given
then
# test if executable exists
 if [ ! -x "$(which $1 2> /dev/null)" ] 
then
echo "$1: No such executable!"
# if running from X, display zenity dialog:
[ -z "$DISPLAY" ] || zenity --error --text="$1: No such executable!" 2> /dev/null
exit 127
fi
# generate exec line
EXECL="$(which $1)"
shift 1
EXECL="$EXECL $*"
EXECPH=""

# prepare to start new X sessions if no arguments passed
else
EXECL=""
EXECPH="New X session"
fi

# if runing from X, display zenity dialog:
[ -z "$DISPLAY" ] || zenity --question --title "Launch?" --text="Will launch \"$EXECL$EXECPH\"

tty$LVT
X display $NEWDISP

Continue?" 2> /dev/null || exit 1

echo "Will launch \"$EXECL$EXECPH\" on tty$LVT, X display $NEWDISP..."
[ -z "$DISPLAY" ] && sleep 1s


# This flag is used for indication of unaccessible or broken DRI.
# It is set, for example, when using fglrx+compiz-manager.
# Some games will refuse to start if it is set.
# Unsetting it should not do any harm, and can be useful.
unset LIBGL_ALWAYS_INDIRECT

##########################################################
# main execution
xinit $EXECL -- $NEWDISP vt$LVT -nolisten tcp -br &
##########################################################

# set our new dislplay
DISPLAY=$NEWDISP
# wait some time for X to load
sleep 4s

# then we set useful parameters

# disable non-linear mouse acceleration
xset m 1 0

# disable hard-coded default 10m screensaver
xset s 0 0

# while X is running, persistently do something useful
# i.e. prevent apps from enabling mouse acceleration and screensaver
while xset -q > /dev/null
do 
xset m 1 0
xset s 0 0
sleep 3s
done


wait
sleep 5

Example command:

/home/bagheera/xgame taskset -c 0 wine /home/bagheera/.wine/drive_c/Gry/settlers3/S3.EXE

The problem is, most older games run at 1024x768, where my LCD is 1280x1024. After launching new wine session resolution is changed, but not screen size. And then, if i move mouse cursor to the right or bottom screen edge, it scrolls until 1280x1024 size is reached. That moves 1024x768 box partially outside visible area and i see black areas at the bottom and right.

That's very annoying and uncomfortable to play syberia, heroes3 or settler3.

I was playing with xrandr in the script, but it won't work..

xrandr --newmode "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync
xrandr --addmode DVI-I-2 1024x768_60.00
xrandr --output DVI-I-2 --mode 1024x768_60.00

gives in output:

xrandr: cannot find mode 1024x768_60.00

I suspect it is wine specific bug, because it seem to be triggered by setting 1024x768 resolution. When i run settlers3, main menu is 800x600, and moving mouse cursor to the edge of the screen does not make visible area move. But once first map is loaded and 1024x768 resolution is set, it makes 1024x768 box scrolling away from visible area, if i move mouse cursor at edge of the screen. Later then, if i back to main menu and 800x600 resolution, 800x600 box is scrolling away even more.

Any ideas how to fix that?

Running MS WIndows is not an option smile


---update

I do have installed lib32-libxrandr.

bagheera@tux:~$ sudo yaourt -Ss lib32-libxrandr
multilib/lib32-libxrandr 1.4.2-1 [installed]
    X11 RandR extension library (32-bit)

and following nvidia driver (gtx 460 card)

extra/nvidia 337.12-1 [installed: 319.32-4]
    NVIDIA drivers for linux

Last edited by bagheera (2014-04-18 22:26:51)


arch linux user

Offline

#2 2014-04-19 00:35:51

emeres
Member
Registered: 2013-10-08
Posts: 1,570

Re: Change screen size (virtual resolution) on new display

I use a somewhat different setup, where X is run on two screens from beginning, so I neither start or nest a new X server. Depending on DISPLAY variable use this command to change resolution on the fly:

env DISPLAY=:0.1 xrandr -s 1024x768

You are not adding a newmode to your desired output, which is the reason it is not found. Try this:

xrandr --output DVI-I-2 --newmode "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync
xrandr --output DVI-I-2 --addmode DVI-I-2 1024x768_60.00
xrandr --output DVI-I-2 --mode '1024x768_60.00'

Or:

env DISPLAY=:0.1 xrandr --output DVI-I-2 --newmode "1024x768_60.00"   63.50  1024 1072 1176 1328  768 771 775 798 -hsync +vsync
env DISPLAY=:0.1 xrandr --output DVI-I-2 --addmode DVI-I-2 1024x768_60.00
env DISPLAY=:0.1 xrandr --output DVI-I-2 --mode '1024x768_60.00'

Your problem should be also solvable by wine though, since it appears to change resolution only. Why not run wine in a virtual desktop? I use this code in generated scripts:

env ALSA_DEFAULT_PCM=wine WINEARCH=win32 WINEDEBUG=-all \
WINEPREFIX=/home/user/.PlayOnLinux/wineprefix/Windows7 \
wine explorer /desktop=$APP_NAME,$PRE_RES $WINE_APP

Where $APP_NAME is the name displayed as title of virtual desktop, $PRE_RES would be in your case "1024x768" and $WINE_APP  S3.EXE.
For mouse issues that might occur with virtual desktop, use these registry settings to enable or force mouse override for a specific application (S3.EXE in your example) or use it as a global setting, although I do not recommend that.

REGEDIT4

[HKEY_CURRENT_USER\Software\Wine\AppDefaults\_EXE_\DirectInput]
"MouseWarpOverride"="disable"
"MouseWarpOverride"="enable"
"MouseWarpOverride"="force"

Use one of the values for MouseWarpOverride and replace _EXE_ with S3.EXE for Settlers 3. To register those settings use:

env WINEPREFIX=/home/user/.PlayOnLinux/wineprefix/Windows7 regsvr32 REGFILE

Customize to your setup.

Offline

#3 2014-04-19 05:17:09

bagheera
Member
Registered: 2009-06-13
Posts: 84

Re: Change screen size (virtual resolution) on new display

Thanks for instructions. I will try this out.
However, it is wine/nvidia specific bug:

http://bugs.winehq.org/show_bug.cgi?id=33632


arch linux user

Offline

Board footer

Powered by FluxBB