Skip to content

Commit

Permalink
Merge branch 'release/4.7.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-ueding committed Apr 14, 2016
2 parents 06c5bc1 + df877e2 commit f4ec597
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 8 deletions.
15 changes: 14 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
.. Copyright © 2012-2015 Martin Ueding <dev@martin-ueding.de>
.. Copyright © 2012-2016 Martin Ueding <dev@martin-ueding.de>
#########
Changelog
#########

v4.7.2
Released: 2016-04-14 21:07:41 +0200

- Ubuntu seems to ship with a version of XRandR which set the ``Wacom
Rotation`` property of a few devices, but not all of them. As we have
switched to the rotation matrix some versions ago, we and XRandR
interfere with each other. Now we reset the rotation made by XRandR. Jim
tested this on Ubuntu 15.10, so that should fix GH-117 and GH-112.

- Debug shell commands are pretty-printed using ``shlex.quote``. That way,
one can directly paste the log output into a shell and re-run a given
command.

v4.7.1
Released: 2015-10-20 17:14:26 +0200

Expand Down
8 changes: 5 additions & 3 deletions tps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Copyright © 2014-2015 Martin Ueding <dev@martin-ueding.de>
# Copyright © 2014-2016 Martin Ueding <dev@martin-ueding.de>
# Copyright © 2014 Jim Turner <jturner314@gmail.com>
# Licensed under The GNU Public License Version 2 (or later)

Expand All @@ -11,9 +11,10 @@

import collections
import functools
import subprocess
import logging
import os
import shlex
import subprocess

Direction = collections.namedtuple(
'Direction', ['xrandr', 'subpixel', 'physically_closed', 'rot_mat']
Expand Down Expand Up @@ -133,7 +134,8 @@ def print_command_decorate(function):
'''
@functools.wraps(function)
def wrapper(command, local_logger, *args, **kwargs):
local_logger.debug('subprocess “{}”'.format(' '.join(command)))
shell_command = ' '.join(map(shlex.quote,command))
local_logger.debug('subprocess “{}”'.format(shell_command))
return function(command, *args, **kwargs)
return wrapper

Expand Down
40 changes: 38 additions & 2 deletions tps/input.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Copyright © 2014-2015 Martin Ueding <dev@martin-ueding.de>
# Copyright © 2014-2016 Martin Ueding <dev@martin-ueding.de>
# Licensed under The GNU Public License Version 2 (or later)

'''
Expand Down Expand Up @@ -72,9 +72,45 @@ def map_rotate_all_input_devices(output, orientation):
'''
matrix = generate_xinput_coordinate_transformation_matrix(output,
orientation)
for device in get_wacom_device_ids():
wacom_device_ids = get_wacom_device_ids()

logger.info('Mapping and rotating all input devices.')
for device in wacom_device_ids:
map_rotate_input_device(device, matrix)

logger.info('Resetting “Wacom Rotation” property.')
for device in wacom_device_ids:
wacom_rotate_reset(device)


def wacom_rotate_reset(device):
'''
Resets the “Wacom Rotation” property of devices.
In GH-117__ we noticed that in Ubuntu the ``xrandr`` rotation command will
also rotate some input devices. This is probably meant in a good way but
interferes with our rotation here. Therefore we reset the “Wacom Rotation”
after setting the transformation matrix.
__ https://github.com/martin-ueding/thinkpad-scripts/issues/117
'''
if has_device_property(device, 'Wacom Rotation'):
command = ['xinput', 'set-prop', str(device), 'Wacom Rotation', '0']
tps.check_call(command, logger)


def has_device_property(device, property_):
'''
Checks whether a given device supports a property.
'''
command = ['xinput', '--list-props', str(device)]
output = tps.check_output(command, logger).decode()
regex = r'^\s+({})\s+\(\d+\):'.format(re.escape(property_))
has_property = re.search(regex, output, re.MULTILINE) is not None
logger.debug('Device %i %s property “%s”', device,
'has' if has_property else 'does not have', property_)
return has_property


def get_xinput_id(name):
'''
Expand Down
5 changes: 3 additions & 2 deletions tps/rotate.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# Copyright © 2014-2015 Martin Ueding <dev@martin-ueding.de>
# Copyright © 2014-2016 Martin Ueding <dev@martin-ueding.de>
# Licensed under The GNU Public License Version 2 (or later)

import argparse
Expand All @@ -27,7 +27,8 @@ def main():

config = tps.config.get_config()

# Quickly abort if the call is by the hook and the user disabled the trigger.
# Quickly abort if the call is by the hook and the user disabled the
# trigger.
if options.via_hook and not config['trigger'].getboolean('enable_rotate'):
sys.exit(0)

Expand Down

0 comments on commit f4ec597

Please sign in to comment.