Changeset View
Changeset View
Standalone View
Standalone View
shadow.cpp
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 52 | { | |||
---|---|---|---|---|---|
60 | if (!shadow && kwinApp()->x11Connection()) { | 60 | if (!shadow && kwinApp()->x11Connection()) { | ||
61 | shadow = createShadowFromX11(toplevel); | 61 | shadow = createShadowFromX11(toplevel); | ||
62 | } | 62 | } | ||
63 | if (!shadow) { | 63 | if (!shadow) { | ||
64 | return nullptr; | 64 | return nullptr; | ||
65 | } | 65 | } | ||
66 | if (toplevel->effectWindow() && toplevel->effectWindow()->sceneWindow()) { | 66 | if (toplevel->effectWindow() && toplevel->effectWindow()->sceneWindow()) { | ||
67 | toplevel->effectWindow()->sceneWindow()->updateShadow(shadow); | 67 | toplevel->effectWindow()->sceneWindow()->updateShadow(shadow); | ||
68 | } | 68 | emit toplevel->shadowChanged(); | ||
69 | if (toplevel->effectWindow()) { | | |||
70 | toplevel->effectWindow()->buildQuads(true); | | |||
71 | } | 69 | } | ||
72 | return shadow; | 70 | return shadow; | ||
73 | } | 71 | } | ||
74 | 72 | | |||
75 | Shadow *Shadow::createShadowFromX11(Toplevel *toplevel) | 73 | Shadow *Shadow::createShadowFromX11(Toplevel *toplevel) | ||
76 | { | 74 | { | ||
77 | auto data = Shadow::readX11ShadowProperty(toplevel->window()); | 75 | auto data = Shadow::readX11ShadowProperty(toplevel->window()); | ||
78 | if (!data.isEmpty()) { | 76 | if (!data.isEmpty()) { | ||
▲ Show 20 Lines • Show All 249 Lines • ▼ Show 20 Line(s) | 253 | { | |||
328 | leftQuad[ 1 ] = WindowVertex(outerRect.x() + left.width(), outerRect.y() + topLeft.height(), 1.0, 0.0); | 326 | leftQuad[ 1 ] = WindowVertex(outerRect.x() + left.width(), outerRect.y() + topLeft.height(), 1.0, 0.0); | ||
329 | leftQuad[ 2 ] = WindowVertex(outerRect.x() + left.width(), outerRect.bottom() - bottomLeft.height(), 1.0, 1.0); | 327 | leftQuad[ 2 ] = WindowVertex(outerRect.x() + left.width(), outerRect.bottom() - bottomLeft.height(), 1.0, 1.0); | ||
330 | leftQuad[ 3 ] = WindowVertex(outerRect.x(), outerRect.bottom() - bottomLeft.height(), 0.0, 1.0); | 328 | leftQuad[ 3 ] = WindowVertex(outerRect.x(), outerRect.bottom() - bottomLeft.height(), 0.0, 1.0); | ||
331 | m_shadowQuads.append(leftQuad); | 329 | m_shadowQuads.append(leftQuad); | ||
332 | } | 330 | } | ||
333 | 331 | | |||
334 | bool Shadow::updateShadow() | 332 | bool Shadow::updateShadow() | ||
335 | { | 333 | { | ||
336 | auto clear = [this]() { | 334 | auto clear = [this] { | ||
337 | if (m_topLevel && m_topLevel->effectWindow() && m_topLevel->effectWindow()->sceneWindow() && | 335 | if (m_topLevel && m_topLevel->shadow()) { | ||
338 | m_topLevel->effectWindow()->sceneWindow()->shadow()) { | | |||
339 | auto w = m_topLevel->effectWindow(); | 336 | auto w = m_topLevel->effectWindow(); | ||
340 | // this also deletes the shadow | 337 | // this also deletes the shadow | ||
341 | w->sceneWindow()->updateShadow(nullptr); | 338 | w->sceneWindow()->updateShadow(nullptr); | ||
342 | w->buildQuads(true); | 339 | emit m_topLevel->shadowChanged(); | ||
343 | } | 340 | } | ||
344 | }; | 341 | }; | ||
342 | | ||||
343 | if (!m_topLevel) { | ||||
344 | return false; | ||||
345 | } | ||||
346 | | ||||
345 | if (m_decorationShadow) { | 347 | if (m_decorationShadow) { | ||
346 | if (AbstractClient *c = qobject_cast<AbstractClient*>(m_topLevel)) { | 348 | if (AbstractClient *c = qobject_cast<AbstractClient*>(m_topLevel)) { | ||
347 | if (c->decoration()) { | 349 | if (c->decoration()) { | ||
348 | if (init(c->decoration())) { | 350 | if (init(c->decoration())) { | ||
349 | if (m_topLevel && m_topLevel->effectWindow()) | 351 | emit m_topLevel->shadowChanged(); | ||
350 | m_topLevel->effectWindow()->buildQuads(true); | | |||
351 | return true; | 352 | return true; | ||
352 | } | 353 | } | ||
353 | } | 354 | } | ||
354 | } | 355 | } | ||
355 | clear(); | 356 | clear(); | ||
356 | return false; | 357 | return false; | ||
357 | } | 358 | } | ||
359 | | ||||
358 | if (waylandServer()) { | 360 | if (waylandServer()) { | ||
359 | if (m_topLevel && m_topLevel->surface()) { | 361 | if (m_topLevel && m_topLevel->surface()) { | ||
360 | if (const auto &s = m_topLevel->surface()->shadow()) { | 362 | if (const auto &s = m_topLevel->surface()->shadow()) { | ||
361 | if (init(s)) { | 363 | if (init(s)) { | ||
362 | if (m_topLevel->effectWindow()) { | 364 | emit m_topLevel->shadowChanged(); | ||
363 | m_topLevel->effectWindow()->buildQuads(true); | | |||
364 | } | | |||
365 | return true; | 365 | return true; | ||
366 | } | 366 | } | ||
367 | } | 367 | } | ||
368 | } | 368 | } | ||
369 | } | 369 | } | ||
370 | if (!m_topLevel) { | 370 | | ||
371 | clear(); | | |||
372 | return false; | | |||
373 | } | | |||
374 | auto data = Shadow::readX11ShadowProperty(m_topLevel->window()); | 371 | auto data = Shadow::readX11ShadowProperty(m_topLevel->window()); | ||
375 | if (data.isEmpty()) { | 372 | if (data.isEmpty()) { | ||
376 | clear(); | 373 | clear(); | ||
377 | return false; | 374 | return false; | ||
378 | } | 375 | } | ||
376 | | ||||
379 | init(data); | 377 | init(data); | ||
380 | if (m_topLevel && m_topLevel->effectWindow()) | 378 | emit m_topLevel->shadowChanged(); | ||
381 | m_topLevel->effectWindow()->buildQuads(true); | 379 | | ||
382 | return true; | 380 | return true; | ||
383 | } | 381 | } | ||
384 | 382 | | |||
385 | void Shadow::setToplevel(Toplevel *topLevel) | 383 | void Shadow::setToplevel(Toplevel *topLevel) | ||
386 | { | 384 | { | ||
387 | m_topLevel = topLevel; | 385 | m_topLevel = topLevel; | ||
388 | connect(m_topLevel, SIGNAL(geometryChanged()), SLOT(geometryChanged())); | 386 | connect(m_topLevel, SIGNAL(geometryChanged()), SLOT(geometryChanged())); | ||
389 | } | 387 | } | ||
▲ Show 20 Lines • Show All 52 Lines • Show Last 20 Lines |