Changeset View
Changeset View
Standalone View
Standalone View
abstract_client.cpp
Show All 33 Lines | |||||
34 | #include "useractions.h" | 34 | #include "useractions.h" | ||
35 | #include "workspace.h" | 35 | #include "workspace.h" | ||
36 | 36 | | |||
37 | #include "wayland_server.h" | 37 | #include "wayland_server.h" | ||
38 | #include <KWayland/Server/plasmawindowmanagement_interface.h> | 38 | #include <KWayland/Server/plasmawindowmanagement_interface.h> | ||
39 | 39 | | |||
40 | #include <KDecoration2/Decoration> | 40 | #include <KDecoration2/Decoration> | ||
41 | 41 | | |||
42 | #include <KDesktopFile> | ||||
43 | | ||||
42 | #include <QMouseEvent> | 44 | #include <QMouseEvent> | ||
43 | #include <QStyleHints> | 45 | #include <QStyleHints> | ||
44 | 46 | | |||
45 | namespace KWin | 47 | namespace KWin | ||
46 | { | 48 | { | ||
47 | 49 | | |||
48 | QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> AbstractClient::s_palettes; | 50 | QHash<QString, std::weak_ptr<Decoration::DecorationPalette>> AbstractClient::s_palettes; | ||
49 | std::shared_ptr<Decoration::DecorationPalette> AbstractClient::s_defaultPalette; | 51 | std::shared_ptr<Decoration::DecorationPalette> AbstractClient::s_defaultPalette; | ||
▲ Show 20 Lines • Show All 619 Lines • ▼ Show 20 Line(s) | 651 | { | |||
669 | w->setMinimized(isMinimized()); | 671 | w->setMinimized(isMinimized()); | ||
670 | w->setOnAllDesktops(isOnAllDesktops()); | 672 | w->setOnAllDesktops(isOnAllDesktops()); | ||
671 | w->setDemandsAttention(isDemandingAttention()); | 673 | w->setDemandsAttention(isDemandingAttention()); | ||
672 | w->setCloseable(isCloseable()); | 674 | w->setCloseable(isCloseable()); | ||
673 | w->setMaximizeable(isMaximizable()); | 675 | w->setMaximizeable(isMaximizable()); | ||
674 | w->setMinimizeable(isMinimizable()); | 676 | w->setMinimizeable(isMinimizable()); | ||
675 | w->setFullscreenable(isFullScreenable()); | 677 | w->setFullscreenable(isFullScreenable()); | ||
676 | w->setIcon(icon()); | 678 | w->setIcon(icon()); | ||
677 | w->setAppId(QString::fromUtf8(resourceName())); | 679 | auto updateAppId = [this, w] { | ||
680 | w->setAppId(QString::fromUtf8(m_desktopFileName.isEmpty() ? resourceName() : m_desktopFileName)); | ||||
681 | }; | ||||
682 | updateAppId(); | ||||
678 | w->setSkipTaskbar(skipTaskbar()); | 683 | w->setSkipTaskbar(skipTaskbar()); | ||
679 | w->setShadeable(isShadeable()); | 684 | w->setShadeable(isShadeable()); | ||
680 | w->setShaded(isShade()); | 685 | w->setShaded(isShade()); | ||
681 | w->setResizable(isResizable()); | 686 | w->setResizable(isResizable()); | ||
682 | w->setMovable(isMovable()); | 687 | w->setMovable(isMovable()); | ||
683 | w->setVirtualDesktopChangeable(true); // FIXME Matches Client::actionSupported(), but both should be implemented. | 688 | w->setVirtualDesktopChangeable(true); // FIXME Matches Client::actionSupported(), but both should be implemented. | ||
684 | w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); | 689 | w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); | ||
685 | w->setGeometry(geom); | 690 | w->setGeometry(geom); | ||
Show All 25 Lines | 712 | connect(this, static_cast<void (AbstractClient::*)(AbstractClient*,MaximizeMode)>(&AbstractClient::clientMaximizedStateChanged), w, | |||
711 | } | 716 | } | ||
712 | ); | 717 | ); | ||
713 | connect(this, &AbstractClient::demandsAttentionChanged, w, [w, this] { w->setDemandsAttention(isDemandingAttention()); }); | 718 | connect(this, &AbstractClient::demandsAttentionChanged, w, [w, this] { w->setDemandsAttention(isDemandingAttention()); }); | ||
714 | connect(this, &AbstractClient::iconChanged, w, | 719 | connect(this, &AbstractClient::iconChanged, w, | ||
715 | [w, this] { | 720 | [w, this] { | ||
716 | w->setIcon(icon()); | 721 | w->setIcon(icon()); | ||
717 | } | 722 | } | ||
718 | ); | 723 | ); | ||
719 | connect(this, &AbstractClient::windowClassChanged, w, | 724 | connect(this, &AbstractClient::windowClassChanged, w, updateAppId); | ||
720 | [w, this] { | 725 | connect(this, &AbstractClient::desktopFileNameChanged, w, updateAppId); | ||
721 | w->setAppId(QString::fromUtf8(resourceName())); | | |||
722 | } | | |||
723 | ); | | |||
724 | connect(this, &AbstractClient::shadeChanged, w, [w, this] { w->setShaded(isShade()); }); | 726 | connect(this, &AbstractClient::shadeChanged, w, [w, this] { w->setShaded(isShade()); }); | ||
725 | connect(this, &AbstractClient::transientChanged, w, | 727 | connect(this, &AbstractClient::transientChanged, w, | ||
726 | [w, this] { | 728 | [w, this] { | ||
727 | w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); | 729 | w->setParentWindow(transientFor() ? transientFor()->windowManagementInterface() : nullptr); | ||
728 | } | 730 | } | ||
729 | ); | 731 | ); | ||
730 | connect(this, &AbstractClient::geometryChanged, w, | 732 | connect(this, &AbstractClient::geometryChanged, w, | ||
731 | [w, this] { | 733 | [w, this] { | ||
▲ Show 20 Lines • Show All 902 Lines • ▼ Show 20 Line(s) | 1632 | { | |||
1634 | return Toplevel::inputGeometry(); | 1636 | return Toplevel::inputGeometry(); | ||
1635 | } | 1637 | } | ||
1636 | 1638 | | |||
1637 | bool AbstractClient::dockWantsInput() const | 1639 | bool AbstractClient::dockWantsInput() const | ||
1638 | { | 1640 | { | ||
1639 | return false; | 1641 | return false; | ||
1640 | } | 1642 | } | ||
1641 | 1643 | | |||
1644 | void AbstractClient::setDesktopFileName(const QByteArray &name) | ||||
1645 | { | ||||
1646 | if (name == m_desktopFileName) { | ||||
1647 | return; | ||||
1648 | } | ||||
1649 | m_desktopFileName = name; | ||||
1650 | emit desktopFileNameChanged(); | ||||
1651 | } | ||||
1652 | | ||||
1653 | QString AbstractClient::iconFromDesktopFile() const | ||||
1654 | { | ||||
1655 | if (m_desktopFileName.isEmpty()) { | ||||
1656 | return QString(); | ||||
1657 | } | ||||
1658 | QString desktopFile = QString::fromUtf8(m_desktopFileName); | ||||
1659 | if (!desktopFile.endsWith(QLatin1String(".desktop"))) { | ||||
1660 | desktopFile.append(QLatin1String(".desktop")); | ||||
1661 | } | ||||
1662 | KDesktopFile df(desktopFile); | ||||
1663 | return df.readIcon(); | ||||
1664 | } | ||||
1665 | | ||||
1642 | } | 1666 | } |