mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
fix: adjust for window padding when calculating whether selection has started
This commit is contained in:

committed by
Mitchell Hashimoto

parent
a44e5a9ae4
commit
c49c300c3a
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
.vscode
|
||||||
.direnv/
|
.direnv/
|
||||||
.flatpak-builder/
|
.flatpak-builder/
|
||||||
zig-cache/
|
zig-cache/
|
||||||
|
@ -1871,20 +1871,20 @@ fn dragLeftClickSingle(
|
|||||||
//
|
//
|
||||||
|
|
||||||
// the boundary point at which we consider selection or non-selection
|
// the boundary point at which we consider selection or non-selection
|
||||||
const cell_xboundary = @as(f32, @floatFromInt(self.cell_size.width)) * 0.6;
|
const cell_width_f64: f64 = @floatFromInt(self.cell_size.width);
|
||||||
|
const cell_xboundary = cell_width_f64 * 0.6;
|
||||||
|
|
||||||
// first xpos of the clicked cell
|
// first xpos of the clicked cell adjusted for padding
|
||||||
const cell_xstart = @as(
|
const left_padding_f64: f64 = @as(f64, @floatFromInt(self.padding.left));
|
||||||
f32,
|
const cell_xstart = @as(f64, @floatFromInt(self.mouse.left_click_point.x)) * cell_width_f64;
|
||||||
@floatFromInt(self.mouse.left_click_point.x),
|
const cell_start_xpos = self.mouse.left_click_xpos - cell_xstart - left_padding_f64;
|
||||||
) * @as(f32, @floatFromInt(self.cell_size.width));
|
|
||||||
const cell_start_xpos = self.mouse.left_click_xpos - cell_xstart;
|
|
||||||
|
|
||||||
// If this is the same cell, then we only start the selection if weve
|
// If this is the same cell, then we only start the selection if weve
|
||||||
// moved past the boundary point the opposite direction from where we
|
// moved past the boundary point the opposite direction from where we
|
||||||
// started.
|
// started.
|
||||||
if (std.meta.eql(screen_point, self.mouse.left_click_point)) {
|
if (std.meta.eql(screen_point, self.mouse.left_click_point)) {
|
||||||
const cell_xpos = xpos - cell_xstart;
|
// Ensuring to adjusting the cursor position for padding
|
||||||
|
const cell_xpos = xpos - cell_xstart - left_padding_f64;
|
||||||
const selected: bool = if (cell_start_xpos < cell_xboundary)
|
const selected: bool = if (cell_start_xpos < cell_xboundary)
|
||||||
cell_xpos >= cell_xboundary
|
cell_xpos >= cell_xboundary
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user