Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pep8

  • Loading branch information...
commit a1e131580e0b3f909148537b10849b8672ea41bc 1 parent 059d716
@paradoxxxzero paradoxxxzero authored
View
2  libqtile/__init__.py
@@ -1,2 +0,0 @@
-
-
View
64 libqtile/command.py
@@ -1,15 +1,15 @@
# Copyright (c) 2008, Aldo Cortesi. All rights reserved.
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -18,11 +18,20 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-import inspect, traceback, textwrap, os
+import inspect
+import traceback
+import textwrap
+import os
import ipc
-class CommandError(Exception): pass
-class CommandException(Exception): pass
+
+class CommandError(Exception):
+ pass
+
+
+class CommandException(Exception):
+ pass
+
class _SelectError(Exception):
def __init__(self, name, sel):
@@ -48,7 +57,7 @@ def formatSelector(lst):
expr.append(".")
expr.append(i[0])
if i[1] is not None:
- expr.append("[%s]"%repr(i[1]))
+ expr.append("[%s]" % repr(i[1]))
return "".join(expr)
@@ -73,11 +82,11 @@ def call(self, data):
except _SelectError, v:
e = formatSelector([(v.name, v.sel)])
s = formatSelector(selectors)
- return ERROR, "No object %s in path '%s'"%(e, s)
+ return ERROR, "No object %s in path '%s'" % (e, s)
cmd = obj.command(name)
if not cmd:
return ERROR, "No such command."
- self.qtile.log.add("Command: %s(%s, %s)"%(name, args, kwargs))
+ self.qtile.log.add("Command: %s(%s, %s)" % (name, args, kwargs))
try:
return SUCCESS, cmd(*args, **kwargs)
except CommandError, v:
@@ -108,7 +117,9 @@ class _CommandTree(object):
commands themselves appear on the object as callable attributes.
"""
def __init__(self, call, selectors, myselector, parent):
- self.call, self.selectors, self.myselector = call, selectors, myselector
+ self.call = call
+ self.selectors = selectors
+ self.myselector = myselector
self.parent = parent
@property
@@ -120,7 +131,7 @@ def path(self):
def __getitem__(self, select):
if self.myselector:
- raise KeyError, "No such key: %s"%select
+ raise KeyError("No such key: %s" % select)
c = self.__class__(self.call, self.selectors, select, self)
return c
@@ -177,6 +188,7 @@ class _TGroup(_CommandTree):
class _CommandRoot(_CommandTree):
name = None
_contains = ["layout", "widget", "screen", "bar", "window", "group"]
+
def __init__(self):
"""
This method constructs the entire hierarchy of callable commands
@@ -185,13 +197,13 @@ def __init__(self):
_CommandTree.__init__(self, self.call, [], None, None)
def __getitem__(self, select):
- raise KeyError, "No such key: %s"%select
+ raise KeyError("No such key: %s" % select)
def call(self, selectors, name, *args, **kwargs):
"""
This method is called for issued commands.
-
- :selectors A list of (name, selector) tuples.
+
+ :selectors A list of (name, selector) tuples.
:name Command name.
"""
pass
@@ -208,9 +220,10 @@ def find_sockfile(display=None):
if '.' not in display:
display += '.0'
cache_directory = os.path.expandvars('$XDG_CACHE_HOME')
- if cache_directory == '$XDG_CACHE_HOME': #if variable wasn't set
+ if cache_directory == '$XDG_CACHE_HOME':
+ # if variable wasn't set
cache_directory = os.path.expanduser("~/.cache")
- return os.path.join(cache_directory, SOCKBASE%display)
+ return os.path.join(cache_directory, SOCKBASE % display)
class Client(_CommandRoot):
@@ -266,7 +279,7 @@ def call(self, selectors, name, *args, **kwargs):
class CommandObject(object):
"""
Base class for objects that expose commands. Each command should be a
- method named cmd_X, where X is the command name.
+ method named cmd_X, where X is the command name.
"""
def select(self, selectors):
if not selectors:
@@ -292,17 +305,17 @@ def items(self, name):
"""
ret = self._items(name)
if ret is None:
- raise CommandError("Unknown item class: %s"%name)
+ raise CommandError("Unknown item class: %s" % name)
return ret
def _items(self, name):
"""
- Return (root, items) tuple for the specified item class, with:
-
+ Return (root, items) tuple for the specified item class, with:
+
root: True if this class accepts a "naked" specification
without an item specification (i.e. "layout"), and False if it
- does not.
-
+ does not.
+
items is a list of contained items, or None if this object is
not a valid container.
@@ -335,8 +348,8 @@ def commands(self):
def cmd_commands(self):
"""
- Returns a list of possible commands for this object. Used by __qsh__
- for command completion and online help.
+ Returns a list of possible commands for this object.
+ Used by __qsh__ for command completion and online help.
"""
return self.commands()
@@ -370,5 +383,4 @@ def cmd_doc(self, name):
if name in self.commands():
return self.doc(name)
else:
- raise CommandError("No such command: %s"%name)
-
+ raise CommandError("No such command: %s" % name)
View
5 libqtile/confreader.py
@@ -48,7 +48,8 @@ class File(Config):
def __init__(self, fname=None):
if not fname:
config_directory = os.path.expandvars('$XDG_CONFIG_HOME')
- if config_directory == '$XDG_CONFIG_HOME': #if variable wasn't set
+ if config_directory == '$XDG_CONFIG_HOME':
+ # if variable wasn't set
config_directory = os.path.expanduser("~/.config")
fname = os.path.join(config_directory, "qtile", "config.py")
elif fname == "default":
@@ -57,7 +58,7 @@ def __init__(self, fname=None):
self.fname = fname
if not os.path.isfile(fname):
- raise ConfigError("Config file does not exist: %s"%fname)
+ raise ConfigError("Config file does not exist: %s" % fname)
try:
sys.path.insert(0, os.path.dirname(self.fname))
config = __import__(os.path.basename(self.fname)[:-3])
View
58 libqtile/drawer.py
@@ -1,10 +1,14 @@
-import utils, math
-import pangocairo, cairo, pango
+import utils
+import math
+import pangocairo
+import cairo
+import pango
import xcb.xproto
class TextLayout(object):
- def __init__(self, drawer, text, colour, font_family, font_size, wrap=True, markup=False):
+ def __init__(self, drawer, text, colour, font_family, font_size,
+ wrap=True, markup=False):
self.drawer, self.colour = drawer, colour
layout = drawer.ctx.create_layout()
layout.set_alignment(pango.ALIGN_CENTER)
@@ -25,7 +29,7 @@ def text(self):
@text.setter
def text(self, value):
- if self.markup :
+ if self.markup:
attrlist, value, accel_char = pango.parse_markup(value)
self.layout.set_attributes(attrlist)
return self.layout.set_text(utils.scrub_to_utf8(value))
@@ -128,11 +132,12 @@ def draw_fill(self, x, y, rounded=True):
@property
def height(self):
- return self.layout.height + self.pad_y*2
+ return self.layout.height + self.pad_y * 2
@property
def width(self):
- return self.layout.width + self.pad_x*2
+ return self.layout.width + self.pad_x * 2
+
class Drawer:
"""
@@ -181,15 +186,19 @@ def _rounded_rect(self, x, y, width, height, linewidth):
aspect = 1.0
corner_radius = height / 10.0
radius = corner_radius / aspect
- degrees = math.pi/180.0
+ degrees = math.pi / 180.0
self.ctx.new_sub_path()
- delta = radius + linewidth/2
- self.ctx.arc(x + width - delta, y + delta, radius, -90 * degrees, 0 * degrees)
- self.ctx.arc(x + width - delta, y + height - delta, radius, 0 * degrees, 90 * degrees)
- self.ctx.arc(x + delta, y + height - delta, radius, 90 * degrees, 180 * degrees)
- self.ctx.arc(x + delta, y + delta, radius, 180 * degrees, 270 * degrees)
+ delta = radius + linewidth / 2
+ self.ctx.arc(x + width - delta, y + delta, radius,
+ -90 * degrees, 0 * degrees)
+ self.ctx.arc(x + width - delta, y + height - delta,
+ radius, 0 * degrees, 90 * degrees)
+ self.ctx.arc(x + delta, y + height - delta, radius,
+ 90 * degrees, 180 * degrees)
+ self.ctx.arc(x + delta, y + delta, radius,
+ 180 * degrees, 270 * degrees)
self.ctx.close_path()
def rounded_rectangle(self, x, y, width, height, linewidth):
@@ -201,12 +210,12 @@ def rounded_fillrect(self, x, y, width, height, linewidth):
self._rounded_rect(x, y, width, height, linewidth)
self.ctx.fill()
- def rectangle(self, x, y, width, height, linewidth = 2):
+ def rectangle(self, x, y, width, height, linewidth=2):
self.ctx.set_line_width(linewidth)
self.ctx.rectangle(x, y, width, height)
self.ctx.stroke()
- def fillrect(self, x, y, width, height, linewidth = 2):
+ def fillrect(self, x, y, width, height, linewidth=2):
self.ctx.set_line_width(linewidth)
self.ctx.rectangle(x, y, width, height)
self.ctx.fill()
@@ -221,8 +230,8 @@ def draw(self, offset, width):
self.pixmap,
self.wid,
self.gc,
- 0, 0, # srcx, srcy
- offset, 0, # dstx, dsty
+ 0, 0, # srcx, srcy
+ offset, 0, # dstx, dsty
width, self.height
)
@@ -257,11 +266,13 @@ def textlayout(self, text, colour, font_family, font_size, **kw):
return TextLayout(self, text, colour, font_family, font_size, **kw)
_sizelayout = None
+
def max_layout_size(self, texts, font_family, font_size):
- # FIXME: This is incredibly clumsy, to avoid a memory leak in pygtk. See
- # comment on textlayout() for details.
+ # FIXME: This is incredibly clumsy, to avoid a memory leak in pygtk.
+ # See comment on textlayout() for details.
if not self._sizelayout:
- self._sizelayout = self.textlayout("", "ffffff", font_family, font_size)
+ self._sizelayout = self.textlayout(
+ "", "ffffff", font_family, font_size)
widths, heights = [], []
self._sizelayout.font_family = font_family
self._sizelayout.font_size = font_size
@@ -290,8 +301,9 @@ def fit_fontsize(self, heightlimit):
height.
"""
self.ctx.set_font_size(heightlimit)
- asc, desc, height, _, _ = self.font_extents()
- self.ctx.set_font_size(int(heightlimit*(heightlimit/float(height))))
+ asc, desc, height, _, _ = self.font_extents()
+ self.ctx.set_font_size(
+ int(heightlimit * (heightlimit / float(height))))
return self.font_extents()
def fit_text(self, strings, heightlimit):
@@ -303,7 +315,8 @@ def fit_text(self, strings, heightlimit):
_, _, _, maxheight, _, _ = self.ctx.text_extents("".join(strings))
if not maxheight:
return 0, 0
- self.ctx.set_font_size(int(heightlimit*(heightlimit/float(maxheight))))
+ self.ctx.set_font_size(
+ int(heightlimit * (heightlimit / float(maxheight))))
maxwidth, maxheight = 0, 0
for i in strings:
_, _, x, y, _, _ = self.ctx.text_extents(i)
@@ -324,4 +337,3 @@ def draw_hbar(self, color, x1, x2, y, linewidth=1):
self.ctx.line_to(x2, y)
self.ctx.set_line_width(linewidth)
self.ctx.stroke()
-
View
17 libqtile/hook.py
@@ -2,6 +2,8 @@
subscriptions = {}
SKIPLOG = set()
+qtile = None
+
def init(q):
global qtile
@@ -19,7 +21,7 @@ def __init__(self):
if not i.startswith("_"):
hooks.add(i)
self.hooks = hooks
-
+
def _subscribe(self, event, func):
lst = subscriptions.setdefault(event, [])
if not func in lst:
@@ -97,7 +99,7 @@ def client_managed(self, func):
Called after Qtile starts managing a new client. That is, after a
window is assigned to a group, or when a window is made static.
This hook is not called for internal windows.
-
+
- arguments: window.Window object
"""
return self._subscribe("client_managed", func)
@@ -156,6 +158,7 @@ def layout_change(self, func):
subscribe = Subscribe()
+
class Unsubscribe(Subscribe):
"""
This class mirrors subscribe, except the _subscribe member has been
@@ -166,15 +169,17 @@ def _subscribe(self, event, func):
try:
lst.remove(func)
except ValueError:
- raise manager.QtileError("Tried to unsubscribe a hook that was not currently subscribed")
-
+ raise manager.QtileError("Tried to unsubscribe a hook that was not"
+ " currently subscribed")
unsubscribe = Unsubscribe()
+
def fire(event, *args, **kwargs):
if event not in subscribe.hooks:
- raise manager.QtileError("Unknown event: %s"%event)
+ raise manager.QtileError("Unknown event: %s" % event)
if not event in SKIPLOG:
- qtile.log.add("Internal event: %s(%s, %s)"%(event, args, kwargs))
+ qtile.log.add("Internal event: %s(%s, %s)" %
+ (event, args, kwargs))
for i in subscriptions.get(event, []):
i(*args, **kwargs)
View
1  libqtile/layout/max.py
@@ -29,6 +29,7 @@ class Max(SingleWindow):
commands to switch to next and previous windows in the stack.
"""
name = "max"
+
def __init__(self):
SingleWindow.__init__(self)
self.clients = []
View
65 libqtile/sh.py
@@ -1,15 +1,15 @@
# Copyright (c) 2008, Aldo Cortesi. All rights reserved.
-#
+#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
-#
+#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
-#
+#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -20,8 +20,14 @@
"""
A command shell for Qtile.
"""
-import readline, sys, pprint, re, textwrap
-import fcntl, termios, struct
+import readline
+import sys
+import pprint
+import re
+import textwrap
+import fcntl
+import termios
+import struct
import command
@@ -36,12 +42,13 @@ def terminalWidth():
class QSh:
- def __init__(self, client, completekey = "tab"):
+
+ def __init__(self, client, completekey="tab"):
self.clientroot, self.current = client, client
self.completekey = completekey
self.termwidth = terminalWidth()
readline.set_completer(self.complete)
- readline.parse_and_bind(self.completekey+": complete")
+ readline.parse_and_bind(self.completekey + ": complete")
readline.set_completer_delims(" ()|")
self.builtins = [i[3:] for i in dir(self) if i.startswith("do_")]
@@ -74,23 +81,23 @@ def complete(self, arg, state):
@property
def prompt(self):
- return "%s> "%self.current.path
+ return "%s> " % self.current.path
def columnize(self, lst):
ret = []
if lst:
lst = [str(i) for i in lst]
mx = max([len(i) for i in lst])
- cols = self.termwidth / (mx+2)
+ cols = self.termwidth / (mx + 2)
if not cols:
cols = 1
- for i in range(len(lst)/cols):
- sl = lst[i*cols:(i+1)*cols]
- sl = [x + " "*(mx-len(x)) for x in sl]
+ for i in range(len(lst) / cols):
+ sl = lst[i * cols: (i + 1) * cols]
+ sl = [x + " " * (mx - len(x)) for x in sl]
ret.append(" ".join(sl))
- if len(lst)%cols:
- sl = lst[-(len(lst)%cols):]
- sl = [x + " "*(mx-len(x)) for x in sl]
+ if len(lst) % cols:
+ sl = lst[-(len(lst) % cols):]
+ sl = [x + " " * (mx - len(x)) for x in sl]
ret.append(" ".join(sl))
return "\n".join(ret)
@@ -152,7 +159,7 @@ def _findNode(self, src, *path):
def do_cd(self, arg):
"""
Change to another path.
-
+
Examples:
cd layout/0
@@ -176,7 +183,7 @@ def do_ls(self, arg):
ls ../layout
"""
l = self._ls(self.current)
- l = ["%s/"%i for i in l]
+ l = ["%s/" % i for i in l]
return self.columnize(l)
def do_help(self, arg):
@@ -185,9 +192,9 @@ def do_help(self, arg):
help on a specific command or builtin.
Examples:
-
+
help
-
+
help command
"""
cmds = self._commands()
@@ -208,12 +215,12 @@ def do_help(self, arg):
]
return "\n".join(lst)
elif arg in cmds:
- return self._call("doc", "(\"%s\")"%arg)
+ return self._call("doc", "(\"%s\")" % arg)
elif arg in self.builtins:
- c = getattr(self, "do_"+arg)
+ c = getattr(self, "do_" + arg)
return textwrap.dedent(c.__doc__).lstrip()
else:
- return "No such command: %s"%arg
+ return "No such command: %s" % arg
def do_exit(self, args):
"""
@@ -226,7 +233,7 @@ def do_exit(self, args):
def _call(self, cmd, args):
cmds = self._commands()
if cmd not in cmds:
- return "No such command: %s"%cmd
+ return "No such command: %s" % cmd
cmd = getattr(self.current, cmd)
if args:
@@ -235,15 +242,15 @@ def _call(self, cmd, args):
args = "()"
try:
val = eval(
- "cmd%s"%args,
+ "cmd%s" % args,
{},
dict(cmd=cmd)
)
return val
except SyntaxError, v:
- return "Syntax error in expression: %s"%v.text
+ return "Syntax error in expression: %s" % v.text
except command.CommandException, val:
- return "Command exception: %s\n"%val
+ return "Command exception: %s\n" % val
def loop(self):
while True:
@@ -256,11 +263,12 @@ def loop(self):
match = re.search(r"\W", line)
if match:
- cmd, args = line[:match.start()].strip(), line[match.start():].strip()
+ cmd, args = line[:match.start()].strip(), line[
+ match.start():].strip()
else:
cmd, args = line, ""
- builtin = getattr(self, "do_"+cmd, None)
+ builtin = getattr(self, "do_" + cmd, None)
if builtin:
val = builtin(args)
else:
@@ -269,4 +277,3 @@ def loop(self):
print val
elif val:
pprint.pprint(val)
-
View
140 libqtile/window.py
@@ -18,11 +18,14 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-import sys, struct, contextlib
+import sys
+import struct
+import contextlib
import xcb.xcb
from xcb.xproto import EventMask, StackMode, SetMode
import xcb.xproto
-import command, utils
+import command
+import utils
import hook
@@ -45,7 +48,7 @@
PAspect = (1 << 7)
PBaseSize = (1 << 8)
PWinGravity = (1 << 9)
-PAllHints = (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
+PAllHints = (PPosition | PSize | PMinSize | PMaxSize | PResizeInc | PAspect)
InputHint = (1 << 0)
StateHint = (1 << 1)
IconPixmapHint = (1 << 2)
@@ -54,9 +57,9 @@
IconMaskHint = (1 << 5)
WindowGroupHint = (1 << 6)
MessageHint = (1 << 7)
-UrgencyHint = (1 << 8)
-AllHints = (InputHint|StateHint|IconPixmapHint|IconWindowHint|
- IconPositionHint|IconMaskHint|WindowGroupHint|MessageHint|
+UrgencyHint = (1 << 8)
+AllHints = (InputHint | StateHint | IconPixmapHint | IconWindowHint |
+ IconPositionHint | IconMaskHint | WindowGroupHint | MessageHint |
UrgencyHint)
WithdrawnState = 0
@@ -90,13 +93,14 @@
XCNOENT = 2
# float states
-NOT_FLOATING = 1 # not floating
+NOT_FLOATING = 1 # not floating
FLOATING = 2
MAXIMIZED = 3
FULLSCREEN = 4
TOP = 5
MINIMIZED = 6
+
class _Window(command.CommandObject):
def __init__(self, window, qtile):
self.window, self.qtile = window, qtile
@@ -120,7 +124,7 @@ def __init__(self, window, qtile):
self.hints = {
'input': True,
- 'state': NormalState, #Normal state
+ 'state': NormalState, # Normal state
'icon_pixmap': None,
'icon_window': None,
'icon_x': 0,
@@ -178,11 +182,13 @@ def updateHints(self):
if(not normh['base_width']
and normh['min_width'] and normh['width_inc']):
# seems xcb does ignore base width :(
- normh['base_width'] = normh['min_width'] % normh['width_inc']
+ normh['base_width'] = (normh['min_width'] %
+ normh['width_inc'])
if(not normh['base_height']
and normh['min_height'] and normh['height_inc']):
# seems xcb does ignore base height :(
- normh['base_height'] = normh['min_height'] % normh['height_inc']
+ normh['base_height'] = (normh['min_height'] %
+ normh['height_inc'])
self.hints.update(normh)
if h and 'UrgencyHint' in h['flags']:
@@ -210,19 +216,18 @@ def info(self):
else:
group = None
return dict(
- name = self.name,
- x = self.x,
- y = self.y,
- width = self.width,
- height = self.height,
- group = group,
- id = self.window.wid,
- floating = self._float_state != NOT_FLOATING,
- float_info = self._float_info,
- maximized = self._float_state == MAXIMIZED,
- minimized = self._float_state == MINIMIZED,
- fullscreen = self._float_state == FULLSCREEN
-
+ name=self.name,
+ x=self.x,
+ y=self.y,
+ width=self.width,
+ height=self.height,
+ group=group,
+ id=self.window.wid,
+ floating=self._float_state != NOT_FLOATING,
+ float_info=self._float_info,
+ maximized=self._float_state == MAXIMIZED,
+ minimized=self._float_state == MINIMIZED,
+ fullscreen=self._float_state == FULLSCREEN
)
@property
@@ -242,14 +247,15 @@ def setOpacity(self, opacity):
return
def getOpacity(self):
- opacity = self.window.get_property("_NET_WM_WINDOW_OPACITY", unpack="I")
+ opacity = self.window.get_property(
+ "_NET_WM_WINDOW_OPACITY", unpack="I")
if not opacity:
return 1.0
else:
value = opacity[0]
as_float = round(
- (float(value)/0xffffffff),
- 2 #2 decimal places
+ (float(value) / 0xffffffff),
+ 2 # 2 decimal places
)
return as_float
@@ -259,13 +265,15 @@ def kill(self):
if "WM_DELETE_WINDOW" in self.window.get_wm_protocols():
#e = event.ClientMessage(
# window = self.window,
- # client_type = self.qtile.display.intern_atom("WM_PROTOCOLS"),
+ # client_type = self.qtile.display.intern_atom(
+ # "WM_PROTOCOLS"),
# data = [
# # Use 32-bit format:
# 32,
# # Must be exactly 20 bytes long:
# [
- # self.qtile.display.intern_atom("WM_DELETE_WINDOW"),
+ # self.qtile.display.intern_atom(
+ # "WM_DELETE_WINDOW"),
# X.CurrentTime,
# 0,
# 0,
@@ -274,8 +282,8 @@ def kill(self):
# ]
#)
vals = [
- 33, # ClientMessageEvent
- 32, # Format
+ 33, # ClientMessageEvent
+ 32, # Format
0,
self.window.wid,
self.qtile.conn.atoms["WM_PROTOCOLS"],
@@ -309,7 +317,7 @@ def disableMask(self, mask):
def _disableMask(self, mask):
self.window.set_attribute(
- eventmask=self._windowMask&(~mask)
+ eventmask=self._windowMask & (~mask)
)
def _resetMask(self):
@@ -330,7 +338,8 @@ def place(self, x, y, width, height, borderwidth, bordercolor,
# to obey all those hints
#if self.hints['width_inc']:
# width = (width -
- # ((width - self.hints['base_width']) % self.hints['width_inc']))
+ # ((width - self.hints['base_width']) %
+ # self.hints['width_inc']))
#if self.hints['height_inc']:
# height = (height -
# ((height - self.hints['base_height'])
@@ -379,7 +388,7 @@ def place(self, x, y, width, height, borderwidth, bordercolor,
if bordercolor is not None:
self.window.set_attribute(
- borderpixel = bordercolor
+ borderpixel=bordercolor
)
def focus(self, warp):
@@ -387,7 +396,7 @@ def focus(self, warp):
self.window.set_input_focus()
try:
if warp and self.qtile.config.cursor_warp:
- self.window.warp_pointer(self.width//2, self.height//2)
+ self.window.warp_pointer(self.width // 2, self.height // 2)
except AttributeError:
pass
hook.fire("client_focus", self)
@@ -438,18 +447,18 @@ def cmd_inspect(self):
return dict(
attributes=attrs,
properties=props,
- name = self.window.get_name(),
- wm_class = self.window.get_wm_class(),
- wm_window_role = self.window.get_wm_window_role(),
- wm_type = self.window.get_wm_type(),
- wm_transient_for = self.window.get_wm_transient_for(),
- protocols = protocols,
- wm_icon_name = self.window.get_wm_icon_name(),
- wm_client_machine = self.window.get_wm_client_machine(),
- normalhints = normalhints,
- hints = hints,
- state = state,
- float_info = self._float_info
+ name=self.window.get_name(),
+ wm_class=self.window.get_wm_class(),
+ wm_window_role=self.window.get_wm_window_role(),
+ wm_type=self.window.get_wm_type(),
+ wm_transient_for=self.window.get_wm_transient_for(),
+ protocols=protocols,
+ wm_icon_name=self.window.get_wm_icon_name(),
+ wm_client_machine=self.window.get_wm_client_machine(),
+ normalhints=normalhints,
+ hints=hints,
+ state=state,
+ float_info=self._float_info
)
@@ -464,6 +473,7 @@ class Internal(_Window):
EventMask.Exposure |\
EventMask.ButtonPress |\
EventMask.KeyPress
+
@classmethod
def create(klass, qtile, x, y, width, height, opacity=1.0):
win = qtile.conn.create_window(
@@ -476,7 +486,7 @@ def create(klass, qtile, x, y, width, height, opacity=1.0):
return i
def __repr__(self):
- return "Internal(%s, %s)"%(self.name, self.window.wid)
+ return "Internal(%s, %s)" % (self.name, self.window.wid)
class Static(_Window):
@@ -488,12 +498,17 @@ class Static(_Window):
EventMask.EnterWindow |\
EventMask.FocusChange |\
EventMask.Exposure
- def __init__(self, win, qtile, screen, x=None, y=None, width=None, height=None):
+
+ def __init__(self, win, qtile, screen,
+ x=None, y=None, width=None, height=None):
_Window.__init__(self, win, qtile)
self.updateName()
self.conf_x, self.conf_y = x, y
self.conf_width, self.conf_height = width, height
- self.x, self.y, self.width, self.height = x or 0, y or 0, width or 0, height or 0
+ self.x = x or 0
+ self.y = y or 0
+ self.width = width or 0
+ self.height = height or 0
self.screen = screen
if None not in (x, y, width, height):
self.place(x, y, width, height, 0, 0)
@@ -520,7 +535,7 @@ def handle_ConfigureRequest(self, e):
return False
def __repr__(self):
- return "Static(%s)"%self.name
+ return "Static(%s)" % self.name
class Window(_Window):
@@ -567,7 +582,6 @@ def floating(self, do_float):
if self._float_state == NOT_FLOATING:
self.enablefloating()
-
@property
def fullscreen(self):
return self._float_state == FULLSCREEN
@@ -607,7 +621,6 @@ def minimized(self, do_minimize):
if self._float_state == MINIMIZED:
self.disablefloating()
-
def static(self, screen, x=None, y=None, width=None, height=None):
"""
Makes this window a static window, attached to a Screen. If any of
@@ -625,7 +638,6 @@ def static(self, screen, x=None, y=None, width=None, height=None):
hook.fire("client_managed", s)
return s
-
def tweak_float(self, x=None, y=None, dx=0, dy=0,
w=None, h=None, dw=0, dh=0):
if x is not None:
@@ -707,8 +719,9 @@ def _reconfigure_floating(self, new_float_state=FLOATING):
else:
# make sure x, y is on the screen
screen = self.qtile.find_closest_screen(self.x, self.y)
- if screen is not None and self.group is not None and \
- self.group.screen is not None and screen != self.group.screen:
+ if (screen is not None and self.group is not None and
+ self.group.screen is not None and
+ screen != self.group.screen):
self.x = self.group.screen.x
self.y = self.group.screen.y
self.place(self.x,
@@ -721,11 +734,12 @@ def _reconfigure_floating(self, new_float_state=FLOATING):
)
if self._float_state != new_float_state:
self._float_state = new_float_state
- if self.group: # may be not, if it's called from hook
+ if self.group: # may be not, if it's called from hook
self.group.mark_floating(self, True)
hook.fire('float_change')
- def _enablefloating(self, x=None, y=None, w=None, h=None, new_float_state=FLOATING):
+ def _enablefloating(self, x=None, y=None, w=None, h=None,
+ new_float_state=FLOATING):
if new_float_state != MINIMIZED:
self.x = x
self.y = y
@@ -733,7 +747,6 @@ def _enablefloating(self, x=None, y=None, w=None, h=None, new_float_state=FLOATI
self.height = h
self._reconfigure_floating(new_float_state=new_float_state)
-
def enablefloating(self):
fi = self._float_info
self._enablefloating(fi['x'], fi['y'], fi['w'], fi['h'])
@@ -755,7 +768,7 @@ def togroup(self, groupName):
"""
group = self.qtile.groupMap.get(groupName)
if group is None:
- raise command.CommandError("No such group: %s"%groupName)
+ raise command.CommandError("No such group: %s" % groupName)
if self.group is not group:
self.hide()
if self.group:
@@ -781,7 +794,8 @@ def match(self, wname=None, wmclass=None, role=None):
- role matches against the `WM_WINDOW_ROLE` property
"""
if not (wname or wmclass or role):
- raise TypeError, "Either a name, a wmclass or a role must be specified"
+ raise TypeError(
+ "Either a name, a wmclass or a role must be specified")
if wname and wname == self.name:
return True
@@ -885,7 +899,7 @@ def _select(self, name, sel):
return self.group.screen
def __repr__(self):
- return "Window(%s)"%self.name
+ return "Window(%s)" % self.name
def cmd_static(self, screen, x, y, width, height):
self.static(screen, x, y, width, height)
@@ -977,7 +991,7 @@ def cmd_bring_to_front(self):
if self.floating:
self.window.configure(stackmode=StackMode.Above)
else:
- self._reconfigure_floating() #atomatically above
+ self._reconfigure_floating() # atomatically above
def cmd_match(self, *args, **kwargs):
return self.match(*args, **kwargs)
@@ -985,7 +999,7 @@ def cmd_match(self, *args, **kwargs):
def cmd_opacity(self, opacity):
if opacity < .1:
self.opacity = .1
- else if opacity > 1:
+ elif opacity > 1:
self.opacity = 1
else:
self.opacity = opacity

0 comments on commit a1e1315

Please sign in to comment.
Something went wrong with that request. Please try again.