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(core): add an option for preventing window overflow #9687

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

Conversation

Legend-Master
Copy link
Contributor

Closes #9671

@Legend-Master Legend-Master marked this pull request as ready for review May 7, 2024 09:50
@Legend-Master Legend-Master requested a review from a team as a code owner May 7, 2024 09:50
@Legend-Master
Copy link
Contributor Author

We probably need some better documentations and names, and also implementation for linux and mac

core/tauri-runtime-wry/src/lib.rs Outdated Show resolved Hide resolved
core/tauri-runtime-wry/src/lib.rs Outdated Show resolved Hide resolved
@pewsheen
Copy link
Contributor

pewsheen commented May 8, 2024

Just a note: on macOS, you will need to turn off System Settings > Desktop & Dock > Mission Control > Displays have separate Spaces to let the window span across monitors.

Copy link
Contributor

github-actions bot commented Aug 8, 2024

Package Changes Through 657b479

There are 8 changes which include tauri-bundler with minor, tauri-cli with minor, @tauri-apps/cli with minor, tauri with minor, tauri-runtime with minor, tauri-runtime-wry with minor, tauri-utils with patch, @tauri-apps/api with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
@tauri-apps/api 2.1.1 2.1.2
tauri-utils 2.1.0 2.1.1
tauri-bundler 2.1.0 2.2.0
tauri-runtime 2.2.0 2.3.0
tauri-runtime-wry 2.2.0 2.3.0
tauri-codegen 2.0.3 2.0.4
tauri-macros 2.0.3 2.0.4
tauri-plugin 2.0.3 2.0.4
tauri-build 2.0.3 2.0.4
tauri 2.1.1 2.2.0
@tauri-apps/cli 2.1.0 2.2.0
tauri-cli 2.1.0 2.2.0

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master
Copy link
Contributor Author

Searched around a bit but didn't find a good way of doing it on linux, I guess falling back to use the monitor size is not all that bad

.changes/prevent-window-overflow.md Outdated Show resolved Hide resolved
@@ -3906,7 +3945,7 @@ fn create_window<T: UserEvent, F: Fn(RawWindow) + Send + 'static>(
}

#[cfg(desktop)]
if window_builder.center {
if window_builder.prevent_overflow.is_some() || window_builder.center {
let monitor = if let Some(window_position) = &window_builder.inner.window.position {
event_loop.available_monitors().find(|m| {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why we are doing it this way, but can't we change this to monitor_from_point

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

window_builder.inner.window.position is a Position here that we need to convert to physical position with scale factor so I don't think we can use monitor_from_point here, also I think monitor_from_point was introduced after this PR was made?

crates/tauri-utils/src/config.rs Outdated Show resolved Hide resolved
crates/tauri/src/window/mod.rs Show resolved Hide resolved
packages/api/src/window.ts Outdated Show resolved Hide resolved
crates/tauri-runtime-wry/src/lib.rs Outdated Show resolved Hide resolved
///
/// ## Platform-specific
///
/// - **Linux:** Prevent overflowing the monitor instead of workarea
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, didn't know it exits, do you think we can move this get_work_area_size to tao instead? If not we'll need a way to access the inner gdk::Monitor from tao

Comment on lines +3980 to +3982
// Left and right window shadow counts as part of the window on Windows
// We need to include it when calculating positions, but not size
let mut shadow_width = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need to include it? I think we should just include the starting of the window border not shadow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remembered correctly, the shadow counts as part of the window when we set the positions, say your shadow is 5px left right bottom, and you set the window's position to (0, 0), then the actual window's top left will be placed at (5, 0

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

Successfully merging this pull request may close these issues.

[feat] add an option to prevent window overflow
4 participants