Changeset View
Changeset View
Standalone View
Standalone View
useractions.cpp
Show First 20 Lines • Show All 1037 Lines • ▼ Show 20 Line(s) | 1035 | // client_keys->setEnabled( true ); | |||
---|---|---|---|---|---|
1038 | closeActivePopup(); | 1038 | closeActivePopup(); | ||
1039 | client_keys_dialog->deleteLater(); | 1039 | client_keys_dialog->deleteLater(); | ||
1040 | client_keys_dialog = NULL; | 1040 | client_keys_dialog = NULL; | ||
1041 | client_keys_client = NULL; | 1041 | client_keys_client = NULL; | ||
1042 | if (active_client) | 1042 | if (active_client) | ||
1043 | active_client->takeFocus(); | 1043 | active_client->takeFocus(); | ||
1044 | } | 1044 | } | ||
1045 | 1045 | | |||
1046 | void Workspace::clientShortcutUpdated(Client* c) | 1046 | void Workspace::clientShortcutUpdated(AbstractClient* c) | ||
1047 | { | 1047 | { | ||
1048 | QString key = QStringLiteral("_k_session:%1").arg(c->window()); | 1048 | QString key = QStringLiteral("_k_session:%1").arg(c->window()); | ||
1049 | QAction* action = findChild<QAction*>(key); | 1049 | QAction* action = findChild<QAction*>(key); | ||
1050 | if (!c->shortcut().isEmpty()) { | 1050 | if (!c->shortcut().isEmpty()) { | ||
1051 | if (action == NULL) { // new shortcut | 1051 | if (action == NULL) { // new shortcut | ||
1052 | action = new QAction(this); | 1052 | action = new QAction(this); | ||
1053 | action->setProperty("componentName", QStringLiteral(KWIN_NAME)); | 1053 | action->setProperty("componentName", QStringLiteral(KWIN_NAME)); | ||
1054 | action->setObjectName(key); | 1054 | action->setObjectName(key); | ||
▲ Show 20 Lines • Show All 732 Lines • ▼ Show 20 Line(s) | 1742 | { | |||
1787 | 1787 | | |||
1788 | if (!succeeded) | 1788 | if (!succeeded) | ||
1789 | qCDebug(KWIN_CORE) << "sorry - neither Xrandr, nor XF86VidModeSetGammaRamp worked and there's no inversion supplying effect plugin either"; | 1789 | qCDebug(KWIN_CORE) << "sorry - neither Xrandr, nor XF86VidModeSetGammaRamp worked and there's no inversion supplying effect plugin either"; | ||
1790 | 1790 | | |||
1791 | } | 1791 | } | ||
1792 | 1792 | | |||
1793 | #undef USABLE_ACTIVE_CLIENT | 1793 | #undef USABLE_ACTIVE_CLIENT | ||
1794 | 1794 | | |||
1795 | void Client::setShortcut(const QString& _cut) | 1795 | void AbstractClient::setShortcut(const QString& _cut) | ||
1796 | { | 1796 | { | ||
1797 | QString cut = rules()->checkShortcut(_cut); | 1797 | QString cut = rules()->checkShortcut(_cut); | ||
1798 | if (cut.isEmpty()) | 1798 | auto updateShortcut = [this](const QKeySequence &cut = QKeySequence()) { | ||
1799 | return setShortcutInternal(); | 1799 | if (_shortcut == cut) | ||
1800 | return; | ||||
1801 | _shortcut = cut; | ||||
1802 | setShortcutInternal(); | ||||
1803 | }; | ||||
1804 | if (cut.isEmpty()) { | ||||
1805 | updateShortcut(); | ||||
1806 | return; | ||||
1807 | } | ||||
1800 | if (cut == shortcut().toString()) { | 1808 | if (cut == shortcut().toString()) { | ||
1801 | return; // no change | 1809 | return; // no change | ||
1802 | } | 1810 | } | ||
1803 | // Format: | 1811 | // Format: | ||
1804 | // base+(abcdef)<space>base+(abcdef) | 1812 | // base+(abcdef)<space>base+(abcdef) | ||
1805 | // E.g. Alt+Ctrl+(ABCDEF);Meta+X,Meta+(ABCDEF) | 1813 | // E.g. Alt+Ctrl+(ABCDEF);Meta+X,Meta+(ABCDEF) | ||
1806 | if (!cut.contains(QLatin1Char('(')) && !cut.contains(QLatin1Char(')')) && !cut.contains(QLatin1String(" - "))) { | 1814 | if (!cut.contains(QLatin1Char('(')) && !cut.contains(QLatin1Char(')')) && !cut.contains(QLatin1String(" - "))) { | ||
1807 | if (workspace()->shortcutAvailable(cut, this)) | 1815 | if (workspace()->shortcutAvailable(cut, this)) | ||
1808 | setShortcutInternal(QKeySequence(cut)); | 1816 | updateShortcut(QKeySequence(cut)); | ||
1809 | else | 1817 | else | ||
1810 | setShortcutInternal(); | 1818 | updateShortcut(); | ||
1811 | return; | 1819 | return; | ||
1812 | } | 1820 | } | ||
1813 | QList< QKeySequence > keys; | 1821 | QList< QKeySequence > keys; | ||
1814 | QStringList groups = cut.split(QStringLiteral(" - ")); | 1822 | QStringList groups = cut.split(QStringLiteral(" - ")); | ||
1815 | for (QStringList::ConstIterator it = groups.constBegin(); | 1823 | for (QStringList::ConstIterator it = groups.constBegin(); | ||
1816 | it != groups.constEnd(); | 1824 | it != groups.constEnd(); | ||
1817 | ++it) { | 1825 | ++it) { | ||
1818 | QRegExp reg(QStringLiteral("(.*\\+)\\((.*)\\)")); | 1826 | QRegExp reg(QStringLiteral("(.*\\+)\\((.*)\\)")); | ||
Show All 20 Lines | 1845 | for (auto it = keys.constBegin(); | |||
1839 | ++it) { | 1847 | ++it) { | ||
1840 | if (_shortcut == *it) // current one is in the list | 1848 | if (_shortcut == *it) // current one is in the list | ||
1841 | return; | 1849 | return; | ||
1842 | } | 1850 | } | ||
1843 | for (auto it = keys.constBegin(); | 1851 | for (auto it = keys.constBegin(); | ||
1844 | it != keys.constEnd(); | 1852 | it != keys.constEnd(); | ||
1845 | ++it) { | 1853 | ++it) { | ||
1846 | if (workspace()->shortcutAvailable(*it, this)) { | 1854 | if (workspace()->shortcutAvailable(*it, this)) { | ||
1847 | setShortcutInternal(*it); | 1855 | updateShortcut(*it); | ||
1848 | return; | 1856 | return; | ||
1849 | } | 1857 | } | ||
1850 | } | 1858 | } | ||
1851 | setShortcutInternal(); | 1859 | updateShortcut(); | ||
1852 | } | 1860 | } | ||
1853 | 1861 | | |||
1854 | void Client::setShortcutInternal(const QKeySequence &cut) | 1862 | void AbstractClient::setShortcutInternal() | ||
1863 | { | ||||
1864 | workspace()->clientShortcutUpdated(this); | ||||
1865 | } | ||||
1866 | | ||||
1867 | void Client::setShortcutInternal() | ||||
1855 | { | 1868 | { | ||
1856 | if (_shortcut == cut) | | |||
1857 | return; | | |||
1858 | _shortcut = cut; | | |||
1859 | updateCaption(); | 1869 | updateCaption(); | ||
1860 | #if 0 | 1870 | #if 0 | ||
1861 | workspace()->clientShortcutUpdated(this); | 1871 | workspace()->clientShortcutUpdated(this); | ||
1862 | #else | 1872 | #else | ||
1863 | // Workaround for kwin<->kglobalaccel deadlock, when KWin has X grab and the kded | 1873 | // Workaround for kwin<->kglobalaccel deadlock, when KWin has X grab and the kded | ||
1864 | // kglobalaccel module tries to create the key grab. KWin should preferably grab | 1874 | // kglobalaccel module tries to create the key grab. KWin should preferably grab | ||
1865 | // they keys itself anyway :(. | 1875 | // they keys itself anyway :(. | ||
1866 | QTimer::singleShot(0, this, SLOT(delayedSetShortcut())); | 1876 | QTimer::singleShot(0, this, SLOT(delayedSetShortcut())); | ||
1867 | #endif | 1877 | #endif | ||
1868 | } | 1878 | } | ||
1869 | 1879 | | |||
1870 | void Client::delayedSetShortcut() | 1880 | void Client::delayedSetShortcut() | ||
1871 | { | 1881 | { | ||
1872 | workspace()->clientShortcutUpdated(this); | 1882 | workspace()->clientShortcutUpdated(this); | ||
1873 | } | 1883 | } | ||
1874 | 1884 | | |||
1875 | bool Workspace::shortcutAvailable(const QKeySequence &cut, Client* ignore) const | 1885 | bool Workspace::shortcutAvailable(const QKeySequence &cut, AbstractClient* ignore) const | ||
1876 | { | 1886 | { | ||
1877 | if (ignore && cut == ignore->shortcut()) | 1887 | if (ignore && cut == ignore->shortcut()) | ||
1878 | return true; | 1888 | return true; | ||
1879 | 1889 | | |||
1880 | if (!KGlobalAccel::getGlobalShortcutsByKey(cut).isEmpty()) { | 1890 | if (!KGlobalAccel::getGlobalShortcutsByKey(cut).isEmpty()) { | ||
1881 | return false; | 1891 | return false; | ||
1882 | } | 1892 | } | ||
1883 | for (ClientList::ConstIterator it = clients.constBegin(); | 1893 | for (auto it = m_allClients.constBegin(); | ||
1884 | it != clients.constEnd(); | 1894 | it != m_allClients.constEnd(); | ||
1885 | ++it) { | 1895 | ++it) { | ||
1886 | if ((*it) != ignore && (*it)->shortcut() == cut) | 1896 | if ((*it) != ignore && (*it)->shortcut() == cut) | ||
1887 | return false; | 1897 | return false; | ||
1888 | } | 1898 | } | ||
1889 | return true; | 1899 | return true; | ||
1890 | } | 1900 | } | ||
1891 | 1901 | | |||
1892 | } // namespace | 1902 | } // namespace |