1
0
mirror of https://github.com/KDE/latte-dock.git synced 2024-12-23 01:33:50 +03:00

make blockHiding multiple state

--blockHiding now tracks down which event has
requested it and it can work flawlessly with
multiple events

BUG:419034
This commit is contained in:
Michail Vourlakos 2020-04-05 14:40:32 +03:00
parent 778dcc3e5a
commit aa3aba50d9
12 changed files with 157 additions and 105 deletions

View File

@ -51,6 +51,8 @@
#include <Plasma/Applet>
#include <Plasma/Containment>
#define SHORTCUTBLOCKHIDINGTYPE "globalshortcuts::blockHiding()"
namespace Latte {
const int APPLETEXECUTIONDELAY = 400;
@ -254,11 +256,12 @@ void GlobalShortcuts::activateLauncherMenu()
if (highestPriorityView->visibility()->isHidden() && highestPriorityView->interface()->applicationLauncherInPopup()) {
m_lastInvokedAction = m_singleMetaAction;
highestPriorityView->visibility()->setBlockHiding(true);
highestPriorityView->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
//! delay the execution in order to show first the view
QTimer::singleShot(APPLETEXECUTIONDELAY, [this, highestPriorityView]() {
highestPriorityView->toggleAppletExpanded(highestPriorityView->interface()->applicationLauncherId());
highestPriorityView->visibility()->removeBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
});
} else {
highestPriorityView->toggleAppletExpanded(highestPriorityView->interface()->applicationLauncherId());
@ -348,7 +351,7 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
}
if (delayed) {
view->visibility()->setBlockHiding(true);
view->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
m_hideViewsTimer.start();
}
@ -421,7 +424,7 @@ void GlobalShortcuts::showViews()
if (!m_hideViewsTimer.isActive()) {
m_hideViews.append(viewWithTasks);
viewWithTasks->visibility()->setBlockHiding(true);
viewWithTasks->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
}
}
@ -431,7 +434,7 @@ void GlobalShortcuts::showViews()
if (!m_hideViewsTimer.isActive()) {
m_hideViews.append(viewWithMeta);
viewWithMeta->visibility()->setBlockHiding(true);
viewWithMeta->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
}
}
@ -450,7 +453,7 @@ void GlobalShortcuts::showViews()
if (view != viewWithTasks && view != viewWithMeta) {
if (view->interface()->showShortcutBadges(false, false)) {
m_hideViews.append(view);
view->visibility()->setBlockHiding(true);
view->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
}
}
}
@ -525,7 +528,7 @@ void GlobalShortcuts::hideViewsTimerSlot()
if (viewsToHideAreValid()) {
for(const auto latteView : m_hideViews) {
latteView->visibility()->setBlockHiding(false);
latteView->visibility()->removeBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
latteView->interface()->hideShortcutBadges();
}
}

View File

@ -40,6 +40,8 @@
#include <Plasma/Corona>
#include <PlasmaQuick/AppletQuickItem>
#define BLOCKHIDINGTYPE "View::contextMenu()"
namespace Latte {
namespace ViewPart {
@ -66,10 +68,6 @@ void ContextMenu::menuAboutToHide()
m_contextMenu = 0;
if (!m_latteView->containment()->isUserConfiguring()) {
m_latteView->visibility()->setBlockHiding(false);
}
emit menuChanged();
}
@ -284,7 +282,7 @@ bool ContextMenu::mousePressEvent(QMouseEvent *event)
}
connect(desktopMenu, SIGNAL(aboutToHide()), this, SLOT(menuAboutToHide()));
m_latteView->visibility()->setBlockHiding(true);
desktopMenu->popup(pos);
event->setAccepted(true);
emit menuChanged();

View File

@ -59,6 +59,10 @@
#include <Plasma/ContainmentActions>
#include <PlasmaQuick/AppletQuickItem>
#define BLOCKHIDINGDRAGTYPE "View::ContainsDrag()"
#define BLOCKHIDINGNEEDSATTENTIONTYPE "View::Containment::NeedsAttentionState()"
#define BLOCKHIDINGREQUESTSINPUTTYPE "View::Containment::RequestsInputState()"
namespace Latte {
//! both alwaysVisible and byPassWM are passed through corona because
@ -100,6 +104,8 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
m_releaseGrabTimer.setSingleShot(true);
connect(&m_releaseGrabTimer, &QTimer::timeout, this, &View::releaseGrab);
connect(m_contextMenu, &ViewPart::ContextMenu::menuChanged, this, &View::updateTransientWindowsTracking);
connect(this, &View::containmentChanged
, this, [ &, byPassWM]() {
qDebug() << "dock view c++ containment changed 1...";
@ -135,6 +141,9 @@ View::View(Plasma::Corona *corona, QScreen *targetScreen, bool byPassWM)
}
});
connect(m_visibility, &ViewPart::VisibilityManager::containsMouseChanged,
this, &View::updateTransientWindowsTracking);
emit visibilityChanged();
}
@ -534,12 +543,57 @@ void View::updateAbsoluteGeometry(bool bypassChecks)
void View::statusChanged(Plasma::Types::ItemStatus status)
{
if (containment()) {
if (containment()->status() >= Plasma::Types::NeedsAttentionStatus &&
containment()->status() != Plasma::Types::HiddenStatus) {
setBlockHiding(true);
} else if (!containment()->isUserConfiguring()){
setBlockHiding(false);
if (!containment()) {
return;
}
if (status == Plasma::Types::NeedsAttentionStatus) {
m_visibility->addBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
setFlags(flags() | Qt::WindowDoesNotAcceptFocus);
} else if (status == Plasma::Types::AcceptingInputStatus) {
m_visibility->removeBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
setFlags(flags() & ~Qt::WindowDoesNotAcceptFocus);
KWindowSystem::forceActiveWindow(winId());
} else {
updateTransientWindowsTracking();
m_visibility->removeBlockHidingEvent(BLOCKHIDINGNEEDSATTENTIONTYPE);
setFlags(flags() | Qt::WindowDoesNotAcceptFocus);
}
}
void View::addTransientWindow(QWindow *window)
{
if (!m_transientWindows.contains(window)) {
m_transientWindows.append(window);
QString winPtrStr = "0x" + QString::number((qulonglong)window,16);
m_visibility->addBlockHidingEvent(winPtrStr);
connect(window, &QWindow::visibleChanged, this, &View::removeTransientWindow);
}
}
void View::removeTransientWindow(const bool &visible)
{
QWindow *window = static_cast<QWindow *>(QObject::sender());
if (window && !visible) {
QString winPtrStr = "0x" + QString::number((qulonglong)window,16);
m_visibility->removeBlockHidingEvent(winPtrStr);
disconnect(window, &QWindow::visibleChanged, this, &View::removeTransientWindow);
m_transientWindows.removeAll(window);
updateTransientWindowsTracking();
}
}
void View::updateTransientWindowsTracking()
{
for(QWindow *window: qApp->topLevelWindows()) {
if (window->transientParent() == this){
if (window->isVisible()) {
addTransientWindow(window);
break;
}
}
}
}
@ -572,7 +626,6 @@ void View::setAlternativesIsShown(bool show)
m_alternativesIsShown = show;
setBlockHiding(show);
emit alternativesIsShownChanged();
}
@ -588,6 +641,14 @@ void View::setContainsDrag(bool contains)
}
m_containsDrag = contains;
if (m_containsDrag) {
m_visibility->addBlockHidingEvent(BLOCKHIDINGDRAGTYPE);
} else {
m_visibility->removeBlockHidingEvent(BLOCKHIDINGDRAGTYPE);
}
emit containsDragChanged();
}
@ -1125,25 +1186,6 @@ void View::moveToLayout(QString layoutName)
}
}
void View::setBlockHiding(bool block)
{
if (!block) {
auto *configView = qobject_cast<ViewPart::PrimaryConfigView *>(m_configView);
if (m_alternativesIsShown || (configView && configView->sticker() && configView->isVisible())) {
return;
}
if (m_visibility) {
m_visibility->setBlockHiding(false);
}
} else {
if (m_visibility) {
m_visibility->setBlockHiding(true);
}
}
}
void View::configViewCreatedFor(Latte::View *view)
{
if (view!=this && m_configView) {
@ -1160,8 +1202,6 @@ void View::configViewCreatedFor(Latte::View *view)
void View::hideWindowsForSlidingOut()
{
setBlockHiding(false);
if (m_configView) {
auto configDialog = qobject_cast<ViewPart::PrimaryConfigView *>(m_configView);
@ -1512,6 +1552,7 @@ void View::mousePressEvent(QMouseEvent *event)
if (result) {
PlasmaQuick::ContainmentView::mousePressEvent(event);
updateTransientWindowsTracking();
}
}
//!END overriding context menus behavior

View File

@ -41,6 +41,7 @@
// Qt
#include <QQuickView>
#include <QMenu>
#include <QMetaObject>
#include <QMimeData>
#include <QScreen>
#include <QPointer>
@ -244,7 +245,6 @@ public slots:
Q_INVOKABLE void deactivateApplets();
Q_INVOKABLE void moveToLayout(QString layoutName);
Q_INVOKABLE void removeTasksPlasmoid();
Q_INVOKABLE void setBlockHiding(bool block);
Q_INVOKABLE void toggleAppletExpanded(const int id);
Q_INVOKABLE bool appletIsExpandable(const int id);
@ -326,8 +326,12 @@ private slots:
void preferredViewForShortcutsChangedSlot(Latte::View *view);
void releaseGrab();
void reloadSource();
void updateTransientWindowsTracking();
void statusChanged(Plasma::Types::ItemStatus);
void addTransientWindow(QWindow *window);
void removeTransientWindow(const bool &visible);
void restoreConfig();
void saveConfig();
@ -400,6 +404,9 @@ private:
//! Connections to release and bound for the assigned layout
QList<QMetaObject::Connection> connectionsLayout;
//! track transientWindows
QList<QWindow *> m_transientWindows;
QPointer<Latte::Corona> m_corona;
KWayland::Client::PlasmaShellSurface *m_shellSurface{nullptr};

View File

@ -58,6 +58,8 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
m_corona = qobject_cast<Latte::Corona *>(view->corona());
m_wm = m_corona->wm();
connect(this, &VisibilityManager::hidingIsBlockedChanged, this, &VisibilityManager::on_hidingIsBlockedChanged);
connect(this, &VisibilityManager::slideOutFinished, this, &VisibilityManager::updateHiddenState);
connect(this, &VisibilityManager::slideInFinished, this, &VisibilityManager::updateHiddenState);
@ -99,7 +101,7 @@ VisibilityManager::VisibilityManager(PlasmaQuick::ContainmentView *view)
}
});
connect(&m_timerHide, &QTimer::timeout, this, [&]() {
if (!m_blockHiding && !m_isHidden && !m_isBelowLayer && !m_dragEnter) {
if (!hidingIsBlocked() && !m_isHidden && !m_isBelowLayer && !m_dragEnter) {
if (m_latteView->isFloatingWindow()) {
//! first check if mouse is inside the floating gap
checkMouseInFloatingArea();
@ -418,7 +420,7 @@ void VisibilityManager::setIsHidden(bool isHidden)
if (m_isHidden == isHidden)
return;
if (m_blockHiding && isHidden) {
if (hidingIsBlocked() && isHidden) {
qWarning() << "isHidden property is blocked, ignoring update";
return;
}
@ -430,21 +432,48 @@ void VisibilityManager::setIsHidden(bool isHidden)
emit isHiddenChanged();
}
bool VisibilityManager::blockHiding() const
bool VisibilityManager::hidingIsBlocked() const
{
return m_blockHiding;
return (m_blockHidingEvents.count() > 0);
}
void VisibilityManager::setBlockHiding(bool blockHiding)
void VisibilityManager::addBlockHidingEvent(const QString &type)
{
if (m_blockHiding == blockHiding) {
if (m_blockHidingEvents.contains(type) || type.isEmpty()) {
return;
}
m_blockHiding = blockHiding;
//qDebug() << "blockHiding:" << blockHiding;
qDebug() << " adding block hiding event :: " << type;
if (m_blockHiding) {
bool prevHidingIsBlocked = hidingIsBlocked();
m_blockHidingEvents << type;
if (prevHidingIsBlocked != hidingIsBlocked()) {
emit hidingIsBlockedChanged();
}
}
void VisibilityManager::removeBlockHidingEvent(const QString &type)
{
if (!m_blockHidingEvents.contains(type) || type.isEmpty()) {
return;
}
qDebug() << " remove block hiding event :: " << type;
bool prevHidingIsBlocked = hidingIsBlocked();
m_blockHidingEvents.removeAll(type);
if (prevHidingIsBlocked != hidingIsBlocked()) {
emit hidingIsBlockedChanged();
}
}
void VisibilityManager::on_hidingIsBlockedChanged()
{
if (hidingIsBlocked()) {
m_timerHide.stop();
if (m_isHidden) {
@ -453,8 +482,6 @@ void VisibilityManager::setBlockHiding(bool blockHiding)
} else {
updateHiddenState();
}
emit blockHidingChanged();
}
int VisibilityManager::timerShow() const
@ -542,7 +569,7 @@ void VisibilityManager::show()
void VisibilityManager::raiseView(bool raise)
{
if (m_blockHiding || m_mode == Latte::Types::SideBar)
if (hidingIsBlocked() || m_mode == Latte::Types::SideBar)
return;
if (raise) {
@ -592,7 +619,11 @@ void VisibilityManager::toggleHiddenState()
emit mustBeHide();
}
} else {
setBlockHiding(!m_blockHiding);
if (!m_blockHidingEvents.contains(Q_FUNC_INFO)) {
addBlockHidingEvent(Q_FUNC_INFO);
} else {
removeBlockHidingEvent(Q_FUNC_INFO);
}
}
}
}

View File

@ -52,13 +52,13 @@ namespace ViewPart {
class VisibilityManager : public QObject
{
Q_OBJECT
Q_PROPERTY(bool hidingIsBlocked READ hidingIsBlocked NOTIFY hidingIsBlockedChanged)
Q_PROPERTY(Latte::Types::Visibility mode READ mode WRITE setMode NOTIFY modeChanged)
Q_PROPERTY(bool raiseOnDesktop READ raiseOnDesktop WRITE setRaiseOnDesktop NOTIFY raiseOnDesktopChanged)
Q_PROPERTY(bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged)
Q_PROPERTY(bool raiseOnActivity READ raiseOnActivity WRITE setRaiseOnActivity NOTIFY raiseOnActivityChanged)
Q_PROPERTY(bool isHidden READ isHidden WRITE setIsHidden NOTIFY isHiddenChanged)
Q_PROPERTY(bool isBelowLayer READ isBelowLayer NOTIFY isBelowLayerChanged)
Q_PROPERTY(bool blockHiding READ blockHiding WRITE setBlockHiding NOTIFY blockHidingChanged)
Q_PROPERTY(bool isBelowLayer READ isBelowLayer NOTIFY isBelowLayerChanged)
Q_PROPERTY(bool containsMouse READ containsMouse NOTIFY containsMouseChanged)
//! KWin Edges Support Options
@ -88,8 +88,7 @@ public:
bool isHidden() const;
void setIsHidden(bool isHidden);
bool blockHiding() const;
void setBlockHiding(bool blockHiding);
bool hidingIsBlocked() const;
bool containsMouse() const;
@ -115,6 +114,9 @@ public slots:
Q_INVOKABLE void setViewOnBackLayer();
Q_INVOKABLE void setViewOnFrontLayer();
Q_INVOKABLE void addBlockHidingEvent(const QString &type);
Q_INVOKABLE void removeBlockHidingEvent(const QString &type);
void initViewFlags();
signals:
@ -129,7 +131,7 @@ signals:
void raiseOnActivityChanged();
void isBelowLayerChanged();
void isHiddenChanged();
void blockHidingChanged();
void hidingIsBlockedChanged();
void containsMouseChanged();
void timerShowChanged();
void timerHideChanged();
@ -144,6 +146,8 @@ private slots:
void setIsBelowLayer(bool below);
void on_hidingIsBlockedChanged();
//! KWin Edges Support functions
void updateKWinEdgesSupport();
@ -190,13 +194,14 @@ private:
bool m_isBelowLayer{false};
bool m_isHidden{false};
bool m_dragEnter{false};
bool m_blockHiding{false};
bool m_containsMouse{false};
bool m_raiseTemporarily{false};
bool m_raiseOnDesktopChange{false};
bool m_raiseOnActivityChange{false};
bool m_hideNow{false};
QStringList m_blockHidingEvents;
QRect m_publishedStruts;
QRegion m_lastMask;

View File

@ -249,14 +249,6 @@ Window{
}
}
Text{
text: "Actions Block Hiding "+space
}
Text{
text: root.actionsBlockHiding
}
Text{
text: "Contains Mouse (flag)"+space
}

View File

@ -511,7 +511,6 @@ Item {
appletItem.latteApplet.signalAnimationsNeedBothAxis.connect(slotAnimationsNeedBothAxis);
appletItem.latteApplet.signalAnimationsNeedLength.connect(slotAnimationsNeedLength);
appletItem.latteApplet.signalAnimationsNeedThickness.connect(slotAnimationsNeedThickness);
appletItem.latteApplet.signalActionsBlockHiding.connect(slotActionsBlockHiding);
appletItem.latteApplet.signalPreviewsShown.connect(slotPreviewsShown);
appletItem.latteApplet.clearZoomSignal.connect(titleTooltipDialog.hide);
}
@ -554,7 +553,6 @@ Item {
appletItem.latteApplet.signalAnimationsNeedBothAxis.disconnect(slotAnimationsNeedBothAxis);
appletItem.latteApplet.signalAnimationsNeedLength.disconnect(slotAnimationsNeedLength);
appletItem.latteApplet.signalAnimationsNeedThickness.disconnect(slotAnimationsNeedThickness);
appletItem.latteApplet.signalActionsBlockHiding.disconnect(slotActionsBlockHiding);
appletItem.latteApplet.signalPreviewsShown.disconnect(slotPreviewsShown);
appletItem.latteApplet.clearZoomSignal.disconnect(titleTooltipDialog.hide);
}

View File

@ -238,10 +238,9 @@ Item{
onInEditModeChanged: {
if (inEditMode) {
latteView.setBlockHiding(true);
latteView.visibility.addBlockHidingEvent("EditVisual[qml]::inEditMode()");
} else {
latteView.setBlockHiding(false);
latteView.visibility.removeBlockHidingEvent("EditVisual[qml]::inEditMode()");
if (latteView.visibility.isHidden) {
latteView.visibility.mustBeShown();
}

View File

@ -254,8 +254,6 @@ Item {
property alias hoveredIndex: layoutsContainer.hoveredIndex
property alias directRenderDelayerIsRunning: directRenderDelayerForEnteringTimer.running
property int actionsBlockHiding: 0 //actions that block hiding
property int animationsNeedBothAxis:0 //animations need space in both axes, e.g zooming a task
property int animationsNeedLength: 0 // animations need length, e.g. adding a task
property int animationsNeedThickness: 0 // animations need thickness, e.g. bouncing animation
@ -1384,27 +1382,6 @@ Item {
appletsNeedWindowsTracking = Math.max(appletsNeedWindowsTracking + step, 0);
}
//this is used when dragging a task in order to not hide the dock
//and also by the menu appearing from tasks for the same reason
function slotActionsBlockHiding(step) {
//if (root.editMode) {
// return;
// }
if ((step === 0) || (!latteView)) {
return;
}
actionsBlockHiding = Math.max(actionsBlockHiding + step, 0);
if (actionsBlockHiding > 0){
latteView.setBlockHiding(true);
} else {
if (!root.editMode)
latteView.setBlockHiding(false);
}
}
function slotPreviewsShown(){
if (latteView) {
latteView.deactivateApplets();

View File

@ -83,7 +83,6 @@ PlasmaComponents.ContextMenu {
function show() {
//trying to use the dragging mechanism in order to not hide the dock
root.disableRestoreZoom = true;
root.signalActionsBlockHiding(1);
//root.signalDraggingState(true);
loadDynamicLaunchActions(visualParent.m.LauncherUrlWithoutIcon);
// backend.ungrabMouse(visualParent);
@ -334,7 +333,6 @@ PlasmaComponents.ContextMenu {
if (!changingLayout) {
root.contextMenu = null;
backend.ungrabMouse(visualParent);
root.signalActionsBlockHiding(-1);
//root.signalDraggingState(false);
root.disableRestoreZoom = false;
root.startCheckRestoreZoomTimer(100);

View File

@ -300,7 +300,6 @@ Item {
signal presentWindows(variant winIds);
signal requestLayout;
signal separatorsUpdated();
signal signalActionsBlockHiding(int value);
signal signalAnimationsNeedBothAxis(int value);
signal signalAnimationsNeedLength(int value);
signal signalAnimationsNeedThickness(int value);
@ -379,6 +378,12 @@ Item {
}
}
Binding {
target: plasmoid
property: "status"
value: (tasksModel.anyTaskDemandsAttentionInValidTime || root.dragSource ?
PlasmaCore.Types.NeedsAttentionStatus : PlasmaCore.Types.PassiveStatus);
}
/////
PlasmaCore.ColorScope{
@ -530,13 +535,11 @@ Item {
onDragSourceChanged: {
if (dragSource == null) {
root.draggingFinished();
root.signalActionsBlockHiding(-1);
tasksModel.syncLaunchers();
restoreDraggingPhaseTimer.start();
} else {
inDraggingPhase = true;
root.signalActionsBlockHiding(1);
}
}
@ -569,7 +572,6 @@ Item {
if (latteView && signalSent) {
//it is used to unblock dock hiding
root.signalActionsBlockHiding(-1);
signalSent = false;
}
@ -601,7 +603,6 @@ Item {
if (latteView && !signalSent) {
//it is used to block dock hiding
root.signalActionsBlockHiding(1);
signalSent = true;
}
@ -703,6 +704,8 @@ Item {
groupMode: groupTasksByDefault ? TaskManager.TasksModel.GroupApplications : TaskManager.TasksModel.GroupDisabled
sortMode: TaskManager.TasksModel.SortManual
property bool anyTaskDemandsAttentionInValidTime: false
function updateLaunchersList(){
if (latteView.universalSettings
&& (latteView.launchersGroup === Latte.Types.LayoutLaunchers
@ -771,7 +774,7 @@ Item {
onAnyTaskDemandsAttentionChanged: {
if (anyTaskDemandsAttention){
plasmoid.status = PlasmaCore.Types.RequiresAttentionStatus;
anyTaskDemandsAttentionInValidTime = true;
attentionTimerComponent.createObject(root);
}
}
@ -971,7 +974,7 @@ Item {
id: attentionTimer
interval:8500
onTriggered: {
plasmoid.status = PlasmaCore.Types.PassiveStatus;
tasksModel.anyTaskDemandsAttentionInValidTime = false;
destroy();
if (latteView && latteView.debugModeTimers) {