Skip to content

Commit

Permalink
fix: only autohide UI when the cursor autohides
Browse files Browse the repository at this point in the history
The cursor isn't allowed to autohide while hovering elements, so the UI
shouldn't autohide either. Otherwise this leads to the situation where
the UI autohides while e.g. hovering the timeline, and then the
cursor autohides afterwards because it's not hovering anything anymore.
  • Loading branch information
christoph-heinrich committed Nov 4, 2023
1 parent 650118e commit e56c4bd
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/uosc/lib/cursor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,17 @@ function cursor:decide_keybinds()
if enable_mbtn_left_dbl ~= self.mbtn_left_dbl_enabled then
mp[(enable_mbtn_left_dbl and 'enable' or 'disable') .. '_key_bindings']('mbtn_left_dbl')
self.mbtn_left_dbl_enabled = enable_mbtn_left_dbl
self:queue_autohide()
end
if enable_mbtn_right ~= self.mbtn_right_enabled then
mp[(enable_mbtn_right and 'enable' or 'disable') .. '_key_bindings']('mbtn_right')
self.mbtn_right_enabled = enable_mbtn_right
self:queue_autohide()
end
if enable_wheel ~= self.wheel_enabled then
mp[(enable_wheel and 'enable' or 'disable') .. '_key_bindings']('wheel')
self.wheel_enabled = enable_wheel
self:queue_autohide()
end
end

Expand Down Expand Up @@ -256,13 +259,22 @@ end

function cursor:leave() self:move(math.huge, math.huge) end

function cursor:allow_autohide()
return options.autohide and
not (self.mbtn_left_dbl_enabled or self.mbtn_right_enabled or self.wheel_enabled) and
not Menu:is_open()
end

-- Cursor auto-hiding after period of inactivity.
function cursor:autohide()
if #self.zone_handlers.primary_up == 0 and not Menu:is_open() then self:leave() end
if self:allow_autohide() then
self:leave()
self.autohide_timer:kill()
end
end

function cursor:queue_autohide()
if options.autohide and #self.zone_handlers.primary_up == 0 then
if self:allow_autohide() then
self.autohide_timer:kill()
self.autohide_timer:resume()
end
Expand Down

0 comments on commit e56c4bd

Please sign in to comment.