Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwineffects.cpp
Show First 20 Lines • Show All 769 Lines • ▼ Show 20 Line(s) | |||||
770 | //**************************************** | 770 | //**************************************** | ||
771 | 771 | | |||
772 | class Q_DECL_HIDDEN EffectWindow::Private | 772 | class Q_DECL_HIDDEN EffectWindow::Private | ||
773 | { | 773 | { | ||
774 | public: | 774 | public: | ||
775 | Private(EffectWindow *q); | 775 | Private(EffectWindow *q); | ||
776 | 776 | | |||
777 | EffectWindow *q; | 777 | EffectWindow *q; | ||
778 | bool managed = false; | | |||
779 | bool waylandClient; | | |||
780 | bool x11Client; | | |||
781 | }; | 778 | }; | ||
782 | 779 | | |||
783 | EffectWindow::Private::Private(EffectWindow *q) | 780 | EffectWindow::Private::Private(EffectWindow *q) | ||
784 | : q(q) | 781 | : q(q) | ||
785 | { | 782 | { | ||
786 | } | 783 | } | ||
787 | 784 | | |||
788 | EffectWindow::EffectWindow(QObject *parent) | 785 | EffectWindow::EffectWindow(QObject *parent) | ||
789 | : QObject(parent) | 786 | : QObject(parent) | ||
790 | , d(new Private(this)) | 787 | , d(new Private(this)) | ||
791 | { | 788 | { | ||
792 | // Deleted windows are not managed. So, when windowClosed signal is | | |||
793 | // emitted, effects can't distinguish managed windows from unmanaged | | |||
794 | // windows(e.g. combo box popups, popup menus, etc). Save value of the | | |||
795 | // managed property during construction of EffectWindow. At that time, | | |||
796 | // parent can be Client, ShellClient, or Unmanaged. So, later on, when | | |||
797 | // an instance of Deleted becomes parent of the EffectWindow, effects | | |||
798 | // can still figure out whether it is/was a managed window. | | |||
799 | d->managed = parent->property("managed").value<bool>(); | | |||
800 | | ||||
801 | d->waylandClient = parent->inherits("KWin::ShellClient"); | | |||
802 | d->x11Client = !d->waylandClient; | | |||
803 | } | 789 | } | ||
804 | 790 | | |||
805 | EffectWindow::~EffectWindow() | 791 | EffectWindow::~EffectWindow() | ||
806 | { | 792 | { | ||
807 | } | 793 | } | ||
808 | 794 | | |||
809 | #define WINDOW_HELPER( rettype, prototype, propertyname ) \ | | |||
810 | rettype EffectWindow::prototype ( ) const \ | | |||
811 | { \ | | |||
812 | return parent()->property( propertyname ).value< rettype >(); \ | | |||
813 | } | | |||
814 | | ||||
815 | WINDOW_HELPER(double, opacity, "opacity") | | |||
816 | WINDOW_HELPER(bool, hasAlpha, "alpha") | | |||
817 | WINDOW_HELPER(int, x, "x") | | |||
818 | WINDOW_HELPER(int, y, "y") | | |||
819 | WINDOW_HELPER(int, width, "width") | | |||
820 | WINDOW_HELPER(int, height, "height") | | |||
821 | WINDOW_HELPER(QPoint, pos, "pos") | | |||
822 | WINDOW_HELPER(QSize, size, "size") | | |||
823 | WINDOW_HELPER(int, screen, "screen") | | |||
824 | WINDOW_HELPER(QRect, geometry, "geometry") | | |||
825 | WINDOW_HELPER(QRect, expandedGeometry, "visibleRect") | | |||
826 | WINDOW_HELPER(QRect, rect, "rect") | | |||
827 | #ifndef KWIN_NO_DEPRECATED | | |||
828 | WINDOW_HELPER(int, desktop, "desktop") | | |||
829 | #endif | | |||
830 | WINDOW_HELPER(bool, isDesktop, "desktopWindow") | | |||
831 | WINDOW_HELPER(bool, isDock, "dock") | | |||
832 | WINDOW_HELPER(bool, isToolbar, "toolbar") | | |||
833 | WINDOW_HELPER(bool, isMenu, "menu") | | |||
834 | WINDOW_HELPER(bool, isNormalWindow, "normalWindow") | | |||
835 | WINDOW_HELPER(bool, isDialog, "dialog") | | |||
836 | WINDOW_HELPER(bool, isSplash, "splash") | | |||
837 | WINDOW_HELPER(bool, isUtility, "utility") | | |||
838 | WINDOW_HELPER(bool, isDropdownMenu, "dropdownMenu") | | |||
839 | WINDOW_HELPER(bool, isPopupMenu, "popupMenu") | | |||
840 | WINDOW_HELPER(bool, isTooltip, "tooltip") | | |||
841 | WINDOW_HELPER(bool, isNotification, "notification") | | |||
842 | WINDOW_HELPER(bool, isOnScreenDisplay, "onScreenDisplay") | | |||
843 | WINDOW_HELPER(bool, isComboBox, "comboBox") | | |||
844 | WINDOW_HELPER(bool, isDNDIcon, "dndIcon") | | |||
845 | WINDOW_HELPER(bool, isDeleted, "deleted") | | |||
846 | WINDOW_HELPER(bool, hasOwnShape, "shaped") | | |||
847 | WINDOW_HELPER(QString, windowRole, "windowRole") | | |||
848 | WINDOW_HELPER(QStringList, activities, "activities") | | |||
849 | WINDOW_HELPER(bool, skipsCloseAnimation, "skipsCloseAnimation") | | |||
850 | WINDOW_HELPER(KWayland::Server::SurfaceInterface *, surface, "surface") | | |||
851 | WINDOW_HELPER(QVector<uint>, desktops, "x11DesktopIds") | | |||
852 | WINDOW_HELPER(bool, isPopupWindow, "popupWindow") | | |||
853 | | ||||
854 | QString EffectWindow::windowClass() const | | |||
855 | { | | |||
856 | return parent()->property("resourceName").toString() + QLatin1Char(' ') + parent()->property("resourceClass").toString(); | | |||
857 | } | | |||
858 | | ||||
859 | QRect EffectWindow::contentsRect() const | | |||
860 | { | | |||
861 | return QRect(parent()->property("clientPos").toPoint(), parent()->property("clientSize").toSize()); | | |||
862 | } | | |||
863 | | ||||
864 | NET::WindowType EffectWindow::windowType() const | | |||
865 | { | | |||
866 | return static_cast<NET::WindowType>(parent()->property("windowType").toInt()); | | |||
867 | } | | |||
868 | | ||||
869 | bool EffectWindow::isOnActivity(QString activity) const | 795 | bool EffectWindow::isOnActivity(QString activity) const | ||
870 | { | 796 | { | ||
871 | const QStringList activities = parent()->property("activities").toStringList(); | 797 | const QStringList _activities = activities(); | ||
872 | return activities.isEmpty() || activities.contains(activity); | 798 | return _activities.isEmpty() || _activities.contains(activity); | ||
873 | } | 799 | } | ||
874 | 800 | | |||
875 | bool EffectWindow::isOnAllActivities() const | 801 | bool EffectWindow::isOnAllActivities() const | ||
876 | { | 802 | { | ||
877 | return parent()->property("activities").toStringList().isEmpty(); | 803 | return activities().isEmpty(); | ||
878 | } | | |||
879 | | ||||
880 | #undef WINDOW_HELPER | | |||
881 | | ||||
882 | #define WINDOW_HELPER_DEFAULT( rettype, prototype, propertyname, defaultValue ) \ | | |||
883 | rettype EffectWindow::prototype ( ) const \ | | |||
884 | { \ | | |||
885 | const QVariant variant = parent()->property( propertyname ); \ | | |||
886 | if (!variant.isValid()) { \ | | |||
887 | return defaultValue; \ | | |||
888 | } \ | | |||
889 | return variant.value< rettype >(); \ | | |||
890 | } | 804 | } | ||
891 | 805 | | |||
892 | WINDOW_HELPER_DEFAULT(bool, isMinimized, "minimized", false) | | |||
893 | WINDOW_HELPER_DEFAULT(bool, isMovable, "moveable", false) | | |||
894 | WINDOW_HELPER_DEFAULT(bool, isMovableAcrossScreens, "moveableAcrossScreens", false) | | |||
895 | WINDOW_HELPER_DEFAULT(QString, caption, "caption", QString()) | | |||
896 | WINDOW_HELPER_DEFAULT(bool, keepAbove, "keepAbove", true) | | |||
897 | WINDOW_HELPER_DEFAULT(bool, keepBelow, "keepBelow", false) | | |||
898 | WINDOW_HELPER_DEFAULT(bool, isModal, "modal", false) | | |||
899 | WINDOW_HELPER_DEFAULT(QSize, basicUnit, "basicUnit", QSize(1, 1)) | | |||
900 | WINDOW_HELPER_DEFAULT(bool, isUserMove, "move", false) | | |||
901 | WINDOW_HELPER_DEFAULT(bool, isUserResize, "resize", false) | | |||
902 | WINDOW_HELPER_DEFAULT(QRect, iconGeometry, "iconGeometry", QRect()) | | |||
903 | WINDOW_HELPER_DEFAULT(bool, isSpecialWindow, "specialWindow", true) | | |||
904 | WINDOW_HELPER_DEFAULT(bool, acceptsFocus, "wantsInput", true) // We don't actually know... | | |||
905 | WINDOW_HELPER_DEFAULT(QIcon, icon, "icon", QIcon()) | | |||
906 | WINDOW_HELPER_DEFAULT(bool, isSkipSwitcher, "skipSwitcher", false) | | |||
907 | WINDOW_HELPER_DEFAULT(bool, isCurrentTab, "isCurrentTab", true) | | |||
908 | WINDOW_HELPER_DEFAULT(bool, decorationHasAlpha, "decorationHasAlpha", false) | | |||
909 | WINDOW_HELPER_DEFAULT(bool, isFullScreen, "fullScreen", false) | | |||
910 | WINDOW_HELPER_DEFAULT(bool, isUnresponsive, "unresponsive", false) | | |||
911 | | ||||
912 | #undef WINDOW_HELPER_DEFAULT | | |||
913 | | ||||
914 | #define WINDOW_HELPER_SETTER( prototype, propertyname, args, value ) \ | 806 | #define WINDOW_HELPER_SETTER( prototype, propertyname, args, value ) \ | ||
915 | void EffectWindow::prototype ( args ) \ | 807 | void EffectWindow::prototype ( args ) \ | ||
916 | {\ | 808 | {\ | ||
917 | const QVariant variant = parent()->property( propertyname ); \ | 809 | const QVariant variant = parent()->property( propertyname ); \ | ||
918 | if (variant.isValid()) { \ | 810 | if (variant.isValid()) { \ | ||
919 | parent()->setProperty( propertyname, value ); \ | 811 | parent()->setProperty( propertyname, value ); \ | ||
920 | } \ | 812 | } \ | ||
921 | } | 813 | } | ||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Line(s) | |||||
992 | 884 | | |||
993 | bool EffectWindow::isVisible() const | 885 | bool EffectWindow::isVisible() const | ||
994 | { | 886 | { | ||
995 | return !isMinimized() | 887 | return !isMinimized() | ||
996 | && isOnCurrentDesktop() | 888 | && isOnCurrentDesktop() | ||
997 | && isOnCurrentActivity(); | 889 | && isOnCurrentActivity(); | ||
998 | } | 890 | } | ||
999 | 891 | | |||
1000 | bool EffectWindow::isManaged() const | | |||
1001 | { | | |||
1002 | return d->managed; | | |||
1003 | } | | |||
1004 | | ||||
1005 | bool EffectWindow::isWaylandClient() const | | |||
1006 | { | | |||
1007 | return d->waylandClient; | | |||
1008 | } | | |||
1009 | | ||||
1010 | bool EffectWindow::isX11Client() const | | |||
1011 | { | | |||
1012 | return d->x11Client; | | |||
1013 | } | | |||
1014 | | ||||
1015 | //**************************************** | 892 | //**************************************** | ||
1016 | // EffectWindowGroup | 893 | // EffectWindowGroup | ||
1017 | //**************************************** | 894 | //**************************************** | ||
1018 | 895 | | |||
1019 | EffectWindowGroup::~EffectWindowGroup() | 896 | EffectWindowGroup::~EffectWindowGroup() | ||
1020 | { | 897 | { | ||
1021 | } | 898 | } | ||
1022 | 899 | | |||
▲ Show 20 Lines • Show All 1102 Lines • Show Last 20 Lines |