Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
92 | { | 92 | { | ||
93 | 93 | | |||
94 | KWIN_SINGLETON_FACTORY(WaylandServer) | 94 | KWIN_SINGLETON_FACTORY(WaylandServer) | ||
95 | 95 | | |||
96 | WaylandServer::WaylandServer(QObject *parent) | 96 | WaylandServer::WaylandServer(QObject *parent) | ||
97 | : QObject(parent) | 97 | : QObject(parent) | ||
98 | { | 98 | { | ||
99 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | 99 | qRegisterMetaType<KWayland::Server::OutputInterface::DpmsMode>(); | ||
100 | | ||||
101 | connect(kwinApp(), &Application::screensCreated, this, &WaylandServer::initOutputs); | | |||
102 | } | 100 | } | ||
103 | 101 | | |||
104 | WaylandServer::~WaylandServer() | 102 | WaylandServer::~WaylandServer() | ||
105 | { | 103 | { | ||
106 | destroyInputMethodConnection(); | 104 | destroyInputMethodConnection(); | ||
107 | } | 105 | } | ||
108 | 106 | | |||
109 | void WaylandServer::destroyInternalConnection() | 107 | void WaylandServer::destroyInternalConnection() | ||
▲ Show 20 Lines • Show All 426 Lines • ▼ Show 20 Line(s) | 518 | { | |||
536 | ); | 534 | ); | ||
537 | 535 | | |||
538 | if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) { | 536 | if (m_initFlags.testFlag(InitalizationFlag::LockScreen)) { | ||
539 | ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); | 537 | ScreenLocker::KSldApp::self()->lock(ScreenLocker::EstablishLock::Immediate); | ||
540 | } | 538 | } | ||
541 | emit initialized(); | 539 | emit initialized(); | ||
542 | } | 540 | } | ||
543 | 541 | | |||
544 | void WaylandServer::initOutputs() | | |||
545 | { | | |||
546 | if (kwinApp()->platform()->handlesOutputs()) { | | |||
547 | return; | | |||
548 | } | | |||
549 | syncOutputsToWayland(); | | |||
550 | connect(screens(), &Screens::changed, this, | | |||
551 | [this] { | | |||
552 | // when screens change we need to sync this to Wayland. | | |||
553 | // Unfortunately we don't have much information and cannot properly match a KWin screen | | |||
554 | // to a Wayland screen. | | |||
555 | // Thus we just recreate all outputs and delete the old ones | | |||
556 | const auto outputs = m_display->outputs(); | | |||
557 | syncOutputsToWayland(); | | |||
558 | qDeleteAll(outputs); | | |||
559 | } | | |||
560 | ); | | |||
561 | } | | |||
562 | | ||||
563 | void WaylandServer::syncOutputsToWayland() | | |||
564 | { | | |||
565 | Screens *s = screens(); | | |||
566 | Q_ASSERT(s); | | |||
567 | for (int i = 0; i < s->count(); ++i) { | | |||
568 | OutputInterface *output = m_display->createOutput(m_display); | | |||
569 | auto xdgOutput = xdgOutputManager()->createXdgOutput(output, output); | | |||
570 | | ||||
571 | output->setScale(s->scale(i)); | | |||
572 | const QRect &geo = s->geometry(i); | | |||
573 | output->setGlobalPosition(geo.topLeft()); | | |||
574 | output->setPhysicalSize(s->physicalSize(i).toSize()); | | |||
575 | output->addMode(geo.size()); | | |||
576 | | ||||
577 | xdgOutput->setLogicalPosition(geo.topLeft()); | | |||
578 | xdgOutput->setLogicalSize(geo.size()); | | |||
579 | xdgOutput->done(); | | |||
580 | | ||||
581 | output->create(); | | |||
582 | } | | |||
583 | } | | |||
584 | | ||||
585 | WaylandServer::SocketPairConnection WaylandServer::createConnection() | 542 | WaylandServer::SocketPairConnection WaylandServer::createConnection() | ||
586 | { | 543 | { | ||
587 | SocketPairConnection ret; | 544 | SocketPairConnection ret; | ||
588 | int sx[2]; | 545 | int sx[2]; | ||
589 | if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) { | 546 | if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) { | ||
590 | qCWarning(KWIN_CORE) << "Could not create socket"; | 547 | qCWarning(KWIN_CORE) << "Could not create socket"; | ||
591 | return ret; | 548 | return ret; | ||
592 | } | 549 | } | ||
▲ Show 20 Lines • Show All 272 Lines • Show Last 20 Lines |