On some Linux machines ALFIS is unable to get primary monitor (what do you expect from Linux?). Fixed that.
This commit is contained in:
+20
-10
@@ -44,24 +44,34 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>) {
|
|||||||
let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build();
|
let event_loop = EventLoopBuilder::<UserEvent>::with_user_event().build();
|
||||||
let proxy = event_loop.create_proxy();
|
let proxy = event_loop.create_proxy();
|
||||||
|
|
||||||
// Get primary monitor and calculate center position
|
|
||||||
let primary_monitor = event_loop.primary_monitor().unwrap();
|
|
||||||
let monitor_size = primary_monitor.size();
|
|
||||||
let monitor_position = primary_monitor.position();
|
|
||||||
|
|
||||||
let window_size = tao::dpi::LogicalSize::new(1024, 720);
|
let window_size = tao::dpi::LogicalSize::new(1024, 720);
|
||||||
let scaled = window_size.to_physical::<i32>(primary_monitor.scale_factor());
|
// Get primary monitor and calculate center position
|
||||||
|
let position = match event_loop.primary_monitor() {
|
||||||
|
Some(monitor) => {
|
||||||
|
let monitor_size = monitor.size();
|
||||||
|
let monitor_position = monitor.position();
|
||||||
|
|
||||||
|
let scaled = window_size.to_physical::<i32>(monitor.scale_factor());
|
||||||
let center_x = monitor_position.x + (monitor_size.width as i32 - scaled.width) / 2;
|
let center_x = monitor_position.x + (monitor_size.width as i32 - scaled.width) / 2;
|
||||||
let center_y = monitor_position.y + (monitor_size.height as i32 - scaled.height) / 2;
|
let center_y = monitor_position.y + (monitor_size.height as i32 - scaled.height) / 2;
|
||||||
|
|
||||||
let window = WindowBuilder::new()
|
Some(PhysicalPosition::new(center_x, center_y))
|
||||||
|
}
|
||||||
|
None => None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut builder = WindowBuilder::new()
|
||||||
.with_title(&title)
|
.with_title(&title)
|
||||||
.with_inner_size(window_size)
|
.with_inner_size(window_size)
|
||||||
.with_min_inner_size(tao::dpi::LogicalSize::new(773, 350))
|
.with_min_inner_size(tao::dpi::LogicalSize::new(773, 350))
|
||||||
.with_position(PhysicalPosition::new(center_x, center_y))
|
|
||||||
.with_resizable(true)
|
.with_resizable(true)
|
||||||
.with_visible(true)
|
.with_visible(true);
|
||||||
.build(&event_loop)
|
|
||||||
|
if let Some(position) = position {
|
||||||
|
builder = builder.with_position(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
let window = builder.build(&event_loop)
|
||||||
.expect("Failed to create the window");
|
.expect("Failed to create the window");
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
|
|||||||
Reference in New Issue
Block a user