Skip to content

Commit

Permalink
Fix spurious notification bubbles
Browse files Browse the repository at this point in the history
  • Loading branch information
LBPHacker committed Nov 14, 2024
1 parent 8996340 commit 5b9cf0d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 22 deletions.
2 changes: 2 additions & 0 deletions tptmp/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ local function run()
begin_chat_func = begin_chat,
window_status_func = get_window_status,
sync_func = function()
win:set_silent(true)
cmd:parse("/sync")
win:set_silent(false)
end,
})

Expand Down
36 changes: 19 additions & 17 deletions tptmp/client/profile/vanilla.lua
Original file line number Diff line number Diff line change
Expand Up @@ -924,26 +924,28 @@ function profile_i:handle_mousedown(px, py, button)
if key == "unknown" then
local identifier = self.display_toolwarn_identifier_
local ids = self.xidr_unsupported_[identifier]
local display_as = identifier
if elem[identifier] then
display_as = elem.property(elem[identifier], "Name")
end
self.log_event_func_(("The following users in the room cannot use %s, please avoid using it while connected"):format(display_as))
local str = ""
local function commit()
self.log_event_func_(" - " .. str)
str = ""
end
for i = 1, #ids do
str = str .. self.client_.id_to_member[ids[i]].formatted_nick
if i < #ids then
str = str .. "\bw, "
if ids then -- TODO: remove; this should always be a table but there's some sequencing problem that I can't figure out
local display_as = identifier
if elem[identifier] then
display_as = elem.property(elem[identifier], "Name")
end
self.log_event_func_(("The following users in the room cannot use %s, please avoid using it while connected"):format(display_as))
local str = ""
local function commit()
self.log_event_func_(" - " .. str)
str = ""
end
if gfx.textSize(str) > gfx.WIDTH / 2 then
commit()
for i = 1, #ids do
str = str .. self.client_.id_to_member[ids[i]].formatted_nick
if i < #ids then
str = str .. "\bw, "
end
if gfx.textSize(str) > gfx.WIDTH / 2 then
commit()
end
end
commit()
end
commit()
else
self.log_event_func_(toolwarn_messages[key])
end
Expand Down
27 changes: 22 additions & 5 deletions tptmp/client/window.lua
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ function window_i:backlog_update_()
end

function window_i:backlog_push_(collect, important)
if self.silent_ then
important = false
end
self.backlog_unique_ = self.backlog_unique_ + 1
local msg = {
unique = self.backlog_unique_,
Expand Down Expand Up @@ -323,6 +326,10 @@ function window_i:backlog_push_str(str, important)
end
end

function window_i:backlog_mark_seen()
self.backlog_last_seen_ = self.backlog_last_wrapped_
end

function window_i:backlog_bump_marker()
self.backlog_enable_marker_ = false
if self.backlog_last_seen_ < self.backlog_unique_ then
Expand Down Expand Up @@ -395,7 +402,7 @@ function window_i:handle_tick()
local now = socket.gettime()

if self.backlog_auto_scroll_ and not floating then
self.backlog_last_seen_ = self.backlog_last_wrapped_
self:backlog_mark_seen()
else
if self.backlog_last_seen_ < self.backlog_unique_ and not self.backlog_enable_marker_ then
self:backlog_bump_marker()
Expand Down Expand Up @@ -580,10 +587,15 @@ function window_i:handle_mousedown(px, py, button)
end
end

function window_i:hide_window()
self:backlog_mark_seen()
self.hide_window_func_()
end

function window_i:handle_mouseup(px, py, button)
if button == ui.SDL_BUTTON_LEFT then
if self.close_active_ then
self.hide_window_func_()
self:hide_window()
end
self.resizer_active_ = false
self.dragger_active_ = false
Expand Down Expand Up @@ -652,7 +664,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
self:input_reset_()
end
if shift or force_hide then
self.hide_window_func_()
self:hide_window()
end
else
self.in_focus = true
Expand Down Expand Up @@ -783,7 +795,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
if self.hide_when_chat_done then
self.hide_when_chat_done = false
self.in_focus = false
self.hide_window_func_()
self:hide_window()
end
end
else
Expand Down Expand Up @@ -870,7 +882,7 @@ function window_i:handle_keypress(key, scan, rep, shift, ctrl, alt)
return not modkey_scan[scan]
else
if not ctrl and not alt and scan == ui.SDL_SCANCODE_ESCAPE then
self.hide_window_func_()
self:hide_window()
return true
end
end
Expand Down Expand Up @@ -925,6 +937,10 @@ local function set_size_clamp(new_width, new_height, new_pos_x, new_pos_y)
return width, height, pos_x, pos_y
end

function window_i:set_silent(silent)
self.silent_ = silent
end

function window_i:set_size(new_width, new_height)
self.width_, self.height_, self.pos_x_, self.pos_y_ = set_size_clamp(new_width, new_height, self.pos_x_, self.pos_y_)
self:input_update_()
Expand Down Expand Up @@ -1127,6 +1143,7 @@ local function new(params)
local title_width = gfx.textSize(title)
local win = setmetatable({
in_focus = false,
silent_ = false,
pos_x_ = pos_x,
pos_y_ = pos_y,
width_ = width,
Expand Down

0 comments on commit 5b9cf0d

Please sign in to comment.