Skip to content

Commit

Permalink
Fix not to show invalid windows
Browse files Browse the repository at this point in the history
  • Loading branch information
oniatsu committed Dec 9, 2021
1 parent e378259 commit c1e58fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 18 deletions.
18 changes: 9 additions & 9 deletions lib/controller/MainController.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,28 @@ MainController.new = function()
self.windowModel:focusPreviousWindowForCancel()
self:finish()
else
local t1 = TimeChecker.new()
-- local t1 = TimeChecker.new()

self.windowModel.previousWindow = hs.window.frontmostWindow()

-- Enable hotkeys before refresh windows,
-- because refreshing windows is sometimes slow and take time.
local t2 = TimeChecker.new()
-- local t2 = TimeChecker.new()
self.hotkeyController:enableHotkeys()
t2:diff("MainController:enableHotkeys")
-- t2:diff("MainController:enableHotkeys")
self.panelLayoutView:activateHammerspoonWindow()
t2:diff("MainController:activateHammerspoonWindow")
-- t2:diff("MainController:activateHammerspoonWindow")

self.windowModel:refreshOrderedWindows()
t2:diff("MainController:refreshOrderedWindows")
-- t2:diff("MainController:refreshOrderedWindows")
self.keyStatusModel:createKeyStatuses()
t2:diff("MainController:createKeyStatuses")
-- t2:diff("MainController:createKeyStatuses")
self.panelLayoutView:show()
t2:diff("MainController:show")
-- t2:diff("MainController:show")
self.appWatchModel:watchAppliationDeactivated(function() self:finish() end)
t2:diff("MainController:watchAppliationDeactivated")
-- t2:diff("MainController:watchAppliationDeactivated")

t1:diff("All")
-- t1:diff("All")
end
end

Expand Down
9 changes: 4 additions & 5 deletions lib/model/WindowModel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,19 @@ WindowModel.new = function()

-- Here is another way, but it's slow.
-- local orderedWindows = hs.window.orderedWindows()
-- orderedWindows = self.removeInvalidWindows(orderedWindows)

orderedWindows = self.removeInvalidWindows(orderedWindows)

self.cachedOrderedWindows = orderedWindows
return orderedWindows
end

-- Deprecated
obj.removeInvalidWindows = function(orderedWindows)
-- Google Chrome's search box is treated as visible window.
-- So you need remove such invalid windows.
local cleanedOrderedWindows = {}
for i = 1, #orderedWindows do
local window = orderedWindows[i]
if window:subrole() ~= "AXUnknown" then
local subrole = window:subrole()
if subrole ~= "AXUnknown" and subrole ~= "AXSystemDialog" then
table.insert(cleanedOrderedWindows, window)
end
end
Expand Down
8 changes: 4 additions & 4 deletions lib/view/PanelLayoutView.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ PanelLayoutView.new = function(windowModel, settingModel, keyStatusModel)
self.selectedRowCanvasView.position = defaultRowPosition
end

local t = TimeChecker.new()
-- local t = TimeChecker.new()
self.baseCanvasView:show()
t:diff("PanelLayoutView:baseCanvasView:show")
-- t:diff("PanelLayoutView:baseCanvasView:show")
self.selectedRowCanvasView:createSelectedRow()
t:diff("PanelLayoutView:selectedRowCanvasView:createSelectedRow")
-- t:diff("PanelLayoutView:selectedRowCanvasView:createSelectedRow")

self.selectedRowCanvasView:replaceSelectedRow()
t:diff("PanelLayoutView:selectedRowCanvasView:replaceSelectedRow")
-- t:diff("PanelLayoutView:selectedRowCanvasView:replaceSelectedRow")
end

obj.hide = function(self)
Expand Down

0 comments on commit c1e58fa

Please sign in to comment.