8000 enhancement: a new config for centering the window based on resolution · Issue #1350 · marc2332/freya · GitHub
[go: up one dir, main page]

Skip to content

enhancement: a new config for centering the window based on resolution #1350

@0xSovereign

Description

@0xSovereign

Essentially, having a simple config in LaunchConfig for making the application start centered would be pretty nice.

Currently this does the job.

use winit::dpi::LogicalPosition;
use winit::dpi::Position;
use winapi::um::winuser::{GetSystemMetrics, SM_CXSCREEN, SM_CYSCREEN};

...

            #[cfg(target_os = "windows")]
            {
                let screen_w = unsafe { GetSystemMetrics(SM_CXSCREEN) };
                let screen_h = unsafe { GetSystemMetrics(SM_CYSCREEN) };

                let x = (screen_w - 1020) / 2;
                let y = (screen_h - 620) / 2;

                let pos = LogicalPosition::new(x as f64, y as f64);

                attrs = attrs.with_position(Position::Logical(pos));
            }

Metadata

Metadata

Assignees

Labels

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0