Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show First 20 Lines • Show All 322 Lines • ▼ Show 20 Line(s) | 283 | { | |||
---|---|---|---|---|---|
323 | m_xdgShell = m_display->createXdgShell(XdgShellInterfaceVersion::Stable, m_display); | 323 | m_xdgShell = m_display->createXdgShell(XdgShellInterfaceVersion::Stable, m_display); | ||
324 | m_xdgShell->create(); | 324 | m_xdgShell->create(); | ||
325 | connect(m_xdgShell, &XdgShellInterface::surfaceCreated, this, &WaylandServer::createSurface<XdgShellSurfaceInterface>); | 325 | connect(m_xdgShell, &XdgShellInterface::surfaceCreated, this, &WaylandServer::createSurface<XdgShellSurfaceInterface>); | ||
326 | connect(m_xdgShell, &XdgShellInterface::xdgPopupCreated, this, &WaylandServer::createSurface<XdgShellPopupInterface>); | 326 | connect(m_xdgShell, &XdgShellInterface::xdgPopupCreated, this, &WaylandServer::createSurface<XdgShellPopupInterface>); | ||
327 | 327 | | |||
328 | m_xdgDecorationManager = m_display->createXdgDecorationManager(m_xdgShell, m_display); | 328 | m_xdgDecorationManager = m_display->createXdgDecorationManager(m_xdgShell, m_display); | ||
329 | m_xdgDecorationManager->create(); | 329 | m_xdgDecorationManager->create(); | ||
330 | connect(m_xdgDecorationManager, &XdgDecorationManagerInterface::xdgDecorationInterfaceCreated, this, [this] (XdgDecorationInterface *deco) { | 330 | connect(m_xdgDecorationManager, &XdgDecorationManagerInterface::xdgDecorationInterfaceCreated, this, [this] (XdgDecorationInterface *deco) { | ||
331 | if (XdgShellClient *client = findClient(deco->surface()->surface())) { | 331 | if (XdgShellClient *client = findXdgShellClient(deco->surface()->surface())) { | ||
332 | client->installXdgDecoration(deco); | 332 | client->installXdgDecoration(deco); | ||
333 | } | 333 | } | ||
334 | }); | 334 | }); | ||
335 | 335 | | |||
336 | m_display->createShm(); | 336 | m_display->createShm(); | ||
337 | m_seat = m_display->createSeat(m_display); | 337 | m_seat = m_display->createSeat(m_display); | ||
338 | m_seat->create(); | 338 | m_seat->create(); | ||
339 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | 339 | m_display->createPointerGestures(PointerGesturesInterfaceVersion::UnstableV1, m_display)->create(); | ||
340 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | 340 | m_display->createPointerConstraints(PointerConstraintsInterfaceVersion::UnstableV1, m_display)->create(); | ||
341 | m_dataDeviceManager = m_display->createDataDeviceManager(m_display); | 341 | m_dataDeviceManager = m_display->createDataDeviceManager(m_display); | ||
342 | m_dataDeviceManager->create(); | 342 | m_dataDeviceManager->create(); | ||
343 | m_idle = m_display->createIdle(m_display); | 343 | m_idle = m_display->createIdle(m_display); | ||
344 | m_idle->create(); | 344 | m_idle->create(); | ||
345 | auto idleInhibition = new IdleInhibition(m_idle); | 345 | auto idleInhibition = new IdleInhibition(m_idle); | ||
346 | connect(this, &WaylandServer::shellClientAdded, idleInhibition, &IdleInhibition::registerXdgShellClient); | 346 | connect(this, &WaylandServer::shellClientAdded, idleInhibition, &IdleInhibition::registerClient); | ||
347 | m_display->createIdleInhibitManager(IdleInhibitManagerInterfaceVersion::UnstableV1, m_display)->create(); | 347 | m_display->createIdleInhibitManager(IdleInhibitManagerInterfaceVersion::UnstableV1, m_display)->create(); | ||
348 | m_plasmaShell = m_display->createPlasmaShell(m_display); | 348 | m_plasmaShell = m_display->createPlasmaShell(m_display); | ||
349 | m_plasmaShell->create(); | 349 | m_plasmaShell->create(); | ||
350 | connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated, | 350 | connect(m_plasmaShell, &PlasmaShellInterface::surfaceCreated, | ||
351 | [this] (PlasmaShellSurfaceInterface *surface) { | 351 | [this] (PlasmaShellSurfaceInterface *surface) { | ||
352 | if (XdgShellClient *client = findClient(surface->surface())) { | 352 | if (XdgShellClient *client = findXdgShellClient(surface->surface())) { | ||
353 | client->installPlasmaShellSurface(surface); | 353 | client->installPlasmaShellSurface(surface); | ||
354 | } else { | 354 | } else { | ||
355 | m_plasmaShellSurfaces << surface; | 355 | m_plasmaShellSurfaces << surface; | ||
356 | connect(surface, &QObject::destroyed, this, | 356 | connect(surface, &QObject::destroyed, this, | ||
357 | [this, surface] { | 357 | [this, surface] { | ||
358 | m_plasmaShellSurfaces.removeOne(surface); | 358 | m_plasmaShellSurfaces.removeOne(surface); | ||
359 | } | 359 | } | ||
360 | ); | 360 | ); | ||
361 | } | 361 | } | ||
362 | } | 362 | } | ||
363 | ); | 363 | ); | ||
364 | m_appMenuManager = m_display->createAppMenuManagerInterface(m_display); | 364 | m_appMenuManager = m_display->createAppMenuManagerInterface(m_display); | ||
365 | m_appMenuManager->create(); | 365 | m_appMenuManager->create(); | ||
366 | connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated, | 366 | connect(m_appMenuManager, &AppMenuManagerInterface::appMenuCreated, | ||
367 | [this] (AppMenuInterface *appMenu) { | 367 | [this] (AppMenuInterface *appMenu) { | ||
368 | if (XdgShellClient *client = findClient(appMenu->surface())) { | 368 | if (XdgShellClient *client = findXdgShellClient(appMenu->surface())) { | ||
369 | client->installAppMenu(appMenu); | 369 | client->installAppMenu(appMenu); | ||
370 | } | 370 | } | ||
371 | } | 371 | } | ||
372 | ); | 372 | ); | ||
373 | m_paletteManager = m_display->createServerSideDecorationPaletteManager(m_display); | 373 | m_paletteManager = m_display->createServerSideDecorationPaletteManager(m_display); | ||
374 | m_paletteManager->create(); | 374 | m_paletteManager->create(); | ||
375 | connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated, | 375 | connect(m_paletteManager, &ServerSideDecorationPaletteManagerInterface::paletteCreated, | ||
376 | [this] (ServerSideDecorationPaletteInterface *palette) { | 376 | [this] (ServerSideDecorationPaletteInterface *palette) { | ||
377 | if (XdgShellClient *client = findClient(palette->surface())) { | 377 | if (XdgShellClient *client = findXdgShellClient(palette->surface())) { | ||
378 | client->installPalette(palette); | 378 | client->installPalette(palette); | ||
379 | } | 379 | } | ||
380 | } | 380 | } | ||
381 | ); | 381 | ); | ||
382 | 382 | | |||
383 | m_windowManagement = m_display->createPlasmaWindowManagement(m_display); | 383 | m_windowManagement = m_display->createPlasmaWindowManagement(m_display); | ||
384 | m_windowManagement->create(); | 384 | m_windowManagement->create(); | ||
385 | m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled); | 385 | m_windowManagement->setShowingDesktopState(PlasmaWindowManagementInterface::ShowingDesktopState::Disabled); | ||
Show All 29 Lines | |||||
415 | auto shadowManager = m_display->createShadowManager(m_display); | 415 | auto shadowManager = m_display->createShadowManager(m_display); | ||
416 | shadowManager->create(); | 416 | shadowManager->create(); | ||
417 | 417 | | |||
418 | m_display->createDpmsManager(m_display)->create(); | 418 | m_display->createDpmsManager(m_display)->create(); | ||
419 | 419 | | |||
420 | m_decorationManager = m_display->createServerSideDecorationManager(m_display); | 420 | m_decorationManager = m_display->createServerSideDecorationManager(m_display); | ||
421 | connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, | 421 | connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, | ||
422 | [this] (ServerSideDecorationInterface *deco) { | 422 | [this] (ServerSideDecorationInterface *deco) { | ||
423 | if (XdgShellClient *c = findClient(deco->surface())) { | 423 | if (XdgShellClient *c = findXdgShellClient(deco->surface())) { | ||
424 | c->installServerSideDecoration(deco); | 424 | c->installServerSideDecoration(deco); | ||
425 | } | 425 | } | ||
426 | connect(deco, &ServerSideDecorationInterface::modeRequested, this, | 426 | connect(deco, &ServerSideDecorationInterface::modeRequested, this, | ||
427 | [this, deco] (ServerSideDecorationManagerInterface::Mode mode) { | 427 | [this, deco] (ServerSideDecorationManagerInterface::Mode mode) { | ||
428 | // always acknowledge the requested mode | 428 | // always acknowledge the requested mode | ||
429 | deco->setMode(mode); | 429 | deco->setMode(mode); | ||
430 | } | 430 | } | ||
431 | ); | 431 | ); | ||
▲ Show 20 Lines • Show All 202 Lines • ▼ Show 20 Line(s) | 618 | connect(registry, &Registry::interfacesAnnounced, this, | |||
634 | } | 634 | } | ||
635 | ); | 635 | ); | ||
636 | registry->setup(); | 636 | registry->setup(); | ||
637 | } | 637 | } | ||
638 | ); | 638 | ); | ||
639 | m_internalConnection.client->initConnection(); | 639 | m_internalConnection.client->initConnection(); | ||
640 | } | 640 | } | ||
641 | 641 | | |||
642 | void WaylandServer::removeClient(XdgShellClient *c) | 642 | void WaylandServer::removeClient(AbstractClient *c) | ||
643 | { | 643 | { | ||
644 | m_clients.removeAll(c); | 644 | m_clients.removeAll(c); | ||
645 | emit shellClientRemoved(c); | 645 | emit shellClientRemoved(c); | ||
646 | } | 646 | } | ||
647 | 647 | | |||
648 | void WaylandServer::dispatch() | 648 | void WaylandServer::dispatch() | ||
649 | { | 649 | { | ||
650 | if (!m_display) { | 650 | if (!m_display) { | ||
651 | return; | 651 | return; | ||
652 | } | 652 | } | ||
653 | if (m_internalConnection.server) { | 653 | if (m_internalConnection.server) { | ||
654 | m_internalConnection.server->flush(); | 654 | m_internalConnection.server->flush(); | ||
655 | } | 655 | } | ||
656 | m_display->dispatchEvents(0); | 656 | m_display->dispatchEvents(0); | ||
657 | } | 657 | } | ||
658 | 658 | | |||
659 | static XdgShellClient *findClientInList(const QList<XdgShellClient *> &clients, quint32 id) | 659 | static AbstractClient *findClientInList(const QList<AbstractClient *> &clients, quint32 id) | ||
660 | { | 660 | { | ||
661 | auto it = std::find_if(clients.begin(), clients.end(), | 661 | auto it = std::find_if(clients.begin(), clients.end(), | ||
662 | [id] (XdgShellClient *c) { | 662 | [id] (AbstractClient *c) { | ||
663 | return c->windowId() == id; | 663 | return c->windowId() == id; | ||
664 | } | 664 | } | ||
665 | ); | 665 | ); | ||
666 | if (it == clients.end()) { | 666 | if (it == clients.end()) { | ||
667 | return nullptr; | 667 | return nullptr; | ||
668 | } | 668 | } | ||
669 | return *it; | 669 | return *it; | ||
670 | } | 670 | } | ||
671 | 671 | | |||
672 | static XdgShellClient *findClientInList(const QList<XdgShellClient *> &clients, KWayland::Server::SurfaceInterface *surface) | 672 | static AbstractClient *findClientInList(const QList<AbstractClient *> &clients, KWayland::Server::SurfaceInterface *surface) | ||
673 | { | 673 | { | ||
674 | auto it = std::find_if(clients.begin(), clients.end(), | 674 | auto it = std::find_if(clients.begin(), clients.end(), | ||
675 | [surface] (XdgShellClient *c) { | 675 | [surface] (AbstractClient *c) { | ||
676 | return c->surface() == surface; | 676 | return c->surface() == surface; | ||
677 | } | 677 | } | ||
678 | ); | 678 | ); | ||
679 | if (it == clients.end()) { | 679 | if (it == clients.end()) { | ||
680 | return nullptr; | 680 | return nullptr; | ||
681 | } | 681 | } | ||
682 | return *it; | 682 | return *it; | ||
683 | } | 683 | } | ||
684 | 684 | | |||
685 | XdgShellClient *WaylandServer::findClient(quint32 id) const | 685 | AbstractClient *WaylandServer::findClient(quint32 id) const | ||
686 | { | 686 | { | ||
687 | if (id == 0) { | 687 | if (id == 0) { | ||
688 | return nullptr; | 688 | return nullptr; | ||
689 | } | 689 | } | ||
690 | if (XdgShellClient *c = findClientInList(m_clients, id)) { | 690 | if (AbstractClient *c = findClientInList(m_clients, id)) { | ||
691 | return c; | 691 | return c; | ||
692 | } | 692 | } | ||
693 | return nullptr; | 693 | return nullptr; | ||
694 | } | 694 | } | ||
695 | 695 | | |||
696 | XdgShellClient *WaylandServer::findClient(SurfaceInterface *surface) const | 696 | AbstractClient *WaylandServer::findClient(SurfaceInterface *surface) const | ||
697 | { | 697 | { | ||
698 | if (!surface) { | 698 | if (!surface) { | ||
699 | return nullptr; | 699 | return nullptr; | ||
700 | } | 700 | } | ||
701 | if (XdgShellClient *c = findClientInList(m_clients, surface)) { | 701 | if (AbstractClient *c = findClientInList(m_clients, surface)) { | ||
702 | return c; | 702 | return c; | ||
703 | } | 703 | } | ||
704 | return nullptr; | 704 | return nullptr; | ||
705 | } | 705 | } | ||
706 | 706 | | |||
707 | AbstractClient *WaylandServer::findAbstractClient(SurfaceInterface *surface) const | 707 | XdgShellClient *WaylandServer::findXdgShellClient(SurfaceInterface *surface) const | ||
708 | { | 708 | { | ||
709 | return findClient(surface); | 709 | return qobject_cast<XdgShellClient *>(findClient(surface)); | ||
710 | } | 710 | } | ||
711 | 711 | | |||
712 | quint32 WaylandServer::createWindowId(SurfaceInterface *surface) | 712 | quint32 WaylandServer::createWindowId(SurfaceInterface *surface) | ||
713 | { | 713 | { | ||
714 | auto it = m_clientIds.constFind(surface->client()); | 714 | auto it = m_clientIds.constFind(surface->client()); | ||
715 | quint16 clientId = 0; | 715 | quint16 clientId = 0; | ||
716 | if (it != m_clientIds.constEnd()) { | 716 | if (it != m_clientIds.constEnd()) { | ||
717 | clientId = it.value(); | 717 | clientId = it.value(); | ||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |