Changeset View
Changeset View
Standalone View
Standalone View
thumbnailitem.cpp
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
72 | void AbstractThumbnailItem::findParentEffectWindow() | 72 | void AbstractThumbnailItem::findParentEffectWindow() | ||
73 | { | 73 | { | ||
74 | if (effects) { | 74 | if (effects) { | ||
75 | QQuickWindow *qw = window(); | 75 | QQuickWindow *qw = window(); | ||
76 | if (!qw) { | 76 | if (!qw) { | ||
77 | qCDebug(KWIN_CORE) << "No QQuickWindow assigned yet"; | 77 | qCDebug(KWIN_CORE) << "No QQuickWindow assigned yet"; | ||
78 | return; | 78 | return; | ||
79 | } | 79 | } | ||
80 | if (auto *w = static_cast<EffectWindowImpl*>(effects->findWindow(qw->winId()))) { | 80 | if (auto *w = static_cast<EffectWindowImpl*>(effects->findWindow(qw))) { | ||
81 | m_parent = QWeakPointer<EffectWindowImpl>(w); | 81 | m_parent = QWeakPointer<EffectWindowImpl>(w); | ||
82 | } | 82 | } | ||
83 | } | 83 | } | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | void AbstractThumbnailItem::effectWindowAdded() | 86 | void AbstractThumbnailItem::effectWindowAdded() | ||
87 | { | 87 | { | ||
88 | // the window might be added before the EffectWindow is created | 88 | // the window might be added before the EffectWindow is created | ||
Show All 38 Lines | 124 | WindowThumbnailItem::WindowThumbnailItem(QQuickItem* parent) | |||
127 | , m_client(NULL) | 127 | , m_client(NULL) | ||
128 | { | 128 | { | ||
129 | } | 129 | } | ||
130 | 130 | | |||
131 | WindowThumbnailItem::~WindowThumbnailItem() | 131 | WindowThumbnailItem::~WindowThumbnailItem() | ||
132 | { | 132 | { | ||
133 | } | 133 | } | ||
134 | 134 | | |||
135 | void WindowThumbnailItem::setWId(qulonglong wId) | 135 | void WindowThumbnailItem::setWId(const QUuid &wId) | ||
136 | { | 136 | { | ||
137 | if (m_wId == wId) { | 137 | if (m_wId == wId) { | ||
138 | return; | 138 | return; | ||
139 | } | 139 | } | ||
140 | m_wId = wId; | 140 | m_wId = wId; | ||
141 | if (m_wId != 0) { | 141 | if (m_wId != 0) { | ||
142 | AbstractClient *c = Workspace::self()->findClient(Predicate::WindowMatch, m_wId); | 142 | setClient(workspace()->findAbstractClient([this] (const AbstractClient *c) { return c->internalId() == m_wId; })); | ||
143 | if (!c && waylandServer()) { | | |||
144 | c = waylandServer()->findClient(m_wId); | | |||
145 | } | | |||
146 | setClient(c); | | |||
147 | } else if (m_client) { | 143 | } else if (m_client) { | ||
148 | m_client = NULL; | 144 | m_client = NULL; | ||
149 | emit clientChanged(); | 145 | emit clientChanged(); | ||
150 | } | 146 | } | ||
151 | emit wIdChanged(wId); | 147 | emit wIdChanged(wId); | ||
152 | } | 148 | } | ||
153 | 149 | | |||
154 | void WindowThumbnailItem::setClient(AbstractClient *client) | 150 | void WindowThumbnailItem::setClient(AbstractClient *client) | ||
155 | { | 151 | { | ||
156 | if (m_client == client) { | 152 | if (m_client == client) { | ||
157 | return; | 153 | return; | ||
158 | } | 154 | } | ||
159 | m_client = client; | 155 | m_client = client; | ||
160 | if (m_client) { | 156 | if (m_client) { | ||
161 | setWId(m_client->windowId()); | 157 | setWId(m_client->internalId()); | ||
162 | } else { | 158 | } else { | ||
163 | setWId(0); | 159 | setWId({}); | ||
164 | } | 160 | } | ||
165 | emit clientChanged(); | 161 | emit clientChanged(); | ||
166 | } | 162 | } | ||
167 | 163 | | |||
168 | void WindowThumbnailItem::paint(QPainter *painter) | 164 | void WindowThumbnailItem::paint(QPainter *painter) | ||
169 | { | 165 | { | ||
170 | if (effects) { | 166 | if (effects) { | ||
171 | return; | 167 | return; | ||
172 | } | 168 | } | ||
173 | Client *client = Workspace::self()->findClient(Predicate::WindowMatch, m_wId); | 169 | auto client = workspace()->findAbstractClient([this] (const AbstractClient *c) { return c->internalId() == m_wId; }); | ||
174 | if (!client) { | 170 | if (!client) { | ||
175 | return; | 171 | return; | ||
176 | } | 172 | } | ||
177 | QPixmap pixmap = client->icon().pixmap(boundingRect().size().toSize()); | 173 | QPixmap pixmap = client->icon().pixmap(boundingRect().size().toSize()); | ||
178 | const QSize size(boundingRect().size().toSize() - pixmap.size()); | 174 | const QSize size(boundingRect().size().toSize() - pixmap.size()); | ||
179 | painter->drawPixmap(boundingRect().adjusted(size.width()/2.0, size.height()/2.0, -size.width()/2.0, -size.height()/2.0).toRect(), | 175 | painter->drawPixmap(boundingRect().adjusted(size.width()/2.0, size.height()/2.0, -size.width()/2.0, -size.height()/2.0).toRect(), | ||
180 | pixmap); | 176 | pixmap); | ||
181 | } | 177 | } | ||
182 | 178 | | |||
183 | void WindowThumbnailItem::repaint(KWin::EffectWindow *w) | 179 | void WindowThumbnailItem::repaint(KWin::EffectWindow *w) | ||
184 | { | 180 | { | ||
185 | if (static_cast<KWin::EffectWindowImpl*>(w)->window()->windowId() == m_wId) { | 181 | if (static_cast<KWin::EffectWindowImpl*>(w)->window()->internalId() == m_wId) { | ||
186 | update(); | 182 | update(); | ||
187 | } | 183 | } | ||
188 | } | 184 | } | ||
189 | 185 | | |||
190 | DesktopThumbnailItem::DesktopThumbnailItem(QQuickItem *parent) | 186 | DesktopThumbnailItem::DesktopThumbnailItem(QQuickItem *parent) | ||
191 | : AbstractThumbnailItem(parent) | 187 | : AbstractThumbnailItem(parent) | ||
192 | , m_desktop(0) | 188 | , m_desktop(0) | ||
193 | { | 189 | { | ||
Show All 34 Lines |