Changeset View
Changeset View
Standalone View
Standalone View
scene.cpp
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Line(s) | |||||
80 | #include "subsurfacemonitor.h" | 80 | #include "subsurfacemonitor.h" | ||
81 | #include "wayland_server.h" | 81 | #include "wayland_server.h" | ||
82 | 82 | | |||
83 | #include "thumbnailitem.h" | 83 | #include "thumbnailitem.h" | ||
84 | 84 | | |||
85 | #include <KWaylandServer/buffer_interface.h> | 85 | #include <KWaylandServer/buffer_interface.h> | ||
86 | #include <KWaylandServer/subcompositor_interface.h> | 86 | #include <KWaylandServer/subcompositor_interface.h> | ||
87 | #include <KWaylandServer/surface_interface.h> | 87 | #include <KWaylandServer/surface_interface.h> | ||
88 | #include <KWaylandServer/screencast_interface.h> | ||||
89 | #include <KWaylandServer/plasmawindowmanagement_interface.h> | ||||
90 | #include <KLocalizedString> | ||||
88 | 91 | | |||
89 | namespace KWin | 92 | namespace KWin | ||
90 | { | 93 | { | ||
91 | 94 | | |||
92 | //**************************************** | 95 | //**************************************** | ||
93 | // Scene | 96 | // Scene | ||
94 | //**************************************** | 97 | //**************************************** | ||
95 | 98 | | |||
96 | Scene::Scene(QObject *parent) | 99 | Scene::Scene(QObject *parent) | ||
97 | : QObject(parent) | 100 | : QObject(parent) | ||
98 | { | 101 | { | ||
99 | last_time.invalidate(); // Initialize the timer | 102 | last_time.invalidate(); // Initialize the timer | ||
103 | | ||||
104 | if (waylandServer()) { | ||||
105 | connect(waylandServer()->screencast(), &KWaylandServer::ScreencastInterface::windowScreencastRequested, this, [this] (KWaylandServer::ScreencastStreamInterface* stream, quint32 winid) { | ||||
106 | Scene::Window *window = nullptr; | ||||
107 | for (auto it = m_windows.constBegin(), itEnd = m_windows.constEnd(); it != itEnd; ++it) { | ||||
108 | if (it.key()->windowManagementInterface() && it.key()->windowManagementInterface()->internalId() == winid) { | ||||
109 | window = it.value(); | ||||
110 | break; | ||||
111 | } | ||||
112 | } | ||||
113 | | ||||
114 | if (!window) { | ||||
115 | stream->sendFailed(i18n("Could not find window id %1", winid)); | ||||
116 | return; | ||||
117 | } | ||||
118 | | ||||
119 | window->startStreaming(stream); | ||||
120 | }); | ||||
121 | } | ||||
100 | } | 122 | } | ||
101 | 123 | | |||
102 | Scene::~Scene() | 124 | Scene::~Scene() | ||
103 | { | 125 | { | ||
104 | Q_ASSERT(m_windows.isEmpty()); | 126 | Q_ASSERT(m_windows.isEmpty()); | ||
105 | } | 127 | } | ||
106 | 128 | | |||
107 | // returns mask and possibly modified region | 129 | // returns mask and possibly modified region | ||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Line(s) | 465 | { | |||
452 | if (window->shadow()) { | 474 | if (window->shadow()) { | ||
453 | window->shadow()->setToplevel(deleted); | 475 | window->shadow()->setToplevel(deleted); | ||
454 | } | 476 | } | ||
455 | m_windows[deleted] = window; | 477 | m_windows[deleted] = window; | ||
456 | } | 478 | } | ||
457 | 479 | | |||
458 | void Scene::windowGeometryShapeChanged(Toplevel *c) | 480 | void Scene::windowGeometryShapeChanged(Toplevel *c) | ||
459 | { | 481 | { | ||
460 | if (!m_windows.contains(c)) // this is ok, shape is not valid by default | 482 | Window *w = m_windows.value(c); | ||
483 | if (!w) // this is ok, shape is not valid by default | ||||
461 | return; | 484 | return; | ||
462 | Window *w = m_windows[ c ]; | | |||
463 | w->discardShape(); | 485 | w->discardShape(); | ||
464 | } | 486 | } | ||
465 | 487 | | |||
466 | void Scene::createStackingOrder(const QList<Toplevel *> &toplevels) | 488 | void Scene::createStackingOrder(const QList<Toplevel *> &toplevels) | ||
467 | { | 489 | { | ||
468 | // TODO: cache the stacking_order in case it has not changed | 490 | // TODO: cache the stacking_order in case it has not changed | ||
469 | foreach (Toplevel *c, toplevels) { | 491 | foreach (Toplevel *c, toplevels) { | ||
470 | Q_ASSERT(m_windows.contains(c)); | 492 | Q_ASSERT(m_windows.contains(c)); | ||
▲ Show 20 Lines • Show All 614 Lines • ▼ Show 20 Line(s) | 1106 | { | |||
1085 | // The tracked damage will be reset after the scene is done with copying buffer's data. | 1107 | // The tracked damage will be reset after the scene is done with copying buffer's data. | ||
1086 | // Note that we have to be prepared for the case where no damage has occurred since kwin | 1108 | // Note that we have to be prepared for the case where no damage has occurred since kwin | ||
1087 | // core may discard the current window pixmap at any moment. | 1109 | // core may discard the current window pixmap at any moment. | ||
1088 | if (!m_currentPixmap || !window()->damage().isEmpty()) { | 1110 | if (!m_currentPixmap || !window()->damage().isEmpty()) { | ||
1089 | updatePixmap(); | 1111 | updatePixmap(); | ||
1090 | } | 1112 | } | ||
1091 | } | 1113 | } | ||
1092 | 1114 | | |||
1115 | void Scene::Window::startStreaming(KWaylandServer::ScreencastStreamInterface *stream) | ||||
1116 | { | ||||
1117 | stream->sendFailed(i18n("Streaming not supported")); | ||||
1118 | } | ||||
1119 | | ||||
1093 | //**************************************** | 1120 | //**************************************** | ||
1094 | // WindowPixmap | 1121 | // WindowPixmap | ||
1095 | //**************************************** | 1122 | //**************************************** | ||
1096 | WindowPixmap::WindowPixmap(Scene::Window *window) | 1123 | WindowPixmap::WindowPixmap(Scene::Window *window) | ||
1097 | : m_window(window) | 1124 | : m_window(window) | ||
1098 | , m_pixmap(XCB_PIXMAP_NONE) | 1125 | , m_pixmap(XCB_PIXMAP_NONE) | ||
1099 | , m_discarded(false) | 1126 | , m_discarded(false) | ||
1100 | { | 1127 | { | ||
▲ Show 20 Lines • Show All 210 Lines • Show Last 20 Lines |