Avoid always calling system.get_window_mode
This commit is contained in:
parent
46791aefe5
commit
4de97d51fb
|
@ -411,6 +411,7 @@ function core.init()
|
||||||
core.clip_rect_stack = {{ 0,0,0,0 }}
|
core.clip_rect_stack = {{ 0,0,0,0 }}
|
||||||
core.log_items = {}
|
core.log_items = {}
|
||||||
core.docs = {}
|
core.docs = {}
|
||||||
|
core.window_mode = "normal"
|
||||||
core.threads = setmetatable({}, { __mode = "k" })
|
core.threads = setmetatable({}, { __mode = "k" })
|
||||||
|
|
||||||
local project_dir_abs = system.absolute_path(project_dir)
|
local project_dir_abs = system.absolute_path(project_dir)
|
||||||
|
@ -812,6 +813,10 @@ function core.on_event(type, ...)
|
||||||
core.root_view:on_mouse_released(...)
|
core.root_view:on_mouse_released(...)
|
||||||
elseif type == "mousewheel" then
|
elseif type == "mousewheel" then
|
||||||
core.root_view:on_mouse_wheel(...)
|
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
|
elseif type == "filedropped" then
|
||||||
local filename, mx, my = ...
|
local filename, mx, my = ...
|
||||||
local info = system.get_file_info(filename)
|
local info = system.get_file_info(filename)
|
||||||
|
|
|
@ -36,8 +36,7 @@ function TitleView:update()
|
||||||
self.size.y = 0
|
self.size.y = 0
|
||||||
end
|
end
|
||||||
TitleView.super.update(self)
|
TitleView.super.update(self)
|
||||||
local window_mode = system.get_window_mode()
|
title_commands[2] = core.window_mode == "maximized" and restore_command or maximize_command
|
||||||
title_commands[2] = window_mode == "maximized" and restore_command or maximize_command
|
|
||||||
local title_height = self.size.y
|
local title_height = self.size.y
|
||||||
if core.window_borderless and title_height ~= core.hit_test_title_height then
|
if core.window_borderless and title_height ~= core.hit_test_title_height then
|
||||||
local icon_w = style.icon_font:get_width("_")
|
local icon_w = style.icon_font:get_width("_")
|
||||||
|
|
|
@ -117,6 +117,16 @@ top:
|
||||||
rencache_invalidate();
|
rencache_invalidate();
|
||||||
lua_pushstring(L, "exposed");
|
lua_pushstring(L, "exposed");
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if (e.window.event == SDL_WINDOWEVENT_MINIMIZED) {
|
||||||
|
lua_pushstring(L, "minimized");
|
||||||
|
return 1;
|
||||||
|
} else if (e.window.event == SDL_WINDOWEVENT_MAXIMIZED) {
|
||||||
|
fprintf(stderr, "maximized event!\n");
|
||||||
|
lua_pushstring(L, "maximized");
|
||||||
|
return 1;
|
||||||
|
} else if (e.window.event == SDL_WINDOWEVENT_RESTORED) {
|
||||||
|
lua_pushstring(L, "restored");
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
if (e.window.event == SDL_WINDOWEVENT_FOCUS_LOST) {
|
||||||
lua_pushstring(L, "focuslost");
|
lua_pushstring(L, "focuslost");
|
||||||
|
|
Loading…
Reference in New Issue