Gtk4SessionLock.Instance

g GObject.Object GObject.Object Gtk4SessionLock.Instance Gtk4SessionLock.Instance GObject.Object->Gtk4SessionLock.Instance

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

assign_window_to_monitor (window, monitor)

is_locked ()

lock ()

unlock ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

failed

The ::failed signal is fired when the lock could not be acquired.

locked

The ::locked signal is fired when the screen is successfully locked.

monitor

The ::monitor signal is fired once for each monitor that exists when a lock is started, and then whenever a new monitor is detected during the lock.

unlocked

The ::unlocked signal is fired when the session is unlocked, which may have been caused by a call to Gtk4SessionLock.Instance.unlock() or by the compositor.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gtk4SessionLock.Instance(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gtk4SessionLock.InstanceClass

An instance of the object used to control locking the screen. Multiple instances can exist at once, but only one can be locked at a time.

New in version 1.1.

classmethod new()
Returns:

new session lock instance

Return type:

Gtk4SessionLock.Instance

assign_window_to_monitor(window, monitor)
Parameters:
  • window (Gtk.Window) – The GTK Window to use as a lock surface

  • monitor (Gdk.Monitor) – The monitor to show it on

This must be called with a different unrealized window once for each monitor immediately after calling gtk_session_lock_lock(). Hiding a window that is active on a monitor or not letting a window be resized by the library is not allowed (may result in a Wayland protocol error). The window will be unmapped and Gtk.Window.destroy() called on it when the current lock ends.

is_locked()
Return type:

bool

Returns if this instance currently holds a lock.

lock()
Returns:

false on immediate fail, true if lock acquisition was successfully started

Return type:

bool

Lock the screen. This should be called before assigning any windows to monitors. If this function fails the ::failed signal is emitted, if it succeeds the ::locked signal is emitted. The ::failed signal may be emitted before the function returns (for example, if another Gtk4SessionLock.Instance holds a lock) or later (if another process holds a lock). The only case where neither signal is triggered is if the instance is already locked.

unlock()

If the screen is locked by this instance unlocks it and fires ::unlocked. Otherwise has no effect

Signal Details

Gtk4SessionLock.Instance.signals.failed(instance)
Signal Name:

failed

Flags:

RUN_FIRST

Parameters:

instance (Gtk4SessionLock.Instance) – The object which received the signal

The ::failed signal is fired when the lock could not be acquired.

Gtk4SessionLock.Instance.signals.locked(instance)
Signal Name:

locked

Flags:

RUN_FIRST

Parameters:

instance (Gtk4SessionLock.Instance) – The object which received the signal

The ::locked signal is fired when the screen is successfully locked.

Gtk4SessionLock.Instance.signals.monitor(instance, monitor)
Signal Name:

monitor

Flags:

RUN_FIRST

Parameters:

The ::monitor signal is fired once for each monitor that exists when a lock is started, and then whenever a new monitor is detected during the lock. You generally want to call Gtk4SessionLock.Instance.assign_window_to_monitor() once in the handler for this signal with a newly created window and the given monitor.

This API does not directly tell you when a monitor is removed (GTK APIs can be used for that), however the window you send to Gtk4SessionLock.Instance.assign_window_to_monitor() will be automatically unmapped and dereferenced when its monitor is removed or the screen is unlocked.

New in version 1.2.

Gtk4SessionLock.Instance.signals.unlocked(instance)
Signal Name:

unlocked

Flags:

RUN_FIRST

Parameters:

instance (Gtk4SessionLock.Instance) – The object which received the signal

The ::unlocked signal is fired when the session is unlocked, which may have been caused by a call to Gtk4SessionLock.Instance.unlock() or by the compositor.