Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
print("Could not open window on display %s" % (sys.argv[1]), file=sys.stderr)
sys.exit(1)
screen = conn.get_setup().roots[conn.pref_screen]
window = conn.generate_id()
background = conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE).reply().pixel # Color "#2883ce"
conn.core.CreateWindow(xcffib.CopyFromParent, window, screen.root,
100, 100, 100, 100, 1,
xcffib.xproto.WindowClass.InputOutput, screen.root_visual,
xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask,
[background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure])
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, xcffib.xproto.Atom.WM_NAME,
xcffib.xproto.Atom.STRING, 8, len(sys.argv[2]),
sys.argv[2])
wm_protocols = "WM_PROTOCOLS"
wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom
wm_delete_window = "WM_DELETE_WINDOW"
wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, wm_protocols,
xcffib.xproto.Atom.ATOM, 32, 1,
[wm_delete_window])
conn.core.ConfigureWindow(window,
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
else:
print("Could not open window on display %s" % (sys.argv[1]), file=sys.stderr)
sys.exit(1)
screen = conn.get_setup().roots[conn.pref_screen]
window = conn.generate_id()
background = conn.core.AllocColor(screen.default_colormap, 0x2828, 0x8383, 0xCECE).reply().pixel # Color "#2883ce"
conn.core.CreateWindow(xcffib.CopyFromParent, window, screen.root,
100, 100, 100, 100, 1,
xcffib.xproto.WindowClass.InputOutput, screen.root_visual,
xcffib.xproto.CW.BackPixel | xcffib.xproto.CW.EventMask,
[background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure])
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, xcffib.xproto.Atom.WM_NAME,
xcffib.xproto.Atom.STRING, 8, len(sys.argv[2]),
sys.argv[2])
wm_protocols = "WM_PROTOCOLS"
wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom
wm_delete_window = "WM_DELETE_WINDOW"
wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, wm_protocols,
xcffib.xproto.Atom.ATOM, 32, 1,
[wm_delete_window])
conn.core.ConfigureWindow(window,
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
[background, xcffib.xproto.EventMask.StructureNotify | xcffib.xproto.EventMask.Exposure])
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, xcffib.xproto.Atom.WM_NAME,
xcffib.xproto.Atom.STRING, 8, len(sys.argv[2]),
sys.argv[2])
wm_protocols = "WM_PROTOCOLS"
wm_protocols = conn.core.InternAtom(0, len(wm_protocols), wm_protocols).reply().atom
wm_delete_window = "WM_DELETE_WINDOW"
wm_delete_window = conn.core.InternAtom(0, len(wm_delete_window), wm_delete_window).reply().atom
conn.core.ChangeProperty(xcffib.xproto.PropMode.Replace,
window, wm_protocols,
xcffib.xproto.Atom.ATOM, 32, 1,
[wm_delete_window])
conn.core.ConfigureWindow(window,
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
xcffib.xproto.ConfigWindow.BorderWidth,
[0, 0, 100, 100, 1])
conn.core.MapWindow(window)
conn.flush()
conn.core.ConfigureWindow(window,
xcffib.xproto.ConfigWindow.X | xcffib.xproto.ConfigWindow.Y |
xcffib.xproto.ConfigWindow.Width | xcffib.xproto.ConfigWindow.Height |
xcffib.xproto.ConfigWindow.BorderWidth,
[0, 0, 100, 100, 1])
try:
def _get_pixmap_property(self, name):
reply = self.conn.core.GetProperty(
False, self.root, self._intern_atom(name),
xcffib.xproto.Atom.PIXMAP, 0, 32
).reply()
if not reply.value_len:
return None
return struct.unpack('I', reply.value.buf())[0]
def __init__(self, conn):
self.conn = conn
self.atoms = {}
self.reverse = {}
# We can change the pre-loads not to wait for a return
for name in WindowTypes.keys():
self.insert(name=name)
for i in dir(xcffib.xproto.Atom):
if not i.startswith("_"):
self.insert(name=i, atom=getattr(xcffib.xproto.Atom, i))
"""Tries to retrieve a canonical window name.
We test the following properties in order of preference:
- _NET_WM_VISIBLE_NAME
- _NET_WM_NAME
- WM_NAME.
"""
r = self.get_property("_NET_WM_VISIBLE_NAME", "UTF8_STRING")
if r:
return self._property_utf8(r)
r = self.get_property("_NET_WM_NAME", "UTF8_STRING")
if r:
return self._property_utf8(r)
r = self.get_property(xcffib.xproto.Atom.WM_NAME, "UTF8_STRING")
if r:
return self._property_utf8(r)
r = self.get_property(
xcffib.xproto.Atom.WM_NAME,
xcffib.xproto.GetPropertyType.Any
)
if r:
return self._property_string(r)
def __init__(self, conn):
self.conn = conn
self.atoms = {}
self.reverse = {}
# We can change the pre-loads not to wait for a return
for name in WindowTypes.keys():
self.insert(name=name)
for i in dir(xcffib.xproto.Atom):
if not i.startswith("_"):
self.insert(name=i, atom=getattr(xcffib.xproto.Atom, i))
def ungrab_button(self, button, modifiers):
"""Passing None means any key, or any modifier"""
if button is None:
button = xcffib.xproto.Atom.Any
if modifiers is None:
modifiers = xcffib.xproto.ModMask.Any
self.conn.conn.core.UngrabButton(button, self.wid, modifiers)