0

I'm looking something similar than HazeOver, Focus and other apps that helps to focus on the active application dimming or tinting with other color the not actives, but I'm trying to do it by my own using swift 5.7 on MacOS app but I do not find how to add a background color or tint color for the non active applications. Here you'll find a portion of my code:

    @objc func receiveFrontAppChangeNote(_ notification: Notification) {
        
        
        let application = NSWorkspace.shared.frontmostApplication!
        let currentApp = application.processIdentifier
              
        let options = CGWindowListOption(arrayLiteral: CGWindowListOption.excludeDesktopElements, CGWindowListOption.optionOnScreenOnly)
        let windowListInfo = CGWindowListCopyWindowInfo(options, CGWindowID(0))
        let windowInfoList = windowListInfo as NSArray? as? [[String: AnyObject]]
                               
        for info in windowInfoList! {
            let windowPID = info["kCGWindowOwnerPID"]   as! UInt32
            let windowNumber = info["kCGWindowNumber"]   as! UInt32
                            
            if  windowPID == currentApp {
                // This is the windowNumber of the Active Application
                print(windowNumber)
                
            }else{
                // This is a not active app
                let notActiveApp = NSRunningApplication(processIdentifier: pid_t(windowPID))
                
                // Add here how to tint or add background color to the notActiveApp 
                // ...                    
            }
            
        }
    }

Thanks to all!!

  • 2
    You make a semi transparent window and place it in front of them. – matt Jul 03 '22 at 03:52
  • Thanks for the answer. If you put a window over the others, you'll cannot interact with them. I imagine a way to add a tint color or effect of every window under the active one. I know all the processIdentifier of each one. Sure there is a way to add this kind of effect, but I do not know the way to do it. – Daniel Atik Jul 03 '22 at 19:52
  • "If you put a window over the others, you'll cannot interact with them" No, that's not true. It depends on the type of window. If you examine, say, HazeOver with the QuartzDebug tool, you will see that what I'm saying is correct. "there is a way to add this kind of effect, but I do not know the way to do it" If you listened to what I'm telling you, you would know the way to do it. – matt Jul 03 '22 at 20:13
  • 1
    Think about the concepts "borderless window", "window alphaValue", and "ignores mouse events". – matt Jul 03 '22 at 20:20

0 Answers0