Commit 8ca43611 authored by Christian Duerr's avatar Christian Duerr Committed by Peter van der meulen

Fix selection

The selection was not working properly because it relied on logical
sizes but the code expected the old physical sizes.

This has been fixed by taking the incoming mouse movement event and
translating its position to physical sizes before propagating it to the
event handler.
parent f006cba7
......@@ -142,19 +142,19 @@ impl Display {
// get window properties for initializing the other subsystems
let mut viewport_size = window.inner_size_pixels()
.expect("glutin returns window size");
let dpr = if config.font().scale_with_dpi() {
let dpi_factor = if config.font().scale_with_dpi() {
window.hidpi_factor()
} else {
1.0
};
info!("device_pixel_ratio: {}", dpr);
info!("device_pixel_ratio: {}", dpi_factor);
// Create renderer
let mut renderer = QuadRenderer::new(config, viewport_size.to_physical(window.hidpi_factor()))?;
let (glyph_cache, cell_width, cell_height) =
Self::new_glyph_cache(dpr as f32, &mut renderer, config)?;
Self::new_glyph_cache(dpi_factor, &mut renderer, config)?;
let dimensions = options.dimensions()
......@@ -170,7 +170,7 @@ impl Display {
(height + 2 * u32::from(config.padding().y)) as f64);
window.set_inner_size(new_viewport_size);
renderer.resize(new_viewport_size.to_physical(dpr));
renderer.resize(new_viewport_size.to_physical(dpi_factor));
viewport_size = new_viewport_size;
}
......@@ -178,6 +178,7 @@ impl Display {
let psize = viewport_size.to_physical(window.hidpi_factor());
let size_info = SizeInfo {
dpi_factor,
width: psize.width as f32,
height: psize.height as f32,
cell_width: cell_width as f32,
......@@ -214,11 +215,11 @@ impl Display {
})
}
fn new_glyph_cache(dpr: f32, renderer: &mut QuadRenderer, config: &Config)
fn new_glyph_cache(dpi_factor: f64, renderer: &mut QuadRenderer, config: &Config)
-> Result<(GlyphCache, f32, f32), Error>
{
let font = config.font().clone();
let rasterizer = font::Rasterizer::new(dpr, config.use_thin_strokes())?;
let rasterizer = font::Rasterizer::new(dpi_factor as f32, config.use_thin_strokes())?;
// Initialize glyph cache
let glyph_cache = {
......@@ -292,8 +293,15 @@ impl Display {
new_size = Some(sz.to_physical(self.window.hidpi_factor()));
}
let dpi_factor = if config.font().scale_with_dpi() {
self.window.hidpi_factor()
} else {
1.0
};
// Font size modification detected
if terminal.font_size != self.font_size {
if terminal.font_size != self.font_size || dpi_factor != self.size_info.dpi_factor {
self.size_info.dpi_factor = dpi_factor;
self.font_size = terminal.font_size;
self.update_glyph_cache(config);
......
......@@ -353,7 +353,7 @@ impl<N: Notify> Processor<N> {
}
},
CursorMoved { position: lpos, modifiers, .. } => {
let (x, y) = lpos.into();
let (x, y) = lpos.to_physical(processor.ctx.size_info.dpi_factor).into();
let x: i32 = limit(x, 0, processor.ctx.size_info.width as i32);
let y: i32 = limit(y, 0, processor.ctx.size_info.height as i32);
......
......@@ -786,6 +786,9 @@ pub struct SizeInfo {
/// Horizontal window padding
pub padding_y: f32,
/// DPI factor of the current window
pub dpi_factor: f64,
}
impl SizeInfo {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment