/usr/lib/python2.7/dist-packages/autopilot/display/_X11.py is in python-autopilot 1.4.1+15.10.20150911-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
#
# Autopilot Functional Test Tool
# Copyright (C) 2012-2013 Canonical
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from autopilot.display import Display as DisplayBase
from autopilot.utilities import Silence
class Display(DisplayBase):
def __init__(self):
# Note: MUST import these here, rather than at the top of the file.
# Why? Because sphinx imports these modules to build the API
# documentation, which in turn tries to import Gdk, which in turn
# fails because there's no DISPLAY environment set in the package
# builder.
with Silence():
from gi import require_version
require_version('Gdk', '3.0')
from gi.repository import Gdk
self._default_screen = Gdk.Screen.get_default()
if self._default_screen is None:
raise RuntimeError(
"Unable to determine default screen information")
self._blacklisted_drivers = ["NVIDIA"]
def get_num_screens(self):
"""Get the number of screens attached to the PC.
:returns: int indicating number of screens attached.
"""
return self._default_screen.get_n_monitors()
def get_primary_screen(self):
"""Return an integer of which screen is considered the primary."""
return self._default_screen.get_primary_monitor()
def get_screen_width(self, screen_number=0):
# return self._default_screen.get_width()
return self.get_screen_geometry(screen_number)[2]
def get_screen_height(self, screen_number=0):
#return self._default_screen.get_height()
return self.get_screen_geometry(screen_number)[3]
def get_screen_geometry(self, screen_number):
"""Get the geometry for a particular screen.
:return: Tuple containing (x, y, width, height).
"""
if screen_number < 0 or screen_number >= self.get_num_screens():
raise ValueError('Specified screen number is out of range.')
rect = self._default_screen.get_monitor_geometry(screen_number)
return (rect.x, rect.y, rect.width, rect.height)
|