Avoid always calling system.get_window_mode

This commit is contained in:
Francesco Abbate
2021-04-12 13:31:32 +02:00
parent 46791aefe5
commit 4de97d51fb
3 changed files with 16 additions and 2 deletions
+5
View File
@@ -411,6 +411,7 @@ function core.init()
core.clip_rect_stack = {{ 0,0,0,0 }}
core.log_items = {}
core.docs = {}
core.window_mode = "normal"
core.threads = setmetatable({}, { __mode = "k" })
local project_dir_abs = system.absolute_path(project_dir)
@@ -812,6 +813,10 @@ function core.on_event(type, ...)
core.root_view:on_mouse_released(...)
elseif type == "mousewheel" then
core.root_view:on_mouse_wheel(...)
elseif type == "resized" then
core.window_mode = system.get_window_mode()
elseif type == "minimized" or type == "maximized" or type == "restored" then
core.window_mode = type == "restored" and "normal" or type
elseif type == "filedropped" then
local filename, mx, my = ...
local info = system.get_file_info(filename)
+1 -2
View File
@@ -36,8 +36,7 @@ function TitleView:update()
self.size.y = 0
end
TitleView.super.update(self)
local window_mode = system.get_window_mode()
title_commands[2] = window_mode == "maximized" and restore_command or maximize_command
title_commands[2] = core.window_mode == "maximized" and restore_command or maximize_command
local title_height = self.size.y
if core.window_borderless and title_height ~= core.hit_test_title_height then
local icon_w = style.icon_font:get_width("_")