-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Open
wjtje
wants to merge
2
commits into
domferr:v17.1
Choose a base branch
from
wjtje:feat/monitor-aspect-in-layout-preview
base: v17.1
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
]; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { buildBlurEffect } from '@utils/gnomesupport'; | |
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) + | ||
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? |
||
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( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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!