KStartupInfo Class

Class for manipulating the application startup notification. More...

Header: #include <KStartupInfo>
CMake: find_package(KF6 REQUIRED COMPONENTS KWindowSystem)
target_link_libraries(mytarget PRIVATE KF6::KWindowSystem)
Inherits: QObject

Public Types

enum startup_t { NoMatch, Match, CantDetect }

Public Functions

KStartupInfo(int flags, QObject *parent = nullptr)
KStartupInfo::startup_t checkStartup(WId w)
KStartupInfo::startup_t checkStartup(WId w, KStartupInfoData &data)
KStartupInfo::startup_t checkStartup(WId w, KStartupInfoId &id)
KStartupInfo::startup_t checkStartup(WId w, KStartupInfoId &id, KStartupInfoData &data)
void setTimeout(unsigned int secs)

Signals

void gotNewStartup(const KStartupInfoId &id, const KStartupInfoData &data)
void gotRemoveStartup(const KStartupInfoId &id, const KStartupInfoData &data)
void gotStartupChange(const KStartupInfoId &id, const KStartupInfoData &data)

Static Public Members

void appStarted()
void appStarted(const QByteArray &startup_id)
QByteArray createNewStartupId()
(since 5.5) QByteArray createNewStartupIdForTimestamp(quint32 timestamp)
void resetStartupEnv()
bool sendChange(const KStartupInfoId &id, const KStartupInfoData &data)
(since 5.18) bool sendChangeXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)
bool sendFinish(const KStartupInfoId &id)
bool sendFinish(const KStartupInfoId &id, const KStartupInfoData &data)
(since 5.18) bool sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id)
(since 5.18) bool sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)
bool sendStartup(const KStartupInfoId &id, const KStartupInfoData &data)
(since 5.18) bool sendStartupXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)
void setNewStartupId(QWindow *window, const QByteArray &startup_id)
void setStartupId(const QByteArray &startup_id)
QByteArray windowStartupId(WId w)

Detailed Description

This class can be used to send information about started application, change the information and receive this information. For detailed description, see https://invent.kde.org/frameworks/kwindowsystem/-/blob/master/docs/README.kstartupinfo.

You usually don't need to use this class for sending the notification information, as KDE libraries should do this when an application is started (e.g. KRun class).

For receiving the startup notification info, create an instance and connect to its slots. It will automatically detect started applications and when they are ready.

See also KStartupInfoId and KStartupInfoData.

Member Type Documentation

enum KStartupInfo::startup_t

ConstantValueDescription
KStartupInfo::NoMatch0The window doesn't match any existing startup notification.
KStartupInfo::Match1The window matches an existing startup notification.
KStartupInfo::CantDetect2Unable to detect if the window matches any existing startup notification.

Member Function Documentation

[explicit] KStartupInfo::KStartupInfo(int flags, QObject *parent = nullptr)

Creates an instance that will receive the startup notifications, as a child of parent.

The various flags passed may be:

ConstantDescription
CleanOnCantDetectWhen a new unknown window appears, all startup notifications for applications that are not compliant with the startup protocol are removed.
DisableKWinModuleKWinModule, which is normally used to detect new windows, is disabled. With this flag, checkStartup() must be called in order to check newly mapped windows.
AnnounceSilenceChangesNormally, startup notifications are "removed" when they're silenced, and "recreated" when they're resumed. With this flag, the change is normally announced with gotStartupChange().

[static] void KStartupInfo::appStarted()

Manual notification that the application has started.

If you do not map a (toplevel) window, then startup notification will not disappear for the application until a timeout. You can use this as an alternative method in this case.

[static] void KStartupInfo::appStarted(const QByteArray &startup_id)

Sends explicit notification that the startup notification with startup_id should end.

KStartupInfo::startup_t KStartupInfo::checkStartup(WId w)

Checks if the given window w matches any existing startup notification.

KStartupInfo::startup_t KStartupInfo::checkStartup(WId w, KStartupInfoData &data)

Checks if the given window w matches any existing startup notification, if yes, returns the notification data in data.

KStartupInfo::startup_t KStartupInfo::checkStartup(WId w, KStartupInfoId &id)

Checks if the given window w matches any existing startup notification, if yes, returns the identification in id.

KStartupInfo::startup_t KStartupInfo::checkStartup(WId w, KStartupInfoId &id, KStartupInfoData &data)

Checks if the given window w matches any existing startup notification, if yes, returns the identification in id and notification data in data.

[static] QByteArray KStartupInfo::createNewStartupId()

Creates and returns a new startup id. The id includes properly setup user timestamp.

On the X11 platform the current timestamp will be fetched from the X-Server. If the caller has an adequate timestamp (e.g. from a QMouseEvent) it should prefer using createNewStartupIdForTimestamp to not trigger a roundtrip to the X-Server.

See also createNewStartupIdForTimestamp.

[static, since 5.5] QByteArray KStartupInfo::createNewStartupIdForTimestamp(quint32 timestamp)

Creates and returns new startup id with timestamp as user timestamp part.

timestamp The timestamp for the startup id.

This function was introduced in 5.5.

See also createNewStartupId.

[signal] void KStartupInfo::gotNewStartup(const KStartupInfoId &id, const KStartupInfoData &data)

Emitted when a new startup notification is created (i.e. a new application is being started).

id The notification identification.

data The notification data.

[signal] void KStartupInfo::gotRemoveStartup(const KStartupInfoId &id, const KStartupInfoData &data)

Emitted when a startup notification is removed (either because it was detected that the application is ready or because of a timeout).

id The notification identification.

data The notification data.

[signal] void KStartupInfo::gotStartupChange(const KStartupInfoId &id, const KStartupInfoData &data)

Emitted when a startup notification changes.

id The notification identification.

data The notification data.

[static] void KStartupInfo::resetStartupEnv()

Unsets the startup notification environment variable.

[static] bool KStartupInfo::sendChange(const KStartupInfoId &id, const KStartupInfoData &data)

Sends given notification data about started application with the given startup identification.

This is used for updating the notification info, if no notification for this identification exists, it's ignored.

Returns true if successful, false otherwise.

id The id of the application.

data The application's data.

See also KStartupInfoId and KStartupInfoData.

[static, since 5.18] bool KStartupInfo::sendChangeXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)

Like sendChange, uses conn instead of QX11Info::connection() for sending the info.

Returns true if successful, false otherwise.

conn The xcb connection of the application.

screen The x11 screen the connection belongs to.

id The id of the application.

data The application's data.

This function was introduced in 5.18.

[static] bool KStartupInfo::sendFinish(const KStartupInfoId &id)

Ends startup notification with the given identification.

Returns true if successful, false otherwise

id The id of the application.

[static] bool KStartupInfo::sendFinish(const KStartupInfoId &id, const KStartupInfoData &data)

Ends startup notification with the given identification and the given data (e.g. PIDs of processes for this startup notification that exited).

Returns true if successful, false otherwise

id The id of the application.

data The application's data.

[static, since 5.18] bool KStartupInfo::sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id)

Like sendFinish , uses conn instead of QX11Info::connection() for sending the info.

Returns true if successful, false otherwise.

conn The xcb connection of the application.

screen The x11 screen the connection belongs to.

id The id of the application.

This function was introduced in 5.18.

[static, since 5.18] bool KStartupInfo::sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)

Like sendFinish , uses conn instead of QX11Info::connection() for sending the info.

Returns true if successful, false otherwise.

conn The xcb connection of the application.

screen The x11 screen the connection belongs to.

id The id of the application.

data The application's data.

This function was introduced in 5.18.

[static] bool KStartupInfo::sendStartup(const KStartupInfoId &id, const KStartupInfoData &data)

Sends given notification data about started application with the given startup identification.

If no notification for this identification exists yet, it is created, otherwise it's updated. Note that the name field in data is required.

Returns true if successful, false otherwise

id The id of the application.

data The application's data.

See also KStartupInfoId and KStartupInfoData.

[static, since 5.18] bool KStartupInfo::sendStartupXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data)

Like sendStartup, uses conn instead of QX11Info::connection() for sending the info.

Returns true if successful, false otherwise.

conn The xcb connection of the application. Note that the name field in data is required.

screen The x11 screen the connection belongs to.

id The id of the application.

data The application's data.

This function was introduced in 5.18.

[static] void KStartupInfo::setNewStartupId(QWindow *window, const QByteArray &startup_id)

Use this function if the application got a request with startup notification from outside (for example, when KUniqueApplication::newInstance() is called, or e.g. when KHelpCenter opens a new URL in its window).

The window can be either an already existing and visible window, or a new one, before being shown. Note that this function is usually needed only when a window is reused.

startup_id the startup notification identifier

[static] void KStartupInfo::setStartupId(const QByteArray &startup_id)

Sets a new value for the application startup notification window property for newly created toplevel windows.

startup_id The startup notification identifier.

See also KStartupInfo::setNewStartupId.

void KStartupInfo::setTimeout(unsigned int secs)

Sets the timeout for notifications in secs, after this timeout a notification is removed.

[static] QByteArray KStartupInfo::windowStartupId(WId w)

Returns startup notification identification of the given window w.

Returns the startup notification id. Can be null if not found.