diff options
Diffstat (limited to 'LockWindow.py')
-rw-r--r-- | LockWindow.py | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/LockWindow.py b/LockWindow.py index e040ea8..2ead7be 100644 --- a/LockWindow.py +++ b/LockWindow.py @@ -40,14 +40,19 @@ class LockWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self) - bg = Gtk.Image.new_from_file("bg.svg") - self.add(bg) + self.display = Gdk.Display.get_default() + self.screen = self.display.get_default_screen() + + self.overlay = Gtk.Overlay() + self.add(self.overlay) + + self.bg = Gtk.Image.new_from_file("bg.svg") + self.overlay.add(self.bg) + + self.realize() + self.get_window().set_override_redirect(True) - self.set_decorated(False) - self.set_skip_taskbar_hint(True) - self.set_skip_pager_hint(True) - self.set_keep_above(True) - self.fullscreen() + self.set_has_resize_grip(False) builder = Gtk.Builder() @@ -61,12 +66,9 @@ class LockWindow(Gtk.Window): self.logoutButton = builder.get_object('logout_button') self.unlockButton = builder.get_object('unlock_button') - self.unlockWindow.set_position(Gtk.WindowPosition.CENTER_ALWAYS) - self.unlockWindow.set_transient_for(self) - self.unlockWindow.set_modal(True) + self.overlay.add_overlay(self.unlockWindow) self.connect('delete-event', lambda w, e: True) - self.unlockWindow.connect('delete-event', lambda w, e: True) self.promptEntry.connect('activate', lambda w: self._tryUnlock()) self.logoutButton.connect('clicked', lambda w: self._logout()) @@ -74,10 +76,9 @@ class LockWindow(Gtk.Window): self.reset(True) - self.display = Gdk.Display.get_default() self.deviceManager = self.display.get_device_manager() - self.unlockWindow.connect('map-event', self._grab_devices) + self.connect('map-event', self._grabDevices) def _logout(self): self.promptEntry.set_sensitive(False) @@ -128,26 +129,34 @@ class LockWindow(Gtk.Window): def setAuthMessage(self, message): self.messageLabel.set_label(message) - def _grab_devices(self, w, e): + def _grabDevices(self, w, e): + self.get_window().move_resize(0, 0, self.screen.get_width(), self.screen.get_height()) + + self.promptEntry.grab_focus() + for device in self.deviceManager.list_devices(Gdk.DeviceType.MASTER): - device.grab(self.unlockWindow.get_window(), Gdk.GrabOwnership.APPLICATION, True, Gdk.EventMask.ALL_EVENTS_MASK, None, Gdk.CURRENT_TIME) + device.grab(self.get_window(), Gdk.GrabOwnership.APPLICATION, True, Gdk.EventMask.ALL_EVENTS_MASK, None, Gdk.CURRENT_TIME) + + self.present() return False - def _ungrab_devices(self): + def _ungrabDevices(self): for device in self.deviceManager.list_devices(Gdk.DeviceType.MASTER): device.ungrab(Gdk.CURRENT_TIME) def lock(self): - self.show_all() - self.unlockWindow.show_all() + #geom = Gdk.Geometry() + #geom.min_width = self.screen.get_width() + #geom.max_width = self.screen.get_width() + #geom.min_height = self.screen.get_height() + #geom.max_height = self.screen.get_height() + #self.set_geometry_hints(self.overlay, geom, Gdk.WindowHints.MAX_SIZE) - self.promptEntry.grab_focus() + self.show_all() def unlock(self): - self._ungrab_devices() + self._ungrabDevices() - self.unlockWindow.hide() self.hide() - self.reset(True) |