From 79705e9753edc45cfceccd432da86acbab6ae9b8 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 29 Dec 2019 14:08:07 +0200 Subject: [PATCH] option to disable creenEdgeMargin for maximized --improved settings for Floating windows in Behavior tab and add a new option to hide ALL screen gaps meaning both length screen and thickness screen gap when there is a maximized window in the screen BUG:415630 --- app/view/effects.cpp | 2 +- app/view/positioner.cpp | 6 +++ app/view/view.cpp | 14 +++++- app/view/view.h | 3 ++ app/wm/tracker/windowstracker.cpp | 19 +++---- containment/package/contents/config/main.xml | 4 ++ .../package/contents/ui/DebugWindow.qml | 4 +- containment/package/contents/ui/PanelBox.qml | 2 +- .../package/contents/ui/VisibilityManager.qml | 6 ++- .../package/contents/ui/applet/AppletItem.qml | 2 +- containment/package/contents/ui/main.qml | 37 ++++++++++---- .../configuration/pages/BehaviorConfig.qml | 50 ++++++++++++++----- 12 files changed, 107 insertions(+), 42 deletions(-) diff --git a/app/view/effects.cpp b/app/view/effects.cpp index 8e70e6347..8087b6136 100644 --- a/app/view/effects.cpp +++ b/app/view/effects.cpp @@ -60,10 +60,10 @@ void Effects::init() }); connect(m_view, &Latte::View::alignmentChanged, this, &Effects::updateEnabledBorders); - connect(m_view, &Latte::View::screenEdgeMarginChanged, this, &Effects::updateEnabledBorders); connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateEffects); connect(m_view, &Latte::View::behaveAsPlasmaPanelChanged, this, &Effects::updateShadows); connect(m_view, &Latte::View::configWindowGeometryChanged, this, &Effects::updateMask); + connect(m_view, &Latte::View::screenEdgeMarginEnabledChanged, this, &Effects::updateEnabledBorders); connect(&m_theme, &Plasma::Theme::themeChanged, this, [&]() { auto background = m_background; diff --git a/app/view/positioner.cpp b/app/view/positioner.cpp index 429d0e068..c9c07f31c 100644 --- a/app/view/positioner.cpp +++ b/app/view/positioner.cpp @@ -137,6 +137,12 @@ void Positioner::init() } }); + connect(m_view, &Latte::View::screenEdgeMarginEnabledChanged, this, [&]() { + if (m_view->behaveAsPlasmaPanel()) { + syncGeometry(); + } + }); + connect(m_view->effects(), &Latte::ViewPart::Effects::drawShadowsChanged, this, [&]() { if (!m_view->behaveAsPlasmaPanel()) { syncGeometry(); diff --git a/app/view/view.cpp b/app/view/view.cpp index aa3e7d4a6..b2bbadeae 100644 --- a/app/view/view.cpp +++ b/app/view/view.cpp @@ -815,7 +815,17 @@ void View::setOffset(int offset) bool View::screenEdgeMarginEnabled() const { - return (m_screenEdgeMargin > -1); + return m_screenEdgeMarginEnabled; +} + +void View::setScreenEdgeMarginEnabled(bool enabled) +{ + if (m_screenEdgeMarginEnabled == enabled) { + return; + } + + m_screenEdgeMarginEnabled = enabled; + emit screenEdgeMarginEnabledChanged(); } int View::screenEdgeMargin() const @@ -830,6 +840,8 @@ void View::setScreenEdgeMargin(int margin) } m_screenEdgeMargin = margin; + setScreenEdgeMarginEnabled(m_screenEdgeMargin>-1); + emit screenEdgeMarginChanged(); } diff --git a/app/view/view.h b/app/view/view.h index 1f5ecf353..30b257009 100644 --- a/app/view/view.h +++ b/app/view/view.h @@ -286,6 +286,7 @@ signals: void onPrimaryChanged(); void positionerChanged(); void screenEdgeMarginChanged(); + void screenEdgeMarginEnabledChanged(); void screenGeometryChanged(); void typeChanged(); void visibilityChanged(); @@ -323,6 +324,7 @@ private: void updateAppletContainsMethod(); void setContainsDrag(bool contains); + void setScreenEdgeMarginEnabled(bool enabled); private: Plasma::Containment *containmentById(uint id); @@ -337,6 +339,7 @@ private: bool m_isPreferredForShortcuts{false}; bool m_latteTasksArePresent{false}; bool m_onPrimary{true}; + bool m_screenEdgeMarginEnabled{false}; bool m_isTouchingBottomViewAndIsBusy{false}; bool m_isTouchingTopViewAndIsBusy{false}; diff --git a/app/wm/tracker/windowstracker.cpp b/app/wm/tracker/windowstracker.cpp index 1e14dfbef..b729d40ee 100644 --- a/app/wm/tracker/windowstracker.cpp +++ b/app/wm/tracker/windowstracker.cpp @@ -881,27 +881,24 @@ void Windows::updateHints(Latte::View *view) activeWinId = winfo.wid(); } + //! Maximized windows flags + if ((winfo.isActive() && isMaximizedInViewScreen(view, winfo)) //! active maximized windows have higher priority than the rest maximized windows + || (!foundMaximizedInCurScreen && isMaximizedInViewScreen(view, winfo))) { + foundMaximizedInCurScreen = true; + maxWinId = winfo.wid(); + } + + //! Touching windows flags if (isTouchingViewEdge(view, winfo) || isTouchingView(view, winfo)) { if (winfo.isActive()) { //qDebug() << " ACTIVE-TOUCH :: " << winfo.wid() << " _ " << winfo.appName() << " _ " << winfo.geometry() << " _ " << winfo.display(); foundActiveTouchInCurScreen = true; activeTouchWinId = winfo.wid(); - - if (isMaximizedInViewScreen(view, winfo)) { - //! active maximized windows have higher priority than the rest maximized windows - foundMaximizedInCurScreen = true; - maxWinId = winfo.wid(); - } } else { //qDebug() << " TOUCH :: " << winfo.wid() << " _ " << winfo.appName() << " _ " << winfo.geometry() << " _ " << winfo.display(); foundTouchInCurScreen = true; touchWinId = winfo.wid(); } - - if (!foundMaximizedInCurScreen && isMaximizedInViewScreen(view, winfo)) { - foundMaximizedInCurScreen = true; - maxWinId = winfo.wid(); - } } //qDebug() << "window geometry ::: " << winfo.geometry(); diff --git a/containment/package/contents/config/main.xml b/containment/package/contents/config/main.xml index e1abc83fc..eb6a1f6bf 100644 --- a/containment/package/contents/config/main.xml +++ b/containment/package/contents/config/main.xml @@ -57,6 +57,10 @@ false + + false + + -1 diff --git a/containment/package/contents/ui/DebugWindow.qml b/containment/package/contents/ui/DebugWindow.qml index a880d1a00..5ac5692d2 100644 --- a/containment/package/contents/ui/DebugWindow.qml +++ b/containment/package/contents/ui/DebugWindow.qml @@ -120,11 +120,11 @@ Window{ } Text{ - text: "Max Length (user)"+space + text: "Max Length"+space } Text{ - text: plasmoid.configuration.maxLength +"%" + text: root.maxLengthPerCentage +"%" } Text{ diff --git a/containment/package/contents/ui/PanelBox.qml b/containment/package/contents/ui/PanelBox.qml index bacb0a139..30620aa7a 100644 --- a/containment/package/contents/ui/PanelBox.qml +++ b/containment/package/contents/ui/PanelBox.qml @@ -76,7 +76,7 @@ Item{ } property int spacing: { - if (root.panelAlignment === Latte.Types.Justify && plasmoid.configuration.maxLength === 100) { + if (root.panelAlignment === Latte.Types.Justify && root.maxLengthPerCentage === 100) { return 0; } else if (!Latte.WindowSystem.compositingActive) { return root.panelEdgeSpacing/2; diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index 3e9d65d91..8666fb92a 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -165,7 +165,7 @@ Item{ target: latteView property: "maxLength" when: latteView - value: root.inConfigureAppletsMode ? 1 : plasmoid.configuration.maxLength/100 + value: root.inConfigureAppletsMode ? 1 : maxLengthPerCentage/100 } Binding{ @@ -179,7 +179,7 @@ Item{ target: latteView property: "screenEdgeMargin" when: latteView - value: !root.screenEdgeMarginEnabled ? -1 : plasmoid.configuration.screenEdgeMargin + value: !root.screenEdgeMarginEnabled || root.hideThickScreenGap ? -1 : plasmoid.configuration.screenEdgeMargin } Binding{ @@ -292,6 +292,8 @@ Item{ || plasmoid.configuration.solidBackgroundForMaximized || root.disablePanelShadowMaximized || root.windowColors !== Latte.Types.NoneWindowColors)) + || (root.screenEdgeMarginsEnabled /*Dynamic Screen Edge Margin*/ + && plasmoid.configuration.hideScreenGapForMaximized) } Connections{ diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index e6f499581..e0d8007e3 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -96,7 +96,7 @@ Item { if (root.panelAlignment === Latte.Types.Justify) { //! Justify case - if (plasmoid.configuration.maxLength!==100) { + if (root.maxLengthPerCentage!==100) { return false; } diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index 0048c4e8b..1057b871d 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -160,20 +160,33 @@ Item { && !plasmaBackgroundForPopups*/) property bool solidBusyForTouchingBusyVerticalView: false //DISABLED, until to check if the normalBusyForTouchingBusyVerticalView is enough to catch and handle the case - /*(latteView && latteView.windowsTracker /*is touching a vertical view that is in busy state and the user prefers solidness*/ - /* && latteView.windowsTracker.currentScreen.isTouchingBusyVerticalView + /*(latteView && latteView.windowsTracker /*is touching a vertical view that is in busy state and the user prefers solidness*/ + /* && latteView.windowsTracker.currentScreen.isTouchingBusyVerticalView && root.themeColors === Latte.Types.SmartThemeColors && plasmoid.configuration.backgroundOnlyOnMaximized && plasmoid.configuration.solidBackgroundForMaximized && !plasmaBackgroundForPopups)*/ property bool plasmaStyleBusyForTouchingBusyVerticalView: false //DISABLED, until to check if the normalBusyForTouchingBusyVerticalView is enough to catch and handle the case - //(latteView && latteView.windowsTracker /*is touching a vertical view that is in busy state and the user prefers solidness*/ - /* && latteView.windowsTracker.currentScreen.isTouchingBusyVerticalView + //(latteView && latteView.windowsTracker /*is touching a vertical view that is in busy state and the user prefers solidness*/ + /* && latteView.windowsTracker.currentScreen.isTouchingBusyVerticalView && root.themeColors === Latte.Types.SmartThemeColors && plasmoid.configuration.backgroundOnlyOnMaximized && plasmaBackgroundForPopups)*/ + property bool hideThickScreenGap: screenEdgeMarginEnabled + && plasmoid.configuration.hideScreenGapForMaximized + && latteView && latteView.windowsTracker + && latteView.windowsTracker.currentScreen.existsWindowMaximized + + property bool hideLengthScreenGaps: hideThickScreenGap + && (latteView.visibility.mode === Latte.Types.AlwaysVisible + || latteView.visibility.mode === Latte.Types.WindowsGoBelow) + && (plasmoid.configuration.panelPosition === Latte.Types.Justify) + && maxLengthPerCentage>85 + && !root.editMode + + property int themeColors: plasmoid.configuration.themeColors property int windowColors: plasmoid.configuration.windowColors @@ -199,7 +212,7 @@ Item { property bool dockIsShownCompletely: !(dockIsHidden || inSlidingIn || inSlidingOut) && !root.editMode property bool dragActiveWindowEnabled: plasmoid.configuration.dragActiveWindowEnabled property bool immutable: plasmoid.immutable - property bool inFullJustify: (plasmoid.configuration.panelPosition === Latte.Types.Justify) && (plasmoid.configuration.maxLength===100) + property bool inFullJustify: (plasmoid.configuration.panelPosition === Latte.Types.Justify) && (maxLengthPerCentage===100) property bool inSlidingIn: visibilityManager ? visibilityManager.inSlidingIn : false property bool inSlidingOut: visibilityManager ? visibilityManager.inSlidingOut : false property bool inStartup: true @@ -254,11 +267,13 @@ Item { } property int latteAppletPos: -1 + property int maxLengthPerCentage: hideLengthScreenGaps ? 100 : plasmoid.configuration.maxLength + property int maxLength: { if (root.isHorizontal) { - return behaveAsPlasmaPanel ? width : width * (plasmoid.configuration.maxLength/100) + return behaveAsPlasmaPanel ? width : width * (maxLengthPerCentage/100) } else { - return behaveAsPlasmaPanel ? height : height * (plasmoid.configuration.maxLength/100) + return behaveAsPlasmaPanel ? height : height * (maxLengthPerCentage/100) } } @@ -287,7 +302,7 @@ Item { } var forcedNoShadows = (plasmoid.configuration.panelShadows && disablePanelShadowMaximized - && latteView && latteView.windowsTracker && latteView.windowsTracker.currentScreen.activeWindowMaximized); + && latteView && latteView.windowsTracker && latteView.windowsTracker.currentScreen.activeWindowMaximized); if (forcedNoShadows) { return false; @@ -393,8 +408,10 @@ Item { property int thickMargin: thickMarginFactor * root.iconSize property bool screenEdgeMarginEnabled: plasmoid.configuration.screenEdgeMargin >= 0 && !plasmoid.configuration.shrinkThickMargins - property int screenEdgeMargin: !screenEdgeMarginEnabled ? 0 : plasmoid.configuration.screenEdgeMargin - property int localScreenEdgeMargin: (screenEdgeMarginEnabled && behaveAsPlasmaPanel) || !screenEdgeMarginEnabled ? 0 : plasmoid.configuration.screenEdgeMargin + property int screenEdgeMargin: !screenEdgeMarginEnabled || hideThickScreenGap ? 0 : plasmoid.configuration.screenEdgeMargin + property int localScreenEdgeMargin: (screenEdgeMarginEnabled && behaveAsPlasmaPanel) + || !screenEdgeMarginEnabled + || hideThickScreenGap ? 0 : plasmoid.configuration.screenEdgeMargin //! thickness margins are always two and equal in order for items //! to be always correctly centered diff --git a/shell/package/contents/configuration/pages/BehaviorConfig.qml b/shell/package/contents/configuration/pages/BehaviorConfig.qml index 4d0c9bf73..72a4a9d63 100644 --- a/shell/package/contents/configuration/pages/BehaviorConfig.qml +++ b/shell/package/contents/configuration/pages/BehaviorConfig.qml @@ -718,32 +718,56 @@ PlasmaComponents.Page { } } + LatteComponents.CheckBox { + Layout.maximumWidth: dialog.optionsWidth + // Layout.maximumHeight: mouseWheelChk.height + text: i18n("➊ Activate based on position through global shortcuts") + checked: latteView.isPreferredForShortcuts || (!latteView.layout.preferredForShortcutsTouched && latteView.isHighestPriorityView()) + tooltip: i18n("This view is used for based on position global shortcuts. Take note that only one view can have that option enabled for each layout") + + onClicked: { + latteView.isPreferredForShortcuts = checked + if (!latteView.layout.preferredForShortcutsTouched) { + latteView.layout.preferredForShortcutsTouched = true + } + } + } + } + } + + LatteComponents.SubHeader { + id: floatingSubCategory + text: i18n("Floating") + enabled: !plasmoid.configuration.shrinkThickMargins && (plasmoid.configuration.screenEdgeMargin >= 0) + } + + LatteComponents.CheckBoxesColumn { + Layout.leftMargin: units.smallSpacing * 2 + Layout.rightMargin: units.smallSpacing * 2 + enabled: floatingSubCategory.enabled + + LatteComponents.CheckBoxesColumn { LatteComponents.CheckBox { id: fittsLawChk Layout.maximumWidth: dialog.optionsWidth - text: i18n("Always use screen gap for floating panel") + text: i18n("Always use screen gap for user interaction") checked: plasmoid.configuration.fittsLawIsRequested - tooltip: i18n("When the panel is in floating mode, the gap to the screen is also used") - visible: dialog.highLevel - enabled: !plasmoid.configuration.shrinkThickMargins && (plasmoid.configuration.screenEdgeMargin >= 0) + tooltip: i18n("Panels in floating mode use the screen gap for user interaction") onClicked: { - plasmoid.configuration.fittsLawIsRequested = checked + plasmoid.configuration.fittsLawIsRequested = checked; } } LatteComponents.CheckBox { + id: hideScreenGapForMaximizedChk Layout.maximumWidth: dialog.optionsWidth - // Layout.maximumHeight: mouseWheelChk.height - text: i18n("➊ Activate based on position through global shortcuts") - checked: latteView.isPreferredForShortcuts || (!latteView.layout.preferredForShortcutsTouched && latteView.isHighestPriorityView()) - tooltip: i18n("This view is used for based on position global shortcuts. Take note that only one view can have that option enabled for each layout") + text: i18n("Hide screen gap for maximized windows") + checked: plasmoid.configuration.hideScreenGapForMaximized + tooltip: i18n("Panels in floating mode disable their screen gap for maximized windows") onClicked: { - latteView.isPreferredForShortcuts = checked - if (!latteView.layout.preferredForShortcutsTouched) { - latteView.layout.preferredForShortcutsTouched = true - } + plasmoid.configuration.hideScreenGapForMaximized = checked; } } }