#8 rotation.c's rotate_display corrupts screen resolution

v2.x
open
general (5)
5
2011-11-19
2011-08-21
Jim
No

System: Fujitsu T900 (dual digitizer screen), Slackware 64 13.37, 2.6.39.4

Before I click the tablet rotate button, xdpyinfo reports (among other info)
dimensions: 1280x800 pixels (287x180 millimeters)
resolution: 113x113 dots per inch
This is good.

After I click the rotate button once to rotate 90 degrees, it says
dimensions: 800x1280 pixels (288x180 millimeters)
resolution: 71x181 dots per inch
and then after another rotate
dimensions: 1280x800 pixels (180x112 millimeters)
resolution: 181x181 dots per inch
and then
dimensions: 800x1280 pixels (112x179 millimeters)
resolution: 181x182 dots per inch
and then
dimensions: 1280x800 pixels (179x111 millimeters)
resolution: 182x183 dots per inch
and then
dimensions: 800x1280 pixels (111x177 millimeters)
resolution: 183x184 dots per inch
and then
dimensions: 1280x800 pixels (177x110 millimeters)
resolution: 184x185 dots per inch
and then
dimensions: 800x1280 pixels (110x176 millimeters)
resolution: 185x185 dots per inch
and then
dimensions: 1280x800 pixels (176x110 millimeters)
resolution: 185x185 dots per inch
from where it reaches a steady state of 185x185 dpi.

After this I am stuck with a ludicrous resolution.

I have a shell script (see below) which I can use to rotate the
display, and it does not do this to me. (Sadly, nor does it fix the
above breakage.) I have left the "historical" comments in the script
to possibly benefit people using older systems.

This is a show stopper. For now I can (obviously) avoid using the
tablet rotate button, but I may just replace rotate_display() with a
call to my shell script.

Cheers.
Jim

------------------ ~/bin/rotate ------------------

#! /bin/sh

# This is to rotate a screen using X randr extensions

# Note that the simpler "-o", instead of "--output <device> --rotate",
# works after a reboot but has been seen to give up the ghost after a
# while, for no particularly good reason.

# 2011/01/10:
# Update for Fujitsu T900:
# On the IBM X41T, the Wacom device was called simply "cursor" (at least
# as of time of original writing).
# On the T900, "xsetwacom --list" gives these lines in 13.1:
# PnP Device (FUJ02e7) STYLUS
# PnP Device (FUJ02e7) eraser ERASER
# and for the 'xsetwacom set' commands one needs to use 'PnP Device (FUJ02e7)'
# instead of "cursor", which is what worked in July 2007.
# Slack64 13.37: now the device is called "Serial Wacom Tablet stylus".

# Also tell FVWM to restart.

# ALTERNATIVE: note that rotating the wacom input can also be done
# with a command like this (T900):
# xinput set-prop 'PnP Device (FUJ02e7)' 'Wacom Rotation' 1
# normal: 0, right: 1, left: 2, inverted: 3

# Usege: rotate [-norestart] [-ccw]

# echo rotate $@ called > /dev/pts/0

# Restart fvwm if that is our window manager
restart_fvwm()
{
if pidof fvwm > /dev/null || pidof fvwm2 > /dev/null
then
FvwmCommand restart
fi
}

# Determine the name of the cursor device in a kludgy way that works
# for Slackware64 13.1 on the T900 and Slackware 13.0 on the X41T.
# See the rotate-wacom.sh script from the fjbtndrv-2.2.1 package for a
# less kludgy way of finding the wacom device(s).
if xinput list --short | grep FUJ02e7 >/dev/null 2>&1
then
DEV="PnP Device (FUJ02e7)"
DFP=LVDS1
else
if xinput list --short \ | grep "Serial Wacom Tablet stylus" >/dev/null 2>&1
then
DEV="Serial Wacom Tablet stylus"
DFP=LVDS1
else
if xinput list --short \ | grep "Wacom Serial Tablet PC Pen Tablet/Digitizer" >/dev/null 2>&1
then
DEV="Wacom Serial Tablet PC Pen Tablet/Digitizer"
DFP=LVDS
else
echo 1>&2 "`basename $0`: I don't know this machine."
exit 1
fi
fi
fi

if [ "z$1" = "z-norestart" ]
then
no_restart=T
shift
fi

current=`xrandr | grep '^Current rotation' | sed "s/.* //"`
if [ "z$current" = "z" ]
then
# A newer version of xrandr... more difficult to deal with.
current=`xrandr | grep $DFP | sed -e "s/ (.*//" -e "s/.*0 *//"`
# Slack 13.1: if orientation is "normal", current="". But that's OK.
fi

if [ "z$1" = "z-ccw" ]
then
# Rotate 1/4 turn counter-clockwise
case "$current" in
left)
xrandr --output $DFP --rotate inverted
xsetwacom set "$DEV" Rotate half
;;
inverted)
xrandr --output $DFP --rotate right
xsetwacom set "$DEV" Rotate cw
;;
right)
xrandr --output $DFP --rotate normal
xsetwacom set "$DEV" Rotate none
;;
*)
xrandr --output $DFP --rotate left
xsetwacom set "$DEV" Rotate ccw
;;
esac
else
# Rotate 1/4 turn clockwise
case "$current" in
left)
xrandr --output $DFP --rotate normal
xsetwacom set "$DEV" Rotate none
;;
inverted)
xrandr --output $DFP --rotate left
xsetwacom set "$DEV" Rotate cw
;;
right)
xrandr --output $DFP --rotate inverted
xsetwacom set "$DEV" Rotate half
;;
*)
xrandr --output $DFP --rotate right
xsetwacom set "$DEV" Rotate ccw
;;
esac
fi

# If we are using FVWM, it probably needs to be goosed.
if [ "z$no_restart" != "zT" ]
then
restart_fvwm
fi

Discussion

  • Jim
    Jim
    2011-08-21

    I see the web site has destroyed my indentation. Ho hum.

    Also, in the ccw part of the if statement, the cw and ccw are reversed. (In Slackware 13.1 cw and ccw were the other way around, and I had only fixed the "else" clause.)

    Fixed version added as an attachment this time.

     
  • Jim
    Jim
    2011-08-21

     
    Attachments
  • Robert Gerlach
    Robert Gerlach
    2011-11-19

    • milestone: --> v2.x
    • assigned_to: nobody --> khnz