mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
Merge pull request #2009 from injust/use-has-selection
Use `Surface.hasSelection()`
This commit is contained in:
@ -2145,20 +2145,16 @@ pub fn mouseButtonCallback(
|
|||||||
// cursorPosCallback will also do a mouse report so we don't need to do any
|
// cursorPosCallback will also do a mouse report so we don't need to do any
|
||||||
// of the logic below.
|
// of the logic below.
|
||||||
if (button == .left and action == .press) {
|
if (button == .left and action == .press) {
|
||||||
|
// We could do all the conditionals in one but I find it more
|
||||||
|
// readable as a human to break this one up.
|
||||||
if (mods.shift and
|
if (mods.shift and
|
||||||
self.mouse.left_click_count > 0 and
|
self.mouse.left_click_count > 0 and
|
||||||
!shift_capture)
|
!shift_capture)
|
||||||
{
|
{
|
||||||
// Checking for selection requires the renderer state mutex which
|
// We split this conditional out on its own because this is the
|
||||||
// sucks but this should be pretty rare of an event so it won't
|
// only one that requires a renderer mutex grab which is VERY
|
||||||
// cause a ton of contention.
|
// expensive because it could block all our threads.
|
||||||
const selection = selection: {
|
if (self.hasSelection()) {
|
||||||
self.renderer_state.mutex.lock();
|
|
||||||
defer self.renderer_state.mutex.unlock();
|
|
||||||
break :selection self.io.terminal.screen.selection != null;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (selection) {
|
|
||||||
const pos = try self.rt_surface.getCursorPos();
|
const pos = try self.rt_surface.getCursorPos();
|
||||||
try self.cursorPosCallback(pos);
|
try self.cursorPosCallback(pos);
|
||||||
return true;
|
return true;
|
||||||
|
Reference in New Issue
Block a user