Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
add_event_receiver(root, self)
### Create the WM object
self._wm = Wm(self.clobber)
self._wm.connect("new-window", self._new_window_signaled)
self._wm.connect("bell", self._bell_signaled)
self._wm.connect("quit", lambda _: self.quit(True))
self.default_cursor_data = None
self.last_cursor_serial = None
self.send_cursor_pending = False
self.cursor_data = None
def get_default_cursor():
self.default_cursor_data = X11Keyboard.get_cursor_image()
log("get_default_cursor=%s", self.default_cursor_data)
trap.swallow_synced(get_default_cursor)
self._wm.enableCursors(True)
def force_quit(self):
pid = self.get_property("pid")
machine = self.get_property("client-machine")
localhost = gethostname()
if pid > 0 and machine is not None and machine == localhost:
if pid==os.getpid():
log.warn("force_quit() refusing to kill ourselves!")
else:
try:
os.kill(pid, 9)
except OSError:
log.warn("failed to kill() client with pid %s", pid)
trap.swallow_synced(X11Window.XKillClient, get_xwindow(self.client_window))
def _handle_state_changed(self, *args):
# Sync changes to "state" property out to X property.
trap.swallow_synced(prop_set, self.client_window, "_NET_WM_STATE",
["atom"], self.get_property("state"))
def do_unmanaged(self, wm_exiting):
log("unmanaging window: %s (%s - %s)", self, self.corral_window, self.client_window)
self._internal_set_property("owner", None)
if self.corral_window:
remove_event_receiver(self.corral_window, self)
for prop in WindowModel.SCRUB_PROPERTIES:
trap.swallow_synced(X11Window.XDeleteProperty, get_xwindow(self.client_window), prop)
if self.client_reparented:
self.client_window.reparent(gtk.gdk.get_default_root_window(), 0, 0)
self.client_reparented = False
self.client_window.set_events(self.client_window_saved_events)
#it is now safe to destroy the corral window:
self.corral_window.destroy()
self.corral_window = None
# It is important to remove from our save set, even after
# reparenting, because according to the X spec, windows that are
# in our save set are always Mapped when we exit, *even if those
# windows are no longer inferior to any of our windows!* (see
# section 10. Connection Close). This causes "ghost windows", see
# bug #27:
if self.in_save_set:
trap.swallow_synced(X11Window.XRemoveFromSaveSet, get_xwindow(self.client_window))
self.in_save_set = False
def call_setup(self):
try:
self._geometry = trap.call_synced(X11Window.geometry_with_border, self.client_window.xid)
except XError, e:
raise Unmanageable(e)
add_event_receiver(self.client_window, self)
# Keith Packard says that composite state is undefined following a
# reparent, so I'm not sure doing this here in the superclass,
# before we reparent, actually works... let's wait and see.
try:
trap.call_synced(self._composite.setup)
except XError, e:
remove_event_receiver(self.client_window, self)
log("window %#x does not support compositing: %s", self.client_window.xid, e)
trap.swallow_synced(self._composite.destroy)
self._composite = None
raise Unmanageable(e)
#compositing is now enabled, from now on we need to call setup_failed to clean things up
self._managed = True
try:
trap.call_synced(self.setup)
except XError, e:
try:
trap.call_synced(self.setup_failed, e)
except Exception, ex:
log.error("error in cleanup handler: %s", ex)
raise Unmanageable(e)
self._pointer_grab.setup()
self._pointer_grab.connect("grab", self.pointer_grab_event)
self._pointer_grab.connect("ungrab", self.pointer_ungrab_event)
self._setup_done = True
def _process_mouse_common(self, proto, wid, pointer, modifiers):
ss = self._server_sources.get(proto)
if ss is None:
return #gone already!
ss.make_keymask_match(modifiers)
window = self._id_to_window.get(wid)
if not window:
log("_process_mouse_common() invalid window id: %s", wid)
return
def raise_and_move():
window.raise_window()
self._move_pointer(pointer)
trap.swallow_synced(raise_and_move)
def do_unmanaged(self, wm_exiting):
log("unmanaging window: %s (%s - %s)", self, self.corral_window, self.client_window)
self._internal_set_property("owner", None)
if self.corral_window:
remove_event_receiver(self.corral_window, self)
for prop in WindowModel.SCRUB_PROPERTIES:
trap.swallow_synced(X11Window.XDeleteProperty, self.client_window.xid, prop)
if self.client_reparented:
self.client_window.reparent(gtk.gdk.get_default_root_window(), 0, 0)
self.client_reparented = False
self.client_window.set_events(self.client_window_saved_events)
#it is now safe to destroy the corral window:
self.corral_window.destroy()
self.corral_window = None
# It is important to remove from our save set, even after
# reparenting, because according to the X spec, windows that are
# in our save set are always Mapped when we exit, *even if those
# windows are no longer inferior to any of our windows!* (see
# section 10. Connection Close). This causes "ghost windows", see
# bug #27:
if self.in_save_set:
trap.swallow_synced(X11Window.XRemoveFromSaveSet, self.client_window.xid)
self.in_save_set = False
trap.swallow_synced(X11Window.XDeleteProperty, get_xwindow(self.client_window), prop)
if self.client_reparented:
self.client_window.reparent(gtk.gdk.get_default_root_window(), 0, 0)
self.client_reparented = False
self.client_window.set_events(self.client_window_saved_events)
#it is now safe to destroy the corral window:
self.corral_window.destroy()
self.corral_window = None
# It is important to remove from our save set, even after
# reparenting, because according to the X spec, windows that are
# in our save set are always Mapped when we exit, *even if those
# windows are no longer inferior to any of our windows!* (see
# section 10. Connection Close). This causes "ghost windows", see
# bug #27:
if self.in_save_set:
trap.swallow_synced(X11Window.XRemoveFromSaveSet, get_xwindow(self.client_window))
self.in_save_set = False
trap.swallow_synced(X11Window.sendConfigureNotify, get_xwindow(self.client_window))
if wm_exiting:
self.client_window.show_unraised()
BaseWindowModel.do_unmanaged(self, wm_exiting)
#save default xsettings:
self.default_xsettings = XSettingsHelper().get_settings()
settingslog("default_xsettings=%s", self.default_xsettings)
self._settings = {}
self._xsettings_manager = None
#cursor:
self.default_cursor_data = None
self.last_cursor_serial = None
self.send_cursor_pending = False
self.cursor_data = None
self.cursor_sizes = None
def get_default_cursor():
self.default_cursor_data = X11Keyboard.get_cursor_image()
cursorlog("get_default_cursor=%s", self.default_cursor_data)
trap.swallow_synced(get_default_cursor)
self._wm.enableCursors(True)
trap.swallow_synced(X11Window.XDeleteProperty, self.client_window.xid, prop)
if self.client_reparented:
self.client_window.reparent(gtk.gdk.get_default_root_window(), 0, 0)
self.client_reparented = False
self.client_window.set_events(self.client_window_saved_events)
#it is now safe to destroy the corral window:
self.corral_window.destroy()
self.corral_window = None
# It is important to remove from our save set, even after
# reparenting, because according to the X spec, windows that are
# in our save set are always Mapped when we exit, *even if those
# windows are no longer inferior to any of our windows!* (see
# section 10. Connection Close). This causes "ghost windows", see
# bug #27:
if self.in_save_set:
trap.swallow_synced(X11Window.XRemoveFromSaveSet, self.client_window.xid)
self.in_save_set = False
trap.swallow_synced(X11Window.sendConfigureNotify, self.client_window.xid)
if wm_exiting:
self.client_window.show_unraised()
BaseWindowModel.do_unmanaged(self, wm_exiting)