fixes for globalshortcuts highest view identify

--always find the highest view that is going to be
used for global shortcuts based on position activation
--adjust the code a bit for SideBars in order to show
when a SideBar is called for global shortcuts based
on position activation and hide correctly when the
global shortcut is not triggered any more.

BUG:420356
pull/15/head
Michail Vourlakos 5 years ago
parent 3bee600a98
commit 1ad1dd2982

@ -323,6 +323,33 @@ bool GlobalShortcuts::activateLatteEntry(Latte::View *view, int index, Qt::Key m
}
}
bool GlobalShortcuts::activateEntryForView(Latte::View *view, int index, Qt::Key modifier)
{
if (!view) {
return false;
}
bool delayed{false};
bool executed = ((!view->latteTasksArePresent() && view->tasksPresent() &&
activatePlasmaTaskManager(view, index, modifier, &delayed))
|| activateLatteEntry(view, index, modifier, &delayed));
if (executed) {
if (!m_hideViews.contains(view)) {
m_hideViews.append(view);
}
if (delayed) {
view->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
m_hideViewsTimer.start();
}
return true;
}
return false;
}
//! Activate task manager entry
void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
@ -336,30 +363,24 @@ void GlobalShortcuts::activateEntry(int index, Qt::Key modifier)
sortedViews = currentLayout->sortedLatteViews();
}
Latte::View *highest{nullptr};
for (const auto view : sortedViews) {
if (view->layout()->preferredForShortcutsTouched() && !view->isPreferredForShortcuts()) {
continue;
if (view->isPreferredForShortcuts()) {
highest = view;
break;
}
}
bool delayed{false};
if ((!view->latteTasksArePresent() && view->tasksPresent() &&
activatePlasmaTaskManager(view, index, modifier, &delayed))
|| activateLatteEntry(view, index, modifier, &delayed)) {
if (!m_hideViews.contains(view)) {
m_hideViews.append(view);
}
if (delayed) {
view->visibility()->addBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
m_hideViewsTimer.start();
if (highest) {
activateEntryForView(highest, index, modifier);
} else {
for (const auto view : sortedViews) {
if (activateEntryForView(view, index, modifier)) {
return;
}
return;
}
}
}
//! update badge for specific view item
@ -396,10 +417,18 @@ void GlobalShortcuts::showViews()
Latte::View *viewWithTasks{nullptr};
Latte::View *viewWithMeta{nullptr};
bool hasPreferredForShortcutsView{false};
for (const auto view : sortedViews) {
if (view->isPreferredForShortcuts()) {
hasPreferredForShortcutsView = true;
break;
}
}
for(const auto view : sortedViews) {
if (!viewWithTasks
&& view->extendedInterface()->isCapableToShowShortcutBadges()
&& (!view->layout()->preferredForShortcutsTouched() || view->isPreferredForShortcuts())) {
&& (!hasPreferredForShortcutsView || view->isPreferredForShortcuts())) {
viewWithTasks = view;
break;
}
@ -531,6 +560,10 @@ void GlobalShortcuts::hideViewsTimerSlot()
for(const auto latteView : m_hideViews) {
latteView->visibility()->removeBlockHidingEvent(SHORTCUTBLOCKHIDINGTYPE);
latteView->extendedInterface()->hideShortcutBadges();
if (latteView->visibility()->mode() == Latte::Types::SideBar && !latteView->visibility()->isHidden()) {
latteView->visibility()->toggleHiddenState();
}
}
}

@ -75,6 +75,7 @@ private:
bool activateLatteEntry(Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution);
bool activatePlasmaTaskManager(const Latte::View *view, int index, Qt::Key modifier, bool *delayedExecution);
bool activateEntryForView(Latte::View *view, int index, Qt::Key modifier);
bool viewAtLowerEdgePriority(Latte::View *test, Latte::View *base);
bool viewAtLowerScreenPriority(Latte::View *test, Latte::View *base);
bool viewsToHideAreValid();

@ -362,7 +362,7 @@ bool ContainmentInterface::showShortcutBadges(const bool showLatteShortcuts, con
{
identifyMainItem();
if (!m_showShortcutsMethod.isValid()) {
if (!m_showShortcutsMethod.isValid() || !isCapableToShowShortcutBadges()) {
return false;
}

Loading…
Cancel
Save