Changeset View
Changeset View
Standalone View
Standalone View
plugins/kdecorations/aurorae/src/aurorae.cpp
Show First 20 Lines • Show All 325 Lines • ▼ Show 20 Line(s) | 312 | // m_theme->setTabDragMimeType(tabDragMimeType()); | |||
---|---|---|---|---|---|
326 | 326 | | |||
327 | QVariant visualParent = property("visualParent"); | 327 | QVariant visualParent = property("visualParent"); | ||
328 | if (visualParent.isValid()) { | 328 | if (visualParent.isValid()) { | ||
329 | m_item->setParentItem(visualParent.value<QQuickItem*>()); | 329 | m_item->setParentItem(visualParent.value<QQuickItem*>()); | ||
330 | visualParent.value<QQuickItem*>()->setProperty("drawBackground", false); | 330 | visualParent.value<QQuickItem*>()->setProperty("drawBackground", false); | ||
331 | } else { | 331 | } else { | ||
332 | m_renderControl = new QQuickRenderControl(this); | 332 | m_renderControl = new QQuickRenderControl(this); | ||
333 | m_view = new QQuickWindow(m_renderControl); | 333 | m_view = new QQuickWindow(m_renderControl); | ||
334 | bool usingGL = m_view->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; | 334 | const bool usingGL = m_view->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; | ||
335 | m_view->setColor(Qt::transparent); | 335 | m_view->setColor(Qt::transparent); | ||
336 | m_view->setFlags(Qt::FramelessWindowHint); | 336 | m_view->setFlags(Qt::FramelessWindowHint); | ||
337 | if (usingGL) { | 337 | if (usingGL) { | ||
338 | // first create the context | 338 | // first create the context | ||
339 | QSurfaceFormat format; | 339 | QSurfaceFormat format; | ||
340 | format.setDepthBufferSize(16); | 340 | format.setDepthBufferSize(16); | ||
341 | format.setStencilBufferSize(8); | 341 | format.setStencilBufferSize(8); | ||
342 | m_context.reset(new QOpenGLContext); | 342 | m_context.reset(new QOpenGLContext); | ||
343 | m_context->setFormat(format); | 343 | m_context->setFormat(format); | ||
344 | m_context->create(); | 344 | m_context->create(); | ||
345 | // and the offscreen surface | 345 | // and the offscreen surface | ||
346 | m_offscreenSurface.reset(new QOffscreenSurface); | 346 | m_offscreenSurface.reset(new QOffscreenSurface); | ||
347 | m_offscreenSurface->setFormat(m_context->format()); | 347 | m_offscreenSurface->setFormat(m_context->format()); | ||
348 | m_offscreenSurface->create(); | 348 | m_offscreenSurface->create(); | ||
349 | 349 | | |||
350 | } | 350 | } | ||
351 | 351 | | |||
352 | // delay rendering a little bit for better performance | 352 | // delay rendering a little bit for better performance | ||
353 | m_updateTimer.reset(new QTimer); | 353 | m_updateTimer.reset(new QTimer); | ||
354 | m_updateTimer->setSingleShot(true); | 354 | m_updateTimer->setSingleShot(true); | ||
355 | m_updateTimer->setInterval(5); | 355 | m_updateTimer->setInterval(5); | ||
356 | connect(m_updateTimer.data(), &QTimer::timeout, this, | | |||
357 | [this, usingGL] { | | |||
358 | if (usingGL) { | | |||
359 | if (!m_context->makeCurrent(m_offscreenSurface.data())) { | | |||
360 | return; | | |||
361 | } | | |||
362 | if (m_fbo.isNull() || m_fbo->size() != m_view->size()) { | | |||
363 | m_fbo.reset(new QOpenGLFramebufferObject(m_view->size(), QOpenGLFramebufferObject::CombinedDepthStencil)); | | |||
364 | if (!m_fbo->isValid()) { | | |||
365 | qCWarning(AURORAE) << "Creating FBO as render target failed"; | | |||
366 | m_fbo.reset(); | | |||
367 | return; | | |||
368 | } | | |||
369 | } | | |||
370 | m_view->setRenderTarget(m_fbo.data()); | | |||
371 | m_view->resetOpenGLState(); | | |||
372 | } | | |||
373 | 356 | | |||
374 | m_buffer = m_renderControl->grab(); | 357 | connect(m_updateTimer.data(), &QTimer::timeout, this, &Decoration::updateBuffer); | ||
375 | | ||||
376 | m_contentRect = QRect(QPoint(0, 0), m_buffer.size()); | | |||
377 | if (m_padding && | | |||
378 | (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && | | |||
379 | !client().data()->isMaximized()) { | | |||
380 | m_contentRect = m_contentRect.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom()); | | |||
381 | } | | |||
382 | updateShadow(); | | |||
383 | | ||||
384 | QOpenGLFramebufferObject::bindDefault(); | | |||
385 | update(); | | |||
386 | } | | |||
387 | ); | | |||
388 | auto requestUpdate = [this] { | 358 | auto requestUpdate = [this] { | ||
389 | if (m_updateTimer->isActive()) { | 359 | if (m_updateTimer->isActive()) { | ||
390 | return; | 360 | return; | ||
391 | } | 361 | } | ||
392 | m_updateTimer->start(); | 362 | m_updateTimer->start(); | ||
393 | }; | 363 | }; | ||
394 | connect(m_renderControl, &QQuickRenderControl::renderRequested, this, requestUpdate); | 364 | connect(m_renderControl, &QQuickRenderControl::renderRequested, this, requestUpdate); | ||
395 | connect(m_renderControl, &QQuickRenderControl::sceneChanged, this, requestUpdate); | 365 | connect(m_renderControl, &QQuickRenderControl::sceneChanged, this, requestUpdate); | ||
396 | 366 | | |||
397 | m_item->setParentItem(m_view->contentItem()); | 367 | m_item->setParentItem(m_view->contentItem()); | ||
398 | 368 | | |||
399 | if (usingGL) { | 369 | if (usingGL) { | ||
400 | m_context->makeCurrent(m_offscreenSurface.data()); | 370 | m_context->makeCurrent(m_offscreenSurface.data()); | ||
401 | m_renderControl->initialize(m_context.data()); | 371 | m_renderControl->initialize(m_context.data()); | ||
402 | m_context->doneCurrent(); | 372 | m_context->doneCurrent(); | ||
403 | } | 373 | } | ||
404 | } | 374 | } | ||
zzag: We can't do this here because m_view hasn't been resized yet.
Color attachment is considered… | |||||
405 | setupBorders(m_item); | 375 | setupBorders(m_item); | ||
406 | // TODO: Is there a more efficient way to react to border changes? | 376 | // TODO: Is there a more efficient way to react to border changes? | ||
407 | auto trackBorders = [this](KWin::Borders *borders) { | 377 | auto trackBorders = [this](KWin::Borders *borders) { | ||
408 | if (!borders) { | 378 | if (!borders) { | ||
409 | return; | 379 | return; | ||
410 | } | 380 | } | ||
411 | connect(borders, &KWin::Borders::leftChanged, this, &Decoration::updateBorders); | 381 | connect(borders, &KWin::Borders::leftChanged, this, &Decoration::updateBorders); | ||
412 | connect(borders, &KWin::Borders::rightChanged, this, &Decoration::updateBorders); | 382 | connect(borders, &KWin::Borders::rightChanged, this, &Decoration::updateBorders); | ||
Show All 24 Lines | 402 | auto resizeWindow = [this] { | |||
437 | m_view->setGeometry(rect); | 407 | m_view->setGeometry(rect); | ||
438 | }; | 408 | }; | ||
439 | connect(this, &Decoration::bordersChanged, this, resizeWindow); | 409 | connect(this, &Decoration::bordersChanged, this, resizeWindow); | ||
440 | connect(client().data(), &KDecoration2::DecoratedClient::widthChanged, this, resizeWindow); | 410 | connect(client().data(), &KDecoration2::DecoratedClient::widthChanged, this, resizeWindow); | ||
441 | connect(client().data(), &KDecoration2::DecoratedClient::heightChanged, this, resizeWindow); | 411 | connect(client().data(), &KDecoration2::DecoratedClient::heightChanged, this, resizeWindow); | ||
442 | connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, resizeWindow); | 412 | connect(client().data(), &KDecoration2::DecoratedClient::maximizedChanged, this, resizeWindow); | ||
443 | connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, resizeWindow); | 413 | connect(client().data(), &KDecoration2::DecoratedClient::shadedChanged, this, resizeWindow); | ||
444 | resizeWindow(); | 414 | resizeWindow(); | ||
415 | updateBuffer(); | ||||
445 | } else { | 416 | } else { | ||
446 | // create a dummy shadow for the configuration interface | 417 | // create a dummy shadow for the configuration interface | ||
447 | if (m_padding) { | 418 | if (m_padding) { | ||
448 | auto s = QSharedPointer<KDecoration2::DecorationShadow>::create(); | 419 | auto s = QSharedPointer<KDecoration2::DecorationShadow>::create(); | ||
449 | s->setPadding(*m_padding); | 420 | s->setPadding(*m_padding); | ||
450 | s->setInnerShadowRect(QRect(m_padding->left(), m_padding->top(), 1, 1)); | 421 | s->setInnerShadowRect(QRect(m_padding->left(), m_padding->top(), 1, 1)); | ||
451 | setShadow(s); | 422 | setShadow(s); | ||
452 | } | 423 | } | ||
▲ Show 20 Lines • Show All 175 Lines • ▼ Show 20 Line(s) | 592 | { | |||
628 | }; | 599 | }; | ||
629 | update(); | 600 | update(); | ||
630 | connect(item, &QQuickItem::widthChanged, this, update); | 601 | connect(item, &QQuickItem::widthChanged, this, update); | ||
631 | connect(item, &QQuickItem::heightChanged, this, update); | 602 | connect(item, &QQuickItem::heightChanged, this, update); | ||
632 | connect(item, &QQuickItem::xChanged, this, update); | 603 | connect(item, &QQuickItem::xChanged, this, update); | ||
633 | connect(item, &QQuickItem::yChanged, this, update); | 604 | connect(item, &QQuickItem::yChanged, this, update); | ||
634 | } | 605 | } | ||
635 | 606 | | |||
607 | void Decoration::updateBuffer() | ||||
608 | { | ||||
609 | Q_ASSERT(m_view); | ||||
610 | const bool usingGL = m_view->rendererInterface()->graphicsApi() == QSGRendererInterface::OpenGL; | ||||
611 | if (usingGL) { | ||||
612 | Q_ASSERT(m_view->size().isValid()); | ||||
613 | if (!m_context->makeCurrent(m_offscreenSurface.data())) { | ||||
614 | return; | ||||
615 | } | ||||
616 | if (m_fbo.isNull() || m_fbo->size() != m_view->size()) { | ||||
617 | m_fbo.reset(new QOpenGLFramebufferObject(m_view->size(), QOpenGLFramebufferObject::CombinedDepthStencil)); | ||||
618 | if (!m_fbo->isValid()) { | ||||
619 | qCWarning(AURORAE) << "Creating FBO as render target failed"; | ||||
620 | m_fbo.reset(); | ||||
621 | return; | ||||
622 | } | ||||
623 | } | ||||
624 | m_view->setRenderTarget(m_fbo.data()); | ||||
625 | m_view->resetOpenGLState(); | ||||
626 | } | ||||
627 | | ||||
628 | m_buffer = m_renderControl->grab(); | ||||
629 | | ||||
630 | m_contentRect = QRect(QPoint(0, 0), m_buffer.size()); | ||||
631 | if (m_padding && | ||||
632 | (m_padding->left() > 0 || m_padding->top() > 0 || m_padding->right() > 0 || m_padding->bottom() > 0) && | ||||
633 | !client().data()->isMaximized()) { | ||||
634 | m_contentRect = m_contentRect.adjusted(m_padding->left(), m_padding->top(), -m_padding->right(), -m_padding->bottom()); | ||||
635 | } | ||||
636 | updateShadow(); | ||||
637 | | ||||
638 | QOpenGLFramebufferObject::bindDefault(); | ||||
639 | update(); | ||||
zzag: Indent this code with 4 spaces, rather than 8. | |||||
640 | } | ||||
641 | | ||||
636 | KDecoration2::DecoratedClient *Decoration::clientPointer() const | 642 | KDecoration2::DecoratedClient *Decoration::clientPointer() const | ||
637 | { | 643 | { | ||
638 | return client().data(); | 644 | return client().data(); | ||
639 | } | 645 | } | ||
640 | 646 | | |||
641 | ThemeFinder::ThemeFinder(QObject *parent, const QVariantList &args) | 647 | ThemeFinder::ThemeFinder(QObject *parent, const QVariantList &args) | ||
642 | : QObject(parent) | 648 | : QObject(parent) | ||
643 | { | 649 | { | ||
▲ Show 20 Lines • Show All 156 Lines • Show Last 20 Lines |
We can't do this here because m_view hasn't been resized yet.
Color attachment is considered to be incomplete if its width or height is less than 1.
https://gitlab.freedesktop.org/mesa/mesa/blob/master/src/mesa/main/fbobject.c#L856