File indexing completed on 2024-09-08 09:43:19
0001 /* 0002 SPDX-FileCopyrightText: 2001-2003 Lubos Lunak <l.lunak@kde.org> 0003 0004 SPDX-License-Identifier: MIT 0005 */ 0006 0007 #ifndef KSTARTUPINFO_H 0008 #define KSTARTUPINFO_H 0009 0010 #include <kwindowsystem_export.h> 0011 0012 #include <QChildEvent> 0013 #include <QObject> 0014 #include <QString> 0015 #include <QWidgetList> // for WId 0016 #include <QWindow> 0017 0018 #include <sys/types.h> 0019 0020 typedef struct _XDisplay Display; 0021 0022 struct xcb_connection_t; 0023 0024 #ifdef Q_CC_MSVC 0025 typedef int pid_t; 0026 #endif 0027 0028 class KStartupInfoId; 0029 class KStartupInfoData; 0030 0031 /** 0032 * Class for manipulating the application startup notification. 0033 * 0034 * This class can be used to send information about started application, 0035 * change the information and receive this information. For detailed 0036 * description, see kdelibs/kdecore/README.kstartupinfo. 0037 * 0038 * You usually don't need to use this class for sending the notification 0039 * information, as KDE libraries should do this when an application is 0040 * started (e.g. KRun class). 0041 * 0042 * For receiving the startup notification info, create an instance and connect 0043 * to its slots. It will automatically detect started applications and when 0044 * they are ready. 0045 * 0046 * @see KStartupInfoId 0047 * @see KStartupInfoData 0048 * 0049 * @author Lubos Lunak <l.lunak@kde.org> 0050 */ 0051 class KWINDOWSYSTEM_EXPORT KStartupInfo : public QObject 0052 { 0053 Q_OBJECT 0054 public: 0055 /** 0056 * Manual notification that the application has started. 0057 * If you do not map a (toplevel) window, then startup 0058 * notification will not disappear for the application 0059 * until a timeout. You can use this as an alternative 0060 * method in this case. 0061 */ 0062 static void appStarted(); 0063 0064 /** 0065 * Sends explicit notification that the startup notification 0066 * with id startup_id should end. 0067 */ 0068 static void appStarted(const QByteArray &startup_id); 0069 0070 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 102) 0071 /** 0072 * Returns the startup ID set by setStartupId(). 0073 * @return the startup notification identifier 0074 * 0075 * @warning This does not give access to the startup ID the app was launched with. 0076 * Use QX11Info::nextStartupId() to get that. 0077 * 0078 * @deprecated since 5.102, use QX11Info::nextStartupId(). 0079 */ 0080 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 102, "Use QX11Info::nextStartupId()") 0081 static QByteArray startupId(); 0082 #endif 0083 0084 /** 0085 * Sets a new value for the application startup notification window property for newly 0086 * created toplevel windows. 0087 * @param startup_id the startup notification identifier 0088 * @see KStartupInfo::setNewStartupId 0089 */ 0090 static void setStartupId(const QByteArray &startup_id); 0091 0092 /** 0093 * Use this function if the application got a request with startup 0094 * notification from outside (for example, when KUniqueApplication::newInstance() 0095 * is called, or e.g.\ when khelpcenter opens new URL in its window). 0096 * The window can be either an already existing and visible window, 0097 * or a new one, before being shown. Note that this function is usually 0098 * needed only when a window is reused. 0099 */ 0100 static void setNewStartupId(QWindow *window, const QByteArray &startup_id); 0101 0102 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 62) 0103 /** 0104 * Use this function if the application got a request with startup 0105 * notification from outside (for example, when KUniqueApplication::newInstance() 0106 * is called, or e.g.\ when khelpcenter opens new URL in its window). 0107 * The window can be either an already existing and visible window, 0108 * or a new one, before being shown. Note that this function is usually 0109 * needed only when a window is reused. 0110 * @deprecated since 5.62, use setNewStartupId(QWindow *) instead 0111 * Note: if all you have is a QWidget*, you might need to call 0112 * setAttribute(Qt::WA_NativeWindow, true); before calling window()->windowHandle(). 0113 */ 0114 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 62, "Use KStartupInfo::setNewStartupId(QWindow*)") 0115 static void setNewStartupId(QWidget *window, const QByteArray &startup_id); 0116 #endif 0117 0118 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 102) 0119 /** 0120 * If your application shows temporarily some window during its startup, 0121 * for example a dialog, and only after closing it shows the main window, 0122 * startup notification would normally be shown while the dialog is visible. 0123 * To temporarily suspend and resume the notification, use this function. 0124 * Note that this is cumulative, i.e. after suspending twice, you have to 0125 * resume twice. 0126 * 0127 * @deprecated since 5.102, no known users. 0128 */ 0129 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 102, "No known users") 0130 static void silenceStartup(bool silence); 0131 #endif 0132 0133 /** 0134 * Creates and returns new startup id. The id includes properly setup 0135 * user timestamp. 0136 * 0137 * On the X11 platform the current timestamp will be fetched from the 0138 * X-Server. If the caller has an adaquat timestamp (e.g. from a QMouseEvent) 0139 * it should prefer using createNewStartupIdForTimestamp to not trigger a 0140 * roundtrip to the X-Server 0141 * 0142 * @see createNewStartupIdForTimestamp 0143 */ 0144 static QByteArray createNewStartupId(); 0145 /** 0146 * Creates and returns new startup id with @p timestamp as user timestamp part. 0147 * 0148 * @param timestamp The timestamp for the startup id. 0149 * @see createNewStartupId 0150 * @since 5.5 0151 **/ 0152 static QByteArray createNewStartupIdForTimestamp(quint32 timestamp); 0153 /** 0154 * 0155 */ 0156 enum { 0157 CleanOnCantDetect = 1 << 0, 0158 DisableKWinModule = 1 << 1, 0159 AnnounceSilenceChanges = 1 << 2, 0160 }; 0161 0162 /** 0163 * Creates an instance that will receive the startup notifications. 0164 * The various flags passed may be 0165 * @li CleanOnCantDetect - when a new unknown window appears, all startup 0166 * notifications for applications that are not compliant with 0167 * the startup protocol are removed 0168 * @li DisableKWinModule - KWinModule, which is normally used to detect 0169 * new windows, is disabled. With this flag, checkStartup() must be 0170 * called in order to check newly mapped windows. 0171 * @li AnnounceSilenceChanges - normally, startup notifications are 0172 * "removed" when they're silenced, and "recreated" when they're resumed. 0173 * With this flag, the change is normally announced with gotStartupChange(). 0174 * 0175 * @param flags OR-ed combination of flags 0176 * @param parent the parent of this QObject (can be @c nullptr for no parent) 0177 * 0178 */ 0179 explicit KStartupInfo(int flags, QObject *parent = nullptr); 0180 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0181 /** 0182 * Creates an instance that will receive the startup notifications. 0183 * 0184 * @param clean_on_cantdetect if true, and a new unknown window appears, 0185 * removes all notification for applications that are not compliant 0186 * with the app startup protocol 0187 * @param parent the parent of this QObject (can be @c nullptr for no parent) 0188 * 0189 * @deprecated since 5.0 0190 */ 0191 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KStartupInfo(int, QObject *)") 0192 explicit KStartupInfo(bool clean_on_cantdetect, QObject *parent = nullptr); 0193 #endif 0194 ~KStartupInfo() override; 0195 /** 0196 * Sends given notification data about started application 0197 * with the given startup identification. If no notification for this identification 0198 * exists yet, it is created, otherwise it's updated. Note that the name field 0199 * in data is required. 0200 * 0201 * @param id the id of the application 0202 * @param data the application's data 0203 * @return true if successful, false otherwise 0204 * @see KStartupInfoId 0205 * @see KStartupInfoData 0206 */ 0207 static bool sendStartup(const KStartupInfoId &id, const KStartupInfoData &data); 0208 0209 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18) 0210 /** 0211 * Like sendStartup , uses dpy instead of qt_x11display() for sending the info. 0212 * @param dpy the display of the application. Note that the name field 0213 * in data is required. 0214 * @param id the id of the application 0215 * @param data the application's data 0216 * @return true if successful, false otherwise 0217 * @deprecated since 5.18 use sendStartupXcb 0218 */ 0219 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendStartupXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)") 0220 static bool sendStartupX(Display *dpy, const KStartupInfoId &id, const KStartupInfoData &data); 0221 #endif 0222 0223 /** 0224 * Like sendStartup , uses @p conn instead of QX11Info::connection() for sending the info. 0225 * @param conn the xcb connection of the application. Note that the name field 0226 * in data is required. 0227 * @param screen The x11 screen the connection belongs to 0228 * @param id the id of the application 0229 * @param data the application's data 0230 * @return true if successful, false otherwise 0231 * @since 5.18 0232 */ 0233 static bool sendStartupXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data); 0234 0235 /** 0236 * Sends given notification data about started application 0237 * with the given startup identification. This is used for updating the notification 0238 * info, if no notification for this identification exists, it's ignored. 0239 * @param id the id of the application 0240 * @param data the application's data 0241 * @return true if successful, false otherwise 0242 * @see KStartupInfoId 0243 * @see KStartupInfoData 0244 */ 0245 static bool sendChange(const KStartupInfoId &id, const KStartupInfoData &data); 0246 0247 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18) 0248 /** 0249 * Like sendChange , uses dpy instead of qt_x11display() for sending the info. 0250 * @param dpy the display of the application. 0251 * @param id the id of the application 0252 * @param data the application's data 0253 * @return true if successful, false otherwise 0254 * @deprecated since 5.18 use sendChangeXcb 0255 */ 0256 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendChangeXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)") 0257 static bool sendChangeX(Display *dpy, const KStartupInfoId &id, const KStartupInfoData &data); 0258 #endif 0259 0260 /** 0261 * Like sendChange , uses @p conn instead of QX11Info::connection() for sending the info. 0262 * @param conn the xcb connection of the application. 0263 * @param screen The x11 screen the connection belongs to 0264 * @param id the id of the application 0265 * @param data the application's data 0266 * @return true if successful, false otherwise 0267 * @since 5.18 0268 */ 0269 static bool sendChangeXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data); 0270 0271 /** 0272 * Ends startup notification with the given identification. 0273 * @param id the id of the application 0274 * @return true if successful, false otherwise 0275 */ 0276 static bool sendFinish(const KStartupInfoId &id); 0277 0278 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18) 0279 /** 0280 * Like sendFinish , uses dpy instead of qt_x11display() for sending the info. 0281 * @param dpy the display of the application. 0282 * @param id the id of the application 0283 * @return true if successful, false otherwise 0284 * @deprecated since 5.18 use sendFinishXcb 0285 */ 0286 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendFinishXcb(xcb_connection_t *, int, const KStartupInfoId &)") 0287 static bool sendFinishX(Display *dpy, const KStartupInfoId &id); 0288 #endif 0289 0290 /** 0291 * Like sendFinish , uses @p conn instead of QX11Info::connection() for sending the info. 0292 * @param conn the xcb connection of the application. 0293 * @param screen The x11 screen the connection belongs to 0294 * @param id the id of the application 0295 * @return true if successful, false otherwise 0296 * @since 5.18 0297 */ 0298 static bool sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id); 0299 0300 /** 0301 * Ends startup notification with the given identification and the given data 0302 * (e.g.\ PIDs of processes for this startup notification that exited). 0303 * @param id the id of the application 0304 * @param data the application's data 0305 * @return true if successful, false otherwise 0306 */ 0307 static bool sendFinish(const KStartupInfoId &id, const KStartupInfoData &data); 0308 0309 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18) 0310 /** 0311 * Like sendFinish , uses dpy instead of qt_x11display() for sending the info. 0312 * @param dpy the display of the application. 0313 * @param id the id of the application 0314 * @param data the application's data 0315 * @return true if successful, false otherwise 0316 * @deprecated since 5.18 use sendFinishXcb 0317 */ 0318 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendFinishXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)") 0319 static bool sendFinishX(Display *dpy, const KStartupInfoId &id, const KStartupInfoData &data); 0320 #endif 0321 0322 /** 0323 * Like sendFinish , uses @p conn instead of QX11Info::connection() for sending the info. 0324 * @param conn the xcb connection of the application. 0325 * @param screen The x11 screen the connection belongs to 0326 * @param id the id of the application 0327 * @param data the application's data 0328 * @return true if successful, false otherwise 0329 * @since 5.18 0330 */ 0331 static bool sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id, const KStartupInfoData &data); 0332 0333 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 104) 0334 /** 0335 * Returns the current startup notification identification for the current 0336 * startup notification environment variable. Note that QApplication constructor 0337 * unsets the variable and you have to use QX11Info::nextStartupId() . 0338 * @return the current startup notification identification 0339 * 0340 * @deprecated since 5.104, use QX11Info::nextStartupId(). 0341 */ 0342 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 104, "Use QX11Info::nextStartupId()") 0343 static KStartupInfoId currentStartupIdEnv(); 0344 #endif 0345 0346 /** 0347 * Unsets the startup notification environment variable. 0348 */ 0349 static void resetStartupEnv(); 0350 /** 0351 * @li NoMatch - the window doesn't match any existing startup notification 0352 * @li Match - the window matches an existing startup notification 0353 * @li CantDetect - unable to detect if the window matches any existing 0354 * startup notification 0355 */ 0356 enum startup_t { NoMatch, Match, CantDetect }; 0357 /** 0358 * Checks if the given windows matches any existing startup notification. 0359 * @param w the window id to check 0360 * @return the result of the operation 0361 */ 0362 startup_t checkStartup(WId w); 0363 /** 0364 * Checks if the given windows matches any existing startup notification, and 0365 * if yes, returns the identification in id. 0366 * @param w the window id to check 0367 * @param id if found, the id of the startup notification will be written here 0368 * @return the result of the operation 0369 */ 0370 startup_t checkStartup(WId w, KStartupInfoId &id); 0371 /** 0372 * Checks if the given windows matches any existing startup notification, and 0373 * if yes, returns the notification data in data. 0374 * @param w the window id to check 0375 * @param data if found, the data of the startup notification will be written here 0376 * @return the result of the operation 0377 */ 0378 startup_t checkStartup(WId w, KStartupInfoData &data); 0379 /** 0380 * Checks if the given windows matches any existing startup notification, and 0381 * if yes, returns the identification in id and notification data in data. 0382 * @param w the window id to check 0383 * @param id if found, the id of the startup notification will be written here 0384 * @param data if found, the data of the startup notification will be written here 0385 * @return the result of the operation 0386 */ 0387 startup_t checkStartup(WId w, KStartupInfoId &id, KStartupInfoData &data); 0388 /** 0389 * Sets the timeout for notifications, after this timeout a notification is removed. 0390 * @param secs the new timeout in seconds 0391 */ 0392 void setTimeout(unsigned int secs); 0393 0394 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 104) 0395 /** 0396 * Sets the startup notification window property on the given window. 0397 * @param window the id of the window 0398 * @param id the startup notification id 0399 * 0400 * @deprecated since 5.104 0401 */ 0402 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 104, "Use setNewStartupId()") 0403 static void setWindowStartupId(WId window, const QByteArray &id); 0404 #endif 0405 0406 /** 0407 * Returns startup notification identification of the given window. 0408 * @param w the id of the window 0409 * @return the startup notification id. Can be null if not found. 0410 */ 0411 static QByteArray windowStartupId(WId w); 0412 /** 0413 * @internal 0414 */ 0415 class Data; 0416 0417 /** 0418 * @internal 0419 */ 0420 class Private; 0421 Q_SIGNALS: 0422 /** 0423 * Emitted when a new startup notification is created (i.e.\ a new application is 0424 * being started). 0425 * @param id the notification identification 0426 * @param data the notification data 0427 */ 0428 void gotNewStartup(const KStartupInfoId &id, const KStartupInfoData &data); 0429 /** 0430 * Emitted when a startup notification changes. 0431 * @param id the notification identification 0432 * @param data the notification data 0433 */ 0434 void gotStartupChange(const KStartupInfoId &id, const KStartupInfoData &data); 0435 /** 0436 * Emitted when a startup notification is removed (either because it was detected 0437 * that the application is ready or because of a timeout). 0438 * @param id the notification identification 0439 * @param data the notification data 0440 */ 0441 void gotRemoveStartup(const KStartupInfoId &id, const KStartupInfoData &data); 0442 0443 protected: 0444 /** 0445 * 0446 */ 0447 void customEvent(QEvent *e_P) override; 0448 0449 private: 0450 Q_PRIVATE_SLOT(d, void startups_cleanup()) 0451 Q_PRIVATE_SLOT(d, void startups_cleanup_no_age()) 0452 Q_PRIVATE_SLOT(d, void got_message(const QString &msg)) 0453 Q_PRIVATE_SLOT(d, void window_added(WId w)) 0454 Q_PRIVATE_SLOT(d, void slot_window_added(WId w)) 0455 0456 Private *const d; 0457 0458 Q_DISABLE_COPY(KStartupInfo) 0459 }; 0460 0461 /** 0462 * Class representing an identification of application startup notification. 0463 * 0464 * Every existing notification about a starting application has its own unique 0465 * identification, that's used to identify and manipulate the notification. 0466 * 0467 * @see KStartupInfo 0468 * @see KStartupInfoData 0469 * 0470 * @author Lubos Lunak <l.lunak@kde.org> 0471 */ 0472 class KWINDOWSYSTEM_EXPORT KStartupInfoId 0473 { 0474 public: 0475 /** 0476 * Overloaded operator. 0477 * @return true if the notification identifications are the same 0478 */ 0479 bool operator==(const KStartupInfoId &id) const; 0480 /** 0481 * Overloaded operator. 0482 * @return true if the notification identifications are different 0483 */ 0484 bool operator!=(const KStartupInfoId &id) const; 0485 /** 0486 * Checks whether the identifier is valid. 0487 * @return true if this object doesn't represent a valid notification identification 0488 */ 0489 bool isNull() const; 0490 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0) 0491 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KStartupInfoId::isNull()") 0492 bool none() const 0493 { 0494 return isNull(); 0495 } 0496 #endif 0497 0498 /** 0499 * Initializes this object with the given identification ( which may be also "0" 0500 * for no notification ), or if "" is given, tries to read it from the startup 0501 * notification environment variable, and if it's not set, creates a new one. 0502 * @param id the new identification, "0" for no notification or "" to read 0503 * the environment variable 0504 */ 0505 void initId(const QByteArray &id = ""); 0506 /** 0507 * Returns the notification identifier as string. 0508 * @return the identification string for the notification 0509 */ 0510 const QByteArray &id() const; 0511 /** 0512 * Return the user timestamp for the startup notification, or 0 if no timestamp 0513 * is set. 0514 */ 0515 unsigned long timestamp() const; 0516 /** 0517 * Sets the startup notification environment variable to this identification. 0518 * @return true if successful, false otherwise 0519 */ 0520 bool setupStartupEnv() const; 0521 /** 0522 * Creates an empty identification 0523 */ 0524 KStartupInfoId(); 0525 /** 0526 * Copy constructor. 0527 */ 0528 KStartupInfoId(const KStartupInfoId &data); 0529 ~KStartupInfoId(); 0530 KStartupInfoId &operator=(const KStartupInfoId &data); 0531 bool operator<(const KStartupInfoId &id) const; 0532 0533 private: 0534 explicit KStartupInfoId(const QString &txt); 0535 friend class KStartupInfo; 0536 friend class KStartupInfo::Private; 0537 struct Private; 0538 Private *const d; 0539 }; 0540 0541 /** 0542 * Class representing data about an application startup notification. 0543 * 0544 * Such data include the icon of the starting application, the desktop on which 0545 * the application should start, the binary name of the application, etc. 0546 * 0547 * @see KStartupInfo 0548 * @see KStartupInfoId 0549 * 0550 * @author Lubos Lunak <l.lunak@kde.org> 0551 */ 0552 class KWINDOWSYSTEM_EXPORT KStartupInfoData 0553 { 0554 public: 0555 /** 0556 * Sets the binary name of the application (e.g.\ 'kcontrol'). 0557 * @param bin the new binary name of the application 0558 */ 0559 void setBin(const QString &bin); 0560 /** 0561 * Returns the binary name of the starting application 0562 * @return the new binary name of the application 0563 */ 0564 const QString &bin() const; 0565 /** 0566 * Sets the name for the notification (e.g.\ 'Control Center'). 0567 */ 0568 void setName(const QString &name); 0569 /** 0570 * Returns the name of the startup notification. If it's not available, 0571 * it tries to use other information (binary name). 0572 * @return the name of the startup notification 0573 */ 0574 const QString &findName() const; 0575 /** 0576 * Returns the name of the startup notification, or empty if not available. 0577 * @return the name of the startup notification, or an empty string 0578 * if not set. 0579 */ 0580 const QString &name() const; 0581 /** 0582 * Sets the description for the notification (e.g.\ 'Launching Control Center'). 0583 * I.e. name() describes what is being started, while description() is 0584 * the actual action performed by the starting. 0585 */ 0586 void setDescription(const QString &descr); 0587 /** 0588 * Returns the description of the startup notification. If it's not available, 0589 * it returns name(). 0590 * @return the description of the startup notification 0591 */ 0592 const QString &findDescription() const; 0593 /** 0594 * Returns the name of the startup notification, or empty if not available. 0595 * @return the name of the startup notification, or an empty string 0596 * if not set. 0597 */ 0598 const QString &description() const; 0599 /** 0600 * Sets the icon for the startup notification (e.g.\ 'kcontrol'). 0601 * @param icon the name of the icon 0602 */ 0603 void setIcon(const QString &icon); 0604 /** 0605 * Returns the icon of the startup notification, and if it's not available, 0606 * tries to get it from the binary name. 0607 * @return the name of the startup notification's icon, or the name of 0608 * the binary if not set 0609 */ 0610 const QString &findIcon() const; 0611 /** 0612 * Returns the icon of the startup notification, or empty if not available. 0613 * @return the name of the icon, or an empty string if not set. 0614 */ 0615 const QString &icon() const; 0616 /** 0617 * Sets the desktop for the startup notification (i.e.\ the desktop on which 0618 * the starting application should appear ). 0619 * @param desktop the desktop for the startup notification 0620 */ 0621 void setDesktop(int desktop); 0622 /** 0623 * Returns the desktop for the startup notification. 0624 * @return the desktop for the startup notification 0625 */ 0626 int desktop() const; 0627 /** 0628 * Sets a WM_CLASS value for the startup notification, it may be used for increasing 0629 * the chance that the windows created by the starting application will be 0630 * detected correctly. 0631 * @param wmclass the WM_CLASS value for the startup notification 0632 */ 0633 void setWMClass(const QByteArray &wmclass); 0634 /** 0635 * Returns the WM_CLASS value for the startup notification, or binary name if not 0636 * available. 0637 * @return the WM_CLASS value for the startup notification, or the binary name 0638 * if not set 0639 */ 0640 const QByteArray findWMClass() const; 0641 /** 0642 * Returns the WM_CLASS value for the startup notification, or empty if not available. 0643 * @return the WM_CLASS value for the startup notification, or empty 0644 * if not set 0645 */ 0646 QByteArray WMClass() const; 0647 /** 0648 * Adds a PID to the list of processes that belong to the startup notification. It 0649 * may be used to increase the chance that the windows created by the starting 0650 * application will be detected correctly, and also for detecting if the application 0651 * has quit without creating any window. 0652 * @param pid the PID to add 0653 */ 0654 void addPid(pid_t pid); 0655 /** 0656 * Returns all PIDs for the startup notification. 0657 * @return the list of all PIDs 0658 */ 0659 QList<pid_t> pids() const; 0660 /** 0661 * Checks whether the given @p pid is in the list of PIDs for startup 0662 * notification. 0663 * @return true if the given @p pid is in the list of PIDs for the startup notification 0664 */ 0665 bool is_pid(pid_t pid) const; 0666 /** 0667 * Sets the hostname on which the application is starting. It's necessary to set 0668 * it if PIDs are set. 0669 * @param hostname the application's hostname. If it's a null string, the current hostname is used 0670 */ 0671 void setHostname(const QByteArray &hostname = QByteArray()); 0672 /** 0673 * Returns the hostname for the startup notification. 0674 * @return the hostname 0675 */ 0676 QByteArray hostname() const; 0677 0678 /** 0679 * 0680 */ 0681 enum TriState { Yes, No, Unknown }; 0682 0683 /** 0684 * Sets whether the visual feedback for this startup notification 0685 * should be silenced (temporarily suspended). 0686 */ 0687 void setSilent(TriState state); 0688 0689 /** 0690 * Return the silence status for the startup notification. 0691 * @return KStartupInfoData::Yes if visual feedback is silenced 0692 */ 0693 TriState silent() const; 0694 0695 /** 0696 * The X11 screen on which the startup notification is happening, -1 if unknown. 0697 */ 0698 int screen() const; 0699 0700 /** 0701 * Sets the X11 screen on which the startup notification should happen. 0702 * This is usually not necessary to set, as it's set by default to QX11Info::screen(). 0703 */ 0704 void setScreen(int screen); 0705 0706 /** 0707 * The Xinerama screen for the startup notification, -1 if unknown. 0708 */ 0709 int xinerama() const; 0710 0711 /** 0712 * Sets the Xinerama screen for the startup notification ( i.e. the screeen on which 0713 * the starting application should appear ). 0714 * @param xinerama the Xinerama screen for the startup notification 0715 */ 0716 void setXinerama(int xinerama); 0717 0718 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 69) 0719 /** 0720 * The toplevel window of the application that caused this startup notification, 0721 * 0 if unknown. 0722 * @deprecated Since 5.69. No known users. 0723 */ 0724 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 69, "Deprecated because not used anywhere. Tell kde-frameworks-devel@kde.org if you disagree") 0725 WId launchedBy() const; 0726 #endif 0727 0728 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 69) 0729 /** 0730 * Sets the toplevel window of the application that caused this startup notification. 0731 * @param window window ID of the toplevel window that is responsible for this startup 0732 * @deprecated Since 5.69. No known users of launchedBy(). 0733 */ 0734 KWINDOWSYSTEM_DEPRECATED_VERSION(5, 69, "Deprecated because launchedBy() is not used anywhere. Tell kde-frameworks-devel@kde.org if you disagree") 0735 void setLaunchedBy(WId window); 0736 #endif 0737 0738 /** 0739 * The .desktop file used to initiate this startup notification, or empty. This information 0740 * should be used only to identify the application, not to read any additional information. 0741 * @since 4.5 0742 **/ 0743 QString applicationId() const; 0744 0745 /** 0746 * Sets the .desktop file that was used to initiate the startup notification. 0747 * @since 4.5 0748 */ 0749 void setApplicationId(const QString &desktop); 0750 0751 /** 0752 * Updates the notification data from the given data. Some data, such as the desktop 0753 * or the name, won't be rewritten if already set. 0754 * @param data the data to update 0755 */ 0756 void update(const KStartupInfoData &data); 0757 0758 /** 0759 * Constructor. Initializes all the data to their default empty values. 0760 */ 0761 KStartupInfoData(); 0762 0763 /** 0764 * Copy constructor. 0765 */ 0766 KStartupInfoData(const KStartupInfoData &data); 0767 ~KStartupInfoData(); 0768 KStartupInfoData &operator=(const KStartupInfoData &data); 0769 0770 private: 0771 explicit KStartupInfoData(const QString &txt); 0772 friend class KStartupInfo; 0773 friend class KStartupInfo::Data; 0774 friend class KStartupInfo::Private; 0775 struct Private; 0776 Private *const d; 0777 }; 0778 0779 #endif