KWindowSystem

kstartupinfo.h
1 /*
2  SPDX-FileCopyrightText: 2001-2003 Lubos Lunak <[email protected]>
3 
4  SPDX-License-Identifier: MIT
5 */
6 
7 #ifndef KSTARTUPINFO_H
8 #define KSTARTUPINFO_H
9 
10 #include <kwindowsystem_export.h>
11 
12 #include <QObject>
13 #include <QString>
14 #include <QChildEvent>
15 #include <QWidgetList> // for WId
16 #include <QWindow>
17 
18 #include <sys/types.h>
19 
20 typedef struct _XDisplay Display;
21 
22 struct xcb_connection_t;
23 
24 #ifdef Q_CC_MSVC
25 typedef int pid_t;
26 #endif
27 
28 class KStartupInfoId;
29 class KStartupInfoData;
30 
51 class KWINDOWSYSTEM_EXPORT KStartupInfo
52  : public QObject
53 {
54  Q_OBJECT
55 public:
56 
64  static void appStarted();
65 
70  static void appStarted(const QByteArray &startup_id);
71 
77  static QByteArray startupId();
78 
85  static void setStartupId(const QByteArray &startup_id);
86 
95  static void setNewStartupId(QWindow *window, const QByteArray &startup_id);
96 
97 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 62)
98 
109  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 62, "Use KStartupInfo::setNewStartupId(QWindow*)")
110  static void setNewStartupId(QWidget *window, const QByteArray &startup_id);
111 #endif
112 
121  static void silenceStartup(bool silence);
122 
134  static QByteArray createNewStartupId();
142  static QByteArray createNewStartupIdForTimestamp(quint32 timestamp);
146  enum {
147  CleanOnCantDetect = 1 << 0,
148  DisableKWinModule = 1 << 1,
149  AnnounceSilenceChanges = 1 << 2
150  };
151 
169  explicit KStartupInfo(int flags, QObject *parent = nullptr);
170 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
171 
182  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KStartupInfo(int, QObject *)")
183  explicit KStartupInfo(bool clean_on_cantdetect, QObject *parent = nullptr);
184 #endif
185  ~KStartupInfo() override;
198  static bool sendStartup(const KStartupInfoId &id, const KStartupInfoData &data);
199 
200 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18)
201 
210  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendStartupXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)")
211  static bool sendStartupX(Display *dpy, const KStartupInfoId &id,
212  const KStartupInfoData &data);
213 #endif
214 
225  static bool sendStartupXcb(xcb_connection_t *conn, int screen,
226  const KStartupInfoId &id, const KStartupInfoData &data);
227 
238  static bool sendChange(const KStartupInfoId &id, const KStartupInfoData &data);
239 
240 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18)
241 
249  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendChangeXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)")
250  static bool sendChangeX(Display *dpy, const KStartupInfoId &id,
251  const KStartupInfoData &data);
252 #endif
253 
263  static bool sendChangeXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id,
264  const KStartupInfoData &data);
265 
271  static bool sendFinish(const KStartupInfoId &id);
272 
273 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18)
274 
281  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendFinishXcb(xcb_connection_t *, int, const KStartupInfoId &)")
282  static bool sendFinishX(Display *dpy, const KStartupInfoId &id);
283 #endif
284 
293  static bool sendFinishXcb(xcb_connection_t *conn, int screen, const KStartupInfoId &id);
294 
302  static bool sendFinish(const KStartupInfoId &id, const KStartupInfoData &data);
303 
304 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 18)
305 
313  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 18, "Use KStartupInfo::sendFinishXcb(xcb_connection_t *, int, const KStartupInfoId &, const KStartupInfoData &)")
314  static bool sendFinishX(Display *dpy, const KStartupInfoId &id,
315  const KStartupInfoData &data);
316 #endif
317 
327  static bool sendFinishXcb(xcb_connection_t *conn, int screen,
328  const KStartupInfoId &id, const KStartupInfoData &data);
329 
336  static KStartupInfoId currentStartupIdEnv();
340  static void resetStartupEnv();
347  enum startup_t { NoMatch, Match, CantDetect };
353  startup_t checkStartup(WId w);
361  startup_t checkStartup(WId w, KStartupInfoId &id);
369  startup_t checkStartup(WId w, KStartupInfoData &data);
378  startup_t checkStartup(WId w, KStartupInfoId &id, KStartupInfoData &data);
383  void setTimeout(unsigned int secs);
389  static void setWindowStartupId(WId window, const QByteArray &id);
395  static QByteArray windowStartupId(WId w);
399  class Data;
400 
404  class Private;
405 Q_SIGNALS:
412  void gotNewStartup(const KStartupInfoId &id, const KStartupInfoData &data);
418  void gotStartupChange(const KStartupInfoId &id, const KStartupInfoData &data);
425  void gotRemoveStartup(const KStartupInfoId &id, const KStartupInfoData &data);
426 
427 protected:
431  void customEvent(QEvent *e_P) override;
432 
433 private:
434  Q_PRIVATE_SLOT(d, void startups_cleanup())
435  Q_PRIVATE_SLOT(d, void startups_cleanup_no_age())
436  Q_PRIVATE_SLOT(d, void got_message(const QString &msg))
437  Q_PRIVATE_SLOT(d, void window_added(WId w))
438  Q_PRIVATE_SLOT(d, void slot_window_added(WId w))
439 
440  Private *const d;
441 
443 };
444 
456 class KWINDOWSYSTEM_EXPORT KStartupInfoId
457 {
458 public:
463  bool operator==(const KStartupInfoId &id) const;
468  bool operator!=(const KStartupInfoId &id) const;
473  bool isNull() const;
474 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 0)
475  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 0, "Use KStartupInfoId::isNull()")
476  bool none() const { return isNull(); }
477 #endif
478 
486  void initId(const QByteArray &id = "");
491  const QByteArray &id() const;
496  unsigned long timestamp() const;
501  bool setupStartupEnv() const;
505  KStartupInfoId();
509  KStartupInfoId(const KStartupInfoId &data);
510  ~KStartupInfoId();
511  KStartupInfoId &operator=(const KStartupInfoId &data);
512  bool operator<(const KStartupInfoId &id) const;
513 private:
514  explicit KStartupInfoId(const QString &txt);
515  friend class KStartupInfo;
516  friend class KStartupInfo::Private;
517  struct Private;
518  Private *const d;
519 };
520 
532 class KWINDOWSYSTEM_EXPORT KStartupInfoData
533 {
534 public:
539  void setBin(const QString &bin);
544  const QString &bin() const;
548  void setName(const QString &name);
554  const QString &findName() const;
560  const QString &name() const;
566  void setDescription(const QString &descr);
572  const QString &findDescription() const;
578  const QString &description() const;
583  void setIcon(const QString &icon);
590  const QString &findIcon() const;
595  const QString &icon() const;
601  void setDesktop(int desktop);
606  int desktop() const;
613  void setWMClass(const QByteArray &wmclass);
620  const QByteArray findWMClass() const;
626  QByteArray WMClass() const;
634  void addPid(pid_t pid);
639  QList< pid_t > pids() const;
645  bool is_pid(pid_t pid) const;
651  void setHostname(const QByteArray &hostname = QByteArray());
656  QByteArray hostname() const;
657 
661  enum TriState { Yes, No, Unknown };
662 
667  void setSilent(TriState state);
668 
673  TriState silent() const;
674 
678  int screen() const;
679 
684  void setScreen(int screen);
685 
689  int xinerama() const;
690 
696  void setXinerama(int xinerama);
697 
698 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 69)
699 
704  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 69, "Deprecated because not used anywhere. Tell [email protected] if you disagree")
705  WId launchedBy() const;
706 #endif
707 
708 #if KWINDOWSYSTEM_ENABLE_DEPRECATED_SINCE(5, 69)
709 
714  KWINDOWSYSTEM_DEPRECATED_VERSION(5, 69, "Deprecated because launchedBy() is not used anywhere. Tell [email protected] if you disagree")
715  void setLaunchedBy(WId window);
716 #endif
717 
723  QString applicationId() const;
724 
729  void setApplicationId(const QString &desktop);
730 
736  void update(const KStartupInfoData &data);
737 
742 
746  KStartupInfoData(const KStartupInfoData &data);
747  ~KStartupInfoData();
748  KStartupInfoData &operator=(const KStartupInfoData &data);
749 private:
750  explicit KStartupInfoData(const QString &txt);
751  friend class KStartupInfo;
752  friend class KStartupInfo::Data;
753  friend class KStartupInfo::Private;
754  struct Private;
755  Private *const d;
756 };
757 
758 #endif
759 
Class for manipulating the application startup notification.
Definition: kstartupinfo.h:51
Class representing an identification of application startup notification.
Definition: kstartupinfo.h:456
Class representing data about an application startup notification.
Definition: kstartupinfo.h:532
virtual void customEvent(QEvent *event)
Q_DISABLE_COPY(Class)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Aug 14 2020 22:40:18 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.