Changeset View
Changeset View
Standalone View
Standalone View
useractions.cpp
Show First 20 Lines • Show All 1699 Lines • ▼ Show 20 Line(s) | |||||
1700 | void Workspace::slotWindowResize() | 1700 | void Workspace::slotWindowResize() | ||
1701 | { | 1701 | { | ||
1702 | if (USABLE_ACTIVE_CLIENT) | 1702 | if (USABLE_ACTIVE_CLIENT) | ||
1703 | performWindowOperation(active_client, Options::UnrestrictedResizeOp); | 1703 | performWindowOperation(active_client, Options::UnrestrictedResizeOp); | ||
1704 | } | 1704 | } | ||
1705 | 1705 | | |||
1706 | void Workspace::slotInvertScreen() | 1706 | void Workspace::slotInvertScreen() | ||
1707 | { | 1707 | { | ||
1708 | using namespace Xcb::RandR; | 1708 | kwinApp()->platform()->invertScreen(); | ||
1709 | bool succeeded = false; | | |||
1710 | | ||||
1711 | if (Xcb::Extensions::self()->isRandrAvailable()) { | | |||
1712 | ScreenResources res((active_client && active_client->window() != XCB_WINDOW_NONE) ? active_client->window() : rootWindow()); | | |||
1713 | | ||||
1714 | if (!res.isNull()) { | | |||
1715 | for (int j = 0; j < res->num_crtcs; ++j) { | | |||
1716 | auto crtc = res.crtcs()[j]; | | |||
1717 | CrtcGamma gamma(crtc); | | |||
1718 | if (gamma.isNull()) { | | |||
1719 | continue; | | |||
1720 | } | | |||
1721 | if (gamma->size) { | | |||
1722 | qCDebug(KWIN_CORE) << "inverting screen using xcb_randr_set_crtc_gamma"; | | |||
1723 | const int half = gamma->size / 2 + 1; | | |||
1724 | | ||||
1725 | uint16_t *red = gamma.red(); | | |||
1726 | uint16_t *green = gamma.green(); | | |||
1727 | uint16_t *blue = gamma.blue(); | | |||
1728 | for (int i = 0; i < half; ++i) { | | |||
1729 | auto invert = [&gamma, i](uint16_t *ramp) { | | |||
1730 | qSwap(ramp[i], ramp[gamma->size - 1 - i]); | | |||
1731 | }; | | |||
1732 | invert(red); | | |||
1733 | invert(green); | | |||
1734 | invert(blue); | | |||
1735 | } | | |||
1736 | xcb_randr_set_crtc_gamma(connection(), crtc, gamma->size, red, green, blue); | | |||
1737 | succeeded = true; | | |||
1738 | } | | |||
1739 | } | | |||
1740 | } | | |||
1741 | } | | |||
1742 | if (succeeded) | | |||
1743 | return; | | |||
1744 | | ||||
1745 | //BEGIN effect plugin inversion - atm only works with OpenGL and has an overhead to it | | |||
1746 | if (effects) { | | |||
1747 | if (Effect *inverter = static_cast<EffectsHandlerImpl*>(effects)->provides(Effect::ScreenInversion)) { | | |||
1748 | qCDebug(KWIN_CORE) << "inverting screen using Effect plugin"; | | |||
1749 | QMetaObject::invokeMethod(inverter, "toggleScreenInversion", Qt::DirectConnection); | | |||
1750 | } | | |||
1751 | } | | |||
1752 | | ||||
1753 | if (!succeeded) | | |||
1754 | qCDebug(KWIN_CORE) << "sorry - neither Xrandr, nor XF86VidModeSetGammaRamp worked and there's no inversion supplying effect plugin either"; | | |||
1755 | | ||||
1756 | } | 1709 | } | ||
1757 | 1710 | | |||
1758 | #undef USABLE_ACTIVE_CLIENT | 1711 | #undef USABLE_ACTIVE_CLIENT | ||
1759 | 1712 | | |||
1760 | void AbstractClient::setShortcut(const QString& _cut) | 1713 | void AbstractClient::setShortcut(const QString& _cut) | ||
1761 | { | 1714 | { | ||
1762 | QString cut = rules()->checkShortcut(_cut); | 1715 | QString cut = rules()->checkShortcut(_cut); | ||
1763 | auto updateShortcut = [this](const QKeySequence &cut = QKeySequence()) { | 1716 | auto updateShortcut = [this](const QKeySequence &cut = QKeySequence()) { | ||
▲ Show 20 Lines • Show All 100 Lines • Show Last 20 Lines |