Changeset View
Standalone View
shell_client.cpp
Show First 20 Lines • Show All 203 Lines • ▼ Show 20 Line(s) | 203 | if (!m_internal) { | |||
---|---|---|---|---|---|
204 | setupWindowRules(false); | 204 | setupWindowRules(false); | ||
205 | } | 205 | } | ||
206 | setDesktopFileName(rules()->checkDesktopFile(shellSurface->windowClass(), true).toUtf8()); | 206 | setDesktopFileName(rules()->checkDesktopFile(shellSurface->windowClass(), true).toUtf8()); | ||
207 | } | 207 | } | ||
208 | 208 | | |||
209 | void ShellClient::init() | 209 | void ShellClient::init() | ||
210 | { | 210 | { | ||
211 | connect(this, &ShellClient::desktopFileNameChanged, this, &ShellClient::updateIcon); | 211 | connect(this, &ShellClient::desktopFileNameChanged, this, &ShellClient::updateIcon); | ||
212 | findInternalWindow(); | | |||
213 | createWindowId(); | 212 | createWindowId(); | ||
214 | setupCompositing(); | 213 | setupCompositing(); | ||
215 | updateIcon(); | 214 | updateIcon(); | ||
216 | SurfaceInterface *s = surface(); | 215 | SurfaceInterface *s = surface(); | ||
217 | Q_ASSERT(s); | 216 | Q_ASSERT(s); | ||
218 | if (s->buffer()) { | 217 | if (s->buffer()) { | ||
219 | setReadyForPainting(); | 218 | setReadyForPainting(); | ||
220 | if (shouldExposeToWindowManagement()) { | 219 | if (shouldExposeToWindowManagement()) { | ||
221 | setupWindowManagementInterface(); | 220 | setupWindowManagementInterface(); | ||
222 | } | 221 | } | ||
223 | m_unmapped = false; | 222 | m_unmapped = false; | ||
224 | m_clientSize = s->size(); | 223 | m_clientSize = s->size(); | ||
225 | } else { | 224 | } else { | ||
226 | ready_for_painting = false; | 225 | ready_for_painting = false; | ||
227 | } | 226 | } | ||
228 | if (m_internalWindow) { | 227 | if (!m_internal) { | ||
229 | updateInternalWindowGeometry(); | | |||
230 | updateDecoration(true); | | |||
231 | } else { | | |||
232 | doSetGeometry(QRect(QPoint(0, 0), m_clientSize)); | 228 | doSetGeometry(QRect(QPoint(0, 0), m_clientSize)); | ||
233 | } | 229 | } | ||
234 | if (waylandServer()->inputMethodConnection() == s->client()) { | 230 | if (waylandServer()->inputMethodConnection() == s->client()) { | ||
235 | m_windowType = NET::OnScreenDisplay; | 231 | m_windowType = NET::OnScreenDisplay; | ||
236 | } | 232 | } | ||
237 | 233 | | |||
238 | connect(s, &SurfaceInterface::sizeChanged, this, | 234 | connect(s, &SurfaceInterface::sizeChanged, this, | ||
239 | [this] { | 235 | [this] { | ||
▲ Show 20 Lines • Show All 260 Lines • ▼ Show 20 Line(s) | 494 | if (s->size().isValid()) { | |||
500 | updatePendingGeometry(); | 496 | updatePendingGeometry(); | ||
501 | } | 497 | } | ||
502 | markAsMapped(); | 498 | markAsMapped(); | ||
503 | setDepth((s->buffer()->hasAlphaChannel() && !isDesktop()) ? 32 : 24); | 499 | setDepth((s->buffer()->hasAlphaChannel() && !isDesktop()) ? 32 : 24); | ||
504 | repaints_region += damage.translated(clientPos()); | 500 | repaints_region += damage.translated(clientPos()); | ||
505 | Toplevel::addDamage(damage); | 501 | Toplevel::addDamage(damage); | ||
506 | } | 502 | } | ||
507 | 503 | | |||
508 | void ShellClient::setInternalFramebufferObject(const QSharedPointer<QOpenGLFramebufferObject> &fbo) | | |||
509 | { | | |||
510 | if (fbo.isNull()) { | | |||
511 | unmap(); | | |||
512 | return; | | |||
513 | } | | |||
514 | | ||||
515 | m_clientSize = fbo->size() / surface()->scale(); | | |||
516 | markAsMapped(); | | |||
517 | doSetGeometry(QRect(geom.topLeft(), m_clientSize)); | | |||
518 | Toplevel::setInternalFramebufferObject(fbo); | | |||
519 | Toplevel::addDamage(QRegion(0, 0, width(), height())); | | |||
520 | } | | |||
521 | | ||||
522 | void ShellClient::markAsMapped() | 504 | void ShellClient::markAsMapped() | ||
523 | { | 505 | { | ||
524 | if (!m_unmapped) { | 506 | if (!m_unmapped) { | ||
525 | return; | 507 | return; | ||
526 | } | 508 | } | ||
527 | 509 | | |||
528 | m_unmapped = false; | 510 | m_unmapped = false; | ||
529 | if (!ready_for_painting) { | 511 | if (!ready_for_painting) { | ||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 607 | { | |||
634 | if (m_unmapped && m_geomMaximizeRestore.isEmpty() && !geom.isEmpty()) { | 616 | if (m_unmapped && m_geomMaximizeRestore.isEmpty() && !geom.isEmpty()) { | ||
635 | // use first valid geometry as restore geometry | 617 | // use first valid geometry as restore geometry | ||
636 | m_geomMaximizeRestore = geom; | 618 | m_geomMaximizeRestore = geom; | ||
637 | } | 619 | } | ||
638 | 620 | | |||
639 | if (!m_unmapped) { | 621 | if (!m_unmapped) { | ||
640 | addWorkspaceRepaint(visibleRect()); | 622 | addWorkspaceRepaint(visibleRect()); | ||
641 | } | 623 | } | ||
642 | syncGeometryToInternalWindow(); | | |||
643 | if (hasStrut()) { | 624 | if (hasStrut()) { | ||
644 | workspace()->updateClientArea(); | 625 | workspace()->updateClientArea(); | ||
645 | } | 626 | } | ||
646 | const auto old = geometryBeforeUpdateBlocking(); | 627 | const auto old = geometryBeforeUpdateBlocking(); | ||
647 | updateGeometryBeforeUpdateBlocking(); | 628 | updateGeometryBeforeUpdateBlocking(); | ||
648 | emit geometryShapeChanged(this, old); | 629 | emit geometryShapeChanged(this, old); | ||
649 | 630 | | |||
650 | if (isResize()) { | 631 | if (isResize()) { | ||
651 | performMoveResize(); | 632 | performMoveResize(); | ||
652 | } | 633 | } | ||
653 | } | 634 | } | ||
654 | 635 | | |||
655 | void ShellClient::doMove(int x, int y) | | |||
656 | { | | |||
657 | Q_UNUSED(x) | | |||
658 | Q_UNUSED(y) | | |||
659 | syncGeometryToInternalWindow(); | | |||
660 | } | | |||
661 | | ||||
662 | void ShellClient::syncGeometryToInternalWindow() | | |||
663 | { | | |||
664 | if (!m_internalWindow) { | | |||
665 | return; | | |||
666 | } | | |||
667 | const QRect windowRect = QRect(geom.topLeft() + QPoint(borderLeft(), borderTop()), | | |||
668 | geom.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom())); | | |||
669 | if (m_internalWindow->geometry() != windowRect) { | | |||
670 | // delay to end of cycle to prevent freeze, see BUG 384441 | | |||
671 | QTimer::singleShot(0, m_internalWindow, std::bind(static_cast<void (QWindow::*)(const QRect&)>(&QWindow::setGeometry), m_internalWindow, windowRect)); | | |||
672 | } | | |||
673 | } | | |||
674 | | ||||
675 | QByteArray ShellClient::windowRole() const | 636 | QByteArray ShellClient::windowRole() const | ||
676 | { | 637 | { | ||
677 | return QByteArray(); | 638 | return QByteArray(); | ||
678 | } | 639 | } | ||
679 | 640 | | |||
680 | bool ShellClient::belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const | 641 | bool ShellClient::belongsToSameApplication(const AbstractClient *other, SameApplicationChecks checks) const | ||
681 | { | 642 | { | ||
682 | if (checks.testFlag(SameApplicationCheck::AllowCrossProcesses)) { | 643 | if (checks.testFlag(SameApplicationCheck::AllowCrossProcesses)) { | ||
Show All 32 Lines | |||||
715 | void ShellClient::closeWindow() | 676 | void ShellClient::closeWindow() | ||
716 | { | 677 | { | ||
717 | if (m_xdgShellSurface && isCloseable()) { | 678 | if (m_xdgShellSurface && isCloseable()) { | ||
718 | m_xdgShellSurface->close(); | 679 | m_xdgShellSurface->close(); | ||
719 | const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface); | 680 | const qint32 pingSerial = static_cast<XdgShellInterface *>(m_xdgShellSurface->global())->ping(m_xdgShellSurface); | ||
720 | m_pingSerials.insert(pingSerial, PingReason::CloseWindow); | 681 | m_pingSerials.insert(pingSerial, PingReason::CloseWindow); | ||
721 | } else if (m_qtExtendedSurface && isCloseable()) { | 682 | } else if (m_qtExtendedSurface && isCloseable()) { | ||
722 | m_qtExtendedSurface->close(); | 683 | m_qtExtendedSurface->close(); | ||
723 | } else if (m_internalWindow) { | | |||
724 | m_internalWindow->hide(); | | |||
725 | } | 684 | } | ||
726 | } | 685 | } | ||
727 | 686 | | |||
728 | AbstractClient *ShellClient::findModal(bool allow_itself) | 687 | AbstractClient *ShellClient::findModal(bool allow_itself) | ||
729 | { | 688 | { | ||
730 | Q_UNUSED(allow_itself) | 689 | Q_UNUSED(allow_itself) | ||
731 | return nullptr; | 690 | return nullptr; | ||
732 | } | 691 | } | ||
733 | 692 | | |||
734 | bool ShellClient::isCloseable() const | 693 | bool ShellClient::isCloseable() const | ||
735 | { | 694 | { | ||
736 | if (m_windowType == NET::Desktop || m_windowType == NET::Dock) { | 695 | if (m_windowType == NET::Desktop || m_windowType == NET::Dock) { | ||
737 | return false; | 696 | return false; | ||
738 | } | 697 | } | ||
739 | if (m_xdgShellSurface) { | 698 | if (m_xdgShellSurface) { | ||
740 | return true; | 699 | return true; | ||
741 | } | 700 | } | ||
742 | if (m_internal) { | | |||
743 | return true; | | |||
744 | } | | |||
745 | return m_qtExtendedSurface ? true : false; | 701 | return m_qtExtendedSurface ? true : false; | ||
746 | } | 702 | } | ||
747 | 703 | | |||
748 | bool ShellClient::isFullScreen() const | 704 | bool ShellClient::isFullScreen() const | ||
749 | { | 705 | { | ||
750 | return m_fullScreen; | 706 | return m_fullScreen; | ||
751 | } | 707 | } | ||
752 | 708 | | |||
753 | bool ShellClient::isMaximizable() const | 709 | bool ShellClient::isMaximizable() const | ||
754 | { | 710 | { | ||
755 | if (m_internal) { | | |||
756 | return false; | | |||
757 | } | | |||
758 | return true; | 711 | return true; | ||
759 | } | 712 | } | ||
760 | 713 | | |||
761 | bool ShellClient::isMinimizable() const | 714 | bool ShellClient::isMinimizable() const | ||
762 | { | 715 | { | ||
763 | if (m_internal) { | | |||
764 | return false; | | |||
765 | } | | |||
766 | return (!m_plasmaShellSurface || m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal); | 716 | return (!m_plasmaShellSurface || m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal); | ||
767 | } | 717 | } | ||
768 | 718 | | |||
769 | bool ShellClient::isMovable() const | 719 | bool ShellClient::isMovable() const | ||
770 | { | 720 | { | ||
771 | if (m_plasmaShellSurface) { | 721 | if (m_plasmaShellSurface) { | ||
772 | return m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal; | 722 | return m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Normal; | ||
773 | } | 723 | } | ||
▲ Show 20 Lines • Show All 151 Lines • ▼ Show 20 Line(s) | |||||
925 | 875 | | |||
926 | MaximizeMode ShellClient::requestedMaximizeMode() const | 876 | MaximizeMode ShellClient::requestedMaximizeMode() const | ||
927 | { | 877 | { | ||
928 | return m_requestedMaximizeMode; | 878 | return m_requestedMaximizeMode; | ||
929 | } | 879 | } | ||
930 | 880 | | |||
931 | bool ShellClient::noBorder() const | 881 | bool ShellClient::noBorder() const | ||
932 | { | 882 | { | ||
933 | if (isInternal()) { | | |||
934 | return m_internalWindowFlags.testFlag(Qt::FramelessWindowHint) || m_internalWindowFlags.testFlag(Qt::Popup); | | |||
935 | } | | |||
936 | if (m_serverDecoration) { | 883 | if (m_serverDecoration) { | ||
937 | if (m_serverDecoration->mode() == ServerSideDecorationManagerInterface::Mode::Server) { | 884 | if (m_serverDecoration->mode() == ServerSideDecorationManagerInterface::Mode::Server) { | ||
938 | return m_userNoBorder || isFullScreen(); | 885 | return m_userNoBorder || isFullScreen(); | ||
939 | } | 886 | } | ||
940 | } | 887 | } | ||
941 | if (m_xdgDecoration && m_xdgDecoration->requestedMode() != XdgDecorationInterface::Mode::ClientSide) { | 888 | if (m_xdgDecoration && m_xdgDecoration->requestedMode() != XdgDecorationInterface::Mode::ClientSide) { | ||
942 | return m_userNoBorder || isFullScreen(); | 889 | return m_userNoBorder || isFullScreen(); | ||
943 | } | 890 | } | ||
▲ Show 20 Lines • Show All 119 Lines • ▼ Show 20 Line(s) | |||||
1063 | bool ShellClient::userCanSetNoBorder() const | 1010 | bool ShellClient::userCanSetNoBorder() const | ||
1064 | { | 1011 | { | ||
1065 | if (m_serverDecoration && m_serverDecoration->mode() == ServerSideDecorationManagerInterface::Mode::Server) { | 1012 | if (m_serverDecoration && m_serverDecoration->mode() == ServerSideDecorationManagerInterface::Mode::Server) { | ||
1066 | return !isFullScreen() && !isShade() && !tabGroup(); | 1013 | return !isFullScreen() && !isShade() && !tabGroup(); | ||
1067 | } | 1014 | } | ||
1068 | if (m_xdgDecoration && m_xdgDecoration->requestedMode() != XdgDecorationInterface::Mode::ClientSide) { | 1015 | if (m_xdgDecoration && m_xdgDecoration->requestedMode() != XdgDecorationInterface::Mode::ClientSide) { | ||
1069 | return !isFullScreen() && !isShade() && !tabGroup(); | 1016 | return !isFullScreen() && !isShade() && !tabGroup(); | ||
1070 | } | 1017 | } | ||
1071 | if (m_internal) { | | |||
1072 | return !m_internalWindowFlags.testFlag(Qt::FramelessWindowHint) || m_internalWindowFlags.testFlag(Qt::Popup); | | |||
1073 | } | | |||
1074 | return false; | 1018 | return false; | ||
1075 | } | 1019 | } | ||
1076 | 1020 | | |||
1077 | bool ShellClient::wantsInput() const | 1021 | bool ShellClient::wantsInput() const | ||
1078 | { | 1022 | { | ||
1079 | return rules()->checkAcceptFocus(acceptsFocus()); | 1023 | return rules()->checkAcceptFocus(acceptsFocus()); | ||
1080 | } | 1024 | } | ||
1081 | 1025 | | |||
1082 | bool ShellClient::acceptsFocus() const | 1026 | bool ShellClient::acceptsFocus() const | ||
1083 | { | 1027 | { | ||
1084 | if (isInternal()) { | | |||
1085 | return false; | | |||
1086 | } | | |||
1087 | if (waylandServer()->inputMethodConnection() == surface()->client()) { | 1028 | if (waylandServer()->inputMethodConnection() == surface()->client()) { | ||
1088 | return false; | 1029 | return false; | ||
1089 | } | 1030 | } | ||
1090 | if (m_plasmaShellSurface) { | 1031 | if (m_plasmaShellSurface) { | ||
1091 | if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::OnScreenDisplay || | 1032 | if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::OnScreenDisplay || | ||
1092 | m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::ToolTip || | 1033 | m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::ToolTip || | ||
1093 | m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Notification) { | 1034 | m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Notification) { | ||
1094 | return false; | 1035 | return false; | ||
Show All 17 Lines | 1052 | if (m_xdgShellSurface) { | |||
1112 | // TODO: proper | 1053 | // TODO: proper | ||
1113 | return true; | 1054 | return true; | ||
1114 | } | 1055 | } | ||
1115 | return false; | 1056 | return false; | ||
1116 | } | 1057 | } | ||
1117 | 1058 | | |||
1118 | void ShellClient::createWindowId() | 1059 | void ShellClient::createWindowId() | ||
1119 | { | 1060 | { | ||
1120 | if (m_internalWindow) { | 1061 | if (!m_internal) { | ||
1121 | m_windowId = m_internalWindow->winId(); | | |||
1122 | } else { | | |||
1123 | m_windowId = waylandServer()->createWindowId(surface()); | 1062 | m_windowId = waylandServer()->createWindowId(surface()); | ||
1124 | } | 1063 | } | ||
1125 | } | 1064 | } | ||
1126 | 1065 | | |||
1127 | void ShellClient::findInternalWindow() | | |||
1128 | { | | |||
1129 | if (surface()->client() != waylandServer()->internalConnection()) { | | |||
1130 | return; | | |||
1131 | } | | |||
1132 | const QWindowList windows = kwinApp()->topLevelWindows(); | | |||
1133 | for (QWindow *w: windows) { | | |||
1134 | auto s = KWayland::Client::Surface::fromWindow(w); | | |||
1135 | if (!s) { | | |||
1136 | continue; | | |||
1137 | } | | |||
1138 | if (s->id() != surface()->id()) { | | |||
1139 | continue; | | |||
1140 | } | | |||
1141 | m_internalWindow = w; | | |||
1142 | m_internalWindowFlags = m_internalWindow->flags(); | | |||
1143 | connect(m_internalWindow, &QWindow::xChanged, this, &ShellClient::updateInternalWindowGeometry); | | |||
1144 | connect(m_internalWindow, &QWindow::yChanged, this, &ShellClient::updateInternalWindowGeometry); | | |||
1145 | connect(m_internalWindow, &QWindow::destroyed, this, [this] { m_internalWindow = nullptr; }); | | |||
1146 | connect(m_internalWindow, &QWindow::opacityChanged, this, &ShellClient::setOpacity); | | |||
1147 | | ||||
1148 | const QVariant windowType = m_internalWindow->property("kwin_windowType"); | | |||
1149 | if (!windowType.isNull()) { | | |||
1150 | m_windowType = windowType.value<NET::WindowType>(); | | |||
1151 | } | | |||
1152 | setOpacity(m_internalWindow->opacity()); | | |||
1153 | | ||||
1154 | // skip close animation support | | |||
1155 | setSkipCloseAnimation(m_internalWindow->property(s_skipClosePropertyName).toBool()); | | |||
1156 | m_internalWindow->installEventFilter(this); | | |||
1157 | return; | | |||
1158 | } | | |||
1159 | } | | |||
1160 | | ||||
1161 | void ShellClient::updateInternalWindowGeometry() | | |||
1162 | { | | |||
1163 | if (!m_internalWindow) { | | |||
1164 | return; | | |||
1165 | } | | |||
1166 | doSetGeometry(QRect(m_internalWindow->geometry().topLeft() - QPoint(borderLeft(), borderTop()), | | |||
1167 | m_internalWindow->geometry().size() + QSize(borderLeft() + borderRight(), borderTop() + borderBottom()))); | | |||
1168 | } | | |||
1169 | | ||||
1170 | pid_t ShellClient::pid() const | 1066 | pid_t ShellClient::pid() const | ||
1171 | { | 1067 | { | ||
1172 | return surface()->client()->processId(); | 1068 | return surface()->client()->processId(); | ||
1173 | } | 1069 | } | ||
1174 | 1070 | | |||
1175 | bool ShellClient::isInternal() const | 1071 | bool ShellClient::isInternal() const | ||
1176 | { | 1072 | { | ||
1177 | return m_internal; | 1073 | return false; | ||
1178 | } | 1074 | } | ||
1179 | 1075 | | |||
1180 | bool ShellClient::isLockScreen() const | 1076 | bool ShellClient::isLockScreen() const | ||
1181 | { | 1077 | { | ||
1182 | if (m_internalWindow) { | | |||
1183 | return m_internalWindow->property("org_kde_ksld_emergency").toBool(); | | |||
1184 | } | | |||
1185 | return surface()->client() == waylandServer()->screenLockerClientConnection(); | 1078 | return surface()->client() == waylandServer()->screenLockerClientConnection(); | ||
1186 | } | 1079 | } | ||
1187 | 1080 | | |||
1188 | bool ShellClient::isInputMethod() const | 1081 | bool ShellClient::isInputMethod() const | ||
1189 | { | 1082 | { | ||
1190 | if (m_internal && m_internalWindow) { | | |||
1191 | return m_internalWindow->property("__kwin_input_method").toBool(); | | |||
1192 | } | | |||
1193 | return surface()->client() == waylandServer()->inputMethodConnection(); | 1083 | return surface()->client() == waylandServer()->inputMethodConnection(); | ||
1194 | } | 1084 | } | ||
1195 | 1085 | | |||
1196 | void ShellClient::requestGeometry(const QRect &rect) | 1086 | bool ShellClient::requestGeometry(const QRect &rect) | ||
1197 | { | 1087 | { | ||
1198 | if (m_requestGeometryBlockCounter != 0) { | 1088 | if (m_requestGeometryBlockCounter != 0) { | ||
1199 | m_blockedRequestGeometry = rect; | 1089 | m_blockedRequestGeometry = rect; | ||
1200 | return; | 1090 | return false; | ||
1201 | } | 1091 | } | ||
1202 | PendingConfigureRequest configureRequest; | 1092 | PendingConfigureRequest configureRequest; | ||
1203 | configureRequest.positionAfterResize = rect.topLeft(); | 1093 | configureRequest.positionAfterResize = rect.topLeft(); | ||
1204 | configureRequest.maximizeMode = m_requestedMaximizeMode; | 1094 | configureRequest.maximizeMode = m_requestedMaximizeMode; | ||
1205 | 1095 | | |||
1206 | const QSize size = rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); | 1096 | const QSize size = rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()); | ||
1207 | m_requestedClientSize = size; | 1097 | m_requestedClientSize = size; | ||
1208 | 1098 | | |||
Show All 10 Lines | 1107 | if (parent) { | |||
1219 | const QPoint relativeOffset = rect.topLeft() -globalClientContentPos; | 1109 | const QPoint relativeOffset = rect.topLeft() -globalClientContentPos; | ||
1220 | configureRequest.serialId = m_xdgShellPopup->configure(QRect(relativeOffset, rect.size())); | 1110 | configureRequest.serialId = m_xdgShellPopup->configure(QRect(relativeOffset, rect.size())); | ||
1221 | } | 1111 | } | ||
1222 | } | 1112 | } | ||
1223 | 1113 | | |||
1224 | m_pendingConfigureRequests.append(configureRequest); | 1114 | m_pendingConfigureRequests.append(configureRequest); | ||
1225 | 1115 | | |||
1226 | m_blockedRequestGeometry = QRect(); | 1116 | m_blockedRequestGeometry = QRect(); | ||
1227 | if (m_internal) { | 1117 | return true; | ||
1228 | m_internalWindow->setGeometry(QRect(rect.topLeft() + QPoint(borderLeft(), borderTop()), rect.size() - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()))); | | |||
1229 | } | | |||
1230 | } | 1118 | } | ||
1231 | 1119 | | |||
1232 | void ShellClient::updatePendingGeometry() | 1120 | void ShellClient::updatePendingGeometry() | ||
1233 | { | 1121 | { | ||
1234 | QPoint position = geom.topLeft(); | 1122 | QPoint position = geom.topLeft(); | ||
1235 | MaximizeMode maximizeMode = m_maximizeMode; | 1123 | MaximizeMode maximizeMode = m_maximizeMode; | ||
1236 | for (auto it = m_pendingConfigureRequests.begin(); it != m_pendingConfigureRequests.end(); it++) { | 1124 | for (auto it = m_pendingConfigureRequests.begin(); it != m_pendingConfigureRequests.end(); it++) { | ||
1237 | if (it->serialId > m_lastAckedConfigureRequest) { | 1125 | if (it->serialId > m_lastAckedConfigureRequest) { | ||
Show All 33 Lines | 1158 | if (h > area.height()) { | |||
1271 | h = area.height(); | 1159 | h = area.height(); | ||
1272 | } | 1160 | } | ||
1273 | if (m_shellSurface) { | 1161 | if (m_shellSurface) { | ||
1274 | m_shellSurface->requestSize(QSize(w, h)); | 1162 | m_shellSurface->requestSize(QSize(w, h)); | ||
1275 | } | 1163 | } | ||
1276 | if (m_xdgShellSurface) { | 1164 | if (m_xdgShellSurface) { | ||
1277 | m_xdgShellSurface->configure(xdgSurfaceStates(), QSize(w, h)); | 1165 | m_xdgShellSurface->configure(xdgSurfaceStates(), QSize(w, h)); | ||
1278 | } | 1166 | } | ||
1279 | if (m_internal) { | | |||
1280 | m_internalWindow->setGeometry(QRect(pos() + QPoint(borderLeft(), borderTop()), QSize(w, h) - QSize(borderLeft() + borderRight(), borderTop() + borderBottom()))); | | |||
1281 | } | | |||
1282 | } | 1167 | } | ||
1283 | 1168 | | |||
1284 | void ShellClient::unmap() | 1169 | void ShellClient::unmap() | ||
1285 | { | 1170 | { | ||
1286 | m_unmapped = true; | 1171 | m_unmapped = true; | ||
1287 | m_requestedClientSize = QSize(0, 0); | 1172 | m_requestedClientSize = QSize(0, 0); | ||
1288 | destroyWindowManagementInterface(); | 1173 | destroyWindowManagementInterface(); | ||
1289 | if (Workspace::self()) { | 1174 | if (Workspace::self()) { | ||
1290 | addWorkspaceRepaint(visibleRect()); | 1175 | addWorkspaceRepaint(visibleRect()); | ||
1291 | workspace()->clientHidden(this); | 1176 | workspace()->clientHidden(this); | ||
1292 | } | 1177 | } | ||
1293 | emit windowHidden(this); | 1178 | emit windowHidden(this); | ||
1294 | } | 1179 | } | ||
1295 | 1180 | | |||
1296 | void ShellClient::installPlasmaShellSurface(PlasmaShellSurfaceInterface *surface) | 1181 | void ShellClient::installPlasmaShellSurface(PlasmaShellSurfaceInterface *surface) | ||
1297 | { | 1182 | { | ||
1298 | m_plasmaShellSurface = surface; | 1183 | m_plasmaShellSurface = surface; | ||
1299 | auto updatePosition = [this, surface] { | 1184 | auto updatePosition = [this, surface] { | ||
1300 | QRect rect = QRect(surface->position(), m_clientSize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom())); | 1185 | QRect rect = QRect(surface->position(), m_clientSize + QSize(borderLeft() + borderRight(), borderTop() + borderBottom())); | ||
1301 | // Shell surfaces of internal windows are sometimes desync to current value. | | |||
1302 | // Make sure to not set window geometry of internal windows to invalid values (bug 386304) | | |||
1303 | if (!m_internal || rect.isValid()) { | | |||
zzag: If I add `!m_internal` check back, plasma surfaces are no longer misplaced. | |||||
ok, will update. It means the complete if needs to go. !m_internal is always true for Plasma shell so the second part never mattered. graesslin: ok, will update. It means the complete if needs to go. !m_internal is always true for Plasma… | |||||
Hmm, what about internal Plasma::Dialogs(e.g. an osd that shows up after switching between virtual desktops)? Won't this cause any issues? zzag: Hmm, what about internal `Plasma::Dialog`s(e.g. an osd that shows up after switching between… | |||||
Yes and no. Currently this is broken. We have lots of bug reports about geometry being wrong for osd. This is in fact the main motivation for this change and the work on getting the QPA Wayland free. I consider that this won't work after the change, but it won't be broken more than currently and will allow to fixup properly afterwards. graesslin: Yes and no. Currently this is broken. We have lots of bug reports about geometry being wrong… | |||||
Agreed, there are definitely some problems with OSDs, but I personally would prefer to keep things as they are. This change is about splitting internal entities in KWin, so users shouldn't see any difference before and after. zzag: Agreed, there are definitely some problems with OSDs, but I personally would prefer to keep… | |||||
1304 | doSetGeometry(rect); | 1186 | doSetGeometry(rect); | ||
1305 | } | | |||
1306 | }; | 1187 | }; | ||
1307 | auto updateRole = [this, surface] { | 1188 | auto updateRole = [this, surface] { | ||
1308 | NET::WindowType type = NET::Unknown; | 1189 | NET::WindowType type = NET::Unknown; | ||
1309 | switch (surface->role()) { | 1190 | switch (surface->role()) { | ||
1310 | case PlasmaShellSurfaceInterface::Role::Desktop: | 1191 | case PlasmaShellSurfaceInterface::Role::Desktop: | ||
1311 | type = NET::Desktop; | 1192 | type = NET::Desktop; | ||
1312 | break; | 1193 | break; | ||
1313 | case PlasmaShellSurfaceInterface::Role::Panel: | 1194 | case PlasmaShellSurfaceInterface::Role::Panel: | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 1372 | connect(m_paletteInterface, &ServerSideDecorationPaletteInterface::paletteChanged, this, [=](const QString &palette) { | |||
1492 | updatePalette(palette); | 1373 | updatePalette(palette); | ||
1493 | }); | 1374 | }); | ||
1494 | connect(m_paletteInterface, &QObject::destroyed, this, [=]() { | 1375 | connect(m_paletteInterface, &QObject::destroyed, this, [=]() { | ||
1495 | updatePalette(QString()); | 1376 | updatePalette(QString()); | ||
1496 | }); | 1377 | }); | ||
1497 | updatePalette(palette->palette()); | 1378 | updatePalette(palette->palette()); | ||
1498 | } | 1379 | } | ||
1499 | 1380 | | |||
1500 | | ||||
1501 | bool ShellClient::eventFilter(QObject *watched, QEvent *event) | | |||
1502 | { | | |||
1503 | if (watched == m_internalWindow && event->type() == QEvent::DynamicPropertyChange) { | | |||
1504 | QDynamicPropertyChangeEvent *pe = static_cast<QDynamicPropertyChangeEvent*>(event); | | |||
1505 | if (pe->propertyName() == s_skipClosePropertyName) { | | |||
1506 | setSkipCloseAnimation(m_internalWindow->property(s_skipClosePropertyName).toBool()); | | |||
1507 | } | | |||
1508 | if (pe->propertyName() == "kwin_windowType") { | | |||
1509 | m_windowType = m_internalWindow->property("kwin_windowType").value<NET::WindowType>(); | | |||
1510 | workspace()->updateClientArea(); | | |||
1511 | } | | |||
1512 | } | | |||
1513 | return false; | | |||
1514 | } | | |||
1515 | | ||||
1516 | void ShellClient::updateColorScheme() | 1381 | void ShellClient::updateColorScheme() | ||
1517 | { | 1382 | { | ||
1518 | if (m_paletteInterface) { | 1383 | if (m_paletteInterface) { | ||
1519 | AbstractClient::updateColorScheme(rules()->checkDecoColor(m_paletteInterface->palette())); | 1384 | AbstractClient::updateColorScheme(rules()->checkDecoColor(m_paletteInterface->palette())); | ||
1520 | } else { | 1385 | } else { | ||
1521 | AbstractClient::updateColorScheme(rules()->checkDecoColor(QString())); | 1386 | AbstractClient::updateColorScheme(rules()->checkDecoColor(QString())); | ||
1522 | } | 1387 | } | ||
1523 | } | 1388 | } | ||
▲ Show 20 Lines • Show All 316 Lines • ▼ Show 20 Line(s) | 1704 | connect(m_xdgDecoration, &XdgDecorationInterface::modeRequested, this, | |||
1840 | [this] () { | 1705 | [this] () { | ||
1841 | //force is true as we must send a new configure response | 1706 | //force is true as we must send a new configure response | ||
1842 | updateDecoration(false, true); | 1707 | updateDecoration(false, true); | ||
1843 | }); | 1708 | }); | ||
1844 | } | 1709 | } | ||
1845 | 1710 | | |||
1846 | bool ShellClient::shouldExposeToWindowManagement() | 1711 | bool ShellClient::shouldExposeToWindowManagement() | ||
1847 | { | 1712 | { | ||
1848 | if (isInternal()) { | 1713 | if (m_internal) { | ||
1849 | return false; | 1714 | return false; | ||
1850 | } | 1715 | } | ||
1851 | if (isLockScreen()) { | 1716 | if (isLockScreen()) { | ||
1852 | return false; | 1717 | return false; | ||
1853 | } | 1718 | } | ||
1854 | if (m_xdgShellPopup) { | 1719 | if (m_xdgShellPopup) { | ||
1855 | return false; | 1720 | return false; | ||
1856 | } | 1721 | } | ||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 1794 | if (m_plasmaShellSurface->role() == PlasmaShellSurfaceInterface::Role::Panel) { | |||
1930 | return m_plasmaShellSurface->panelTakesFocus(); | 1795 | return m_plasmaShellSurface->panelTakesFocus(); | ||
1931 | } | 1796 | } | ||
1932 | } | 1797 | } | ||
1933 | return false; | 1798 | return false; | ||
1934 | } | 1799 | } | ||
1935 | 1800 | | |||
1936 | void ShellClient::killWindow() | 1801 | void ShellClient::killWindow() | ||
1937 | { | 1802 | { | ||
1938 | if (isInternal()) { | | |||
1939 | return; | | |||
1940 | } | | |||
1941 | if (!surface()) { | 1803 | if (!surface()) { | ||
1942 | return; | 1804 | return; | ||
1943 | } | 1805 | } | ||
1944 | auto c = surface()->client(); | 1806 | auto c = surface()->client(); | ||
1945 | if (c->processId() == getpid() || c->processId() == 0) { | 1807 | if (c->processId() == getpid() || c->processId() == 0) { | ||
1946 | c->destroy(); | 1808 | c->destroy(); | ||
1947 | return; | 1809 | return; | ||
1948 | } | 1810 | } | ||
Show All 30 Lines | 1832 | { | |||
1979 | surface()->setOutputs(clientOutputs); | 1841 | surface()->setOutputs(clientOutputs); | ||
1980 | } | 1842 | } | ||
1981 | 1843 | | |||
1982 | bool ShellClient::isPopupWindow() const | 1844 | bool ShellClient::isPopupWindow() const | ||
1983 | { | 1845 | { | ||
1984 | if (Toplevel::isPopupWindow()) { | 1846 | if (Toplevel::isPopupWindow()) { | ||
1985 | return true; | 1847 | return true; | ||
1986 | } | 1848 | } | ||
1987 | if (isInternal()) { | | |||
1988 | return m_internalWindowFlags.testFlag(Qt::Popup); | | |||
1989 | } | | |||
1990 | if (m_shellSurface != nullptr) { | 1849 | if (m_shellSurface != nullptr) { | ||
1991 | return m_shellSurface->isPopup(); | 1850 | return m_shellSurface->isPopup(); | ||
1992 | } | 1851 | } | ||
1993 | if (m_xdgShellPopup != nullptr) { | 1852 | if (m_xdgShellPopup != nullptr) { | ||
1994 | return true; | 1853 | return true; | ||
1995 | } | 1854 | } | ||
1996 | return false; | 1855 | return false; | ||
1997 | } | 1856 | } | ||
1998 | 1857 | | |||
1858 | QWindow *ShellClient::internalWindow() const | ||||
1859 | { | ||||
1860 | return nullptr; | ||||
1861 | } | ||||
1862 | | ||||
1999 | } | 1863 | } |
If I add !m_internal check back, plasma surfaces are no longer misplaced.