Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple displays (monitors) issues #106

Open
hamir-suspect opened this issue May 11, 2022 · 4 comments
Open

Multiple displays (monitors) issues #106

hamir-suspect opened this issue May 11, 2022 · 4 comments

Comments

@hamir-suspect
Copy link

Not sure how to replicate this issue yet, but I suspect it has to do with restarting and reopening windows on login. I am using multiple displays that are arranged like this
+----------------+
| |
| |
+----------------+
+------+
| |
+------+
where lower one is my macbooks display. In case I have a stack on upper display, clicking in the area (on lower display) where stacklike creates clickable app images to change window results in changing the window on that upper display.

@acdifran
Copy link

acdifran commented May 23, 2022

I think I'm having the same issue you're describing. Clicking the upper left corner of single window on my top monitor registers as clicking one of the stack icons, even though there aren't any, and so it moves my mouse focus. For example if I have a chrome window on my top monitor and I click the "back" button, I can see this in the logs:

Clicked window at hs.geometry.point(-441.77093505859,-1379.7335205078)

which move focus away from chrome instead of "clicking" back.

Seems to be the same issue as #100 (comment) as well.

@kiryph
Copy link

kiryph commented Jul 26, 2022

@hamir-suspect, @acdifran, @pomdtr

Can you try following fix?

diff --git a/stackline/stack.lua b/stackline/stack.lua
index a664063..0977a60 100644
--- a/stackline/stack.lua
+++ b/stackline/stack.lua
@@ -66,32 +66,24 @@ function Stack:deleteAllIndicators() -- {{{
 end -- }}}

 function Stack:getWindowByPoint(p)
-   if p.x < 0 or p.y < 0 then
-      -- FIX: https://github.com/AdamWagner/stackline/issues/62
-      -- NOTE: Window indicator frame coordinates are relative to the window's screen.
-      -- So, if click point has negative X or Y vals, then convert its coordinates
-      -- to relative to the clicked screen before comparing to window indicator frames.
-      -- TODO: Clean this up after fix is confirmed
+  -- Get the screen with frame that contains point 'p'
+  local function findClickedScreen(_p) -- {{{
+     return table.unpack(
+        u.filter(hs.screen.allScreens(), function(s)
+           return _p:inside(s:frame())
+        end)
+     )
+  end -- }}}

-      -- Get the screen with frame that contains point 'p'
-      local function findClickedScreen(_p) -- {{{
-         return table.unpack(
-            u.filter(hs.screen.allScreens(), function(s)
-               return _p:inside(s:frame())
-            end)
-         )
-      end -- }}}
-
-      local clickedScren = findClickedScreen(p)
-      p = clickedScren
-         and clickedScren:absoluteToLocal(p)
-         or p
-   end
+  local clickedScreen = findClickedScreen(p)
+  p = clickedScreen
+     and clickedScreen:absoluteToLocal(p)
+     or p

    return table.unpack(
          u.filter(self.windows, function(w)
           local indicatorFrame = w.indicator and w.indicator:canvasElements()[1].frame
-          if not indicatorFrame then return false end
+          if not indicatorFrame or w.screen:id() ~= clickedScreen:id() then return false end
           return p:inside(indicatorFrame) -- NOTE: frame *must* be a hs.geometry.rect instance
       end)
    )

@ispringle
Copy link

ispringle commented Aug 18, 2022

@kiryph that worked for me! Thanks

Edit:

Actually, this just moved the issue, with this patch the top menu bar is now unclickable if there is a stack visible on any display.

@ispringle
Copy link

ispringle commented Aug 19, 2022

@kiryph Try this instead, I guess hammerspoon doesn't count the top menu bar as part of the screen, so when you click up there clickedScreen is nil which errors when trying to access clickedScreen:id()

if not clickedScreen or not indicatorFrame or w.screen:id() ~= clickedScreen:id() then return false end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants