Skip to content
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

feat: allow setting window size and position using physical units close #5228 #5381

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

ysinsane
Copy link

@ysinsane ysinsane commented Oct 10, 2022

Close #5228

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Docs
  • New Binding issue #___
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change?

  • Yes, and the changes were approved in issue #___
  • No

Checklist

  • When resolving issues, they are referenced in the PR's title (e.g fix: remove a typo, closes #___, #___)
  • A change file is added if any packages will require a version bump due to this PR per the instructions in the readme.
  • I have added a convincing reason for adding this feature, if necessary

Other information

@ysinsane ysinsane requested a review from a team as a code owner October 10, 2022 09:54
@ysinsane ysinsane changed the title feat: allow setting window size and position using physical units feat: allow setting window size and position using physical units close #5228 Oct 10, 2022
@ysinsane ysinsane marked this pull request as draft October 10, 2022 09:59
@ysinsane ysinsane marked this pull request as ready for review October 10, 2022 10:06
core/tauri-utils/src/lib.rs Outdated Show resolved Hide resolved
core/tauri-utils/src/lib.rs Outdated Show resolved Hide resolved
tooling/api/src/window.ts Outdated Show resolved Hide resolved
@ysinsane
Copy link
Author

@amrbashir May I ask anything more I could do on this PR? I am willing to do more to pass this PR.

@amrbashir
Copy link
Member

It is just waiting for lucas review. He is a bit busy so we appreciate your patience.

@lucasfernog
Copy link
Member

I did check it a week ago and I think we should consider a different format for specifying physical units. My first idea was to use a number for logical values e.g. 100 and a string for physical ones such as 100px. The approach on this PR is kinda restrictive since you can't mix logical and physical values in the configuration.

@amrbashir
Copy link
Member

I think @ysinsane had that before, where we add a sizeUnit and positionUnit fields but I asked him to combine them but I am fine with changing them back.

I think 100px would hint at there maybe some other css units like 100vw and I don't like that.

@ysinsane
Copy link
Author

ysinsane commented Nov 2, 2022

I actually kind of like lucas's idea, although it takes more work to implement it. As for detail, I'd like to know your idea on mix of logical and physical unit, for example 100 window width and 100px window height?
Cause I found it is not supported by the WRY API. @lucasfernog

@amrbashir
Copy link
Member

I don't feel like we should support different width and height. It doesn't make sense tbh and since it requires changes upstream I don't think we should do it now, maybe after switch to winit. For now, we can just add sizeUnit and positionUnit, what do you think @lucasfernog ?

@lucasfernog
Copy link
Member

Yeah we shouldn't mix different formats for the same property. I think for v1 we could go with the unit parameters, but refactor the entire configuration format for v2.

@Miniontoby
Copy link
Contributor

Miniontoby commented May 9, 2023

Hi!

I am now using this branch/fork and I don't seem to get it to work yet; as in the sizes still don't work...
image

When I manually correct it with shortcuts from windows it looks like:
image

So yeah the code I use:

const webviewwindow = new WebviewWindow('presentation', {
    url: this.url, fullscreen: true, resizable: false,
    title: 'presentation',
    x: monitor.position.x, y: monitor.position.y,
    width: monitor.size.width, height: monitor.size.height,
    pixelUnit: 'physical'
});

What am I doing wrong?

Btw when adding this code:

webviewwindow.once('tauri:https://created', async function () {
    console.log(monitor.position, await webviewwindow.innerPosition())
    console.log(monitor.size, await webviewwindow.innerSize())
});

This is the output:

{ "type": "Physical", "x": -1680, "y": -908 }, { "type": "Physical", "x": -1680, "y": -908 }

{ "type": "Physical", "width": 1680, "height": 1050 }, { "type": "Physical", "width": 1920, "height": 1080 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 📬Proposal
Development

Successfully merging this pull request may close these issues.

[feat] Window builder physical size/position
4 participants