Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
if display_name is None:
display_name = os.environ.get("DISPLAY")
if not display_name:
raise QtileError("No DISPLAY set")
self.conn = xcbq.Connection(display_name)
self._display_name = display_name
# Because we only do Xinerama multi-screening,
# we can assume that the first
# screen's root is _the_ root.
self._root = self.conn.default_screen.root
self._root.set_attribute(
eventmask=(
xcffib.xproto.EventMask.StructureNotify
| xcffib.xproto.EventMask.SubstructureNotify
| xcffib.xproto.EventMask.SubstructureRedirect
| xcffib.xproto.EventMask.EnterWindow
| xcffib.xproto.EventMask.LeaveWindow
)
)
self._root.set_property(
"_NET_SUPPORTED", [self.conn.atoms[x] for x in xcbq.SUPPORTED_ATOMS]
)
wmname = "qtile"
self._supporting_wm_check_window = self.conn.create_window(-1, -1, 1, 1)
self._supporting_wm_check_window.set_property("_NET_WM_NAME", wmname)
self._supporting_wm_check_window.set_property(
"_NET_SUPPORTING_WM_CHECK", self._supporting_wm_check_window.wid
return False
def handle_DestroyNotify(self, event): # noqa: N802
wid = event.window
del(self.qtile.windows_map[wid])
del(self.systray.icons[wid])
self.systray.bar.draw()
return False
handle_UnmapNotify = handle_DestroyNotify # noqa: N815
class Systray(window._Window, base._Widget):
"""A widget that manages system tray"""
_window_mask = EventMask.StructureNotify | \
EventMask.Exposure
orientations = base.ORIENTATION_HORIZONTAL
defaults = [
('icon_size', 20, 'Icon width'),
('padding', 5, 'Padding between icons'),
]
def __init__(self, **config):
base._Widget.__init__(self, bar.CALCULATED, **config)
self.add_defaults(Systray.defaults)
self.icons = {}
self.screen = 0
def calculate_length(self):
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
)
class Internal(_Window):
"""An internal window, that should not be managed by qtile"""
_window_mask = EventMask.StructureNotify | \
EventMask.PropertyChange | \
EventMask.EnterWindow | \
EventMask.FocusChange | \
EventMask.Exposure | \
EventMask.ButtonPress | \
EventMask.ButtonRelease | \
EventMask.KeyPress
@classmethod
def create(cls, qtile, x, y, width, height, opacity=1.0):
win = qtile.conn.create_window(x, y, width, height)
win.set_property("QTILE_INTERNAL", 1)
i = Internal(win, qtile)
i.place(x, y, width, height, 0, None)
i.opacity = opacity
return i
atoms['_NET_SYSTEM_TRAY_S{:d}'.format(self.screen)],
xcffib.CurrentTime
)
data = [
xcffib.CurrentTime,
atoms['_NET_SYSTEM_TRAY_S{:d}'.format(self.screen)],
win.wid, 0, 0
]
union = ClientMessageData.synthetic(data, "I" * 5)
event = ClientMessageEvent.synthetic(
format=32,
window=qtile.root.wid,
type=atoms['MANAGER'],
data=union
)
qtile.root.send_event(event, mask=EventMask.StructureNotify)
above_sibling = False
override_redirect = False
event = xcffib.xproto.ConfigureNotifyEvent.synthetic(
event=window,
window=window,
above_sibling=above_sibling,
x=x,
y=y,
width=width,
height=height,
border_width=self.borderwidth,
override_redirect=override_redirect
)
self.window.send_event(event, mask=EventMask.StructureNotify)
def hide(self):
# We don't want to get the UnmapNotify for this unmap
with self.disable_mask(xcffib.xproto.EventMask.StructureNotify):
self.window.unmap()
self.hidden = True