Changeset View
Changeset View
Standalone View
Standalone View
toplevel.h
Show First 20 Lines • Show All 204 Lines • ▼ Show 20 Line(s) | 73 | { | |||
---|---|---|---|---|---|
205 | Q_PROPERTY(quint32 surfaceId READ surfaceId NOTIFY surfaceIdChanged) | 205 | Q_PROPERTY(quint32 surfaceId READ surfaceId NOTIFY surfaceIdChanged) | ||
206 | 206 | | |||
207 | /** | 207 | /** | ||
208 | * Interface to the Wayland Surface. | 208 | * Interface to the Wayland Surface. | ||
209 | * Relevant only in Wayland, in X11 it will be nullptr | 209 | * Relevant only in Wayland, in X11 it will be nullptr | ||
210 | */ | 210 | */ | ||
211 | Q_PROPERTY(KWayland::Server::SurfaceInterface *surface READ surface) | 211 | Q_PROPERTY(KWayland::Server::SurfaceInterface *surface READ surface) | ||
212 | 212 | | |||
213 | /** | ||||
214 | * Whether the window is a popup. | ||||
215 | **/ | ||||
216 | Q_PROPERTY(bool popupWindow READ isPopupWindow) | ||||
217 | | ||||
213 | public: | 218 | public: | ||
214 | explicit Toplevel(); | 219 | explicit Toplevel(); | ||
215 | virtual xcb_window_t frameId() const; | 220 | virtual xcb_window_t frameId() const; | ||
216 | xcb_window_t window() const; | 221 | xcb_window_t window() const; | ||
217 | /** | 222 | /** | ||
218 | * @return a unique identifier for the Toplevel. On X11 same as @link {window} | 223 | * @return a unique identifier for the Toplevel. On X11 same as @link {window} | ||
219 | **/ | 224 | **/ | ||
220 | virtual quint32 windowId() const; | 225 | virtual quint32 windowId() const; | ||
▲ Show 20 Lines • Show All 217 Lines • ▼ Show 20 Line(s) | |||||
438 | * a subclass type of Toplevel. | 443 | * a subclass type of Toplevel. | ||
439 | * @param list The list to search in | 444 | * @param list The list to search in | ||
440 | * @param func The condition function (compare std::find_if) | 445 | * @param func The condition function (compare std::find_if) | ||
441 | * @return T* The found Toplevel or @c null if there is no matching Toplevel | 446 | * @return T* The found Toplevel or @c null if there is no matching Toplevel | ||
442 | */ | 447 | */ | ||
443 | template <class T, class U> | 448 | template <class T, class U> | ||
444 | static T *findInList(const QList<T*> &list, std::function<bool (const U*)> func); | 449 | static T *findInList(const QList<T*> &list, std::function<bool (const U*)> func); | ||
445 | 450 | | |||
451 | /** | ||||
452 | * Whether the window is a popup. | ||||
453 | * | ||||
454 | * Popups can be used to implement popup menus, tooltips, combo boxes, etc. | ||||
455 | * | ||||
456 | * @since 5.15 | ||||
457 | **/ | ||||
458 | virtual bool isPopupWindow() const; | ||||
459 | | ||||
446 | Q_SIGNALS: | 460 | Q_SIGNALS: | ||
447 | void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); | 461 | void opacityChanged(KWin::Toplevel* toplevel, qreal oldOpacity); | ||
448 | void damaged(KWin::Toplevel* toplevel, const QRect& damage); | 462 | void damaged(KWin::Toplevel* toplevel, const QRect& damage); | ||
449 | void geometryChanged(); | 463 | void geometryChanged(); | ||
450 | void geometryShapeChanged(KWin::Toplevel* toplevel, const QRect& old); | 464 | void geometryShapeChanged(KWin::Toplevel* toplevel, const QRect& old); | ||
451 | void paddingChanged(KWin::Toplevel* toplevel, const QRect& old); | 465 | void paddingChanged(KWin::Toplevel* toplevel, const QRect& old); | ||
452 | void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted); | 466 | void windowClosed(KWin::Toplevel* toplevel, KWin::Deleted* deleted); | ||
453 | void windowShown(KWin::Toplevel* toplevel); | 467 | void windowShown(KWin::Toplevel* toplevel); | ||
▲ Show 20 Lines • Show All 387 Lines • ▼ Show 20 Line(s) | 854 | static_assert(std::is_base_of<U, T>::value, | |||
841 | "U must be derived from T"); | 855 | "U must be derived from T"); | ||
842 | const auto it = std::find_if(list.begin(), list.end(), func); | 856 | const auto it = std::find_if(list.begin(), list.end(), func); | ||
843 | if (it == list.end()) { | 857 | if (it == list.end()) { | ||
844 | return nullptr; | 858 | return nullptr; | ||
845 | } | 859 | } | ||
846 | return *it; | 860 | return *it; | ||
847 | } | 861 | } | ||
848 | 862 | | |||
863 | inline bool Toplevel::isPopupWindow() const | ||||
864 | { | ||||
865 | switch (windowType()) { | ||||
866 | case NET::ComboBox: | ||||
867 | case NET::DropdownMenu: | ||||
868 | case NET::PopupMenu: | ||||
869 | case NET::Tooltip: | ||||
870 | return true; | ||||
871 | | ||||
872 | default: | ||||
873 | return false; | ||||
874 | } | ||||
875 | } | ||||
876 | | ||||
849 | QDebug& operator<<(QDebug& stream, const Toplevel*); | 877 | QDebug& operator<<(QDebug& stream, const Toplevel*); | ||
850 | QDebug& operator<<(QDebug& stream, const ToplevelList&); | 878 | QDebug& operator<<(QDebug& stream, const ToplevelList&); | ||
851 | 879 | | |||
852 | } // namespace | 880 | } // namespace | ||
853 | Q_DECLARE_METATYPE(KWin::Toplevel*) | 881 | Q_DECLARE_METATYPE(KWin::Toplevel*) | ||
854 | 882 | | |||
855 | #endif | 883 | #endif |