Changeset View
Changeset View
Standalone View
Standalone View
effects/presentwindows/presentwindows.cpp
Show All 32 Lines | |||||
33 | 33 | | |||
34 | #include <QApplication> | 34 | #include <QApplication> | ||
35 | #include <QQmlContext> | 35 | #include <QQmlContext> | ||
36 | #include <QQmlEngine> | 36 | #include <QQmlEngine> | ||
37 | #include <QQuickItem> | 37 | #include <QQuickItem> | ||
38 | #include <QQuickView> | 38 | #include <QQuickView> | ||
39 | #include <QGraphicsObject> | 39 | #include <QGraphicsObject> | ||
40 | #include <QTimer> | 40 | #include <QTimer> | ||
41 | #include <QElapsedTimer> | | |||
42 | #include <QVector2D> | 41 | #include <QVector2D> | ||
43 | #include <QVector4D> | 42 | #include <QVector4D> | ||
44 | 43 | | |||
45 | #include <climits> | 44 | #include <climits> | ||
46 | #include <cmath> | 45 | #include <cmath> | ||
47 | 46 | | |||
48 | namespace KWin | 47 | namespace KWin | ||
49 | { | 48 | { | ||
▲ Show 20 Lines • Show All 1881 Lines • ▼ Show 20 Line(s) | 1928 | { | |||
1931 | for (int i = 0; i < effects->numScreens(); ++i) { | 1930 | for (int i = 0; i < effects->numScreens(); ++i) { | ||
1932 | m_gridSizes.append(GridSize()); | 1931 | m_gridSizes.append(GridSize()); | ||
1933 | } | 1932 | } | ||
1934 | rearrangeWindows(); | 1933 | rearrangeWindows(); | ||
1935 | } | 1934 | } | ||
1936 | 1935 | | |||
1937 | CloseWindowView::CloseWindowView(QObject *parent) | 1936 | CloseWindowView::CloseWindowView(QObject *parent) | ||
1938 | : EffectQuickScene(parent) | 1937 | : EffectQuickScene(parent) | ||
1939 | , m_armTimer(new QElapsedTimer()) | | |||
1940 | { | 1938 | { | ||
1941 | setSource(QUrl(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/presentwindows/main.qml")))); | 1939 | setSource(QUrl(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("kwin/effects/presentwindows/main.qml")))); | ||
1942 | if (QQuickItem *item = rootItem()) { | 1940 | if (QQuickItem *item = rootItem()) { | ||
1943 | connect(item, SIGNAL(clicked()), this, SLOT(clicked())); | 1941 | connect(item, SIGNAL(clicked()), this, SLOT(clicked())); | ||
1944 | setGeometry(QRect(QPoint(), QSize(item->implicitWidth(), item->implicitHeight()))); | 1942 | setGeometry(QRect(QPoint(), QSize(item->implicitWidth(), item->implicitHeight()))); | ||
1945 | } | 1943 | } | ||
1946 | m_armTimer->restart(); | 1944 | m_armTimer.restart(); | ||
1947 | } | 1945 | } | ||
1948 | 1946 | | |||
1949 | void CloseWindowView::clicked() | 1947 | void CloseWindowView::clicked() | ||
1950 | { | 1948 | { | ||
1951 | // 50ms until the window is elevated (seen!) and 300ms more to be "realized" by the user. | 1949 | // 50ms until the window is elevated (seen!) and 300ms more to be "realized" by the user. | ||
1952 | if (m_armTimer->hasExpired(350)) { | 1950 | if (m_armTimer.hasExpired(350)) { | ||
1953 | emit requestClose(); | 1951 | emit requestClose(); | ||
1954 | } | 1952 | } | ||
1955 | } | 1953 | } | ||
1956 | 1954 | | |||
1957 | void CloseWindowView::disarm() | 1955 | void CloseWindowView::disarm() | ||
1958 | { | 1956 | { | ||
1959 | m_armTimer->restart(); | 1957 | m_armTimer.restart(); | ||
1960 | } | 1958 | } | ||
1961 | 1959 | | |||
1962 | 1960 | | |||
1963 | } // namespace | 1961 | } // namespace | ||
1964 | 1962 | |