Comments (2)
Hi!
Works as described :-) I mistook the declaration of
switcher = hs.window.switcher.new()
for a general function (switcher.ui.highlight). Sorry for that - I was tired...
Thank you for clarifying; marked as solved!
Have a nice day!
from hammerspoon.
It doesn't look like there's currently any official way to make those corners rounded, but it could probably be added.
As a workaround for now, if you're okay poking around inside hs.window.switcher
's implementation details, you can get the hs.drawing
object being used to draw the highlight rectangle and set its corner radius manually using the setRoundedRectRadii
method:
ws = hs.window.switcher.new( --[[ whatever arguments ]] )
-- any ws.ui configuration goes here
local highlightRadius = 10 -- or whatever
ws.drawings.highlightRect:setRoundedRectRadii(highlightRadius, highlightRadius)
Make sure you finish modifying that switcher's ui
object before you set the radius. Any changes to ws.ui
will cause the highlight drawing to be recreated and lose that change. (Changes to the global hs.window.switcher.ui
object won't do that, but they also won't properly update switchers you've already created.)
If you want to avoid losing the radius whenever you change `ws.ui`…
It's possible, but requires messing with hs.window.switcher
's internals even more using Lua's debug
functions:
local function findUpvalue(f, name)
local i = 0
local n, v
repeat
i = i + 1
n, v = debug.getupvalue(f, i)
until not n or n == name
if not n then return nil end
return i, v
end
local setUiPrefsUpvalueIndex, oldSetUiPrefs = findUpvalue(hs.window.switcher.new, 'setUiPrefs')
if not setUiPrefsUpvalueIndex then
error "Couldn't find hs.window.switcher's setUiPrefs function"
end
debug.setupvalue(hs.window.switcher.new, setUiPrefsUpvalueIndex, function(self)
oldSetUiPrefs(self)
local highlightRadius = self.ui.highlightRadius or 0
self.drawings.highlightRect:setRoundedRectRadii(highlightRadius, highlightRadius)
end)
-- Now you can do:
hs.window.switcher.ui.highlightRadius = 10 -- or whatever
ws = hs.window.switcher.new( --[[ whatever arguments ]] )
-- or for a specific switcher:
ws.ui.highlightRadius = 15 -- or whatever
If you want to make it match the size of the existing rounded corners…
There are three radii that are computed and used by hs.window.switcher
, so it depends which one you're trying to match:
ui.titleRectRadius
: Used for the window titles in the main switcher area. Defined as 1/4 ofui.textSize
(which defaults to 16, making this radius 4).selectedRectRadius
: Used for the large preview box for the selected window, as well as the title box at the top of that preview. Defined as 1/4 of the height of an uppercaseO
in the selected-window title font (with the odd effect of not rounding those corners if you turn that title off). With default settings, that seems to work out to 8.padding
: Used for the corners of the switcher itself. Also has some non-corner-radius uses: It's the amount of space between two thumbnails, or between the first/last thumbnail and the corresponding edge of the switcher. Defined in a complicated way based onui.thumbnailSize
, the number of windows, and the available screen width. If you're trying to match the switcher's corners, it will probably take a more involved patch to actually find that value.
from hammerspoon.
Related Issues (20)
- Problem at Boot with Symlinks? HOT 1
- Hammerspoon executes AppleScript not like the way Script Editor does HOT 2
- Hammerspoon brings back `com.apple.keylayout.ABC` HOT 1
- Hotkey script results in garbled text on remote Windows server HOT 5
- Mouse events break on space change. HOT 8
- Chrome no longer responds to hs.grid.set() after update to macOS Sonoma Version 14.4.1 (23E224) HOT 1
- Sonoma: Beachball of Death and growing Memory about 1GB every 20seconds HOT 6
- Custom HotKey Creation for Java-based app in MacOS HOT 2
- hs.application.get() taking over 1s when it doesn't find matches HOT 2
- hs.eventtap.event.types.gesture stops responding HOT 2
- Hammerspoon conflict with JetBrain products HOT 2
- add POLO objects to registry? eq. `hs.geometry`
- Sequoia and ScreenCapture HOT 6
- Problem with hs.spaces.moveWindowToSpace in 1.0.0 HOT 1
- Focus Filter HOT 1
- Reordering Spaces HOT 2
- hs.window.filter.new(nil) - first subscribe: 30s delay HOT 2
- How should I scroll the canvas, is there an API to generate a scroll canvas? HOT 2
- Support for dart and Flutter
- Sometimes hammerspoon hangs. Is there an easy way to profile our config? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hammerspoon.