Changeset View
Changeset View
Standalone View
Standalone View
wayland_server.cpp
Show All 37 Lines | |||||
38 | #include <KWayland/Server/datadevicemanager_interface.h> | 38 | #include <KWayland/Server/datadevicemanager_interface.h> | ||
39 | #include <KWayland/Server/datasource_interface.h> | 39 | #include <KWayland/Server/datasource_interface.h> | ||
40 | #include <KWayland/Server/display.h> | 40 | #include <KWayland/Server/display.h> | ||
41 | #include <KWayland/Server/dpms_interface.h> | 41 | #include <KWayland/Server/dpms_interface.h> | ||
42 | #include <KWayland/Server/idle_interface.h> | 42 | #include <KWayland/Server/idle_interface.h> | ||
43 | #include <KWayland/Server/idleinhibit_interface.h> | 43 | #include <KWayland/Server/idleinhibit_interface.h> | ||
44 | #include <KWayland/Server/output_interface.h> | 44 | #include <KWayland/Server/output_interface.h> | ||
45 | #include <KWayland/Server/plasmashell_interface.h> | 45 | #include <KWayland/Server/plasmashell_interface.h> | ||
46 | #include <KWayland/Server/plasmavirtualdesktop_interface.h> | ||||
46 | #include <KWayland/Server/plasmawindowmanagement_interface.h> | 47 | #include <KWayland/Server/plasmawindowmanagement_interface.h> | ||
47 | #include <KWayland/Server/pointerconstraints_interface.h> | 48 | #include <KWayland/Server/pointerconstraints_interface.h> | ||
48 | #include <KWayland/Server/pointergestures_interface.h> | 49 | #include <KWayland/Server/pointergestures_interface.h> | ||
49 | #include <KWayland/Server/qtsurfaceextension_interface.h> | 50 | #include <KWayland/Server/qtsurfaceextension_interface.h> | ||
50 | #include <KWayland/Server/seat_interface.h> | 51 | #include <KWayland/Server/seat_interface.h> | ||
51 | #include <KWayland/Server/server_decoration_interface.h> | 52 | #include <KWayland/Server/server_decoration_interface.h> | ||
52 | #include <KWayland/Server/server_decoration_palette_interface.h> | 53 | #include <KWayland/Server/server_decoration_palette_interface.h> | ||
53 | #include <KWayland/Server/shadow_interface.h> | 54 | #include <KWayland/Server/shadow_interface.h> | ||
▲ Show 20 Lines • Show All 269 Lines • ▼ Show 20 Line(s) | 322 | default: | |||
323 | break; | 324 | break; | ||
324 | } | 325 | } | ||
325 | if (set == workspace()->showingDesktop()) { | 326 | if (set == workspace()->showingDesktop()) { | ||
326 | return; | 327 | return; | ||
327 | } | 328 | } | ||
328 | workspace()->setShowingDesktop(set); | 329 | workspace()->setShowingDesktop(set); | ||
329 | } | 330 | } | ||
330 | ); | 331 | ); | ||
332 | | ||||
333 | | ||||
334 | m_virtualDesktopManagement = m_display->createPlasmaVirtualDesktopManagement(m_display); | ||||
335 | m_virtualDesktopManagement->create(); | ||||
336 | m_windowManagement->setPlasmaVirtualDesktopManagementInterface(m_virtualDesktopManagement); | ||||
337 | | ||||
331 | auto shadowManager = m_display->createShadowManager(m_display); | 338 | auto shadowManager = m_display->createShadowManager(m_display); | ||
332 | shadowManager->create(); | 339 | shadowManager->create(); | ||
333 | 340 | | |||
334 | m_display->createDpmsManager(m_display)->create(); | 341 | m_display->createDpmsManager(m_display)->create(); | ||
335 | 342 | | |||
336 | m_decorationManager = m_display->createServerSideDecorationManager(m_display); | 343 | m_decorationManager = m_display->createServerSideDecorationManager(m_display); | ||
337 | connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, | 344 | connect(m_decorationManager, &ServerSideDecorationManagerInterface::decorationCreated, this, | ||
338 | [this] (ServerSideDecorationInterface *deco) { | 345 | [this] (ServerSideDecorationInterface *deco) { | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | 385 | if (!c) { | |||
380 | return; | 387 | return; | ||
381 | } | 388 | } | ||
382 | disconnect(c, &ShellClient::windowShown, this, &WaylandServer::shellClientShown); | 389 | disconnect(c, &ShellClient::windowShown, this, &WaylandServer::shellClientShown); | ||
383 | emit shellClientAdded(c); | 390 | emit shellClientAdded(c); | ||
384 | } | 391 | } | ||
385 | 392 | | |||
386 | void WaylandServer::initWorkspace() | 393 | void WaylandServer::initWorkspace() | ||
387 | { | 394 | { | ||
395 | //TODO: RFC: those connections are better here or in VirtualDesktopManager itself? | ||||
396 | //handle created: from VirtualDesktopManager to the wayland interface | ||||
397 | connect(VirtualDesktopManager::self(), &VirtualDesktopManager::desktopCreated, this, | ||||
398 | [this](VirtualDesktop *desktop) { | ||||
399 | PlasmaVirtualDesktopInterface *pvd = m_virtualDesktopManagement->createDesktop(desktop->id(), desktop->x11DesktopNumber() - 1); | ||||
400 | pvd->setName(desktop->name()); | ||||
401 | pvd->sendDone(); | ||||
402 | connect(desktop, &VirtualDesktop::nameChanged, this, | ||||
403 | [this, desktop, pvd]() { | ||||
404 | pvd->setName(desktop->name()); | ||||
405 | } | ||||
406 | ); | ||||
407 | } | ||||
408 | ); | ||||
409 | | ||||
410 | //handle removed: from VirtualDesktopManager to the wayland interface | ||||
411 | connect(VirtualDesktopManager::self(), &VirtualDesktopManager::desktopRemoved, this, | ||||
412 | [this](VirtualDesktop *desktop) { | ||||
413 | m_virtualDesktopManagement->removeDesktop(desktop->id()); | ||||
414 | } | ||||
415 | ); | ||||
416 | | ||||
417 | //create a new desktop when the client asks to | ||||
418 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopCreateRequested, this, | ||||
419 | [this](const QString &name, quint32 position) { | ||||
420 | VirtualDesktop *vd = VirtualDesktopManager::self()->createVirtualDesktop(position); | ||||
421 | if (vd) { | ||||
422 | vd->setName(name); | ||||
423 | } | ||||
424 | } | ||||
425 | ); | ||||
426 | | ||||
427 | //remove when the client asks to | ||||
428 | connect (m_virtualDesktopManagement, &PlasmaVirtualDesktopManagementInterface::desktopRemoveRequested, this, | ||||
429 | [this](const QString &id) { | ||||
430 | //here there can be some nice kauthorized check? | ||||
431 | //remove only from VirtualDesktopManager, the other connections will remove it from m_virtualDesktopManagement as well | ||||
432 | VirtualDesktopManager::self()->removeVirtualDesktop(id.toUtf8()); | ||||
433 | } | ||||
434 | ); | ||||
435 | | ||||
436 | for (quint32 i = 1; i <= VirtualDesktopManager::self()->count(); ++i) { | ||||
437 | VirtualDesktop *internalDesktop = VirtualDesktopManager::self()->desktopForX11Id(i); | ||||
438 | PlasmaVirtualDesktopInterface *desktop = m_virtualDesktopManagement->createDesktop(internalDesktop->id()); | ||||
439 | | ||||
440 | desktop->setName(desktop->name()); | ||||
441 | desktop->sendDone(); | ||||
442 | | ||||
443 | connect(desktop, &PlasmaVirtualDesktopInterface::activateRequested, this, | ||||
444 | [this, desktop] () { | ||||
445 | VirtualDesktopManager::self()->setCurrent(VirtualDesktopManager::self()->desktopForId(desktop->id().toUtf8())); | ||||
446 | } | ||||
447 | ); | ||||
448 | } | ||||
449 | //Now we are sure all ids are there | ||||
450 | VirtualDesktopManager::self()->save(); | ||||
451 | | ||||
452 | connect(VirtualDesktopManager::self(), &VirtualDesktopManager::currentChanged, this, | ||||
453 | [this]() { | ||||
454 | for (auto *deskInt : m_virtualDesktopManagement->desktops()) { | ||||
455 | if (deskInt->id() == VirtualDesktopManager::self()->currentDesktop()->id()) { | ||||
456 | deskInt->setActive(true); | ||||
457 | } else { | ||||
458 | deskInt->setActive(false); | ||||
459 | } | ||||
460 | } | ||||
461 | } | ||||
462 | ); | ||||
463 | | ||||
388 | if (m_windowManagement) { | 464 | if (m_windowManagement) { | ||
389 | connect(workspace(), &Workspace::showingDesktopChanged, this, | 465 | connect(workspace(), &Workspace::showingDesktopChanged, this, | ||
390 | [this] (bool set) { | 466 | [this] (bool set) { | ||
391 | using namespace KWayland::Server; | 467 | using namespace KWayland::Server; | ||
392 | m_windowManagement->setShowingDesktopState(set ? | 468 | m_windowManagement->setShowingDesktopState(set ? | ||
393 | PlasmaWindowManagementInterface::ShowingDesktopState::Enabled : | 469 | PlasmaWindowManagementInterface::ShowingDesktopState::Enabled : | ||
394 | PlasmaWindowManagementInterface::ShowingDesktopState::Disabled | 470 | PlasmaWindowManagementInterface::ShowingDesktopState::Disabled | ||
395 | ); | 471 | ); | ||
▲ Show 20 Lines • Show All 382 Lines • Show Last 20 Lines |