-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
assign a window to a specific monitor/display [feat] #6394
Comments
should you be able to move your window between monitors or what you think is just opening the window on the other monitor? |
Both. It would be nice to be able to:
- specify the monitor on window creation
- move a window after creation via a move_to_monitot method
metkm ***@***.***> schrieb am So., 5. März 2023, 23:14:
… should you be able to move your window between monitors or what you think
is just opening the window on the other monitor?
—
Reply to this email directly, view it on GitHub
<#6394 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANP2PFCELUT4C72UAFY2WDW2UF5VANCNFSM6AAAAAAVOW22ZM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Maybe you can do something like this for now. The one weird this was that my x and y positions of display 2 were mixed with display 1. This could be a problem with my system. I don't know. use tauri::{Position, Window, WindowBuilder};
fn move_window_to_other_monitor(window: &Window, i: usize) -> tauri::Result<()> {
let monitors = window.available_monitors()?;
let monitor = monitors.get(i).ok_or(tauri::Error::CreateWindow)?;
let pos = monitor.position();
window.set_position(Position::Physical(
tauri::PhysicalPosition{
x: pos.x,
y: 0
})
)?;
window.center()?;
Ok(())
}
fn main() {
tauri::Builder::default()
.setup(|app| {
let window =
WindowBuilder::new(app, "Main", tauri::WindowUrl::App("index.html".into()))
.build()?;
move_window_to_other_monitor(&window, 1);
Ok(())
})
.run(tauri::generate_context!())
.expect("error while running tauri application");
} |
you can use
Not needed and not very much practical since we can't know which coordinates inside that monitor would you want to assign your window so the solution given by @metkm is the way to do it. |
Thanks for you support @amrbashir and @metkm. This helps me already! |
…6403) Co-authored-by: Lucas Nogueira <lucas@tauri.studio>
How to stop tauri app at mutliple monitors and run only on user choose monitor |
so this is closed because the solution is what? |
@FabianLars also this is not clear :( makes me sad |
so how to use this ?
|
I am trying to use the function without luck all the type types errors |
If you're not familiar with Rust (and don't want to be) then the monitor apis are also available in javascript (if it's about your primary window then you'll have to spawn it |
I solved it with this
and this
|
Describe the problem
I can't programmatically assign / move a window two a display in a multi monitor setup.
Describe the solution you'd like
It would be nice, if the
WindowBuilder
would support assigning a Monitor/Display to a new window.Alternatives considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: