-
-
Notifications
You must be signed in to change notification settings - Fork 95
Use the display aspect ratio instead of 16:9 in layout previews #385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v17.1
Are you sure you want to change the base?
Changes from 1 commit
510ae86
e251fda
2632625
5846122
fa059c6
7fe289f
bfd9dde
62d58a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import { St } from '@gi.ext'; | ||
| import { getScalingFactorOf } from '@utils/ui'; | ||
| export default class LayoutUtils { | ||
| static calc_size( | ||
| widget: St.Widget, | ||
| monitorIndex: number, | ||
| smallEdgeSize: number, | ||
| ): [number, number] { | ||
| const monitorGeometry = | ||
| global.display.get_monitor_geometry(monitorIndex); | ||
|
|
||
| const aspectRatio = monitorGeometry.width / monitorGeometry.height; | ||
| const [, scalingFactor] = getScalingFactorOf(widget); | ||
|
|
||
| if (aspectRatio === 1) { | ||
| return [ | ||
| smallEdgeSize * scalingFactor, | ||
| smallEdgeSize * scalingFactor, | ||
| ]; | ||
| } | ||
|
|
||
| return [ | ||
| (aspectRatio > 1.0 | ||
| ? Math.round(smallEdgeSize * aspectRatio) | ||
| : smallEdgeSize) * scalingFactor, | ||
| (aspectRatio < 1.0 | ||
| ? Math.round(smallEdgeSize / aspectRatio) | ||
| : smallEdgeSize) * scalingFactor, | ||
| ]; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { GObject, St, Clutter, Mtk, Meta, Gio } from '@gi.ext'; | |
| import SnapAssistTile from './snapAssistTile'; | ||
| import SnapAssistLayout from './snapAssistLayout'; | ||
| import Layout from '../layout/Layout'; | ||
| import LayoutUtils from '../layout/LayoutUtils'; | ||
| import Tile from '../layout/Tile'; | ||
| import Settings from '@settings/settings'; | ||
| import GlobalState from '@utils/globalState'; | ||
|
|
@@ -19,9 +20,9 @@ import { logger } from '@utils/logger'; | |
| export const SNAP_ASSIST_SIGNAL = 'snap-assist'; | ||
|
|
||
| const GAPS = 4; | ||
| // 16:9 ratio and then rounded to int | ||
| const SNAP_ASSIST_LAYOUT_WIDTH = 120; | ||
| const SNAP_ASSIST_LAYOUT_HEIGHT = 68; | ||
| // The size of the smallest size of the monitor | ||
| // Will result into a size of 120x68 if the monitor is 16:9 | ||
| const SNAP_ASSIST_LAYOUT_SIZE = 68; | ||
|
|
||
| const debug = logger('SnapAssist'); | ||
|
|
||
|
|
@@ -209,7 +210,7 @@ class SnapAssistContent extends St.BoxLayout { | |
| ? Math.max( | ||
| 0, | ||
| this._snapAssistantThreshold - | ||
| this.height / 2 + | ||
| 46 * getMonitorScalingFactor(this._monitorIndex) + | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why 46?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was the height of the snap-assist dropdown, before any of my changes. Maybe a better calculation would be one of these:
Or change it entirely to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private get _desiredY(): number {
return this._isEnlarged
? Math.max(0, this._padding)
: -this.height + this._padding;
} |
||
| this._padding, | ||
| ) | ||
| : -this.height + this._padding; | ||
|
|
@@ -237,12 +238,13 @@ class SnapAssistContent extends St.BoxLayout { | |
| this._snapAssistLayouts.forEach((lay) => lay.destroy()); | ||
| this.remove_all_children(); | ||
|
|
||
| const [, scalingFactor] = getScalingFactorOf(this); | ||
|
|
||
| const layoutGaps = buildMarginOf(GAPS); | ||
| const [width, height] = LayoutUtils.calc_size( | ||
| this, | ||
| this._monitorIndex, | ||
| SNAP_ASSIST_LAYOUT_SIZE, | ||
| ); | ||
|
|
||
| const width = SNAP_ASSIST_LAYOUT_WIDTH * scalingFactor; | ||
| const height = SNAP_ASSIST_LAYOUT_HEIGHT * scalingFactor; | ||
| // build the layouts inside the snap assistant. Place a spacer between each layout | ||
| this._snapAssistLayouts = layouts.map((lay, ind) => { | ||
| const saLay = new SnapAssistLayout( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a great idea!