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

Allow creation of large window that can exceed the monitor size #3389

Closed
EvinceMoi opened this issue Sep 25, 2023 · 3 comments · Fixed by #4337
Closed

Allow creation of large window that can exceed the monitor size #3389

EvinceMoi opened this issue Sep 25, 2023 · 3 comments · Fixed by #4337
Labels
eframe Relates to epi and eframe

Comments

@EvinceMoi
Copy link

Is your feature request related to a problem? Please describe.
When I set initial_window_size in eframe::NativeOptions with large value (bigger than the logical size of the monitor), the size is chop by largest_monitor_point_size, this blocks some cases like displaying a workspace screenshot on multiple monitors, like #3185, or display high resolution pic/videos in actical size. I'm curious about the reason behind it.

Describe the solution you'd like
maybe add a option like unbounded_size: bool the disable the max window restriction?

Describe alternatives you've considered
N/A

Additional context
An simple example(all values are logical)

monitor x y width height mode
m1 0 0 1080 1920 portrait
m2 1080 840 1920 1080 landscape

with this setup, a window across all screen should have the size of 3000x1920. Setting initial_window_size to 3000x1920 , initial_window_pos to 0, 0, a window at 0, 0 with size 1920x1080 wat created in my case.

@lopo12123
Copy link
Contributor

Hello @emilk , is there any progress on this issue? I would like to know what the motivation is for using largest_monitor_point_size, and whether it is possible to provide a bool value for users to choose whether to apply this option.

@emilk
Copy link
Owner

emilk commented Apr 3, 2024

The motivation can be found here:

// Make sure we don't try to create a window larger than the largest monitor
// because on Linux that can lead to a crash.
*size = size.at_most(largest_monitor_size_points);

And yes, we can make that a bool, though I suggest we avoid negations in names and go with clamp_size_to_monitor_size or something like that, and default it to true only on Linux? 🤷

PRs welcome!

@emilk emilk added the eframe Relates to epi and eframe label Apr 3, 2024
@lopo12123
Copy link
Contributor

Thanks for the answer🙇‍

If the situation on linux is the only thing to consider, then I would try adding this field and then pr.

It may take me four or five days (I have three days off next and I have to go to the company to have multiple monitors for testing)

emilk added a commit that referenced this issue Apr 22, 2024
#4337)

Added clamp_size_to_monitor_size field on ViewportBuilder, which means
whether clamp the window's size to monitor's size. (default to `true`)

* Closes #3389

### simple example

```rust
pub struct MyApp {}

impl MyApp {
    pub fn new() -> MyApp {
        MyApp {}
    }
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
        egui::CentralPanel::default()
            .frame(Frame::none().fill(Color32::DARK_GRAY))
            .show(ctx, |ui| {
                if ctx.input(|i| i.key_pressed(Key::Escape)) {
                    ctx.send_viewport_cmd(ViewportCommand::Close);
                }
            });
    }
}

pub fn main() {
    let option = eframe::NativeOptions {
        viewport: ViewportBuilder::default()
            .with_position([10.0, 10.0])
            .with_inner_size([3000.0, 2000.0])
            .with_clamp_size_to_monitor_size(false),
        ..Default::default()
    };

    eframe::run_native(
        "a large window app",
        option,
        Box::new(|ctx| Box::new(MyApp::new())),
    ).unwrap();
}
```

It works on my windows (with 3 monitors), but I don't have a test
environment for macos

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
hacknus pushed a commit to hacknus/egui that referenced this issue Oct 30, 2024
emilk#4337)

Added clamp_size_to_monitor_size field on ViewportBuilder, which means
whether clamp the window's size to monitor's size. (default to `true`)

* Closes emilk#3389

### simple example

```rust
pub struct MyApp {}

impl MyApp {
    pub fn new() -> MyApp {
        MyApp {}
    }
}

impl eframe::App for MyApp {
    fn update(&mut self, ctx: &Context, frame: &mut eframe::Frame) {
        egui::CentralPanel::default()
            .frame(Frame::none().fill(Color32::DARK_GRAY))
            .show(ctx, |ui| {
                if ctx.input(|i| i.key_pressed(Key::Escape)) {
                    ctx.send_viewport_cmd(ViewportCommand::Close);
                }
            });
    }
}

pub fn main() {
    let option = eframe::NativeOptions {
        viewport: ViewportBuilder::default()
            .with_position([10.0, 10.0])
            .with_inner_size([3000.0, 2000.0])
            .with_clamp_size_to_monitor_size(false),
        ..Default::default()
    };

    eframe::run_native(
        "a large window app",
        option,
        Box::new(|ctx| Box::new(MyApp::new())),
    ).unwrap();
}
```

It works on my windows (with 3 monitors), but I don't have a test
environment for macos

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
eframe Relates to epi and eframe
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants