Changeset View
Changeset View
Standalone View
Standalone View
workspace.cpp
Show First 20 Lines • Show All 282 Lines • ▼ Show 20 Line(s) | 279 | QDBusConnection::sessionBus().connect(QString(), | |||
---|---|---|---|---|---|
283 | this, SLOT(reconfigure())); | 283 | this, SLOT(reconfigure())); | ||
284 | 284 | | |||
285 | active_client = nullptr; | 285 | active_client = nullptr; | ||
286 | 286 | | |||
287 | initWithX11(); | 287 | initWithX11(); | ||
288 | 288 | | |||
289 | Scripting::create(this); | 289 | Scripting::create(this); | ||
290 | 290 | | |||
291 | if (auto w = waylandServer()) { | 291 | if (auto server = waylandServer()) { | ||
292 | connect(w, &WaylandServer::shellClientAdded, this, | 292 | connect(server, &WaylandServer::shellClientAdded, this, &Workspace::addShellClient); | ||
293 | [this] (XdgShellClient *c) { | 293 | connect(server, &WaylandServer::shellClientRemoved, this, &Workspace::removeShellClient); | ||
294 | setupClientConnections(c); | | |||
295 | c->updateDecoration(false); | | |||
296 | updateClientLayer(c); | | |||
297 | if (!c->isInternal()) { | | |||
298 | const QRect area = clientArea(PlacementArea, Screens::self()->current(), c->desktop()); | | |||
299 | bool placementDone = false; | | |||
300 | if (c->isInitialPositionSet()) { | | |||
301 | placementDone = true; | | |||
302 | } | | |||
303 | if (c->isFullScreen()) { | | |||
304 | placementDone = true; | | |||
305 | } | | |||
306 | if (c->maximizeMode() == MaximizeMode::MaximizeFull) { | | |||
307 | placementDone = true; | | |||
308 | } | | |||
309 | if (c->rules()->checkPosition(invalidPoint, true) != invalidPoint) { | | |||
310 | placementDone = true; | | |||
311 | } | | |||
312 | if (!placementDone) { | | |||
313 | c->placeIn(area); | | |||
314 | } | | |||
315 | m_allClients.append(c); | | |||
316 | if (!unconstrained_stacking_order.contains(c)) | | |||
317 | unconstrained_stacking_order.append(c); // Raise if it hasn't got any stacking position yet | | |||
318 | if (!stacking_order.contains(c)) // It'll be updated later, and updateToolWindows() requires | | |||
319 | stacking_order.append(c); // c to be in stacking_order | | |||
320 | } | | |||
321 | markXStackingOrderAsDirty(); | | |||
322 | updateStackingOrder(true); | | |||
323 | updateClientArea(); | | |||
324 | if (c->wantsInput() && !c->isMinimized()) { | | |||
325 | activateClient(c); | | |||
326 | } | | |||
327 | updateTabbox(); | | |||
328 | connect(c, &XdgShellClient::windowShown, this, | | |||
329 | [this, c] { | | |||
330 | updateClientLayer(c); | | |||
331 | // TODO: when else should we send the client through placement? | | |||
332 | if (c->hasTransientPlacementHint()) { | | |||
333 | const QRect area = clientArea(PlacementArea, Screens::self()->current(), c->desktop()); | | |||
334 | c->placeIn(area); | | |||
335 | } | | |||
336 | markXStackingOrderAsDirty(); | | |||
337 | updateStackingOrder(true); | | |||
338 | updateClientArea(); | | |||
339 | if (c->wantsInput()) { | | |||
340 | activateClient(c); | | |||
341 | } | | |||
342 | } | | |||
343 | ); | | |||
344 | connect(c, &XdgShellClient::windowHidden, this, | | |||
345 | [this] { | | |||
346 | // TODO: update tabbox if it's displayed | | |||
347 | markXStackingOrderAsDirty(); | | |||
348 | updateStackingOrder(true); | | |||
349 | updateClientArea(); | | |||
350 | } | | |||
351 | ); | | |||
352 | } | | |||
353 | ); | | |||
354 | connect(w, &WaylandServer::shellClientRemoved, this, | | |||
355 | [this] (XdgShellClient *c) { | | |||
356 | m_allClients.removeAll(c); | | |||
357 | if (c == most_recently_raised) { | | |||
358 | most_recently_raised = nullptr; | | |||
359 | } | | |||
360 | if (c == delayfocus_client) { | | |||
361 | cancelDelayFocus(); | | |||
362 | } | | |||
363 | if (c == last_active_client) { | | |||
364 | last_active_client = nullptr; | | |||
365 | } | | |||
366 | if (client_keys_client == c) { | | |||
367 | setupWindowShortcutDone(false); | | |||
368 | } | | |||
369 | if (!c->shortcut().isEmpty()) { | | |||
370 | c->setShortcut(QString()); // Remove from client_keys | | |||
371 | } | | |||
372 | clientHidden(c); | | |||
373 | emit clientRemoved(c); | | |||
374 | markXStackingOrderAsDirty(); | | |||
375 | updateStackingOrder(true); | | |||
376 | updateClientArea(); | | |||
377 | updateTabbox(); | | |||
378 | } | | |||
379 | ); | | |||
380 | } | 294 | } | ||
381 | 295 | | |||
382 | // SELI TODO: This won't work with unreasonable focus policies, | 296 | // SELI TODO: This won't work with unreasonable focus policies, | ||
383 | // and maybe in rare cases also if the selected client doesn't | 297 | // and maybe in rare cases also if the selected client doesn't | ||
384 | // want focus | 298 | // want focus | ||
385 | workspaceInit = false; | 299 | workspaceInit = false; | ||
386 | 300 | | |||
387 | // broadcast that Workspace is ready, but first process all events. | 301 | // broadcast that Workspace is ready, but first process all events. | ||
▲ Show 20 Lines • Show All 166 Lines • ▼ Show 20 Line(s) | 459 | for (auto it = stack.constBegin(), end = stack.constEnd(); it != end; ++it) { | |||
554 | // from crashing. | 468 | // from crashing. | ||
555 | clients.removeAll(c); | 469 | clients.removeAll(c); | ||
556 | m_allClients.removeAll(c); | 470 | m_allClients.removeAll(c); | ||
557 | desktops.removeAll(c); | 471 | desktops.removeAll(c); | ||
558 | } | 472 | } | ||
559 | X11Client::cleanupX11(); | 473 | X11Client::cleanupX11(); | ||
560 | 474 | | |||
561 | if (waylandServer()) { | 475 | if (waylandServer()) { | ||
562 | const QList<XdgShellClient *> shellClients = waylandServer()->clients(); | 476 | // TODO: Introduce AbstractClient::destroy(). | ||
563 | for (XdgShellClient *shellClient : shellClients) { | 477 | const QList<AbstractClient *> shellClients = waylandServer()->clients(); | ||
478 | for (AbstractClient *client : shellClients) { | ||||
479 | if (XdgShellClient *shellClient = qobject_cast<XdgShellClient *>(client)) { | ||||
564 | shellClient->destroyClient(); | 480 | shellClient->destroyClient(); | ||
565 | } | 481 | } | ||
566 | } | 482 | } | ||
483 | } | ||||
567 | 484 | | |||
568 | for (auto it = unmanaged.begin(), end = unmanaged.end(); it != end; ++it) | 485 | for (auto it = unmanaged.begin(), end = unmanaged.end(); it != end; ++it) | ||
569 | (*it)->release(ReleaseReason::KWinShutsDown); | 486 | (*it)->release(ReleaseReason::KWinShutsDown); | ||
570 | 487 | | |||
571 | for (InternalClient *client : m_internalClients) { | 488 | for (InternalClient *client : m_internalClients) { | ||
572 | client->destroyClient(); | 489 | client->destroyClient(); | ||
573 | } | 490 | } | ||
574 | 491 | | |||
▲ Show 20 Lines • Show All 193 Lines • ▼ Show 20 Line(s) | 678 | { | |||
768 | if (!c->wasClient()) { | 685 | if (!c->wasClient()) { | ||
769 | return; | 686 | return; | ||
770 | } | 687 | } | ||
771 | if (X11Compositor *compositor = X11Compositor::self()) { | 688 | if (X11Compositor *compositor = X11Compositor::self()) { | ||
772 | compositor->updateClientCompositeBlocking(); | 689 | compositor->updateClientCompositeBlocking(); | ||
773 | } | 690 | } | ||
774 | } | 691 | } | ||
775 | 692 | | |||
693 | void Workspace::addShellClient(AbstractClient *client) | ||||
694 | { | ||||
695 | setupClientConnections(client); | ||||
davidedmundson: Can you clarify this is just a code move from the above?
It's frustrating to review these… | |||||
It's the same.
Yes, I know. I squashed a lot of changes that should be separate because of the goddamn review process on Phabricator. zzag: It's the same.
> It's frustrating to review these patches checking
Yes, I know. I squashed a… | |||||
696 | client->updateDecoration(false); | ||||
697 | updateClientLayer(client); | ||||
698 | | ||||
699 | const QRect area = clientArea(PlacementArea, Screens::self()->current(), client->desktop()); | ||||
700 | bool placementDone = false; | ||||
701 | if (client->isInitialPositionSet()) { | ||||
702 | placementDone = true; | ||||
703 | } | ||||
704 | if (client->isFullScreen()) { | ||||
705 | placementDone = true; | ||||
706 | } | ||||
707 | if (client->maximizeMode() == MaximizeMode::MaximizeFull) { | ||||
708 | placementDone = true; | ||||
709 | } | ||||
710 | if (client->rules()->checkPosition(invalidPoint, true) != invalidPoint) { | ||||
711 | placementDone = true; | ||||
712 | } | ||||
713 | if (!placementDone) { | ||||
714 | client->placeIn(area); | ||||
715 | } | ||||
716 | m_allClients.append(client); | ||||
717 | if (!unconstrained_stacking_order.contains(client)) { | ||||
718 | unconstrained_stacking_order.append(client); // Raise if it hasn't got any stacking position yet | ||||
719 | } | ||||
720 | if (!stacking_order.contains(client)) { // It'll be updated later, and updateToolWindows() requires | ||||
721 | stacking_order.append(client); // client to be in stacking_order | ||||
722 | } | ||||
723 | | ||||
724 | markXStackingOrderAsDirty(); | ||||
725 | updateStackingOrder(true); | ||||
726 | updateClientArea(); | ||||
727 | if (client->wantsInput() && !client->isMinimized()) { | ||||
728 | activateClient(client); | ||||
729 | } | ||||
730 | updateTabbox(); | ||||
731 | connect(client, &AbstractClient::windowShown, this, [this, client] { | ||||
732 | updateClientLayer(client); | ||||
733 | // TODO: when else should we send the client through placement? | ||||
734 | if (client->hasTransientPlacementHint()) { | ||||
735 | const QRect area = clientArea(PlacementArea, Screens::self()->current(), client->desktop()); | ||||
736 | client->placeIn(area); | ||||
737 | } | ||||
738 | markXStackingOrderAsDirty(); | ||||
739 | updateStackingOrder(true); | ||||
740 | updateClientArea(); | ||||
741 | if (client->wantsInput()) { | ||||
742 | activateClient(client); | ||||
743 | } | ||||
744 | }); | ||||
745 | connect(client, &AbstractClient::windowHidden, this, [this] { | ||||
746 | // TODO: update tabbox if it's displayed | ||||
747 | markXStackingOrderAsDirty(); | ||||
748 | updateStackingOrder(true); | ||||
749 | updateClientArea(); | ||||
750 | }); | ||||
751 | } | ||||
752 | | ||||
753 | void Workspace::removeShellClient(AbstractClient *client) | ||||
754 | { | ||||
755 | m_allClients.removeAll(client); | ||||
756 | if (client == most_recently_raised) { | ||||
757 | most_recently_raised = nullptr; | ||||
758 | } | ||||
759 | if (client == delayfocus_client) { | ||||
760 | cancelDelayFocus(); | ||||
761 | } | ||||
762 | if (client == last_active_client) { | ||||
763 | last_active_client = nullptr; | ||||
764 | } | ||||
765 | if (client_keys_client == client) { | ||||
766 | setupWindowShortcutDone(false); | ||||
767 | } | ||||
768 | if (!client->shortcut().isEmpty()) { | ||||
769 | client->setShortcut(QString()); // Remove from client_keys | ||||
770 | } | ||||
771 | clientHidden(client); | ||||
772 | emit clientRemoved(client); | ||||
773 | markXStackingOrderAsDirty(); | ||||
774 | updateStackingOrder(true); | ||||
775 | updateClientArea(); | ||||
776 | updateTabbox(); | ||||
777 | } | ||||
778 | | ||||
776 | void Workspace::updateToolWindows(bool also_hide) | 779 | void Workspace::updateToolWindows(bool also_hide) | ||
777 | { | 780 | { | ||
778 | // TODO: What if Client's transiency/group changes? should this be called too? (I'm paranoid, am I not?) | 781 | // TODO: What if Client's transiency/group changes? should this be called too? (I'm paranoid, am I not?) | ||
779 | if (!options->isHideUtilityWindowsForInactive()) { | 782 | if (!options->isHideUtilityWindowsForInactive()) { | ||
780 | for (auto it = clients.constBegin(); it != clients.constEnd(); ++it) | 783 | for (auto it = clients.constBegin(); it != clients.constEnd(); ++it) | ||
781 | (*it)->hideClient(false); | 784 | (*it)->hideClient(false); | ||
782 | return; | 785 | return; | ||
783 | } | 786 | } | ||
▲ Show 20 Lines • Show All 1285 Lines • ▼ Show 20 Line(s) | 2069 | // qDebug() << "adjusting new_sarea: " << screens[ iS ]; | |||
2069 | // ignore the geometry if it results in the screen getting removed completely | 2072 | // ignore the geometry if it results in the screen getting removed completely | ||
2070 | if (!geo.isEmpty()) { | 2073 | if (!geo.isEmpty()) { | ||
2071 | new_sareas[(*it)->desktop()][ iS ] = geo; | 2074 | new_sareas[(*it)->desktop()][ iS ] = geo; | ||
2072 | } | 2075 | } | ||
2073 | } | 2076 | } | ||
2074 | } | 2077 | } | ||
2075 | } | 2078 | } | ||
2076 | if (waylandServer()) { | 2079 | if (waylandServer()) { | ||
2077 | auto updateStrutsForWaylandClient = [&] (XdgShellClient *c) { | 2080 | auto updateStrutsForWaylandClient = [&] (AbstractClient *c) { | ||
2078 | // assuming that only docks have "struts" and that all docks have a strut | 2081 | // assuming that only docks have "struts" and that all docks have a strut | ||
2079 | if (!c->hasStrut()) { | 2082 | if (!c->hasStrut()) { | ||
2080 | return; | 2083 | return; | ||
2081 | } | 2084 | } | ||
2082 | auto margins = [c] (const QRect &geometry) { | 2085 | auto margins = [c] (const QRect &geometry) { | ||
2083 | QMargins margins; | 2086 | QMargins margins; | ||
2084 | if (!geometry.intersects(c->frameGeometry())) { | 2087 | if (!geometry.intersects(c->frameGeometry())) { | ||
2085 | return margins; | 2088 | return margins; | ||
▲ Show 20 Lines • Show All 696 Lines • Show Last 20 Lines |
Can you clarify this is just a code move from the above?
It's frustrating to review these patches checking line by line as it takes a lot waaay longer than it took the developer to do the original copy paste.